misc/liblua/lobject.h
author unc0rr
Sun, 04 Nov 2012 23:56:27 +0400
branchphysfslayer
changeset 7931 5a27ed7f17b7
parent 3697 d5b30d6373fc
child 10017 de822cd3df3a
permissions -rw-r--r--
Wee, now frontend is able to load translation file
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** Type definitions for Lua objects
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#ifndef lobject_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
#define lobject_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
#include <stdarg.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
#include "llimits.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
#include "lua.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    18
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
/* tags for values visible from Lua */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    20
#define LAST_TAG	LUA_TTHREAD
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    21
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
#define NUM_TAGS	(LAST_TAG+1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
** Extra tags for non-values
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
#define LUA_TPROTO	(LAST_TAG+1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
#define LUA_TUPVAL	(LAST_TAG+2)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
#define LUA_TDEADKEY	(LAST_TAG+3)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    32
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    33
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    34
** Union of all collectable objects
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
typedef union GCObject GCObject;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
** Common Header for all collectable objects (in macro form, to be
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
** included in other objects)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    43
#define CommonHeader	GCObject *next; lu_byte tt; lu_byte marked
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
** Common header in struct form
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
typedef struct GCheader {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
  CommonHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
} GCheader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    57
** Union of all Lua values
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    58
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
typedef union {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    60
  GCObject *gc;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    61
  void *p;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
  lua_Number n;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
  int b;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
} Value;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    67
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    68
** Tagged Values
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    69
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    70
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
#define TValuefields	Value value; int tt
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    72
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    73
typedef struct lua_TValue {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
  TValuefields;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    75
} TValue;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    77
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
/* Macros to test type */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
#define ttisnil(o)	(ttype(o) == LUA_TNIL)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
#define ttisnumber(o)	(ttype(o) == LUA_TNUMBER)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
#define ttisstring(o)	(ttype(o) == LUA_TSTRING)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
#define ttistable(o)	(ttype(o) == LUA_TTABLE)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    83
#define ttisfunction(o)	(ttype(o) == LUA_TFUNCTION)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
#define ttisboolean(o)	(ttype(o) == LUA_TBOOLEAN)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
#define ttisuserdata(o)	(ttype(o) == LUA_TUSERDATA)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
#define ttisthread(o)	(ttype(o) == LUA_TTHREAD)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    87
#define ttislightuserdata(o)	(ttype(o) == LUA_TLIGHTUSERDATA)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
/* Macros to access values */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    90
#define ttype(o)	((o)->tt)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
#define gcvalue(o)	check_exp(iscollectable(o), (o)->value.gc)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
#define pvalue(o)	check_exp(ttislightuserdata(o), (o)->value.p)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    93
#define nvalue(o)	check_exp(ttisnumber(o), (o)->value.n)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    94
#define rawtsvalue(o)	check_exp(ttisstring(o), &(o)->value.gc->ts)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
#define tsvalue(o)	(&rawtsvalue(o)->tsv)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
#define rawuvalue(o)	check_exp(ttisuserdata(o), &(o)->value.gc->u)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
#define uvalue(o)	(&rawuvalue(o)->uv)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
#define clvalue(o)	check_exp(ttisfunction(o), &(o)->value.gc->cl)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
#define hvalue(o)	check_exp(ttistable(o), &(o)->value.gc->h)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
#define bvalue(o)	check_exp(ttisboolean(o), (o)->value.b)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
#define thvalue(o)	check_exp(ttisthread(o), &(o)->value.gc->th)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
#define l_isfalse(o)	(ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
** for internal debug only
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
#define checkconsistency(obj) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
  lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   111
#define checkliveness(g,obj) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   112
  lua_assert(!iscollectable(obj) || \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   113
  ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   114
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   115
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   116
/* Macros to set values */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   117
#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   118
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   119
#define setnvalue(obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   120
  { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   121
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   122
#define setpvalue(obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   123
  { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   124
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   125
#define setbvalue(obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   126
  { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   127
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   128
#define setsvalue(L,obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   129
  { TValue *i_o=(obj); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   130
    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   131
    checkliveness(G(L),i_o); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   132
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   133
#define setuvalue(L,obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   134
  { TValue *i_o=(obj); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   135
    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   136
    checkliveness(G(L),i_o); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   137
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   138
#define setthvalue(L,obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   139
  { TValue *i_o=(obj); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   140
    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   141
    checkliveness(G(L),i_o); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   142
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   143
#define setclvalue(L,obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   144
  { TValue *i_o=(obj); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   145
    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   146
    checkliveness(G(L),i_o); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   147
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   148
#define sethvalue(L,obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   149
  { TValue *i_o=(obj); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   150
    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   151
    checkliveness(G(L),i_o); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   152
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   153
#define setptvalue(L,obj,x) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   154
  { TValue *i_o=(obj); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   155
    i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   156
    checkliveness(G(L),i_o); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   157
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   158
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   159
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   160
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   161
#define setobj(L,obj1,obj2) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   162
  { const TValue *o2=(obj2); TValue *o1=(obj1); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   163
    o1->value = o2->value; o1->tt=o2->tt; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   164
    checkliveness(G(L),o1); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   165
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   166
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   167
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   168
** different types of sets, according to destination
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   169
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   170
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   171
/* from stack to (same) stack */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   172
#define setobjs2s	setobj
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   173
/* to stack (not from same stack) */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   174
#define setobj2s	setobj
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   175
#define setsvalue2s	setsvalue
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   176
#define sethvalue2s	sethvalue
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   177
#define setptvalue2s	setptvalue
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   178
/* from table to same table */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   179
#define setobjt2t	setobj
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   180
/* to table */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   181
#define setobj2t	setobj
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   182
/* to new object */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   183
#define setobj2n	setobj
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   184
#define setsvalue2n	setsvalue
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   185
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   186
#define setttype(obj, tt) (ttype(obj) = (tt))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   187
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   188
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   189
#define iscollectable(o)	(ttype(o) >= LUA_TSTRING)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   190
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   191
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   192
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   193
typedef TValue *StkId;  /* index to stack elements */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   194
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   195
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   196
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   197
** String headers for string table
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   198
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   199
typedef union TString {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   200
  L_Umaxalign dummy;  /* ensures maximum alignment for strings */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   201
  struct {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   202
    CommonHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   203
    lu_byte reserved;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   204
    unsigned int hash;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   205
    size_t len;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   206
  } tsv;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   207
} TString;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   208
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   209
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   210
#define getstr(ts)	cast(const char *, (ts) + 1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   211
#define svalue(o)       getstr(rawtsvalue(o))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   212
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   213
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   214
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   215
typedef union Udata {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   216
  L_Umaxalign dummy;  /* ensures maximum alignment for `local' udata */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   217
  struct {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   218
    CommonHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   219
    struct Table *metatable;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   220
    struct Table *env;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   221
    size_t len;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   222
  } uv;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   223
} Udata;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   224
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   225
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   226
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   227
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   228
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   229
** Function Prototypes
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   230
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   231
typedef struct Proto {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   232
  CommonHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   233
  TValue *k;  /* constants used by the function */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   234
  Instruction *code;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   235
  struct Proto **p;  /* functions defined inside the function */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   236
  int *lineinfo;  /* map from opcodes to source lines */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   237
  struct LocVar *locvars;  /* information about local variables */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   238
  TString **upvalues;  /* upvalue names */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   239
  TString  *source;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   240
  int sizeupvalues;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   241
  int sizek;  /* size of `k' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   242
  int sizecode;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   243
  int sizelineinfo;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   244
  int sizep;  /* size of `p' */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   245
  int sizelocvars;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   246
  int linedefined;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   247
  int lastlinedefined;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   248
  GCObject *gclist;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   249
  lu_byte nups;  /* number of upvalues */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   250
  lu_byte numparams;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   251
  lu_byte is_vararg;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   252
  lu_byte maxstacksize;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   253
} Proto;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   254
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   255
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   256
/* masks for new-style vararg */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   257
#define VARARG_HASARG		1
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   258
#define VARARG_ISVARARG		2
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   259
#define VARARG_NEEDSARG		4
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   260
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   261
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   262
typedef struct LocVar {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   263
  TString *varname;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   264
  int startpc;  /* first point where variable is active */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   265
  int endpc;    /* first point where variable is dead */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   266
} LocVar;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   267
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   268
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   269
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   270
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   271
** Upvalues
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   272
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   273
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   274
typedef struct UpVal {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   275
  CommonHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   276
  TValue *v;  /* points to stack or to its own value */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   277
  union {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   278
    TValue value;  /* the value (when closed) */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   279
    struct {  /* double linked list (when open) */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   280
      struct UpVal *prev;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   281
      struct UpVal *next;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   282
    } l;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   283
  } u;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   284
} UpVal;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   285
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   286
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   287
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   288
** Closures
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   289
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   290
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   291
#define ClosureHeader \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   292
	CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   293
	struct Table *env
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   294
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   295
typedef struct CClosure {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   296
  ClosureHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   297
  lua_CFunction f;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   298
  TValue upvalue[1];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   299
} CClosure;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   300
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   301
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   302
typedef struct LClosure {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   303
  ClosureHeader;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   304
  struct Proto *p;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   305
  UpVal *upvals[1];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   306
} LClosure;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   307
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   308
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   309
typedef union Closure {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   310
  CClosure c;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   311
  LClosure l;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   312
} Closure;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   313
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   314
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   315
#define iscfunction(o)	(ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   316
#define isLfunction(o)	(ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   317
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   318
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   319
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   320
** Tables
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   321
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   322
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   323
typedef union TKey {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   324
  struct {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   325
    TValuefields;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   326
    struct Node *next;  /* for chaining */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   327
  } nk;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   328
  TValue tvk;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   329
} TKey;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   330
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   331
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   332
typedef struct Node {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   333
  TValue i_val;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   334
  TKey i_key;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   335
} Node;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   336
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   337
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   338
typedef struct Table {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   339
  CommonHeader;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 2812
diff changeset
   340
  lu_byte flags;  /* 1<<p means tagmethod(p) is not present */
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   341
  lu_byte lsizenode;  /* log2 of size of `node' array */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   342
  struct Table *metatable;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   343
  TValue *array;  /* array part */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   344
  Node *node;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   345
  Node *lastfree;  /* any free position is before this position */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   346
  GCObject *gclist;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   347
  int sizearray;  /* size of `array' array */
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   348
} Table;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   349
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   350
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   351
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   352
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   353
** `module' operation for hashing (size is always a power of 2)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   354
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   355
#define lmod(s,size) \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   356
	(check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   357
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   358
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   359
#define twoto(x)	(1<<(x))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   360
#define sizenode(t)	(twoto((t)->lsizenode))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   361
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   362
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   363
#define luaO_nilobject		(&luaO_nilobject_)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   364
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   365
LUAI_DATA const TValue luaO_nilobject_;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   366
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   367
#define ceillog2(x)	(luaO_log2((x)-1) + 1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   368
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   369
LUAI_FUNC int luaO_log2 (unsigned int x);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   370
LUAI_FUNC int luaO_int2fb (unsigned int x);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   371
LUAI_FUNC int luaO_fb2int (int x);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   372
LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   373
LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   374
LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   375
                                                       va_list argp);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   376
LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   377
LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   378
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   379
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   380
#endif
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   381