Commit graph

3509 commits

Author SHA1 Message Date
Bill Currie
271d836cd2 [qfcc] Catch static class instances in structs 2020-02-29 21:09:24 +09:00
Bill Currie
e93ca9d828 [qfcc] Fix infinite loop in linker 2020-02-29 20:13:25 +09:00
Bill Currie
8b6d05a4dd [qwaq] Ensure mouse motion reporting gets turned off
It seems that xterm automatically disables it when ncurses shuts down and
mate-terminal does not, or maybe a different version of something. Still,
good to clean up properly.
2020-02-29 16:36:23 +09:00
Bill Currie
ae532870c4 [qwaq] Implement basic color support 2020-02-29 14:48:18 +09:00
Bill Currie
ec4e9b326d [qwaq] Don't call wrefresh in cmd_mvwaddstr
There is now an implementation for wrefresh.
2020-02-29 14:43:08 +09:00
Bill Currie
f5f50ae231 [qwaq] Make stdscr available to progs 2020-02-29 14:38:54 +09:00
Bill Currie
5e4677f8d5 [qwaq] Implement the immediately useful panel functions 2020-02-29 13:06:58 +09:00
Bill Currie
17005637ca [qwaq] Rename the internal function names
Now they reflect the curses functions they wrap. The externally visible
builtin names are not changed because the parameters are in x, y order
rather than curses' y, x order.
2020-02-29 12:52:13 +09:00
Bill Currie
ea69921e6a [qwaq] Validate window before acquiring string
If the window is invalid and recovery is done, string ids will leak if
acquired before validation.

Afterwards, make the rest of the builtin wrappers consistent: extract
parameters, validate, [acquire resources], generate command.
2020-02-29 12:33:45 +09:00
Bill Currie
0119660b01 [qwaq] Convert remaining functions to command queue
Now that the initial prototype seems to be working well, it's time to
implement more commands. I might have to do some wrappers for actual
command writing (and result reading) as it looks like there will be a
lot of nearly identical code.
2020-02-29 11:44:43 +09:00
Bill Currie
513c808875 [qwaq] Make some bad ascii art 2020-02-29 02:07:47 +09:00
Bill Currie
bd98d1d9fb [qwaq] Prepare for threading
So far, no threading has been set up, and only window creation and
printing have been updated, but the basics of the design seem to be
sound.

The builtin functions now no longer call ncurses directly: the build
commands and write them to a command buffer.

Commands that have return values (eg, window creation) write their
results to a results buffer that the originating builtin function
reads. Builtin functions that expect a result "poll" the results buffer
for the correct result (marked by the same command). In a single
UI-thread environment, the results should always be in the same order as
the commands, and in a multi-UI-thread environment, things should
(fingers crossed) sort themselves out as ONE of the threads will be the
originator of the next available result.

Strings in commands (eg, for printing) are handled by acquiring a string
id (index into an array of dstring_t) and including the string id in the
written command. The string id is released upon completion of the
command.

Builtin functions write commands, acquire string ids, and read results.

The command processor reads commands, releases string ids, and writes
results.

Since commands, string ids, and results are all in ring buffers, and
assuming there is only one thread running the builtin functions and only
one thread processing commands (there can be only one because ncurses is
not thread-safe), then there should never be any contention on the
buffers. Of course, if there are multiple threads running the builtin
functions, then locking will be required on the builtin function side.
2020-02-29 01:45:33 +09:00
Bill Currie
644ef93dde [qwaq] Create some ring-buffer macros
I expect I will need several messaging buffers, and ring buffers tend to
be quite robust. Replacing the event buffer code with the macros made
testing easy.
2020-02-28 22:27:29 +09:00
Bill Currie
6a58dcdddd [qwaq] Fix lost output
Turns out all I needed was a refresh() after initialization.
2020-02-27 21:38:55 +09:00
Bill Currie
dd25bf5dfe [qwaq] Read mouse movements
Many thanks to https://gist.github.com/sylt/93d3f7b77e7f3a881603 for the
necessary escape sequence to get xterm reporting mouse movement events.
2020-02-27 21:22:10 +09:00
Bill Currie
a3ed5926b9 [qwaq] Remove unnecessary fields from mouse events
id and z seem to always be 0.

Ironically, it turns out that the work needed for "int id" and "large"
struct nil init wasn't strictly necessary to get to this point, but
without having done that work, I wouldn't know :)
2020-02-27 21:08:12 +09:00
Bill Currie
08bf8a04e4 [qwaq] Implement an event queue
It seems to have an issue with a bogus clearing of the screen, but the
basics seem to be working.
2020-02-27 21:07:56 +09:00
Bill Currie
b4aebc120e [qfcc] Treat { } as nil for initializing compound types 2020-02-27 20:30:39 +09:00
Bill Currie
7c9072aebf [qfcc] Create struct fields for "type typename"
Such declarations were being lost, thus in the following, the id field
never got added:
typedef struct qwaq_mevent_s {
    int         id;
    int         x, y, z;
    int         buttons;
} qwaq_mevent_t;
2020-02-27 17:50:11 +09:00
Bill Currie
dbbb8a1396 [qfcc] Fix syntax error for id as a field name
event.e.mouse.id produced a syntax error, which is contrary to
Objective-C.
2020-02-27 17:43:39 +09:00
Bill Currie
e8c357393f [qwaq] Clear qwaq's print buffer
Didn't realized PR_Sprintf appended. Or, more likely, I had forgotten
because I imagine Deek and I discussed it at the time.
2020-02-27 02:11:54 +09:00
Bill Currie
edde4bad15 Create a basic hello world
And it has begun. It has some problems, but worse, it seems I broke
qfprogs and maybe pr_debug.c.
2020-02-27 01:18:38 +09:00
Bill Currie
126f8502bd Start working on a qwaq console tool
The intention is it will hopefully become a debugger. It will certainly
help with development of the progs engine.
2020-02-26 22:10:59 +09:00
Bill Currie
4cec3bbff6 Unalias types when checking cast-compatibility
This fixes the problem with passing typedefs to function parameters.
2020-02-26 17:49:09 +09:00
Bill Currie
69b5029de5 Throw away function parameter type alias info
typedef is meant to create a simple renaming of a potentially complex
type, not create a new type. Keeping the parameter type alias info makes
the types effectively different when it comes to overloaded function
resolution, which is quite contrary to the goal. Does expose some
breakage elsewhere, though.
2020-02-26 17:46:53 +09:00
Bill Currie
9528c1176e Rename cast_expr's type vars for better clarity 2020-02-26 17:45:08 +09:00
Bill Currie
5c36c60005 Use type check helpers some more 2020-02-26 17:41:45 +09:00
Bill Currie
5d302ff6f4 Fix incorrect usage of signed verbosity 2020-02-26 17:15:52 +09:00
Bill Currie
35c9d6ee38 Make pr_obcode.c mostly thread safe
Its public data is all read-only, and once set up, its private data is
too (just don't call init in multiple threads).
2020-02-26 01:20:28 +09:00
Bill Currie
66dd3ef070 Make a bunch of count things positive-only
This fixes a pile of FIXMEs, because some things should never be
negative.
2020-02-25 21:23:13 +09:00
Bill Currie
282132958f Relocate local def type encodings in debug load
For technical reasons (programmer laziness), qfcc does not fix up local
def type encodings when writing the debug symbols file (type encoding
location not readily accessible).
2020-02-25 20:46:01 +09:00
Bill Currie
89e83d7d73 Move the debug info out of progs_t
The debug subsystem now uses the resources system to ensure it cleans
up, and its data is now semi-private. Unfortunately, PR_LoadDebug had to
remain public for qfprogs because using PR_RunLoadFuncs would cause
builtin resolution to complain.
2020-02-25 20:07:29 +09:00
Bill Currie
ca6fe0730b Fix qfcc test harness tracing
Just a consequence of progs execution state being initialized properly.
2020-02-25 19:02:24 +09:00
Bill Currie
a55b9544ac Improve handling of pr_argc
It is now set to 0 when progs are loaded and every time
PR_ExecuteProgram() returns. This takes care of the default case, but
when setting parameters, pr_argc needs to be set correctly in case a
vararg function is called.
2020-02-25 17:36:29 +09:00
Bill Currie
256dee98a1 Make progs string resources management private
Strangely enough, using the progs resources system. This is a step
towards having progs that can be reset properly, or even dynamically
created VMs.
2020-02-25 00:23:08 +09:00
Bill Currie
1cfac0f11a Resolve local def type encodings
They need to be resolved at load-time.
2020-02-25 00:12:02 +09:00
Bill Currie
c51c9edd9d Fix incorrect encoding of local defs 2020-02-25 00:11:01 +09:00
Bill Currie
7406e0308e Fix some warnings picked up in an optimized build 2020-02-24 11:28:43 +09:00
Bill Currie
c43b9681eb Keep structure members aligned 2020-02-24 08:43:32 +09:00
Bill Currie
2adcad7c84 Allow non-short-circuited logic to work 2020-02-24 02:25:28 +09:00
Bill Currie
ac32bbca40 Improve code for short-circuited float logic 2020-02-24 02:14:44 +09:00
Bill Currie
9c26d12f95 Cast rather than alias for testing constants
Fixes ICE in do { ... } while (1);
2020-02-24 02:13:23 +09:00
Bill Currie
55e53211e2 Generate default type expressions for folded booleans 2020-02-24 02:11:31 +09:00
Bill Currie
d6752c254c Move short-circuit boolean code to its own file 2020-02-24 01:20:24 +09:00
Bill Currie
0bf7ec07b7 Make debug output verbosity 2
and internal diagnostic sources level 1.
2020-02-24 00:22:13 +09:00
Bill Currie
11365024d2 Fix writing of frames files when not requested
I forgot to check for the option for separate compilation.
2020-02-24 00:07:48 +09:00
Bill Currie
27ae5ccfce Fix ICE after incomplete type error
Attempting to define a variable with an incomplete type is an error, and
results in a default size 1 of allocated, but I forgot to set default
alignment when implementing alignment.
2020-02-24 00:07:39 +09:00
Bill Currie
f387b9aa47 Propagate implicit for negating double constants 2020-02-23 23:41:12 +09:00
Bill Currie
5374798ef9 Fix order of operations for implicit casts 2020-02-23 23:18:31 +09:00
Bill Currie
05f6ddbb13 Print promoted warnings as errors
This makes it much easier to see why a compilation failed when only
warnings are visible.
2020-02-23 23:10:56 +09:00