示例#1
0
 /*
 ** This function will use either 'ipairsaux' or 'ipairsaux_raw' to
 ** traverse a table, depending on whether the table has metamethods
 ** that can affect the traversal.
 */
 public static int luaB_ipairs(lua_State L)
 {
     cc.lua_CFunction iter = (cc.luaL_getmetafield(L, 1, "__index") != cc.LUA_TNIL) ? (cc.lua_CFunction)lbase.ipairaux : (cc.lua_CFunction)lbase.ipairsaux_raw;
     cc.luaL_checkany(L, 1);
     cc.lua_pushcfunction(L, iter); /* iteration function */
     cc.lua_pushvalue(L, 1);        /* state */
     cc.lua_pushinteger(L, 0);      /* initial value */
     return(3);
 }
示例#2
0
 public static int pairsmeta(lua_State L, string method, bool iszero, cc.lua_CFunction iter)
 {
     if (cc.luaL_getmetafield(L, 1, method) == cc.LUA_TNIL) /* no metamethod? */
     {
         cc.luaL_checktype(L, 1, cc.LUA_TTABLE);            /* argument must be a table */
         cc.lua_pushcfunction(L, iter);                     /* will return generator, */
         cc.lua_pushvalue(L, 1);                            /* state, */
         if (iszero)
         {
             cc.lua_pushinteger(L, 0);           /* and initial value */
         }
         else
         {
             cc.lua_pushnil(L);
         }
     }
     else
     {
         cc.lua_pushvalue(L, 1); /* argument 'self' to metamethod */
         cc.lua_call(L, 1, 3);   /* get 3 values from metamethod */
     }
     return(3);
 }
示例#3
0
 public static void setfvalue(lua_State L, int o, cc.lua_CFunction t)
 {
     setfvalue(L.stack[o], t);
 }
示例#4
0
 public static void setfvalue(TValue obj, cc.lua_CFunction x)
 {
     obj.value_.o = x; settt_(obj, LUA_TLCF);
 }