mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
implement a couple more obj functions
This commit is contained in:
parent
d9db1a0c04
commit
211908e741
1 changed files with 52 additions and 23 deletions
|
@ -42,6 +42,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
|
#include "QF/dstring.h"
|
||||||
#include "QF/hash.h"
|
#include "QF/hash.h"
|
||||||
#include "QF/pr_obj.h"
|
#include "QF/pr_obj.h"
|
||||||
#include "QF/progs.h"
|
#include "QF/progs.h"
|
||||||
|
@ -124,6 +125,18 @@ dump_ivars (progs_t *pr, pointer_t _ivars)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
object_is_instance (progs_t *pr, pr_id_t *object)
|
||||||
|
{
|
||||||
|
pr_class_t *class;
|
||||||
|
|
||||||
|
if (object) {
|
||||||
|
class = &G_STRUCT (pr, pr_class_t, object->class_pointer);
|
||||||
|
return PR_CLS_ISCLASS (class);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static string_t
|
static string_t
|
||||||
object_get_class_name (progs_t *pr, pr_id_t *object)
|
object_get_class_name (progs_t *pr, pr_id_t *object)
|
||||||
{
|
{
|
||||||
|
@ -311,25 +324,42 @@ obj_msg_lookup_super (progs_t *pr, pr_super_t *super, pr_sel_t *op)
|
||||||
return obj_find_message (pr, class, op);
|
return obj_find_message (pr, class, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
obj_verror (progs_t *pr, pr_id_t *object, int code, const char *fmt, int count,
|
||||||
|
pr_type_t *args)
|
||||||
|
{
|
||||||
|
pr_type_t **arglist = (pr_type_t **) alloca (count * sizeof (pr_type_t *));
|
||||||
|
dstring_t *dstr = dstring_newstr ();
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
arglist[i] = args + i * 3;
|
||||||
|
PR_Sprintf (pr, dstr, "obj_verror", fmt, count, arglist);
|
||||||
|
PR_RunError (pr, "%s", dstr->str);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pr_obj_error (progs_t *pr)
|
pr_obj_error (progs_t *pr)
|
||||||
{
|
{
|
||||||
//pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
||||||
//int code = P_INT (pr, 1);
|
int code = P_INT (pr, 1);
|
||||||
//const char *fmt = P_GSTRING (pr, 2);
|
const char *fmt = P_GSTRING (pr, 2);
|
||||||
//...
|
int count = pr->pr_argc - 3;
|
||||||
//XXX
|
pr_type_t *args = pr->pr_params[3];
|
||||||
PR_RunError (pr, "%s, not implemented", __FUNCTION__);
|
|
||||||
|
obj_verror (pr, object, code, fmt, count, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pr_obj_verror (progs_t *pr)
|
pr_obj_verror (progs_t *pr)
|
||||||
{
|
{
|
||||||
//pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
||||||
//int code = P_INT (pr, 1);
|
int code = P_INT (pr, 1);
|
||||||
//const char *fmt = P_GSTRING (pr, 2);
|
const char *fmt = P_GSTRING (pr, 2);
|
||||||
//XXX
|
pr_va_list_t *val = (pr_va_list_t *) pr->pr_params[3];
|
||||||
PR_RunError (pr, "%s, not implemented", __FUNCTION__);
|
|
||||||
|
obj_verror (pr, object, code, fmt, val->count,
|
||||||
|
&G_STRUCT (pr, pr_type_t, val->list));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -838,14 +868,8 @@ static void
|
||||||
pr_object_is_instance (progs_t *pr)
|
pr_object_is_instance (progs_t *pr)
|
||||||
{
|
{
|
||||||
pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
||||||
pr_class_t *class;
|
|
||||||
|
|
||||||
if (object) {
|
R_INT (pr) = object_is_instance (pr, object);
|
||||||
class = &G_STRUCT (pr, pr_class_t, object->class_pointer);
|
|
||||||
R_INT (pr) = PR_CLS_ISCLASS (class);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
R_INT (pr) = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -871,11 +895,16 @@ pr__i_Object__hash (progs_t *pr)
|
||||||
static void
|
static void
|
||||||
pr__i_Object_error_error_ (progs_t *pr)
|
pr__i_Object_error_error_ (progs_t *pr)
|
||||||
{
|
{
|
||||||
//pr_id_t *object = &P_STRUCT (pr, pr_id_t, 0);
|
pr_id_t *self = &P_STRUCT (pr, pr_id_t, 0);
|
||||||
//const char *fmt = P_GSTRING (pr, 2);
|
const char *fmt = P_GSTRING (pr, 2);
|
||||||
//...
|
dstring_t *dstr = dstring_new ();
|
||||||
//XXX
|
int count = pr->pr_argc - 3;
|
||||||
PR_RunError (pr, "%s, not implemented", __FUNCTION__);
|
pr_type_t *args = pr->pr_params[3];
|
||||||
|
|
||||||
|
dsprintf (dstr, "error: %s (%s)\n%s",
|
||||||
|
PR_GetString (pr, object_get_class_name (pr, self)),
|
||||||
|
object_is_instance (pr, self) ? "instance" : "class", fmt);
|
||||||
|
obj_verror (pr, self, 0, dstr->str, count, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue