Download unify/third_party/lua/src/lobject.h from Snapkitty/repoverse: direct link, hf CLI and curl.
- Browser
- Download file 22.8 kB
-
https://huggingface.co/Snapkitty/repoverse/resolve/main/unify/third_party/lua/src/lobject.h
- Command line
-
hf download hf://Snapkitty/repoverse/unify/third_party/lua/src/lobject.h
-
curl -L -o lobject.h https://huggingface.co/Snapkitty/repoverse/resolve/main/unify/third_party/lua/src/lobject.h
22.8 kB
| /* | |
| ** $Id: lobject.h $ | |
| ** Type definitions for Lua objects | |
| ** See Copyright Notice in lua.h | |
| */ | |
| /* | |
| ** Extra types for collectable non-values | |
| */ | |
| /* | |
| ** number of all possible types (including LUA_TNONE but excluding DEADKEY) | |
| */ | |
| /* | |
| ** tags for Tagged Values have the following use of bits: | |
| ** bits 0-3: actual tag (a LUA_T* constant) | |
| ** bits 4-5: variant bits | |
| ** bit 6: whether value is collectable | |
| */ | |
| /* add variant bits to a type */ | |
| /* | |
| ** Union of all Lua values | |
| */ | |
| typedef union Value { | |
| struct GCObject *gc; /* collectable objects */ | |
| void *p; /* light userdata */ | |
| lua_CFunction f; /* light C functions */ | |
| lua_Integer i; /* integer numbers */ | |
| lua_Number n; /* float numbers */ | |
| /* not used, but may avoid warnings for uninitialized value */ | |
| lu_byte ub; | |
| } Value; | |
| /* | |
| ** Tagged Values. This is the basic representation of values in Lua: | |
| ** an actual value plus a tag with its type. | |
| */ | |
| typedef struct TValue { | |
| TValuefields; | |
| } TValue; | |
| /* raw type tag of a TValue */ | |
| /* tag with no variants (bits 0-3) */ | |
| /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ | |
| /* type of a TValue */ | |
| /* Macros to test type */ | |
| /* Macros for internal tests */ | |
| /* collectable object has the same tag as the original value */ | |
| /* | |
| ** Any value being manipulated by the program either is non | |
| ** collectable, or the collectable object has the right tag | |
| ** and it is not dead. The option 'L == NULL' allows other | |
| ** macros using this one to be used where L is not available. | |
| */ | |
| /* Macros to set values */ | |
| /* set a value's tag */ | |
| /* main macro to copy values (from 'obj2' to 'obj1') */ | |
| /* | |
| ** Different types of assignments, according to source and destination. | |
| ** (They are mostly equal now, but may be different in the future.) | |
| */ | |
| /* from stack to stack */ | |
| /* to stack (not from same stack) */ | |
| /* from table to same table */ | |
| /* to new object */ | |
| /* to table */ | |
| /* | |
| ** Entries in a Lua stack. Field 'tbclist' forms a list of all | |
| ** to-be-closed variables active in this stack. Dummy entries are | |
| ** used when the distance between two tbc variables does not fit | |
| ** in an unsigned short. They are represented by delta==0, and | |
| ** their real delta is always the maximum value that fits in | |
| ** that field. | |
| */ | |
| typedef union StackValue { | |
| TValue val; | |
| struct { | |
| TValuefields; | |
| unsigned short delta; | |
| } tbclist; | |
| } StackValue; | |
| /* index to stack elements */ | |
| typedef StackValue *StkId; | |
| /* | |
| ** When reallocating the stack, change all pointers to the stack into | |
| ** proper offsets. | |
| */ | |
| typedef union { | |
| StkId p; /* actual pointer */ | |
| ptrdiff_t offset; /* used while the stack is being reallocated */ | |
| } StkIdRel; | |
| /* convert a 'StackValue' to a 'TValue' */ | |
| /* | |
| ** {================================================================== | |
| ** Nil | |
| ** =================================================================== | |
| */ | |
| /* Standard nil */ | |
| /* Empty slot (which might be different from a slot containing nil) */ | |
| /* Value returned for a key not found in a table (absent key) */ | |
| /* macro to test for (any kind of) nil */ | |
| /* macro to test for a standard nil */ | |
| /* | |
| ** macro to detect non-standard nils (used only in assertions) | |
| */ | |
| /* | |
| ** By default, entries with any kind of nil are considered empty. | |
| ** (In any definition, values associated with absent keys must also | |
| ** be accepted as empty.) | |
| */ | |
| /* macro defining a value corresponding to an absent key */ | |
| /* mark an entry as empty */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Booleans | |
| ** =================================================================== | |
| */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Threads | |
| ** =================================================================== | |
| */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Collectable Objects | |
| ** =================================================================== | |
| */ | |
| /* | |
| ** Common Header for all collectable objects (in macro form, to be | |
| ** included in other objects) | |
| */ | |
| /* Common type for all collectable objects */ | |
| typedef struct GCObject { | |
| CommonHeader; | |
| } GCObject; | |
| /* Bit mark for collectable types */ | |
| /* mark a tag as collectable */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Numbers | |
| ** =================================================================== | |
| */ | |
| /* Variant tags for numbers */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Strings | |
| ** =================================================================== | |
| */ | |
| /* Variant tags for strings */ | |
| /* set a string to the stack */ | |
| /* set a string to a new object */ | |
| /* | |
| ** Header for a string value. | |
| */ | |
| typedef struct TString { | |
| CommonHeader; | |
| lu_byte extra; /* reserved words for short strings; "has hash" for longs */ | |
| lu_byte shrlen; /* length for short strings, 0xFF for long strings */ | |
| unsigned int hash; | |
| union { | |
| size_t lnglen; /* length for long strings */ | |
| struct TString *hnext; /* linked list for hash table */ | |
| } u; | |
| char contents[1]; | |
| } TString; | |
| /* | |
| ** Get the actual string (array of bytes) from a 'TString'. (Generic | |
| ** version and specialized versions for long and short strings.) | |
| */ | |
| /* get string length from 'TString *s' */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Userdata | |
| ** =================================================================== | |
| */ | |
| /* | |
| ** Light userdata should be a variant of userdata, but for compatibility | |
| ** reasons they are also different types. | |
| */ | |
| /* Ensures that addresses after this type are always fully aligned. */ | |
| typedef union UValue { | |
| TValue uv; | |
| LUAI_MAXALIGN; /* ensures maximum alignment for udata bytes */ | |
| } UValue; | |
| /* | |
| ** Header for userdata with user values; | |
| ** memory area follows the end of this structure. | |
| */ | |
| typedef struct Udata { | |
| CommonHeader; | |
| unsigned short nuvalue; /* number of user values */ | |
| size_t len; /* number of bytes */ | |
| struct Table *metatable; | |
| GCObject *gclist; | |
| UValue uv[1]; /* user values */ | |
| } Udata; | |
| /* | |
| ** Header for userdata with no user values. These userdata do not need | |
| ** to be gray during GC, and therefore do not need a 'gclist' field. | |
| ** To simplify, the code always use 'Udata' for both kinds of userdata, | |
| ** making sure it never accesses 'gclist' on userdata with no user values. | |
| ** This structure here is used only to compute the correct size for | |
| ** this representation. (The 'bindata' field in its end ensures correct | |
| ** alignment for binary data following this header.) | |
| */ | |
| typedef struct Udata0 { | |
| CommonHeader; | |
| unsigned short nuvalue; /* number of user values */ | |
| size_t len; /* number of bytes */ | |
| struct Table *metatable; | |
| union {LUAI_MAXALIGN;} bindata; | |
| } Udata0; | |
| /* compute the offset of the memory area of a userdata */ | |
| /* get the address of the memory block inside 'Udata' */ | |
| /* compute the size of a userdata */ | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Prototypes | |
| ** =================================================================== | |
| */ | |
| /* | |
| ** Description of an upvalue for function prototypes | |
| */ | |
| typedef struct Upvaldesc { | |
| TString *name; /* upvalue name (for debug information) */ | |
| lu_byte instack; /* whether it is in stack (register) */ | |
| lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ | |
| lu_byte kind; /* kind of corresponding variable */ | |
| } Upvaldesc; | |
| /* | |
| ** Description of a local variable for function prototypes | |
| ** (used for debug information) | |
| */ | |
| typedef struct LocVar { | |
| TString *varname; | |
| int startpc; /* first point where variable is active */ | |
| int endpc; /* first point where variable is dead */ | |
| } LocVar; | |
| /* | |
| ** Associates the absolute line source for a given instruction ('pc'). | |
| ** The array 'lineinfo' gives, for each instruction, the difference in | |
| ** lines from the previous instruction. When that difference does not | |
| ** fit into a byte, Lua saves the absolute line for that instruction. | |
| ** (Lua also saves the absolute line periodically, to speed up the | |
| ** computation of a line number: we can use binary search in the | |
| ** absolute-line array, but we must traverse the 'lineinfo' array | |
| ** linearly to compute a line.) | |
| */ | |
| typedef struct AbsLineInfo { | |
| int pc; | |
| int line; | |
| } AbsLineInfo; | |
| /* | |
| ** Function Prototypes | |
| */ | |
| typedef struct Proto { | |
| CommonHeader; | |
| lu_byte numparams; /* number of fixed (named) parameters */ | |
| lu_byte is_vararg; | |
| lu_byte maxstacksize; /* number of registers needed by this function */ | |
| int sizeupvalues; /* size of 'upvalues' */ | |
| int sizek; /* size of 'k' */ | |
| int sizecode; | |
| int sizelineinfo; | |
| int sizep; /* size of 'p' */ | |
| int sizelocvars; | |
| int sizeabslineinfo; /* size of 'abslineinfo' */ | |
| int linedefined; /* debug information */ | |
| int lastlinedefined; /* debug information */ | |
| TValue *k; /* constants used by the function */ | |
| Instruction *code; /* opcodes */ | |
| struct Proto **p; /* functions defined inside the function */ | |
| Upvaldesc *upvalues; /* upvalue information */ | |
| ls_byte *lineinfo; /* information about source lines (debug information) */ | |
| AbsLineInfo *abslineinfo; /* idem */ | |
| LocVar *locvars; /* information about local variables (debug information) */ | |
| TString *source; /* used for debug information */ | |
| GCObject *gclist; | |
| } Proto; | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Functions | |
| ** =================================================================== | |
| */ | |
| /* Variant tags for functions */ | |
| /* | |
| ** Upvalues for Lua closures | |
| */ | |
| typedef struct UpVal { | |
| CommonHeader; | |
| union { | |
| TValue *p; /* points to stack or to its own value */ | |
| ptrdiff_t offset; /* used while the stack is being reallocated */ | |
| } v; | |
| union { | |
| struct { /* (when open) */ | |
| struct UpVal *next; /* linked list */ | |
| struct UpVal **previous; | |
| } open; | |
| TValue value; /* the value (when closed) */ | |
| } u; | |
| } UpVal; | |
| typedef struct CClosure { | |
| ClosureHeader; | |
| lua_CFunction f; | |
| TValue upvalue[1]; /* list of upvalues */ | |
| } CClosure; | |
| typedef struct LClosure { | |
| ClosureHeader; | |
| struct Proto *p; | |
| UpVal *upvals[1]; /* list of upvalues */ | |
| } LClosure; | |
| typedef union Closure { | |
| CClosure c; | |
| LClosure l; | |
| } Closure; | |
| /* }================================================================== */ | |
| /* | |
| ** {================================================================== | |
| ** Tables | |
| ** =================================================================== | |
| */ | |
| /* | |
| ** Nodes for Hash tables: A pack of two TValue's (key-value pairs) | |
| ** plus a 'next' field to link colliding entries. The distribution | |
| ** of the key's fields ('key_tt' and 'key_val') not forming a proper | |
| ** 'TValue' allows for a smaller size for 'Node' both in 4-byte | |
| ** and 8-byte alignments. | |
| */ | |
| typedef union Node { | |
| struct NodeKey { | |
| TValuefields; /* fields for value */ | |
| lu_byte key_tt; /* key type */ | |
| int next; /* for chaining */ | |
| Value key_val; /* key value */ | |
| } u; | |
| TValue i_val; /* direct access to node's value as a proper 'TValue' */ | |
| } Node; | |
| /* copy a value into a key */ | |
| /* copy a value from a key */ | |
| /* | |
| ** About 'alimit': if 'isrealasize(t)' is true, then 'alimit' is the | |
| ** real size of 'array'. Otherwise, the real size of 'array' is the | |
| ** smallest power of two not smaller than 'alimit' (or zero iff 'alimit' | |
| ** is zero); 'alimit' is then used as a hint for #t. | |
| */ | |
| typedef struct Table { | |
| CommonHeader; | |
| lu_byte flags; /* 1<<p means tagmethod(p) is not present */ | |
| lu_byte lsizenode; /* log2 of size of 'node' array */ | |
| unsigned int alimit; /* "limit" of 'array' array */ | |
| TValue *array; /* array part */ | |
| Node *node; | |
| Node *lastfree; /* any free position is before this position */ | |
| struct Table *metatable; | |
| GCObject *gclist; | |
| } Table; | |
| /* | |
| ** Macros to manipulate keys inserted in nodes | |
| */ | |
| /* | |
| ** Dead keys in tables have the tag DEADKEY but keep their original | |
| ** gcvalue. This distinguishes them from regular keys but allows them to | |
| ** be found when searched in a special way. ('next' needs that to find | |
| ** keys removed from a table during a traversal.) | |
| */ | |
| /* }================================================================== */ | |
| /* | |
| ** 'module' operation for hashing (size is always a power of 2) | |
| */ | |
| /* size of buffer for 'luaO_utf8esc' function */ | |
| LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); | |
| LUAI_FUNC int luaO_ceillog2 (unsigned int x); | |
| LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1, | |
| const TValue *p2, TValue *res); | |
| LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1, | |
| const TValue *p2, StkId res); | |
| LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o); | |
| LUAI_FUNC int luaO_hexavalue (int c); | |
| LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj); | |
| LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, | |
| va_list argp); | |
| LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); | |
| LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen); | |