-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On July 10, 2014 7:49:02 PM GMT+03:00, Ben Fritz <
fritzo...@gmail.com> wrote:
>On Wednesday, July 9, 2014 11:24:50 PM UTC-5, Yukihiro Nakadaira wrote:
>>
>> Here is sample code.
>>
>> [edited]
>>
>> L = luaL_newstate();
>>
>> lua_pushcclosure(L, add, 0);
>> lua_pushinteger(L, 111);
>> lua_pushinteger(L, 222);
>> lua_call(L, 2 /* nargs */, 1 /* nresults */);
>> r = lua_tointeger(L, -1);
>> lua_pop(L, 1);
>> lua_close(L);
>
>Thanks! I'll give this a try later. What's the -1 for in
>lua_tointeger()?
Almost all lua_* functions operate with stack. -1 is stack index. Like indexes in lua itself 1 means first value in the stack, 2 means second, ..., -1 means last, -2 means last but one, ...
In lua_pop you though specify how many values to pop, not which element to pop.
>
>Is there a good way to test this when I'm done? E.g. are there LUA
>tests
>in Vim's test suite that will exercise the garbage collector? Or maybe
>a
>toy script using the LUA interface I could run myself?
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1
iQI1BAEBCgAfBQJTvrb/GBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
HhHSvmnCD/9oKtyxddAIENOS3Yj+18oqxBAfgNFKjNiToD7tY87rx999YYFevnIc
KhgHaoiqcyw4cmTLWnBduoA1VmtUGt8iwxT9VXoOpw6HfbWqiuaqAsoIKrLIoLZp
H7zcLZIQX763eimUY/PsUgzDVShR73OsjHl8x0PcoYXsh80KcW42Fa5xNoV7O4lr
eqnG5V3OsQ6zcOz+SjUN6J3yHITDOpLGe0YNBuSctPqRtHooNR191rzfylQAJna9
5Mx5r05rXAg++HKF6sb7btf0lWMaUmYNJvTweRaxd6mSywxgwh9M+jZ7yiGXE9r3
thD7Be3Tk7woQT0ZdgkoioH6/efZNovoVf2NB/eOU17w3Dxm0doHfyH/s4xH5Dqq
4m2wJMtwlV2R0SYVYjzSOUXBVRxunUlU9m0K4CV2FUUwabLGaEJvmfegUt25sUlL
pcO1OFaJNLjGyHM96xbMwv1GpjRgUAfSjVbbDHxjeV/GeanemLlp8etYw1CTP9zs
CNNlVMzoHMSvYC8dGO4lqv7fdXNSFzvfUT/lL6i4trxVupgCvZ3oxWX4VUBTHRd4
Zzjr20iVLe4TGJTlSyCScvpMSZGdNiEEBhYhUpZGE20J5On7w5y2XHryrsNn+dOP
ZLNVywtzroQxKaLK79aOf4UDJhH2eKTGpuOiKQCnTk7/TxUXlPadTw==
=UYLM
-----END PGP SIGNATURE-----