lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Doug Rogers wrote:
> What Peter wrote, plus a copy of the 'class' object, assuming that's
> what you want (untested):
> 
>     lua_rawgeti(L, LUA_REGISTRYINDEX, class);
>     g_assert(lua_type(L, -1) == LUA_TTABLE);
>     lua_getfield(L, -1, cmd);
>     g_assert(lua_type(L, -1) == LUA_TFUNCTION);
>     lua_pushvalue(L, -2);      // Copy 'class' object.
>     lua_pushstring(L, args);
>     g_assert(lua_type(L, -1) == LUA_TSTRING);
>     if (0 != lua_pcall(L, 2, 1, 0)) { // pass 2 args, get 1 value...

Thank you Doug and Peter. Your explanation makes sense and the above
example of pushing the value works. How does lua internally know that
the first argument might be the scope of the method (like python's self
argument) or not?

~ Matthew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklieDkACgkQLrcoBjlTBf0IKwCgkQoSYvu5ONQ21jwLUU959vjv
gacAn2G0sPZ0FbNGkMsULi6p0NP53LiN
=7aAt
-----END PGP SIGNATURE-----