6 |
** $Id$ |
** $Id$ |
7 |
*/ |
*/ |
8 |
|
|
9 |
/* This code is free software; you can redistribute it and/or modify it. |
/* This code is free software; you can redistribute it and/or modify it. |
10 |
** The software provided hereunder is on an "as is" basis, and |
** The software provided hereunder is on an "as is" basis, and |
11 |
** the author has no obligation to provide maintenance, support, updates, |
** the author has no obligation to provide maintenance, support, updates, |
12 |
** enhancements, or modifications. |
** enhancements, or modifications. |
13 |
*/ |
*/ |
14 |
|
|
15 |
#include <stdio.h> |
#include <stdio.h> |
50 |
lua_newtable(L); |
lua_newtable(L); |
51 |
lua_settag(L,tag); |
lua_settag(L,tag); |
52 |
lua_setglobal(L,name); |
lua_setglobal(L,name); |
53 |
|
|
54 |
lua_pushcfunction(L,get); |
lua_pushcfunction(L,get); |
55 |
lua_settagmethod(L,tag,"gettable"); |
lua_settagmethod(L,tag,"gettable"); |
56 |
if (set) |
if (set) |
57 |
lua_pushcfunction(L,set); |
lua_pushcfunction(L,set); |
58 |
else |
else |
60 |
lua_settagmethod(L,tag,"settable"); |
lua_settagmethod(L,tag,"settable"); |
61 |
} |
} |
62 |
|
|
63 |
void tolua_tablevar |
void tolua_tablevar |
64 |
(lua_State* L, char* table, char* name, lua_CFunction get, lua_CFunction set) |
(lua_State* L, const char* table, const char* name, lua_CFunction get, lua_CFunction set) |
65 |
{ |
{ |
66 |
lua_getglobal(L,table); |
lua_getglobal(L,table); |
67 |
|
|
102 |
lua_gettable(L,-2); |
lua_gettable(L,-2); |
103 |
lua_getglobal(L,lua_tostring(L,-1)); |
lua_getglobal(L,lua_tostring(L,-1)); |
104 |
lua_pushstring(L,".array"); |
lua_pushstring(L,".array"); |
105 |
lua_gettable(L,-2); |
lua_gettable(L,-2); |
106 |
lua_pushvalue(L,2); /* field */ |
lua_pushvalue(L,2); /* field */ |
107 |
lua_gettable(L,-2); |
lua_gettable(L,-2); |
108 |
lua_pushstring(L,".self"); |
lua_pushstring(L,".self"); |
141 |
tolua_tablevar(L,table,name,toluaI_get_array,NULL); |
tolua_tablevar(L,table,name,toluaI_get_array,NULL); |
142 |
} |
} |
143 |
|
|
144 |
void tolua_module (lua_State* L, char* name) |
void tolua_module (lua_State* L, const char* name) |
145 |
{ |
{ |
146 |
lua_getglobal(L,name); |
lua_getglobal(L,name); |
147 |
if (!lua_istable(L,-1)) |
if (!lua_istable(L,-1)) |
161 |
lua_pop(L,1); |
lua_pop(L,1); |
162 |
} |
} |
163 |
|
|
164 |
void tolua_cclass (lua_State* L, char* name, char* base) |
void tolua_cclass (lua_State* L, const char* name, const char* base) |
165 |
{ |
{ |
166 |
int t; |
int t; |
167 |
lua_newtable(L); |
lua_newtable(L); |
182 |
} |
} |
183 |
lua_pushvalue(L,-1); /* duplicate top */ |
lua_pushvalue(L,-1); /* duplicate top */ |
184 |
lua_setglobal(L,name); |
lua_setglobal(L,name); |
185 |
t = lua_gettop(L); |
t = lua_gettop(L); |
186 |
toluaI_tm_class(L,t,name); |
toluaI_tm_class(L,t,name); |
187 |
toluaI_tt_class(L,t,name,base); |
toluaI_tt_class(L,t,name,base); |
188 |
lua_pop(L,1); |
lua_pop(L,1); |
206 |
} |
} |
207 |
} |
} |
208 |
|
|
209 |
void tolua_constant (lua_State* L, char* parent, char* name, double value) |
void tolua_constant (lua_State* L, const char* parent, const char* name, double value) |
210 |
{ |
{ |
211 |
if (parent==NULL) |
if (parent==NULL) |
212 |
{ |
{ |