Commit 2032d4956229d9ebe277fdae26d7aed149f4aaf0

Authored by dg
1 parent ad94417d

fuckit

git-svn-id: http://svn.net-core.org/repos/t-engine4@1995 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -977,3 +977,7 @@ function util.browserOpenUrl(url)
977 977 end
978 978 return false
979 979 end
  980 +
  981 +function __dump_fct(f)
  982 + return string.format("%q", string.dump(f))
  983 +end
... ...
... ... @@ -680,7 +680,7 @@ int main(int argc, char *argv[])
680 680 init_gen_rand(time(NULL));
681 681
682 682 // Change to line buffering
683   - setvbuf(stdout, (char *) NULL, _IOLBF, 0);
  683 +// setvbuf(stdout, (char *) NULL, _IOLBF, 0);
684 684
685 685 // Parse arguments
686 686 int i;
... ...
... ... @@ -138,9 +138,24 @@ static bool basic_serialize(lua_State *L, serial_type *s, int type, int idx)
138 138 dump_string(s, str, len);
139 139 writeZipFixed(s, "\"", 1);
140 140 } else if (type == LUA_TFUNCTION) {
  141 +/*
141 142 writeZipFixed(s, "loadstring(\"", 12);
142 143 lua_dump(L, dump_function, s);
143 144 writeZipFixed(s, "\")", 2);
  145 +*/
  146 + lua_getglobal(L, "__dump_fct");
  147 + lua_pushvalue(L, idx-1);
  148 + lua_call(L, 1, 1);
  149 +
  150 + size_t len;
  151 + const char *str = lua_tolstring(L, -1, &len);
  152 +
  153 + writeZipFixed(s, "loadstring(", 11);
  154 + writeZipFixed(s, str, len);
  155 + writeZipFixed(s, ")", 1);
  156 +
  157 + lua_pop(L, 1);
  158 +
144 159 } else if (type == LUA_TTABLE) {
145 160 lua_pushstring(L, "__CLASSNAME");
146 161 lua_rawget(L, idx - 1);
... ...