[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.
This commit is contained in:
Bill Currie 2020-03-09 19:09:08 +09:00
parent e2f4c189f9
commit a487595149
5 changed files with 22 additions and 0 deletions

View File

@ -1209,6 +1209,17 @@ rua___obj_exec_class (progs_t *pr)
PR_GetString (pr, module->name));
}
static void
rua___obj_forward (progs_t *pr)
{
probj_t *probj = pr->pr_objective_resources;
pr_id_t *receiver = &P_STRUCT (pr, pr_id_t, 0);
pr_sel_t *op = &P_STRUCT (pr, pr_sel_t, 1);
PR_RunError (pr, "seriously, dude, %s does not respond to %s",
PR_GetString (pr, object_get_class_name (probj, receiver)),
PR_GetString (pr, probj->selector_names[op->sel_id]));
}
static void
rua_obj_error (progs_t *pr)
{
@ -1928,6 +1939,7 @@ rua_PR_FindGlobal (progs_t *pr)
static builtin_t obj_methods [] = {
{"__obj_exec_class", rua___obj_exec_class, -1},
{"__obj_forward", rua___obj_forward, -1},
{"obj_error", rua_obj_error, -1},
{"obj_verror", rua_obj_verror, -1},

View File

@ -38,6 +38,7 @@ typedef enum {
YES ///< a true value
} BOOL;
@extern void __obj_forward(id, SEL, ...);
@extern void obj_error (id object, int code, string fmt, ...);
@extern void obj_verror (id object, int code, string fmt, @va_list args);
//obj_error_handler obj_set_error_handler (objc_error_handler func);

View File

@ -37,6 +37,7 @@ r_depfiles_remade=
libr_a_SOURCES=\
cbuf.r cmd.r cvar.r hash.r msgbuf.r plist.r qfile.r qfs.r script.r \
sound.r string.r math.r types.r \
obj_forward.r \
Object.r Protocol.r \
AutoreleasePool.r Array.r Array+Private.r Entity.r PropertyList.r Set.r
libr_a_obj=$(libr_a_SOURCES:.r=.o)

View File

@ -1,6 +1,11 @@
#include <Object.h>
#include <AutoreleasePool.h>
static void link__obj_forward (void)
{
__obj_forward (nil, nil);
}
void *PR_FindGlobal (string name) = #0; //FIXME where?
void __obj_exec_class (struct obj_module *msg) = #0;

View File

@ -0,0 +1,3 @@
// __obj_foward is the only thing in this file so it can be readily replaced
// at link time
void __obj_forward(id object, SEL sel, ...) = #0;