Commit 80fce917 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Moved `LuaNativeFunctions` from `ObjectTranslator` to static

parent 28284b24
...@@ -37,14 +37,14 @@ namespace NLua ...@@ -37,14 +37,14 @@ namespace NLua
} }
} }
readonly LuaNativeFunction _registerTableFunction; private static readonly LuaNativeFunction _registerTableFunction = RegisterTable;
readonly LuaNativeFunction _unregisterTableFunction; private static readonly LuaNativeFunction _unregisterTableFunction = UnregisterTable;
readonly LuaNativeFunction _getMethodSigFunction; private static readonly LuaNativeFunction _getMethodSigFunction = GetMethodSignature;
readonly LuaNativeFunction _getConstructorSigFunction; private static readonly LuaNativeFunction _getConstructorSigFunction = GetConstructorSignature;
readonly LuaNativeFunction _importTypeFunction; private static readonly LuaNativeFunction _importTypeFunction = ImportType;
readonly LuaNativeFunction _loadAssemblyFunction; private static readonly LuaNativeFunction _loadAssemblyFunction = LoadAssembly;
readonly LuaNativeFunction _ctypeFunction; private static readonly LuaNativeFunction _ctypeFunction = CType;
readonly LuaNativeFunction _enumFromIntFunction; private static readonly LuaNativeFunction _enumFromIntFunction = EnumFromInt;
// object to object # // object to object #
readonly Dictionary<object, int> _objectsBackMap = new Dictionary<object, int>(new ReferenceComparer()); readonly Dictionary<object, int> _objectsBackMap = new Dictionary<object, int>(new ReferenceComparer());
...@@ -77,15 +77,6 @@ namespace NLua ...@@ -77,15 +77,6 @@ namespace NLua
metaFunctions = new MetaFunctions(this); metaFunctions = new MetaFunctions(this);
assemblies = new List<Assembly>(); assemblies = new List<Assembly>();
_importTypeFunction = ImportType;
_loadAssemblyFunction = LoadAssembly;
_registerTableFunction = RegisterTable;
_unregisterTableFunction = UnregisterTable;
_getMethodSigFunction = GetMethodSignature;
_getConstructorSigFunction = GetConstructorSignature;
_ctypeFunction = CType;
_enumFromIntFunction = EnumFromInt;
CreateLuaObjectList(luaState); CreateLuaObjectList(luaState);
CreateIndexingMetaFunction(luaState); CreateIndexingMetaFunction(luaState);
CreateBaseClassMetatable(luaState); CreateBaseClassMetatable(luaState);
......
...@@ -1722,7 +1722,7 @@ namespace NLuaTest ...@@ -1722,7 +1722,7 @@ namespace NLuaTest
lua.DoString("TestClass=luanet.import_type('NLuaTest.TestTypes.TestClass')"); lua.DoString("TestClass=luanet.import_type('NLuaTest.TestTypes.TestClass')");
lua.DoString("test_cons=luanet.get_constructor_bysig(TestClass,'System.String')"); lua.DoString("test_cons=luanet.get_constructor_bysig(TestClass,'System.String')");
lua.DoString("test=test_cons('test')"); lua.DoString("test=test_cons('test')");
TestTypes.TestClass test = (TestTypes.TestClass)lua["test"]; var test = (TestClass)lua["test"];
Assert.AreEqual("test", test.getStrVal()); Assert.AreEqual("test", test.getStrVal());
} }
...@@ -2402,7 +2402,7 @@ namespace NLuaTest ...@@ -2402,7 +2402,7 @@ namespace NLuaTest
} }
[Test] [Test]
public static void TestUseLuaObjectAfterDisposeShouldNotCrash() public void TestUseLuaObjectAfterDisposeShouldNotCrash()
{ {
LuaTable table; LuaTable table;
LuaFunction function; LuaFunction function;
...@@ -2535,7 +2535,19 @@ namespace NLuaTest ...@@ -2535,7 +2535,19 @@ namespace NLuaTest
} }
} }
[Test]
public void CallStaticMethod()
{
using (var lua = new Lua())
{
lua.DoString("FakeType = {}");
lua["FakeType.bar"] = (Func<object[],int>) TestClass.MethodWithObjectParams;
lua.DoString("i = FakeType.bar('one', 1)");
Assert.AreEqual(2, lua["i"], "#1");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment