aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/test_c.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-03 03:56:41 +1000
committerDavid Walter Seikel2014-04-03 03:56:41 +1000
commitf3a739ac1443bc1a5ebd7c56a0d2082781b217eb (patch)
tree8501a9e62467fd33cb56ba6ccef5d7c0802df295 /ClientHamr/GuiLua/test_c.c
parentDefine window via array instead of argument list. (diff)
downloadSledjHamr-f3a739ac1443bc1a5ebd7c56a0d2082781b217eb.zip
SledjHamr-f3a739ac1443bc1a5ebd7c56a0d2082781b217eb.tar.gz
SledjHamr-f3a739ac1443bc1a5ebd7c56a0d2082781b217eb.tar.bz2
SledjHamr-f3a739ac1443bc1a5ebd7c56a0d2082781b217eb.tar.xz
Shuffle same docs around, and fix up others.
Diffstat (limited to 'ClientHamr/GuiLua/test_c.c')
-rw-r--r--ClientHamr/GuiLua/test_c.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/ClientHamr/GuiLua/test_c.c b/ClientHamr/GuiLua/test_c.c
index 8f6ee7b..3949012 100644
--- a/ClientHamr/GuiLua/test_c.c
+++ b/ClientHamr/GuiLua/test_c.c
@@ -3,7 +3,7 @@
3TODO - see if this still works if it's an app instead of a library. 3TODO - see if this still works if it's an app instead of a library.
4 4
5 5
6Seems to be several problems with linking in various OSes, heres some 6Seems to be several problems with linking in various OSes, here's some
7possibly helpful links - 7possibly helpful links -
8 8
9http://lua.2524044.n2.nabble.com/C-Lua-modules-not-compatible-with-every-Lua-interpreter-td7647522.html 9http://lua.2524044.n2.nabble.com/C-Lua-modules-not-compatible-with-every-Lua-interpreter-td7647522.html
@@ -54,11 +54,11 @@ static void dumpStack(lua_State *L, int i)
54/* local test_c = require 'test_c' 54/* local test_c = require 'test_c'
55 55
56Lua's require() function will strip any stuff from the front of the name 56Lua's require() function will strip any stuff from the front of the name
57separated by a hyphen, so 'GuiLua-test_c' -> 'test_c'. Then it will 57separated by a hyphen, so 'ClientHamr-GuiLua-test_c' -> 'test_c'. Then
58search through a path, and eventually find this test_c.so (or test_c.dll 58it will search through a path, and eventually find this test_c.so (or
59or whatever), then call luaopen_test_c(), which should return a table. 59test_c.dll or whatever), then call luaopen_test_c(), which should return
60The argument (only thing on the stack) for this function will be 60a table. The argument (only thing on the stack) for this function will
61'test_c'. 61be 'test_c'.
62 62
63Normally luaL_register() creates a table of functions, that is the table 63Normally luaL_register() creates a table of functions, that is the table
64returned, but we want to do something different with skang. 64returned, but we want to do something different with skang.
@@ -78,11 +78,8 @@ int luaopen_test_c(lua_State *L)
78// The only locals we care about are skang and _M. 78// The only locals we care about are skang and _M.
79// All modules go into package.loaded[name] as well. 79// All modules go into package.loaded[name] as well.
80// skang is essentially a global anyway. 80// skang is essentially a global anyway.
81// _M we pass back as the result, and our functions get added to it by skang.thing() 81// _M we pass back as the result, and our functions get added to it by skang.thingasm()
82// Not entirely true, skang.things is a proxy table, skang.things.ffunc.func would be our function. 82// Not entirely true, _M is a proxy table, getmetatable(_M).__values[cfunc] would be our function.
83// skang.things.ffunc.module is our _M ('environment of our calling function', so that's the 'environment' right here, since we call skang.thing().
84// test_c.ffunc() -> test_c.__index(test_c, 'ffunc') -> skang.things[ffunc].value() -> test_c.c->ffunc()
85// this is a C function, not a Lua function
86 83
87// local skang = require 'skang' 84// local skang = require 'skang'
88 lua_getglobal(L, "require"); 85 lua_getglobal(L, "require");