public ObjectTranslator(LuaState interpreter, IntPtr luaState) { this.interpreter = interpreter; this.weakTableRef = -1; this.typeChecker = new CheckType(this); this.metaFunctions = new MetaFunctions(this); this.assemblies = new List <Assembly>(); this.assemblies.Add(Assembly.GetExecutingAssembly()); this.importTypeFunction = new LuaCSFunction(ObjectTranslator.importType); this.loadAssemblyFunction = new LuaCSFunction(ObjectTranslator.loadAssembly); this.registerTableFunction = new LuaCSFunction(ObjectTranslator.registerTable); this.unregisterTableFunction = new LuaCSFunction(ObjectTranslator.unregisterTable); this.getMethodSigFunction = new LuaCSFunction(ObjectTranslator.getMethodSignature); this.getConstructorSigFunction = new LuaCSFunction(ObjectTranslator.getConstructorSignature); this.ctypeFunction = new LuaCSFunction(ObjectTranslator.ctype); this.enumFromIntFunction = new LuaCSFunction(ObjectTranslator.enumFromInt); this.createLuaObjectList(luaState); this.createIndexingMetaFunction(luaState); this.createBaseClassMetatable(luaState); this.createClassMetatable(luaState); this.createFunctionMetatable(luaState); this.setGlobalFunctions(luaState); }
internal Array TableToArray(object luaParamValue, Type paramArrayType) { Array array; if (luaParamValue is LuaTable) { LuaTable luaTable = (LuaTable)luaParamValue; IDictionaryEnumerator enumerator = luaTable.GetEnumerator(); enumerator.Reset(); array = Array.CreateInstance(paramArrayType, luaTable.Values.get_Count()); int num = 0; while (enumerator.MoveNext()) { object obj = enumerator.get_Value(); if (paramArrayType == typeof(object) && obj != null && obj.GetType() == typeof(double) && MetaFunctions.IsInteger((double)obj)) { obj = Convert.ToInt32((double)obj); } array.SetValue(Convert.ChangeType(obj, paramArrayType), num); num++; } } else { array = Array.CreateInstance(paramArrayType, 1); array.SetValue(luaParamValue, 0); } return(array); }