aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorame <[email protected]>2024-02-12 11:35:20 -0600
committerame <[email protected]>2024-02-12 11:35:20 -0600
commit5b4723f51f4a0f514959038e58c36c70a82e363f (patch)
treef4ff18c0a40d8642c8b798ccbd10c4e461642455
parente412e6eaddfa1bc03c7e52ca36a05ff138606d35 (diff)
copy now works
-rw-r--r--src/lua.c38
-rw-r--r--src/net.c2
-rw-r--r--tests/net.lua6
3 files changed, 35 insertions, 11 deletions
diff --git a/src/lua.c b/src/lua.c
index 33b9309..e7ff11b 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -24,7 +24,8 @@ void i_dcopy(lua_State* src, lua_State* dest, void* _seen){
if(seen == NULL) seen = parray_init();
size_t len;
int at, at2;
- int *sp = malloc(1);
+ //int *sp = malloc(1);
+ //int *sp;
char* s;
void* whar;
int old_top = lua_gettop(src);
@@ -41,22 +42,43 @@ void i_dcopy(lua_State* src, lua_State* dest, void* _seen){
lua_newtable(dest);
at = lua_gettop(dest);
at2 = lua_gettop(src);
+ char aauwu[50] = {0};
+ sprintf(aauwu, "%p", lua_topointer(src, at2));
- *sp = at;
- whar = parray_get(seen, (void*)lua_topointer(src, at2));
+ int* sp = malloc(1);
+ whar = parray_get(seen, aauwu);
if( whar != NULL){
//printf("%s\n",lua_tostring(src, at2 - 1));
- printf("WHAR\n");
- //lua_pop(dest, 1);
- //lua_pushvalue(dest, *(int*)whar);
+ //printf("WHAR\n");
+ lua_pop(dest, 1);
+ lua_rawgeti(dest, LUA_REGISTRYINDEX, *(int*)whar);
+
+ //lua_pushnumber(dest, 23);
+ /*int abb = lua_gettop(src);
+ l_pprint(src);
+ lua_settop(src, abb);
+ abb = lua_gettop(dest);
+ printf("\n**\n");
+ l_pprint(dest);
+ lua_settop(dest, abb);
+ printf("used %i\n",*(int*)whar);*/
return;
- } else parray_set(seen, (void*)lua_topointer(src, at2), sp);
+ }
+ //lua_pushinteger(dest, 55);
+ int r = luaL_ref(dest, LUA_REGISTRYINDEX);
+ lua_rawgeti(dest, LUA_REGISTRYINDEX, r);
+ *sp = r;
+ parray_set(seen, aauwu, sp);
+ //printf("saved %i\n", *sp);
+ //for(int i = 0; i != seen->len; i++){
+ // printf("%i ", *(int*)seen->P[i].value);
+ //}
lua_pushnil(src);
for(;lua_next(src, at2) != 0;){
lua_pushvalue(src, -2);
int a = lua_gettop(src);
- l_pprint(src);
+ //l_pprint(src);
lua_settop(src, a);
i_dcopy(src, dest, seen);
diff --git a/src/net.c b/src/net.c
index 3447c02..420f229 100644
--- a/src/net.c
+++ b/src/net.c
@@ -579,7 +579,7 @@ int l_req_com(lua_State* L, char* req){
awa->c = a;
awa->len = len;
strcpy(awa->req, req);
- printf("%s\n",awa->req);
+ //printf("%s\n",awa->req);
if(paths == NULL)
paths = parray_init();
diff --git a/tests/net.lua b/tests/net.lua
index 705aaab..3320355 100644
--- a/tests/net.lua
+++ b/tests/net.lua
@@ -8,7 +8,8 @@ sleep = function(a)
end
aea = 5
local wowa = 5
-_G.wo = llib
+--_G.wo = llib
+_G._llib = _G.llib
--_G.ww = llib
--llib.io.pprint(_G)
@@ -33,7 +34,8 @@ llib.net.listen(
--print("hi from first")
--llib.io.pprint(llib.crypto.md5("hewwo"))
--_G.sleep(1)
- _G.llib.io.pprint(_G)
+ _G.llib.io.pprint(_G._G._G._llib.crypto.md5("hi"))
+ --_G.llib.io.pprint(_G._Go)
--_G.llib.io.pprint(_G.wo.crypto.md5("55"))
end)