Пример #1
0
        public CheckType( ObjectTranslator translator )
        {
            this.translator = translator;

            extractValues.Add( typeof( object ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsObject ) );
            extractValues.Add( typeof( sbyte ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsSbyte ) );
            extractValues.Add( typeof( byte ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsByte ) );
            extractValues.Add( typeof( short ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsShort ) );
            extractValues.Add( typeof( ushort ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsUshort ) );
            extractValues.Add( typeof( int ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsInt ) );
            extractValues.Add( typeof( uint ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsUint ) );
            extractValues.Add( typeof( long ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsLong ) );
            extractValues.Add( typeof( ulong ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsUlong ) );
            extractValues.Add( typeof( double ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsDouble ) );
            extractValues.Add( typeof( char ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsChar ) );
            extractValues.Add( typeof( float ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsFloat ) );
            extractValues.Add( typeof( decimal ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsDecimal ) );
            extractValues.Add( typeof( bool ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsBoolean ) );
            extractValues.Add( typeof( string ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsString ) );
            extractValues.Add( typeof( LuaFunction ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsFunction ) );
            extractValues.Add( typeof( LuaTable ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsTable ) );
            extractValues.Add( typeof( LuaUserData ).TypeHandle.Value.ToInt64(), new ExtractValue( getAsUserdata ) );

            extractNetObject = new ExtractValue( getAsNetObject );
        }
Пример #2
0
        /*
         * Constructs the wrapper for a known method name
         */
        public LuaMethodWrapper( ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType )
        {
            _Translator = translator;
            _MethodName = methodName;
            _TargetType = targetType;

            if ( targetType != null )
                _ExtractTarget = translator.typeChecker.getExtractor( targetType );

            _BindingType = bindingType;

            //CP: Removed NonPublic binding search and added IgnoreCase
            _Members = targetType.UnderlyingSystemType.GetMember( methodName, MemberTypes.Method, bindingType | BindingFlags.Public | BindingFlags.IgnoreCase/*|BindingFlags.NonPublic*/);
        }
Пример #3
0
        /*
         * Constructs the wrapper for a known MethodBase instance
         */
        public LuaMethodWrapper( ObjectTranslator translator, object target, IReflect targetType, MethodBase method )
        {
            _Translator = translator;
            _Target = target;
            _TargetType = targetType;
            if ( targetType != null )
                _ExtractTarget = translator.typeChecker.getExtractor( targetType );
            _Method = method;
            _MethodName = method.Name;

            if ( method.IsStatic )
            { _BindingType = BindingFlags.Static; }
            else
            { _BindingType = BindingFlags.Instance; }
        }
Пример #4
0
        public virtual void Dispose()
        {
            if ( translator != null )
            {
                translator.pendingEvents.Dispose();
                translator = null;
            }

            this.Close();
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
        }
Пример #5
0
        public Lua()
        {
            luaState = LuaDLL.luaL_newstate();	// steffenj: Lua 5.1.1 API change (lua_open is gone)
            //LuaDLL.luaopen_base(luaState);	// steffenj: luaopen_* no longer used
            LuaDLL.luaL_openlibs( luaState );		// steffenj: Lua 5.1.1 API change (luaopen_base is gone, just open all libs right here)
            LuaDLL.lua_pushstring( luaState, "LUAINTERFACE LOADED" );
            LuaDLL.lua_pushboolean( luaState, true );
            LuaDLL.lua_settable( luaState, (int)LuaIndexes.LUA_REGISTRYINDEX );
            LuaDLL.lua_newtable( luaState );
            LuaDLL.lua_setglobal( luaState, "luanet" );
            LuaDLL.lua_pushvalue( luaState, (int)LuaIndexes.LUA_GLOBALSINDEX );
            LuaDLL.lua_getglobal( luaState, "luanet" );
            LuaDLL.lua_pushstring( luaState, "getmetatable" );
            LuaDLL.lua_getglobal( luaState, "getmetatable" );
            LuaDLL.lua_settable( luaState, -3 );
            LuaDLL.lua_replace( luaState, (int)LuaIndexes.LUA_GLOBALSINDEX );
            translator = new ObjectTranslator( this, luaState );
            LuaDLL.lua_replace( luaState, (int)LuaIndexes.LUA_GLOBALSINDEX );
            LuaDLL.luaL_dostring( luaState, Lua.init_luanet );	// steffenj: lua_dostring renamed to luaL_dostring

            // We need to keep this in a managed reference so the delegate doesn't get garbage collected
            panicCallback = new LuaCSFunction( PanicCallback );
            LuaDLL.lua_atpanic( luaState, panicCallback );

            //LuaDLL.lua_atlock(luaState, lockCallback = new LuaCSFunction(LockCallback));
            //LuaDLL.lua_atunlock(luaState, unlockCallback = new LuaCSFunction(UnlockCallback));
        }
Пример #6
0
 /*
  * CAUTION: LuaInterface.Lua instances can't share the same lua state! 
  */
 public Lua( Int64 luaState )
 {
     IntPtr lState = new IntPtr( luaState );
     LuaDLL.lua_pushstring( lState, "LUAINTERFACE LOADED" );
     LuaDLL.lua_gettable( lState, (int)LuaIndexes.LUA_REGISTRYINDEX );
     if ( LuaDLL.lua_toboolean( lState, -1 ) )
     {
         LuaDLL.lua_settop( lState, -2 );
         throw new LuaException( "There is already a LuaInterface.Lua instance associated with this Lua state" );
     }
     else
     {
         LuaDLL.lua_settop( lState, -2 );
         LuaDLL.lua_pushstring( lState, "LUAINTERFACE LOADED" );
         LuaDLL.lua_pushboolean( lState, true );
         LuaDLL.lua_settable( lState, (int)LuaIndexes.LUA_REGISTRYINDEX );
         this.luaState = lState;
         LuaDLL.lua_pushvalue( lState, (int)LuaIndexes.LUA_GLOBALSINDEX );
         LuaDLL.lua_getglobal( lState, "luanet" );
         LuaDLL.lua_pushstring( lState, "getmetatable" );
         LuaDLL.lua_getglobal( lState, "getmetatable" );
         LuaDLL.lua_settable( lState, -3 );
         LuaDLL.lua_replace( lState, (int)LuaIndexes.LUA_GLOBALSINDEX );
         translator = new ObjectTranslator( this, this.luaState );
         LuaDLL.lua_replace( lState, (int)LuaIndexes.LUA_GLOBALSINDEX );
         LuaDLL.luaL_dostring( lState, Lua.init_luanet );	// steffenj: lua_dostring renamed to luaL_dostring
     }
 }
 public ClassGenerator( ObjectTranslator translator, Type klass )
 {
     this.translator = translator;
     this.klass = klass;
 }
 public DelegateGenerator( ObjectTranslator translator, Type delegateType )
 {
     this.translator = translator;
     this.delegateType = delegateType;
 }