aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/manual_register.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/manual_register.lua b/tests/manual_register.lua
new file mode 100644
index 0000000..b868bb9
--- /dev/null
+++ b/tests/manual_register.lua
@@ -0,0 +1,35 @@
1
2local register_func = true
3
4local RequireAModuleThatExportsGlobalFunctions = function()
5 -- grab some module that exports C functions, this is good enough for our purpose
6 local lfs = require "lfs"
7 -- make one of these a global
8 GlobalFunc = lfs.attributes
9 -- we need to register it so that it is transferable
10 if register_func then
11 local lanes = require "lanes"
12 lanes.register( "GlobalFunc", GlobalFunc)
13 end
14 print "RequireAModuleThatExportsGlobalFunctions done"
15end
16
17
18local lanes = require "lanes".configure{ with_timers = false, on_state_create = RequireAModuleThatExportsGlobalFunctions}
19
20-- load some module that adds C functions to the global space
21RequireAModuleThatExportsGlobalFunctions()
22
23local GlobalFuncUpval = GlobalFunc
24
25-- a lane that makes use of the above global
26local f = function()
27 GlobalFuncUpval("foo")
28 print "f done"
29end
30
31
32local g = lanes.gen( "*", f)
33
34-- generate a lane, this will transfer f, which pulls GlobalFunc.
35local h = g() \ No newline at end of file