aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/test_c.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-31 22:45:21 +1000
committerDavid Walter Seikel2014-03-31 22:45:21 +1000
commitbd05c036e46f6fbbaa8c79414a48dc02d00e7d33 (patch)
treebd0d349e97147cc4d2a1c6faa1f5a075bb5c9701 /ClientHamr/GuiLua/test_c.c
parentMore ways to call thing, and rename it thingasm. (diff)
downloadSledjHamr-bd05c036e46f6fbbaa8c79414a48dc02d00e7d33.zip
SledjHamr-bd05c036e46f6fbbaa8c79414a48dc02d00e7d33.tar.gz
SledjHamr-bd05c036e46f6fbbaa8c79414a48dc02d00e7d33.tar.bz2
SledjHamr-bd05c036e46f6fbbaa8c79414a48dc02d00e7d33.tar.xz
Clean up after my thingasm.
Diffstat (limited to 'ClientHamr/GuiLua/test_c.c')
-rw-r--r--ClientHamr/GuiLua/test_c.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/ClientHamr/GuiLua/test_c.c b/ClientHamr/GuiLua/test_c.c
index 10af91c..8f6ee7b 100644
--- a/ClientHamr/GuiLua/test_c.c
+++ b/ClientHamr/GuiLua/test_c.c
@@ -65,6 +65,7 @@ returned, but we want to do something different with skang.
65*/ 65*/
66int luaopen_test_c(lua_State *L) 66int luaopen_test_c(lua_State *L)
67{ 67{
68 lua_Number i;
68 69
69 // In theory, the only thing on the stack now is 'test_c' from the require() call. 70 // In theory, the only thing on the stack now is 'test_c' from the require() call.
70 71
@@ -121,16 +122,29 @@ int luaopen_test_c(lua_State *L)
121 122
122// skang.thing('cfooble,c', 'Help text goes here', 1, 'number', \"'edit', 'The fooble:', 1, 1, 10, 50\", true) 123// skang.thing('cfooble,c', 'Help text goes here', 1, 'number', \"'edit', 'The fooble:', 1, 1, 10, 50\", true)
123 lua_getfield(L, skang, "thingasm"); 124 lua_getfield(L, skang, "thingasm");
125 i = 1;
126 lua_newtable(L);
127 lua_pushnumber(L, i++);
124 lua_getfield(L, LUA_REGISTRYINDEX, ourName); // Coz getfenv() can't find C environment. 128 lua_getfield(L, LUA_REGISTRYINDEX, ourName); // Coz getfenv() can't find C environment.
129 lua_settable(L, -3);
130
131 lua_pushnumber(L, i++);
125 lua_pushstring(L, "cfooble,c"); 132 lua_pushstring(L, "cfooble,c");
126 lua_pushstring(L, "Help text"); 133 lua_settable(L, -3);
134
135 lua_pushnumber(L, i++);
136 lua_pushstring(L, "cfooble help text");
137 lua_settable(L, -3);
138
139 lua_pushnumber(L, i++);
127 lua_pushnumber(L, 1); 140 lua_pushnumber(L, 1);
128 lua_pushnil(L); 141 lua_settable(L, -3);
142
129 lua_pushstring(L, "'edit', 'The cfooble:', 1, 1, 10, 50"); 143 lua_pushstring(L, "'edit', 'The cfooble:', 1, 1, 10, 50");
144 lua_setfield(L, -2, "widget");
130 lua_pushboolean(L, 1); // Is required. 145 lua_pushboolean(L, 1); // Is required.
131 lua_pushnil(L); // Default ACL. 146 lua_setfield(L, -2, "required");
132 lua_pushnil(L); // No boss. 147 lua_call(L, 1, 0);
133 lua_call(L, 9, 0);
134 148
135// skang.thing('cbar', 'Help text', 'Default') 149// skang.thing('cbar', 'Help text', 'Default')
136 lua_getfield(L, skang, "thingasm"); 150 lua_getfield(L, skang, "thingasm");
@@ -138,25 +152,13 @@ int luaopen_test_c(lua_State *L)
138 lua_pushstring(L, "cbar"); 152 lua_pushstring(L, "cbar");
139 lua_pushstring(L, "Help text"); 153 lua_pushstring(L, "Help text");
140 lua_pushstring(L, "Default"); 154 lua_pushstring(L, "Default");
141 lua_pushnil(L); // No type. 155 lua_call(L, 4, 0);
142 lua_pushnil(L); // No widget.
143 lua_pushnil(L); // Not required.
144 lua_pushnil(L); // Default ACL.
145 lua_pushnil(L); // No boss.
146 lua_call(L, 9, 0);
147 156
148// skang.thing('cfoo') 157// skang.thing('cfoo')
149 lua_getfield(L, skang, "thingasm"); 158 lua_getfield(L, skang, "thingasm");
150 lua_pushstring(L, "cfoo");
151 lua_pushnil(L); // No help.
152 lua_pushnil(L); // No default.
153 lua_pushnil(L); // No type.
154 lua_pushnil(L); // No widget.
155 lua_pushnil(L); // Not required.
156 lua_pushnil(L); // Default ACL.
157 lua_pushnil(L); // No boss.
158 lua_getfield(L, LUA_REGISTRYINDEX, ourName); // Coz getfenv() can't find C environment. 159 lua_getfield(L, LUA_REGISTRYINDEX, ourName); // Coz getfenv() can't find C environment.
159 lua_call(L, 9, 0); 160 lua_pushstring(L, "cfoo");
161 lua_call(L, 2, 0);
160 162
161// skang.thing('cfunc', 'Help Text', ffunc, 'number,string') 163// skang.thing('cfunc', 'Help Text', ffunc, 'number,string')
162 lua_getfield(L, skang, "thingasm"); 164 lua_getfield(L, skang, "thingasm");
@@ -165,11 +167,7 @@ int luaopen_test_c(lua_State *L)
165 lua_pushstring(L, "cfunc does nothing really"); 167 lua_pushstring(L, "cfunc does nothing really");
166 lua_pushcfunction(L, cfunc); 168 lua_pushcfunction(L, cfunc);
167 lua_pushstring(L, "number,string"); 169 lua_pushstring(L, "number,string");
168 lua_pushnil(L); // No widget. 170 lua_call(L, 5, 0);
169 lua_pushnil(L); // Not required.
170 lua_pushnil(L); // Default ACL.
171 lua_pushnil(L); // No boss.
172 lua_call(L, 9, 0);
173 171
174// skang.moduleEnd(_M) 172// skang.moduleEnd(_M)
175 lua_getfield(L, skang, "moduleEnd"); 173 lua_getfield(L, skang, "moduleEnd");