30 #include "../../common/hashtable.h"
31 #include "../../common/scripts.h"
32 #include "../../common/scripts_lua.h"
33 #include "../../common/swig_lua_runtime.h"
38 #define LOCAL_PROPERTY_SIZE 128
56 if (property ==
nullptr)
57 Com_Error(
ERR_FATAL,
"UI_RegisterNodePropertyPosSize_: UI memory hunk exceeded - increase the size");
63 property->string =
name;
66 property->size =
size;
73 Com_Error(
ERR_FATAL,
"UI_RegisterNodePropertyPosSize_: Property memory of behaviour %s is full.", behaviour->
name);
102 for (; behaviour; behaviour = behaviour->
super) {
103 unsigned char min = 0;
107 const int mid = (min + max) >> 1;
139 if (prop)
return prop;
167 behaviour->
extends =
"abstractnode";
171 Com_Error(
ERR_FATAL,
"UI_InitializeNodeBehaviour: Behaviour '%s' expect a manager class", behaviour->
name);
189 Com_Error(
ERR_FATAL,
"UI_InitializeNodeBehaviour: UI memory hunk exceeded - increase the size");
192 const value_t* previous =
nullptr;
194 const value_t* better =
nullptr;
196 for (
const value_t** current = oldmemory; *current !=
nullptr; current++) {
217 const uiBehaviour_t* b = UI_GetNodeBehaviour(current->string);
220 Com_Error(
ERR_FATAL,
"UI_InitializeNodeBehaviour: property '%s' from node behaviour '%s' overwrite another property", (*property)->string, behaviour->
name);
223 Com_Error(
ERR_FATAL,
"UI_InitializeNodeBehaviour: property '%s' from node behaviour '%s' use the name of an existing node behaviour", (*property)->string, behaviour->
name);
234 if ((*property)->type !=
V_UI_NODEMETHOD && (*property)->ofs + (*property)->size > size)
235 Com_Error(
ERR_FATAL,
"UI_InitializeNodeBehaviour: property '%s' from node behaviour '%s' is outside the node memory. The C code need a fix.", (*property)->string, behaviour->
name);
252 Com_Printf (
"UI_AddBehaviourMethod: registering class method [%s] on behaviour [%s]\n", name, behaviour->
name);
260 Com_Printf(
"UI_AddBehaviourMethod: method [%s] already defined on this behaviour [%s]\n", name, behaviour->
name);
274 for(;behaviour;behaviour = behaviour->
super) {
277 if (val !=
nullptr) {
bool UI_HasBehaviourMethod(uiBehaviour_t *behaviour, const char *name)
Returns true if a node method of given name is available on this behaviour or its super...
const struct value_s * UI_RegisterNodePropertyPosSize_(uiBehaviour_t *behaviour, const char *name, int type, size_t pos, size_t size)
Register a property to a behaviour. It should not be used in the code.
void * UI_AllocHunkMemory(size_t size, int align, bool reset)
QGL_EXTERN GLint GLenum type
void UI_InitializeNodeBehaviour(uiBehaviour_t *behaviour)
Initialize a node behaviour memory, after registration, and before using it.
valueTypes_t
possible values for parsing functions
hashTable_s * nodeMethods
bool UI_GetBehaviourMethod(const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this behaviour or its super.
uiBehaviour_t * behaviour
void Com_Printf(const char *const fmt,...)
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
const value_t * UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char *name)
Get a property from a behaviour or his inheritance It use a dichotomic search.
#define Q_strvalid(string)
Internal data use by the UI package.
void Com_Error(int code, const char *fmt,...)
#define STRUCT_MEMORY_ALIGN
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
#define Q_strcasecmp(a, b)
int LUA_METHOD
holds a reference to a lua event handler
Atomic structure used to define most of the UI.
#define Mem_PoolAllocTypeN(type, n, pool)
#define V_CVAR_OR_LONGSTRING
#define V_UI_NODEMETHOD_LUA
node behaviour, how a node work
uiBehaviour_t * UI_GetNodeBehaviour(const char *name)
Return a node behaviour by name.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void UI_AddBehaviourMethod(uiBehaviour_t *behaviour, const char *name, LUA_METHOD fcn)
Adds a lua based method to the list of available behaviour methods for calling.
const value_t ** localProperties
bool UI_GetNodeMethod(const uiNode_t *node, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this node or its super.
int LUA_FUNCTION
callback signatures for functions defined in Lua
void(* uiNodeMethod_t)(uiNode_t *node, const struct uiCallContext_s *context)
Signature of a function to bind a node method.
const value_t * UI_GetPropertyOrLuaMethod(const uiNode_t *node, const char *name, value_t *out)
Get a property or lua based method from a node, node behaviour or inherted behaviour.
bool HASH_Insert(hashTable_s *t, const void *key, int nkey, const void *value, int nvalue)
Inserts a new value with given key into the hash table.
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
#define LOCAL_PROPERTY_SIZE