QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
VM Builtin functions

Builtin management functions. More...

Data Structures

struct  bfunction_t
 Duplicate the dfunction_t descriptor with the addition of a pointer to the builtin function. More...
 
struct  builtin_t
 Create a static array of these and pass the array to PR_RegisterBuiltins() to register the module's QC builtin functions. More...
 

Macros

#define PR_AUTOBUILTIN   (PR_RANGE_AUTO << PR_RANGE_SHIFT)
 
#define PR_RANGE_AUTO   0x1000
 
#define PR_RANGE_MASK   0xffff0000
 
#define PR_RANGE_MAX   0x7fff
 
#define PR_RANGE_NONE   0xffff
 
#define PR_RANGE_QF   0x000f
 
#define PR_RANGE_SHIFT   16
 

Typedefs

typedef void(* builtin_proc )(progs_t *pr)
 

Functions

builtin_tPR_FindBuiltin (progs_t *pr, const char *name)
 Lookup a builtin function referred by name. More...
 
builtin_tPR_FindBuiltinNum (progs_t *pr, pr_int_t num)
 Lookup a builtin function by builtin number. More...
 
void PR_RegisterBuiltins (progs_t *pr, builtin_t *builtins)
 Register a set of builtin functions with the VM. More...
 
int PR_RelocateBuiltins (progs_t *pr)
 Fixup all automatically resolved builtin functions (func = #0 in QC). More...
 

Detailed Description

Builtin management functions.

Builtins are arranged into groups of 65536 to allow for diffent expantion sets. eg, stock id is 0x0000xxxx, quakeforge is 0x000fxxxx. predefined groups go up to 0x0fffxxxx allowing 4096 different groups. Builtins 0x10000000 to 0x7fffffff are reserved for auto-allocation. The range 0x8000000 to 0xffffffff is unavailable due to the builtin number being a negative statement address.

Macro Definition Documentation

#define PR_AUTOBUILTIN   (PR_RANGE_AUTO << PR_RANGE_SHIFT)
#define PR_RANGE_AUTO   0x1000
#define PR_RANGE_MASK   0xffff0000
#define PR_RANGE_MAX   0x7fff
#define PR_RANGE_NONE   0xffff
#define PR_RANGE_QF   0x000f
#define PR_RANGE_SHIFT   16

Typedef Documentation

typedef void(* builtin_proc)(progs_t *pr)

Function Documentation

builtin_t* PR_FindBuiltin ( progs_t pr,
const char *  name 
)

Lookup a builtin function referred by name.

Parameters
prpointer to progs_t VM struct
namename of the builtin function to lookup
Returns
pointer to the builtin function entry, or NULL if not found
builtin_t* PR_FindBuiltinNum ( progs_t pr,
pr_int_t  num 
)

Lookup a builtin function by builtin number.

Parameters
prpointer to progs_t VM struct
numnumber of the builtin function to lookup
Returns
pointer to the builtin function entry, or NULL if not found
void PR_RegisterBuiltins ( progs_t pr,
builtin_t builtins 
)

Register a set of builtin functions with the VM.

Different VMs within the same program can have different builtin sets. May be called multiple times for the same VM, but redefining a builtin is an error.

Parameters
prpointer to progs_t VM struct
builtinsarray of builtin_t builtins
int PR_RelocateBuiltins ( progs_t pr)

Fixup all automatically resolved builtin functions (func = #0 in QC).

Performs any necessary builtin function number mapping. Also builds the bfunction_t table. Called automatically during progs load.

Parameters
prpointer to progs_t VM struct
Returns
true for success, false for failure