-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdynamo.i
179 lines (163 loc) · 4.78 KB
/
dynamo.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
%module dynamo
%{
#include "Source/dynamo.h"
%}
typedef void (*Obj_destructor_t)(void *aSelf);
/*!
Provides information about a class of objects
*/
typedef struct {
char *name;
long instanceSize;
Obj_destructor_t destructor;
} Class_t;
/*!
The core of an object, contains a reference to it's class & it's reference count<br>
Add OBJ_GUTS at the beginning of a struct type in order to make it a valid, retainable object
*/
typedef struct {
Class_t *isa;
long referenceCount;
} _Obj_guts;
/*!
Represents a reference counted object.
*/
typedef void Obj_t;
#define OBJ_GUTS _Obj_guts _guts;
/*!
Creates an autoreleased object of the given class
*/
Obj_t *obj_create_autoreleased(Class_t *aClass);
/*!
Creates an object of the given class
*/
Obj_t *obj_create(Class_t *aClass);
/*!
Retains an object (increases the reference count by 1)
*/
Obj_t *obj_retain(Obj_t *aObj);
/*!
Releases an object (decreases the reference count by 1)
*/
void obj_release(Obj_t *aObj);
/*!
Adds an object to the autorelease pool causing it to be released at the end of the current runloop iteration.
*/
Obj_t *obj_autorelease(Obj_t *aObj);
/*!
Gets a reference to the class of an object
*/
Class_t *obj_getClass(Obj_t *aObj);
/*!
Checks if an object is of the given class
*/
bool obj_isClass(Obj_t *aObj, Class_t *aClass);
extern Class_t Class_LuaContext;
typedef struct _LuaContext {
OBJ_GUTS
lua_State *luaState;
} LuaContext_t;
extern LuaContext_t *GlobalLuaContext;
/*!
Inits the global context
*/
extern void luaCtx_init();
/*!
Destroys the global context.
*/
extern void luaCtx_teardown();
/*!
Creates a lua context
*/
extern LuaContext_t *luaCtx_createContext();
/*!
Gets a named global variable and pushes it on the lua stack.
*/
extern void luaCtx_getglobal(LuaContext_t *aCtx, const char *k);
/*!
Pops 'n' values off the top of the lua stack.
*/
extern void luaCtx_pop(LuaContext_t *aCtx, int n);
/*!
Creates a table at the top of the lua stack.
*/
extern void luaCtx_createtable(LuaContext_t *aCtx, int narr, int nrec);
/*!
Gets field 'k' in the table at stack index 'idx'.
*/
extern void luaCtx_getfield(LuaContext_t *aCtx, int idx, const char *k);
/*!
Sets the field 'k' in the table at stack index 'idx' to the value at stack index -1.
*/
extern void luaCtx_setfield(LuaContext_t *aCtx, int idx, const char *k);
/*!
Wrapper for pcall that handles errors.
*/
extern bool luaCtx_pcall(LuaContext_t *aCtx, int nargs, int nrseults, int errfunc);
/*!
Loads and executes the file at the given path.
*/
extern bool luaCtx_executeFile(LuaContext_t *aCtx, const char *aPath);
/*!
Executes the given lua string.
*/
extern bool luaCtx_executeString(LuaContext_t *aCtx, const char *aScript);
/*!
Adds a path to the global lua search path (Used by require()).
*/
extern bool luaCtx_addSearchPath(LuaContext_t *aCtx, const char *aPath);
/*!
Pushes the value at 'idx' of the lua stack onto the top of the stack.
*/
extern void luaCtx_pushvalue(LuaContext_t *aCtx, int idx);
/*!
Pushes nil on the lua stack.
*/
extern void luaCtx_pushnil(LuaContext_t *aCtx);
/*!
Pushes a number(float) on the lua stack.
*/
extern void luaCtx_pushnumber(LuaContext_t *aCtx, float n);
/*!
Pushes an integer on the lua stack.
*/
extern void luaCtx_pushinteger(LuaContext_t *aCtx, int n);
/*!
Pushes a string on the lua stack.
*/
extern void luaCtx_pushstring(LuaContext_t *aCtx, const char *s);
/*!
Pushes a boolean on the lua stack.
*/
extern void luaCtx_pushboolean(LuaContext_t *aCtx, int b);
/*!
Pushes a pointer as light userdata object onto the lua stack.
*/
void luaCtx_pushlightuserdata(LuaContext_t *aCtx, void *ptr);
/*!
Pushes a registered script handler onto the lua stack.
*/
extern bool luaCtx_pushScriptHandler(LuaContext_t *aCtx, int aRefId);
/*!
Deletes a script handler from the lua registry.
*/
extern void luaCtx_unregisterScriptHandler(LuaContext_t *aCtx, int aRefId);
/*!
Concatenates the 'n' top elements of the lua stack.
*/
extern void luaCtx_concat(LuaContext_t *aCtx, int n);
extern int luaCtx_next(LuaContext_t *aCtx, int index);
extern int luaCtx_type(LuaContext_t *aCtx, int idx);
extern int luaCtx_isnumber(LuaContext_t *aCtx, int idx);
extern int luaCtx_isstring(LuaContext_t *aCtx, int idx);
extern int luaCtx_isuserdata(LuaContext_t *aCtx, int idx);
extern int luaCtx_istable(LuaContext_t *aCtx, int idx);
extern int luaCtx_islightuserdata(LuaContext_t *aCtx, int idx);
extern int luaCtx_isnil(LuaContext_t *aCtx, int idx);
extern int luaCtx_isboolean(LuaContext_t *aCtx, int idx);
extern int luaCtx_isfunction(LuaContext_t *aCtx, int idx);
extern int luaCtx_isnone(LuaContext_t *aCtx, int idx);
extern float luaCtx_tonumber(LuaContext_t *aCtx, int idx);
extern int luaCtx_tointeger(LuaContext_t *aCtx, int idx);
extern int luaCtx_toboolean(LuaContext_t *aCtx, int idx);
extern const char *luaCtx_tostring(LuaContext_t *aCtx, int idx);