aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2020-04-22 11:26:31 +0200
committerBenoit Germain <bnt.germain@gmail.com>2020-04-22 11:26:31 +0200
commit203790a68020186bf668b2787968aa0d901fc518 (patch)
treed81307bc7a89030620dd49c71eac9814d72dc383
parenta24e54d7d506d4ac38516143b25593922a9959cf (diff)
parent5add9b9e8ecb48d5e29556e5c655e6573c60c2b4 (diff)
downloadlanes-203790a68020186bf668b2787968aa0d901fc518.tar.gz
lanes-203790a68020186bf668b2787968aa0d901fc518.tar.bz2
lanes-203790a68020186bf668b2787968aa0d901fc518.zip
Merge branch 'master' of https://github.com/LuaLanes/lanes
-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