Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lobject.h File Reference
#include <stdarg.h>
#include "llimits.h"
#include "lua.h"

Go to the source code of this file.

Data Structures

struct  GCheader
 
union  Value
 
struct  lua_TValue
 
struct  TString
 
struct  Udata
 
struct  Proto
 
struct  LocVar
 
struct  UpVal
 
struct  CClosure
 
struct  LClosure
 
union  Closure
 
union  TKey
 
union  Node
 
struct  Table
 

Macros

#define LAST_TAG   LUA_TTHREAD
 
#define NUM_TAGS   (LAST_TAG+1)
 
#define LUA_TPROTO   (LAST_TAG+1)
 
#define LUA_TUPVAL   (LAST_TAG+2)
 
#define LUA_TDEADKEY   (LAST_TAG+3)
 
#define CommonHeader   GCObject *next; lu_byte tt; lu_byte marked
 
#define TValuefields   Value value; int tt
 
#define ttisnil(o)   (ttype(o) == LUA_TNIL)
 
#define ttisnumber(o)   (ttype(o) == LUA_TNUMBER)
 
#define ttisstring(o)   (ttype(o) == LUA_TSTRING)
 
#define ttistable(o)   (ttype(o) == LUA_TTABLE)
 
#define ttisfunction(o)   (ttype(o) == LUA_TFUNCTION)
 
#define ttisboolean(o)   (ttype(o) == LUA_TBOOLEAN)
 
#define ttisuserdata(o)   (ttype(o) == LUA_TUSERDATA)
 
#define ttisthread(o)   (ttype(o) == LUA_TTHREAD)
 
#define ttislightuserdata(o)   (ttype(o) == LUA_TLIGHTUSERDATA)
 
#define ttype(o)   ((o)->tt)
 
#define gcvalue(o)   check_exp(iscollectable(o), (o)->value.gc)
 
#define pvalue(o)   check_exp(ttislightuserdata(o), (o)->value.p)
 
#define nvalue(o)   check_exp(ttisnumber(o), (o)->value.n)
 
#define rawtsvalue(o)   check_exp(ttisstring(o), &(o)->value.gc->ts)
 
#define tsvalue(o)   (&rawtsvalue(o)->tsv)
 
#define rawuvalue(o)   check_exp(ttisuserdata(o), &(o)->value.gc->u)
 
#define uvalue(o)   (&rawuvalue(o)->uv)
 
#define clvalue(o)   check_exp(ttisfunction(o), &(o)->value.gc->cl)
 
#define hvalue(o)   check_exp(ttistable(o), &(o)->value.gc->h)
 
#define bvalue(o)   check_exp(ttisboolean(o), (o)->value.b)
 
#define thvalue(o)   check_exp(ttisthread(o), &(o)->value.gc->th)
 
#define l_isfalse(o)   (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
 
#define checkconsistency(obj)    lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
 
#define checkliveness(g, obj)
 
#define setnilvalue(obj)   ((obj)->tt=LUA_TNIL)
 
#define setnvalue(obj, x)    { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
 
#define setpvalue(obj, x)    { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
 
#define setbvalue(obj, x)    { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
 
#define setsvalue(L, obj, x)
 
#define setuvalue(L, obj, x)
 
#define setthvalue(L, obj, x)
 
#define setclvalue(L, obj, x)
 
#define sethvalue(L, obj, x)
 
#define setptvalue(L, obj, x)
 
#define setobj(L, obj1, obj2)
 
#define setobjs2s   setobj
 
#define setobj2s   setobj
 
#define setsvalue2s   setsvalue
 
#define sethvalue2s   sethvalue
 
#define setptvalue2s   setptvalue
 
#define setobjt2t   setobj
 
#define setobj2t   setobj
 
#define setobj2n   setobj
 
#define setsvalue2n   setsvalue
 
#define setttype(obj, tt)   (ttype(obj) = (tt))
 
#define iscollectable(o)   (ttype(o) >= LUA_TSTRING)
 
#define getstr(ts)   cast(const char *, (ts) + 1)
 
#define svalue(o)   getstr(rawtsvalue(o))
 
#define VARARG_HASARG   1
 
#define VARARG_ISVARARG   2
 
#define VARARG_NEEDSARG   4
 
#define ClosureHeader
 
#define iscfunction(o)   (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
 
#define isLfunction(o)   (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
 
#define lmod(s, size)    (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
 
#define twoto(x)   (1<<(x))
 
#define sizenode(t)   (twoto((t)->lsizenode))
 
#define luaO_nilobject   (&luaO_nilobject_)
 
#define ceillog2(x)   (luaO_log2((x)-1) + 1)
 

Typedefs

typedef union GCObject GCObject
 
typedef struct GCheader GCheader
 
typedef struct lua_TValue TValue
 
typedef TValueStkId
 
typedef union TString TString
 
typedef union Udata Udata
 
typedef struct Proto Proto
 
typedef struct LocVar LocVar
 
typedef struct UpVal UpVal
 
typedef struct CClosure CClosure
 
typedef struct LClosure LClosure
 
typedef union Closure Closure
 
typedef union TKey TKey
 
typedef struct Node Node
 
typedef struct Table Table
 

Functions

LUAI_FUNC int luaO_log2 (unsigned int x)
 
LUAI_FUNC int luaO_int2fb (unsigned int x)
 
LUAI_FUNC int luaO_fb2int (int x)
 
LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2)
 
LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result)
 
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 len)
 

Variables

LUAI_DATA const TValue luaO_nilobject_
 

Macro Definition Documentation

◆ bvalue

◆ ceillog2

#define ceillog2 ( x)    (luaO_log2((x)-1) + 1)

Definition at line 367 of file lua-5.1.5/src/lobject.h.

Referenced by countint(), and setnodevector().

◆ checkconsistency

#define checkconsistency ( obj)     lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))

Definition at line 108 of file lua-5.1.5/src/lobject.h.

108#define checkconsistency(obj) \
109 lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))

◆ checkliveness

#define checkliveness ( g,
obj )
Value:
((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
int value
Definition lsqlite3.c:2155
#define isdead(g, v)
#define lua_assert(c)
#define iscollectable(o)
#define ttype(o)

Definition at line 111 of file lua-5.1.5/src/lobject.h.

111#define checkliveness(g,obj) \
112 lua_assert(!iscollectable(obj) || \
113 ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))

◆ ClosureHeader

#define ClosureHeader
Value:
CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
struct Table *env
unsigned char lu_byte
#define CommonHeader

Definition at line 291 of file lua-5.1.5/src/lobject.h.

291#define ClosureHeader \
292 CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
293 struct Table *env

◆ clvalue

◆ CommonHeader

#define CommonHeader   GCObject *next; lu_byte tt; lu_byte marked

Definition at line 43 of file lua-5.1.5/src/lobject.h.

◆ gcvalue

◆ getstr

◆ hvalue

◆ iscfunction

#define iscfunction ( o)    (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)

Definition at line 315 of file lua-5.1.5/src/lobject.h.

Referenced by lua_iscfunction(), and lua_tocfunction().

◆ iscollectable

◆ isLfunction

#define isLfunction ( o)    (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)

Definition at line 316 of file lua-5.1.5/src/lobject.h.

Referenced by lua_dump(), lua_dump(), and lua_getlocal().

◆ l_isfalse

◆ LAST_TAG

#define LAST_TAG   LUA_TTHREAD

Definition at line 20 of file lua-5.1.5/src/lobject.h.

◆ lmod

#define lmod ( s,
size )    (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))

Definition at line 355 of file lua-5.1.5/src/lobject.h.

355#define lmod(s,size) \
356 (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))

Referenced by internshrstr(), internshrstr(), internshrstr(), luaS_newlstr(), luaS_remove(), luaS_resize(), newlstr(), newshrstr(), and tablerehash().

◆ LUA_TDEADKEY

#define LUA_TDEADKEY   (LAST_TAG+3)

Definition at line 30 of file lua-5.1.5/src/lobject.h.

Referenced by findindex(), removeentry(), and traversetable().

◆ LUA_TPROTO

◆ LUA_TUPVAL

#define LUA_TUPVAL   (LAST_TAG+2)

◆ luaO_nilobject

◆ NUM_TAGS

#define NUM_TAGS   (LAST_TAG+1)

Definition at line 22 of file lua-5.1.5/src/lobject.h.

Referenced by lua_newstate(), and markmt().

◆ nvalue

◆ pvalue

◆ rawtsvalue

◆ rawuvalue

#define rawuvalue ( o)    check_exp(ttisuserdata(o), &(o)->value.gc->u)

Definition at line 96 of file lua-5.1.5/src/lobject.h.

Referenced by lua_setmetatable(), and lua_touserdata().

◆ setbvalue

#define setbvalue ( obj,
x )    { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }

Definition at line 125 of file lua-5.1.5/src/lobject.h.

125#define setbvalue(obj,x) \
126 { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }

Referenced by boolK(), boolK(), boolK(), collectvalidlines(), collectvalidlines(), collectvalidlines(), LoadConstants(), LoadConstants(), LoadConstants(), lua_pushboolean(), luaV_execute(), luaV_execute(), and luaX_newstring().

◆ setclvalue

#define setclvalue ( L,
obj,
x )
Value:
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
checkliveness(G(L),i_o); }
#define cast(t, exp)
#define G(L)
#define LUA_TFUNCTION

Definition at line 143 of file lua-5.1.5/src/lobject.h.

143#define setclvalue(L,obj,x) \
144 { TValue *i_o=(obj); \
145 i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
146 checkliveness(G(L),i_o); }

Referenced by f_Ccall(), f_parser(), lua_getinfo(), lua_pushcclosure(), and luaV_execute().

◆ sethvalue

#define sethvalue ( L,
obj,
x )
Value:
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
checkliveness(G(L),i_o); }
#define LUA_TTABLE

Definition at line 148 of file lua-5.1.5/src/lobject.h.

148#define sethvalue(L,obj,x) \
149 { TValue *i_o=(obj); \
150 i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
151 checkliveness(G(L),i_o); }

Referenced by adjust_varargs(), collectvalidlines(), collectvalidlines(), collectvalidlines(), f_luaopen(), index2adr(), init_registry(), init_registry(), init_registry(), lua_createtable(), lua_getfenv(), lua_getmetatable(), lua_getuservalue(), lua_setfenv(), luaV_execute(), luaV_execute(), luaY_parser(), nilK(), nilK(), nilK(), and nilK().

◆ sethvalue2s

◆ setnilvalue

◆ setnvalue

#define setnvalue ( obj,
x )    { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }

◆ setobj

#define setobj ( L,
obj1,
obj2 )
Value:
{ const TValue *o2=(obj2); TValue *o1=(obj1); \
o1->value = o2->value; o1->tt=o2->tt; \
checkliveness(G(L),o1); }

Definition at line 161 of file lua-5.1.5/src/lobject.h.

161#define setobj(L,obj1,obj2) \
162 { const TValue *o2=(obj2); TValue *o1=(obj1); \
163 o1->value = o2->value; o1->tt=o2->tt; \
164 checkliveness(G(L),o1); }

Referenced by addk(), addk(), addk(), addk(), lua_copy(), lua_load(), lua_replace(), lua_setiuservalue(), lua_setupvalue(), luaF_close(), luaF_closeupval(), luaK_exp2const(), luaV_execute(), luaV_execute(), luaV_execute(), luaV_settable(), moveto(), reverse(), and reverse().

◆ setobj2n

#define setobj2n   setobj

Definition at line 183 of file lua-5.1.5/src/lobject.h.

Referenced by adjust_varargs(), lua_pushcclosure(), and luaE_newthread().

◆ setobj2s

◆ setobj2t

◆ setobjs2s

◆ setobjt2t

#define setobjt2t   setobj

Definition at line 179 of file lua-5.1.5/src/lobject.h.

Referenced by luaH_resize(), luaH_resize(), and resize().

◆ setptvalue

#define setptvalue ( L,
obj,
x )
Value:
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
checkliveness(G(L),i_o); }
#define LUA_TPROTO

Definition at line 153 of file lua-5.1.5/src/lobject.h.

153#define setptvalue(L,obj,x) \
154 { TValue *i_o=(obj); \
155 i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
156 checkliveness(G(L),i_o); }

◆ setptvalue2s

#define setptvalue2s   setptvalue

Definition at line 177 of file lua-5.1.5/src/lobject.h.

Referenced by combine(), LoadFunction(), and open_func().

◆ setpvalue

#define setpvalue ( obj,
x )    { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }

Definition at line 122 of file lua-5.1.5/src/lobject.h.

122#define setpvalue(obj,x) \
123 { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }

Referenced by f_Ccall(), lua_pushlightuserdata(), lua_rawgetp(), lua_rawsetp(), luaK_intK(), and luaK_intK().

◆ setsvalue

#define setsvalue ( L,
obj,
x )
Value:
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
checkliveness(G(L),i_o); }
#define LUA_TSTRING

Definition at line 128 of file lua-5.1.5/src/lobject.h.

128#define setsvalue(L,obj,x) \
129 { TValue *i_o=(obj); \
130 i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
131 checkliveness(G(L),i_o); }

Referenced by lua_getfield(), lua_setfield(), luaH_getstr(), luaH_setstr(), luaK_exp2const(), luaK_numberK(), luaK_stringK(), luaO_tostring(), luaX_newstring(), and stringK().

◆ setsvalue2n

#define setsvalue2n   setsvalue

◆ setsvalue2s

◆ setthvalue

#define setthvalue ( L,
obj,
x )
Value:
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
checkliveness(G(L),i_o); }
#define LUA_TTHREAD

Definition at line 138 of file lua-5.1.5/src/lobject.h.

138#define setthvalue(L,obj,x) \
139 { TValue *i_o=(obj); \
140 i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
141 checkliveness(G(L),i_o); }

Referenced by init_registry(), init_registry(), init_registry(), lua_newthread(), and lua_pushthread().

◆ setttype

#define setttype ( obj,
tt )   (ttype(obj) = (tt))

Definition at line 186 of file lua-5.1.5/src/lobject.h.

Referenced by removeentry().

◆ setuvalue

#define setuvalue ( L,
obj,
x )
Value:
{ TValue *i_o=(obj); \
i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
checkliveness(G(L),i_o); }
#define LUA_TUSERDATA

Definition at line 133 of file lua-5.1.5/src/lobject.h.

133#define setuvalue(L,obj,x) \
134 { TValue *i_o=(obj); \
135 i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
136 checkliveness(G(L),i_o); }

Referenced by GCTM(), lua_newuserdata(), and lua_newuserdatauv().

◆ sizenode

◆ svalue

◆ thvalue

#define thvalue ( o)    check_exp(ttisthread(o), &(o)->value.gc->th)

Definition at line 101 of file lua-5.1.5/src/lobject.h.

Referenced by lua_getfenv(), lua_setfenv(), lua_topointer(), and lua_tothread().

◆ tsvalue

◆ ttisboolean

#define ttisboolean ( o)    (ttype(o) == LUA_TBOOLEAN)

Definition at line 84 of file lua-5.1.5/src/lobject.h.

◆ ttisfunction

◆ ttislightuserdata

#define ttislightuserdata ( o)    (ttype(o) == LUA_TLIGHTUSERDATA)

Definition at line 87 of file lua-5.1.5/src/lobject.h.

Referenced by lua_isuserdata().

◆ ttisnil

◆ ttisnumber

◆ ttisstring

◆ ttistable

◆ ttisthread

#define ttisthread ( o)    (ttype(o) == LUA_TTHREAD)

Definition at line 86 of file lua-5.1.5/src/lobject.h.

Referenced by lua_tothread().

◆ ttisuserdata

#define ttisuserdata ( o)    (ttype(o) == LUA_TUSERDATA)

◆ ttype

◆ TValuefields

#define TValuefields   Value value; int tt

Definition at line 71 of file lua-5.1.5/src/lobject.h.

◆ twoto

#define twoto ( x)    (1<<(x))

◆ uvalue

◆ VARARG_HASARG

#define VARARG_HASARG   1

Definition at line 257 of file lua-5.1.5/src/lobject.h.

Referenced by adjust_varargs(), parlist(), and precheck().

◆ VARARG_ISVARARG

#define VARARG_ISVARARG   2

Definition at line 258 of file lua-5.1.5/src/lobject.h.

Referenced by luaY_parser(), parlist(), and symbexec().

◆ VARARG_NEEDSARG

#define VARARG_NEEDSARG   4

Definition at line 259 of file lua-5.1.5/src/lobject.h.

Referenced by adjust_varargs(), parlist(), precheck(), and symbexec().

Typedef Documentation

◆ CClosure

typedef struct CClosure CClosure

◆ Closure

typedef union Closure Closure

◆ GCheader

typedef struct GCheader GCheader

◆ GCObject

typedef union GCObject GCObject

Definition at line 36 of file lua-5.1.5/src/lobject.h.

◆ LClosure

typedef struct LClosure LClosure

◆ LocVar

typedef struct LocVar LocVar

◆ Node

typedef struct Node Node

◆ Proto

typedef struct Proto Proto

◆ StkId

typedef TValue* StkId

Definition at line 193 of file lua-5.1.5/src/lobject.h.

◆ Table

typedef struct Table Table

◆ TKey

typedef union TKey TKey

◆ TString

typedef union TString TString

◆ TValue

typedef struct lua_TValue TValue

◆ Udata

typedef union Udata Udata

◆ UpVal

typedef struct UpVal UpVal

Function Documentation

◆ luaO_chunkid()

LUAI_FUNC void luaO_chunkid ( char * out,
const char * source,
size_t len )

Definition at line 182 of file lua-5.1.5/src/lobject.c.

182 {
183 if (*source == '=') {
184 strncpy(out, source+1, bufflen); /* remove first char */
185 out[bufflen-1] = '\0'; /* ensures null termination */
186 }
187 else { /* out = "source", or "...source" */
188 if (*source == '@') {
189 size_t l;
190 source++; /* skip the `@' */
191 bufflen -= sizeof(" '...' ");
192 l = strlen(source);
193 strcpy(out, "");
194 if (l > bufflen) {
195 source += (l-bufflen); /* get last part of file name */
196 strcat(out, "...");
197 }
198 strcat(out, source);
199 }
200 else { /* out = [string "string"] */
201 size_t len = strcspn(source, "\n\r"); /* stop at first newline */
202 bufflen -= sizeof(" [string \"...\"] ");
203 if (len > bufflen) len = bufflen;
204 strcpy(out, "[string \"");
205 if (source[len] != '\0') { /* must truncate? */
206 strncat(out, source, len);
207 strcat(out, "...");
208 }
209 else
210 strcat(out, source);
211 strcat(out, "\"]");
212 }
213 }
214}
#define bufflen(B)

◆ luaO_fb2int()

LUAI_FUNC int luaO_fb2int ( int x)

Definition at line 47 of file lua-5.1.5/src/lobject.c.

47 {
48 int e = (x >> 3) & 31;
49 if (e == 0) return x;
50 else return ((x & 7)+8) << (e - 1);
51}

◆ luaO_int2fb()

LUAI_FUNC int luaO_int2fb ( unsigned int x)

Definition at line 35 of file lua-5.1.5/src/lobject.c.

35 {
36 int e = 0; /* expoent */
37 while (x >= 16) {
38 x = (x+1) >> 1;
39 e++;
40 }
41 if (x < 8) return x;
42 else return ((e+1) << 3) | (cast_int(x) - 8);
43}
#define cast_int(i)

◆ luaO_log2()

LUAI_FUNC int luaO_log2 ( unsigned int x)

Definition at line 54 of file lua-5.1.5/src/lobject.c.

54 {
55 static const lu_byte log_2[256] = {
56 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
57 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
58 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
59 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
60 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
61 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
62 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
63 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
64 };
65 int l = -1;
66 while (x >= 256) { l += 8; x >>= 8; }
67 return l + log_2[x];
68
69}

◆ luaO_pushfstring()

LUAI_FUNC const char * luaO_pushfstring ( lua_State * L,
const char * fmt,
... )

Definition at line 172 of file lua-5.1.5/src/lobject.c.

172 {
173 const char *msg;
174 va_list argp;
175 va_start(argp, fmt);
176 msg = luaO_pushvfstring(L, fmt, argp);
177 va_end(argp);
178 return msg;
179}
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)

◆ luaO_pushvfstring()

LUAI_FUNC const char * luaO_pushvfstring ( lua_State * L,
const char * fmt,
va_list argp )

Definition at line 111 of file lua-5.1.5/src/lobject.c.

111 {
112 int n = 1;
113 pushstr(L, "");
114 for (;;) {
115 const char *e = strchr(fmt, '%');
116 if (e == NULL) break;
117 setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt));
118 incr_top(L);
119 switch (*(e+1)) {
120 case 's': {
121 const char *s = va_arg(argp, char *);
122 if (s == NULL) s = "(null)";
123 pushstr(L, s);
124 break;
125 }
126 case 'c': {
127 char buff[2];
128 buff[0] = cast(char, va_arg(argp, int));
129 buff[1] = '\0';
130 pushstr(L, buff);
131 break;
132 }
133 case 'd': {
134 setnvalue(L->top, cast_num(va_arg(argp, int)));
135 incr_top(L);
136 break;
137 }
138 case 'f': {
139 setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));
140 incr_top(L);
141 break;
142 }
143 case 'p': {
144 char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */
145 sprintf(buff, "%p", va_arg(argp, void *));
146 pushstr(L, buff);
147 break;
148 }
149 case '%': {
150 pushstr(L, "%");
151 break;
152 }
153 default: {
154 char buff[3];
155 buff[0] = '%';
156 buff[1] = *(e+1);
157 buff[2] = '\0';
158 pushstr(L, buff);
159 break;
160 }
161 }
162 n += 2;
163 fmt = e+2;
164 }
165 pushstr(L, fmt);
166 luaV_concat(L, n+1, cast_int(L->top - L->base) - 1);
167 L->top -= n;
168 return svalue(L->top - 1);
169}
#define NULL
Definition gmacros.h:924
#define incr_top(L)
LUAI_UACNUMBER l_uacNumber
#define cast_num(i)
static void pushstr(lua_State *L, const char *str)
#define setsvalue2s
#define setnvalue(obj, x)
#define svalue(o)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
void luaV_concat(lua_State *L, int total, int last)
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318

◆ luaO_rawequalObj()

LUAI_FUNC int luaO_rawequalObj ( const TValue * t1,
const TValue * t2 )

Definition at line 72 of file lua-5.1.5/src/lobject.c.

72 {
73 if (ttype(t1) != ttype(t2)) return 0;
74 else switch (ttype(t1)) {
75 case LUA_TNIL:
76 return 1;
77 case LUA_TNUMBER:
78 return luai_numeq(nvalue(t1), nvalue(t2));
79 case LUA_TBOOLEAN:
80 return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
82 return pvalue(t1) == pvalue(t2);
83 default:
85 return gcvalue(t1) == gcvalue(t2);
86 }
87}
#define gcvalue(o)
#define pvalue(o)
#define nvalue(o)
#define bvalue(o)
#define LUA_TBOOLEAN
#define LUA_TNUMBER
#define LUA_TLIGHTUSERDATA
#define LUA_TNIL
#define luai_numeq(a, b)

References bvalue, gcvalue, iscollectable, lua_assert, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNUMBER, luai_numeq, nvalue, pvalue, and ttype.

Referenced by addk(), call_orderTM(), findindex(), get_compTM(), lua_rawequal(), and luaH_get().

◆ luaO_str2d()

LUAI_FUNC int luaO_str2d ( const char * s,
lua_Number * result )

Definition at line 90 of file lua-5.1.5/src/lobject.c.

90 {
91 char *endptr;
92 *result = lua_str2number(s, &endptr);
93 if (endptr == s) return 0; /* conversion failed */
94 if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
95 *result = cast_num(strtoul(s, &endptr, 16));
96 if (*endptr == '\0') return 1; /* most common case */
97 while (isspace(cast(unsigned char, *endptr))) endptr++;
98 if (*endptr != '\0') return 0; /* invalid trailing characters? */
99 return 1;
100}
#define lua_str2number(s, p)

References cast, cast_num, lua_str2number, and s.

Referenced by luaV_tonumber(), read_numeral(), and trydecpoint().

Variable Documentation

◆ luaO_nilobject_

LUAI_DATA const TValue luaO_nilobject_

Definition at line 365 of file lua-5.1.5/src/lobject.h.