Put the guts of qwaq's reflection code into ruamoko

This commit is contained in:
Bill Currie 2020-02-19 10:46:16 +09:00
parent 4c40928112
commit 67e183c8b6
5 changed files with 116 additions and 2 deletions

View file

@ -3,7 +3,7 @@ pkgincludedir= $(datarootdir)/qfcc/include
nobase_pkginclude_HEADERS= \
crudefile.h debug.h entities.h infokey.h math.h message.h nq_message.h \
physics.h msgbuf.h qfile.h qfs.h qw_message.h qw_physics.h qw_sys.h \
server.h sound.h script.h string.h sv_sound.h system.h \
server.h sound.h script.h string.h sv_sound.h system.h types.h \
\
draw.h key.h \
\

84
ruamoko/include/types.h Normal file
View file

@ -0,0 +1,84 @@
#ifndef __types_h
#define __types_h
typedef enum {
ev_void,
ev_string,
ev_float,
ev_vector,
ev_entity,
ev_field,
ev_func,
ev_pointer, // end of v6 types
ev_quat,
ev_integer,
ev_uinteger,
ev_short, // value is embedded in the opcode
ev_double,
ev_invalid, // invalid type. used for instruction checking
ev_type_count // not a type, gives number of types
} etype_t;
typedef enum {
ty_none, ///< func/field/pointer or not used
ty_struct,
ty_union,
ty_enum,
ty_array,
ty_class,
} ty_meta_e;
typedef struct qfot_fldptr_s {
etype_t type;
struct qfot_type_s *aux_type;
} qfot_fldptr_t;
typedef struct qfot_func_s {
etype_t type;
struct qfot_type_s *return_type;
int num_params;
struct qfot_type_s *param_types[1];
} qfot_func_t;
typedef struct qfot_var_s {
struct qfot_type_s *type;
string name;
int offset; // value for enum, 0 for union
} qfot_var_t;
typedef struct qfot_struct_s {
string tag;
int num_fields;
qfot_var_t fields[1];
} qfot_struct_t;
typedef struct qfot_array_s {
struct qfot_type_s *type;
int base;
int size;
} qfot_array_t;
typedef struct qfot_type_s {
ty_meta_e meta;
int size;
string encoding;
union {
etype_t type;
qfot_fldptr_t fldptr;
qfot_func_t func;
qfot_struct_t strct;
qfot_array_t array;
string class;
} t;
} qfot_type_t;
typedef struct qfot_type_encodings_s {
qfot_type_t *types;
int size;
} qfot_type_encodings_t;
@extern string ty_meta_name[6];
@extern string pr_type_name[ev_type_count];
#endif

View file

@ -27,7 +27,7 @@ SUFFIXES= .o .r .qc
libr_a_SOURCES=\
cbuf.r cmd.r cvar.r file.r hash.r msgbuf.r plist.r qfile.r qfs.r script.r \
sound.r string.r math.r \
sound.r string.r math.r types.r \
Object.r Protocol.r \
AutoreleasePool.r Array.r Array+Private.r Entity.r PropertyList.r Set.r
libr_a_AR=$(PAK) -cf

28
ruamoko/lib/types.r Normal file
View file

@ -0,0 +1,28 @@
#include <runtime.h>
#include <types.h>
string ty_meta_name[6] = {
"basic",
"struct",
"union",
"enum",
"array",
"class",
};
string pr_type_name[ev_type_count] = {
"void",
"string",
"float",
"vector",
"entity",
"field",
"function",
"pointer",
"quaternion",
"integer",
"uinteger",
"short",
"double"
"invalid",
};

View file

@ -12,6 +12,7 @@ typedef enum {
ev_integer,
ev_uinteger,
ev_short, // value is embedded in the opcode
ev_double,
ev_invalid, // invalid type. used for instruction checking
ev_type_count // not a type, gives number of types
@ -107,6 +108,7 @@ string pr_type_name[ev_type_count] = {
"integer",
"uinteger",
"short",
"double"
"invalid",
};