diff options
author | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-02-17 11:05:19 +0100 |
---|---|---|
committer | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-02-17 11:05:19 +0100 |
commit | 47eb3f94373a13ac9f204ca65dfde602f53bdc1a (patch) | |
tree | 95d7d7a52ca92e6527d46d97207d3f079611a355 /src/tools.h | |
parent | 32ad991eb8c590472607d61e9a831d2ca9db05c5 (diff) | |
download | lanes-47eb3f94373a13ac9f204ca65dfde602f53bdc1a.tar.gz lanes-47eb3f94373a13ac9f204ca65dfde602f53bdc1a.tar.bz2 lanes-47eb3f94373a13ac9f204ca65dfde602f53bdc1a.zip |
Deep userdata support improvements
* bumped version to 3.9.0
* keepers now require "package", receive package.path & package.cpath,
and call on_state_create() if it is a C function
* changed the deep public API (improved deep idfunc signature, renamed
luaG_deep_userdata to luaG_newdeepuserdata)
* if an error occurs while copying a deep userdata, don't raise inside
the keeper state
* fixed situations where raised errors could lead to memory leaks (deep
gc)
Diffstat (limited to 'src/tools.h')
-rw-r--r-- | src/tools.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tools.h b/src/tools.h index be358db..ebe407b 100644 --- a/src/tools.h +++ b/src/tools.h | |||
@@ -99,11 +99,15 @@ extern int debugspew_indent_depth; | |||
99 | void luaG_dump( lua_State* L ); | 99 | void luaG_dump( lua_State* L ); |
100 | 100 | ||
101 | lua_State* luaG_newstate( lua_State* _from, char const* libs); | 101 | lua_State* luaG_newstate( lua_State* _from, char const* libs); |
102 | void luaG_copy_one_time_settings( lua_State* L, lua_State* L2, char const* name_); | 102 | void luaG_copy_one_time_settings( lua_State* L, lua_State* L2); |
103 | 103 | ||
104 | typedef struct { | 104 | // this is pointed to by full userdata proxies, and allocated with malloc() to survive any lua_State lifetime |
105 | volatile int refcount; | 105 | typedef struct |
106 | void *deep; | 106 | { |
107 | volatile int refcount; | ||
108 | void* deep; | ||
109 | // when stored in a keeper state, the full userdata doesn't have a metatable, so we need direct access to the idfunc | ||
110 | luaG_IdFunction idfunc; | ||
107 | } DEEP_PRELUDE; | 111 | } DEEP_PRELUDE; |
108 | 112 | ||
109 | enum eLookupMode | 113 | enum eLookupMode |
@@ -113,7 +117,7 @@ enum eLookupMode | |||
113 | eLM_FromKeeper // send a function from a keeper state to a lane | 117 | eLM_FromKeeper // send a function from a keeper state to a lane |
114 | }; | 118 | }; |
115 | 119 | ||
116 | void luaG_push_proxy( lua_State *L, luaG_IdFunction idfunc, DEEP_PRELUDE *deep_userdata); | 120 | char const* push_deep_proxy( lua_State* L, DEEP_PRELUDE* prelude, enum eLookupMode mode_); |
117 | void luaG_inter_copy_package( lua_State* L, lua_State* L2, int _idx, enum eLookupMode mode_); | 121 | void luaG_inter_copy_package( lua_State* L, lua_State* L2, int _idx, enum eLookupMode mode_); |
118 | 122 | ||
119 | int luaG_inter_copy( lua_State *L, lua_State *L2, uint_t n, enum eLookupMode mode_); | 123 | int luaG_inter_copy( lua_State *L, lua_State *L2, uint_t n, enum eLookupMode mode_); |
@@ -130,6 +134,8 @@ extern MUTEX_T mtid_lock; | |||
130 | void populate_func_lookup_table( lua_State* L, int _i, char const* _name); | 134 | void populate_func_lookup_table( lua_State* L, int _i, char const* _name); |
131 | void serialize_require( lua_State *L); | 135 | void serialize_require( lua_State *L); |
132 | int initialize_on_state_create( lua_State *L); | 136 | int initialize_on_state_create( lua_State *L); |
137 | void call_on_state_create( lua_State* L, lua_State* from_, enum eLookupMode mode_); | ||
138 | |||
133 | extern MUTEX_T require_cs; | 139 | extern MUTEX_T require_cs; |
134 | 140 | ||
135 | // for verbose errors | 141 | // for verbose errors |