lua_pop, lua_pushcfunction, lua_register, lua_getregistry, lua_setglobal, lua_getglobal,
1 lua_pop
#define lua_pop(L,n) lua_settop(L, -(n)-1)
½ºÅÃÀÇ ¸Ç À§¿¡ ÀÖ´Â ¾ÆÀÌÅÛÀ» ÆËÇÑ´Ù.
2 lua_pushcfunction
#define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0)
C ÇÔ¼ö¸¦ ½ºÅÿ¡´Ù Ǫ½¬ÇÑ´Ù. º¸´Ù½ÃÇÇ upvalueÀÇ °¹¼ö´Â 0ÀÌ´Ù.
3 lua_register
#define lua_register(L,n,f) \
(lua_pushstring(L, n), \
lua_pushcfunction(L, f), \
lua_settable(L, LUA_GLOBALSINDEX))
C ÇÔ¼ö¸¦ µî·ÏÇÑ´Ù. n Àμö´Â ÇÔ¼öÀÇ À̸§ ¹®ÀÚ¿, f Àμö´Â ÇÔ¼ö Æ÷ÀÎÅÍ´Ù.
4 lua_getregistry
#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
·¹Áö½ºÆ®¸® Å×À̺íÀ» °¡Á®¿Í ½ºÅÃÀÇ ¸Ç À§¿¡´Ù Ǫ½¬ÇÑ´Ù.
5 lua_setglobal
#define lua_setglobal(L,s) \
(lua_pushstring(L, s), lua_insert(L, -2), lua_settable(L, LUA_GLOBALSINDEX))
Àü¿ª º¯¼öÀÇ °ªÀ» ¼³Á¤ÇÑ´Ù. ÀÌ ¸ÅÅ©·Î¸¦ ¼öÇàÇϱâ ÀÌÀü¿¡ Àü¿ª º¯¼ö¿¡´Ù ÇÒ´çÇÒ ¾ÆÀÌÅÛÀ» ½ºÅÿ¡´Ù Ǫ½¬ÇØµÖ¾ß ÇÑ´Ù. ¼öÇà ÈÄ¿¡´Â ÀÌÀü¿¡ Ǫ½¬ÇÑ ¾ÆÀÌÅÛÀÌ ÆËµÈ´Ù.
lua_pushstring(L, "I'm a value");
lua_setglobal(L, "MyVariable");
6 lua_getglobal
#define lua_getglobal(L,s) \
(lua_pushstring(L, s), lua_gettable(L, LUA_GLOBALSINDEX))
Àü¿ª Å×ÀÌºí¿¡¼ s º¯¼ö¸¦ °¡Á®¿Í ½ºÅÃÀÇ ¸Ç À§¿¡´Ù Ǫ½¬ÇÑ´Ù.
SeriousMoin v1 (koMoinMoin 1.0a4 Modified)