gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/lua-utils.c
diff options
context:
space:
mode:
authorfr4nko <francesco.bbt@gmail.com>2010年06月29日 11:48:05 +0200
committerfr4nko <francesco.bbt@gmail.com>2010年06月29日 11:48:05 +0200
commit1beceb467757384bd5695f5e7ed9acfba590bd4a (patch)
tree009f1a0df1484ebf721a93a6e3f2b1d135e4f4ba /lua-utils.c
parentb5f50727239483643508795750262bc3ab6723ca (diff)
downloadgsl-shell-1beceb467757384bd5695f5e7ed9acfba590bd4a.tar.gz
added new c++ version of agg
Now the agg graphical modules have a different implementations. Now lua code is written directly in C++. We have also changed the memory reference system: now lua is responsable of freeing everything.
Diffstat (limited to 'lua-utils.c')
-rw-r--r--lua-utils.c 59
1 files changed, 59 insertions, 0 deletions
diff --git a/lua-utils.c b/lua-utils.c
index 7f0e465a..24a065c5 100644
--- a/lua-utils.c
+++ b/lua-utils.c
@@ -206,3 +206,62 @@ mlua_fenv_get (lua_State *L, int index, int fenv_index)
lua_rawgeti (L, -1, fenv_index);
lua_remove (L, -2);
}
+
+void
+mlua_fenv_addref (lua_State *L, int refindex)
+{
+ int n;
+ lua_getfenv (L, -1);
+ n = lua_objlen (L, -1);
+ lua_pushvalue (L, refindex);
+ lua_rawseti (L, -2, n+1);
+ lua_pop (L, 1);
+}
+
+void
+mlua_set_fenv_ref (lua_State *L, int refindex)
+{
+ int n;
+ lua_newtable (L);
+ lua_pushvalue (L, refindex);
+ lua_rawseti (L, -2, 1);
+ lua_setfenv (L, -2);
+}
+
+void
+prepare_window_ref_table (lua_State *L)
+{
+ lua_newtable (L);
+ lua_pushinteger (L, 0);
+ lua_setfield (L, -2, "N");
+ lua_setfield (L, LUA_REGISTRYINDEX, "GSL.windows");
+}
+
+int
+mlua_window_ref(lua_State *L, int index)
+{
+ int n;
+
+ lua_getfield (L, LUA_REGISTRYINDEX, "GSL.windows");
+
+ lua_getfield (L, -1, "N");
+ n = lua_tointeger (L, -1);
+ lua_pushinteger (L, n+1);
+ lua_remove (L, -2);
+ lua_setfield (L, -2, "N");
+
+ lua_pushvalue (L, index);
+ lua_rawseti (L, -2, n+1);
+ lua_pop (L, 1);
+
+ return n+1;
+}
+
+void
+mlua_window_unref(lua_State *L, int id)
+{
+ lua_getfield (L, LUA_REGISTRYINDEX, "GSL.windows");
+ lua_pushnil (L);
+ lua_rawseti (L, -2, id);
+ lua_pop (L, 1);
+}
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月18日 14:33:27 +0000

AltStyle によって変換されたページ (->オリジナル) /