Ejemplo n.º 1
0
 /*
  *  Gets the function called name from the provided table,
  * returning null if it does not exist
  */
 public static LuaFunction getTableFunction( LuaTable luaTable, string name )
 {
     object funcObj = luaTable.rawget( name );
     if ( funcObj is LuaFunction )
         return (LuaFunction)funcObj;
     else
         return null;
 }
Ejemplo n.º 2
0
        public ListDictionary GetTableDict( LuaTable table )
        {
            ListDictionary dict = new ListDictionary();

            int oldTop = LuaDLL.lua_gettop( luaState );
            translator.push( luaState, table );
            LuaDLL.lua_pushnil( luaState );
            while ( LuaDLL.lua_next( luaState, -2 ) != 0 )
            {
                dict[translator.getObject( luaState, -2 )] = translator.getObject( luaState, -1 );
                LuaDLL.lua_settop( luaState, -2 );
            }
            LuaDLL.lua_settop( luaState, oldTop );

            return dict;
        }
 /*
  * Gets an instance of an implementation of the klass interface or
  * subclass of klass that delegates public virtual methods to the
  * luaTable table.
  * Caches the generated type.
  */
 public object GetClassInstance( Type klass, LuaTable luaTable )
 {
     LuaClassType luaClassType;
     if ( classCollection.ContainsKey( klass ) )
     {
         luaClassType = classCollection[klass];
     }
     else
     {
         luaClassType = new LuaClassType();
         GenerateClass( klass, out luaClassType.klass, out luaClassType.returnTypes );
         classCollection[klass] = luaClassType;
     }
     return Activator.CreateInstance( luaClassType.klass, new object[] { luaTable, luaClassType.returnTypes } );
 }