Commit graph

59 commits

Author SHA1 Message Date
Bill Currie
ab04a1915e [build] Fix a pile of gcc 10 issues
gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
2020-12-21 14:14:29 +09:00
Bill Currie
62c20aa4ab [ruamoko] Fix incorrect clearing of dtables
The problem was caused by passing the index into the dtables array to
dtable_get which expects a handle. A handle is the ones-compliment
negative of the index which means that handle 0 is invalid (but 0 was
being passed... oops). Fixes the segfault when qw-client-x11 connects to
a server.
2020-08-17 13:58:35 +09:00
Bill Currie
17871b979d [ruamoko] Implement obj_calloc correctly
Forgetting to multiply by the second term leads to not good things.
2020-04-02 19:29:54 +09:00
Bill Currie
e2d1a0f7d2 [ruamoko] Tag object memory with the class name
This makes it a lot easier to see what's leaking.
2020-03-31 16:43:10 +09:00
Bill Currie
59481bdf61 [ruamoko] Report class name in obj_verror 2020-03-31 14:40:22 +09:00
Bill Currie
c23c68cf7f [ruamoko] Allow builtins to inc/dec retain count
Needed for classes that are implemented entirely in C.
2020-03-30 16:58:36 +09:00
Bill Currie
6e473dc8f2 [ruamoko] Return nil IMP for nil method
Fixes a segfault.
2020-03-26 14:13:05 +09:00
Bill Currie
4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie
08b7064a3f [ruamoko] Set pr_argc before calling error methods
Builtins calling ruamoko code need to be careful of the arg count in
case the ruamoko function uses varargs.
2020-03-12 19:40:17 +09:00
Bill Currie
21b64421c3 [ruamoko] Copy ALL the params to the args block
*sigh*
2020-03-10 03:09:21 +09:00
Bill Currie
4b7d5447bb [ruamoko] Correct obj_msg_sendv for __obj_forward
Until I implemented forwarding, I didn't know how obj_msg_sendv was
meant to be used, so no surprise I got the implementation wrong.
2020-03-10 02:56:37 +09:00
Bill Currie
2a152e6356 [ruamoko] Add builtin __obj_responds_to
Fast dtable-based messages response test. However, it does not handle
forwarding.
2020-03-10 00:08:30 +09:00
Bill Currie
af37b660e8 [ruamoko] Push the forwarded args block
This causes the block to be freed when the forward: handler returns
(assuming it's not yet another builtin). This is necessary so calling a
lot of forwarded messages in a loop doesn't leak memory (though it will
get freed eventually).
2020-03-09 23:38:27 +09:00
Bill Currie
9b0368039e [ruamoko] Include param size in size of args block
I forget it every time. It really doesn't help that params are 4 words
and words are 4 bytes, so seeing a size of 12 for 3 parameters *looks*
right.
2020-03-09 22:54:22 +09:00
Bill Currie
fa0a74efdf [ruamoko] Finish implementation of __obj_forward
With this, object's implementing forward:: seem to accept the message
well, including receiving all the original args (not quite sure how to
deal with them in ruamoko code just yet, though).
2020-03-09 22:20:11 +09:00
Bill Currie
e3fe93c586 [gamecode] Implement most of message forwarding
All that's left is the parameter setup of forward::.
2020-03-09 20:41:17 +09:00
Bill Currie
a487595149 [ruamoko,libr] Begin implementation of __obj_forward
libr supplies an __obj_forward definition that links to a builtin, but
as it is the only def in its object file, it is readily replaceable by
an alternative Ruamoko implementation.

The builtin version currently simply errors out (rather facetiously),
but only as a stub to allow progs to load.
2020-03-09 19:09:08 +09:00
Bill Currie
e2f4c189f9 [ruamoko] Install and use dispatch tables
This should speed up ruamoko code somewhat as hash table lookups have
been replaced with direct array indexing. As a bonus, support for
message forwarding has been added (though not tested).
2020-03-09 18:11:36 +09:00
Bill Currie
1ccdd76780 [ruamoko] Clean up runtime init and cleanup
Move the semi-permanent resource initialisation into the module init and
the cleanup of those resources into cleanup. Makes actual runtime init
much easier to read.
2020-03-09 18:09:03 +09:00
Bill Currie
0e40366c7f [ruamoko] Implement class conformsToProtocol
Seems to work nicely, too :)
2020-03-02 15:21:10 +09:00
Bill Currie
a906efac47 [ruamoko] Register protocols and their selectors 2020-03-02 15:20:34 +09:00
Bill Currie
78f552aa87 [ruamoko] Initialize static instances
This is one step closer to implementing conformsToProtocol. However,
protocols are not yet initialized correctly: they are not registered,
nor are their selectors.

While the static initializer list pointer was not written previously,
the module struct always came immediately after the symbols struct, and
the module version has so far always been 0. Thus, the list pointer is
correctly 0 for older progs and there's no need for a version bump.
2020-03-02 13:45:47 +09:00
Bill Currie
bc4bea79cb [ruamoko] Remove a stale FIXME
This was fixed when pr_def_t was introduced. I missed the comment at the
time.
2020-03-02 13:00:33 +09:00
Bill Currie
3577d27a45 Move the ObjQC data into a resource block
This makes it nice and private (though with the cached pointer, ObjQC is
still a first-class component).
2020-02-25 23:14:18 +09:00
Bill Currie
9bb68f2d8c Allow nested use of PR_SaveParams()
PR_SaveParams() is required for implementing the +initialize diversion
used by Objective-QuakeC because builtins do not have local def spaces
(of course, a normal stack calling convention would help). However, it
is entirely possible for a call to +initialize to trigger another call
to +initialize, thus the need for stacking parameter stashes. As a
bonus, this implementation cleans up some fields in progs_t.
2020-02-25 14:30:26 +09:00
Bill Currie
81083698a8 Move to using an in-memory form of ddef_t
This allows the VM to work with extended ddefs transparently. It seems
to have uncovered a typedef alias relocation bug, though.
2020-02-22 22:33:44 +09:00
Bill Currie
e27d7cbd2d Handle alloca "correctly".
Use AC_FUNC_ALLOCA and the #ifdef mess suggested by the autoconf docs
(hidden in qfalloca.h).
2013-01-22 21:02:50 +09:00
Bill Currie
6eb6b6c0ba Change pointer_t to unsigned and clean up the mess.
It doesn't make sense to have negative pointers. The size of the commit is
from enabling gcc's -Wtype-limits warning and cleaning up that mess too.
2012-12-21 21:53:13 +09:00
Bill Currie
427d52511c Fix an uninitialized variable warning.
It's a false positive, but best to be safe.
2012-12-19 17:13:32 +09:00
Bill Currie
3a9fe196b6 Get the return param right for messages to nil.
R_INT(pr) = R_(INT)(pr); is not exactly what I had intended :P
2012-12-16 13:39:59 +09:00
Bill Currie
f631f514e9 Fix the obj_error family of functions.
It seems they were written before quaternion support was added and were not
updated to take into account the variable size of parameters. Now at least
Object's -error: works.
2012-12-16 13:19:31 +09:00
Bill Currie
d5c831b6da Add a little test case for accessing types.
Using ruamoko to access ruamoko type encodings is actually quite pleasant
:)
2012-11-15 13:40:11 +09:00
Bill Currie
6b46cde7c8 Move retainCount out of Object.
Going by "standard" Objective-C, retainCount really doesn't belong in
Object itself. The way GNUStep does it is to stash retainCount in memory
just below the object by allocating extra bytes for the count and returning
a pointer just beyond those extra bytes. Now Ruamoko does the same. This
fixes the inconsistencies in structure layouts for Protocol and class
structs between qfcc generated (internal) structs and user visible structs.
2012-11-08 20:24:25 +09:00
Bill Currie
ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Bill Currie
23a38738fc Massive whitespace cleanup.
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie
bc1b483525 Nuke the rcsid stuff.
It's pretty useless in git.
2012-04-22 10:56:32 +09:00
Bill Currie
cc5140e3a1 Move min/max/bound and field_offset into better locations.
min/max bound into mathlib.h (they /are/ math functions, after all) and
field_offset into qtypes.h.
2011-12-24 10:04:33 +09:00
Bill Currie
f75b0a611b Some compile fixes for OpenBSD 2011-08-25 22:35:20 +09:00
Bill Currie
2bacfdabf2 Interpret func fields as selectors for entities with objects. 2011-03-30 20:19:31 +09:00
Bill Currie
cb0bc7229a Resurect the debugging messages in rua_obj.c
Yet another debug flag: SYS_RUA_OBJ
2011-01-10 12:26:10 +09:00
Bill Currie
8c4fe2f844 Rename Sys_DPrintf to Sys_MaskPrintf.
We now have finer runtime control over what gets printed. Need to do a
SYS_DEV audit, creating new masks as apropriate.
2010-11-26 16:19:26 +09:00
Bill Currie
00e590f5f5 Really nail down the args param in rua_obj_msg_sendv(). 2010-01-13 06:36:16 +00:00
Bill Currie
8abb9a69aa remove support for an optional = in struct/union declarations 2010-01-13 06:34:32 +00:00
Bill Currie
00f9d48f10 be a little more paranoid 2010-01-13 06:33:03 +00:00
Bill Currie
ca0bbd909c correctly save and restore the parameters when calling +initialize. fixes the segfault in the qwaq test. 2007-06-09 13:44:06 +00:00
Bill Currie
ff132bb536 64bit windows patch from phrosty 2007-04-04 07:48:14 +00:00
Bill Currie
81a57bb3fa patch from phrosty for vc2005 support. includes fixes for a bunch of gcc-isms that crept in over the years. 2007-03-22 23:20:57 +00:00
Bill Currie
d084264c3a don't barf on protocols that are used by multiple classes in the same object file. 2006-12-19 12:17:42 +00:00
Bill Currie
d28952dfcc fix a bunch of gcc-4.1 warnings (thanks for the heads up, jordi) 2006-11-30 22:52:36 +00:00
Bill Currie
3fb03fc2be hah, should have been using __attribute__((used)) all that time (rather
than __attribute__((unused))). fixes the missing console in -x11
2005-08-04 15:27:09 +00:00