Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
80fce917
Commit
80fce917
authored
Aug 23, 2019
by
Vinicius Jarina
Browse files
Moved `LuaNativeFunctions` from `ObjectTranslator` to static
parent
28284b24
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ObjectTranslator.cs
View file @
80fce917
...
...
@@ -37,14 +37,14 @@ namespace NLua
}
}
readonly
LuaNativeFunction
_registerTableFunction
;
readonly
LuaNativeFunction
_unregisterTableFunction
;
readonly
LuaNativeFunction
_getMethodSigFunction
;
readonly
LuaNativeFunction
_getConstructorSigFunction
;
readonly
LuaNativeFunction
_importTypeFunction
;
readonly
LuaNativeFunction
_loadAssemblyFunction
;
readonly
LuaNativeFunction
_ctypeFunction
;
readonly
LuaNativeFunction
_enumFromIntFunction
;
private
static
readonly
LuaNativeFunction
_registerTableFunction
=
RegisterTable
;
private
static
readonly
LuaNativeFunction
_unregisterTableFunction
=
UnregisterTable
;
private
static
readonly
LuaNativeFunction
_getMethodSigFunction
=
GetMethodSignature
;
private
static
readonly
LuaNativeFunction
_getConstructorSigFunction
=
GetConstructorSignature
;
private
static
readonly
LuaNativeFunction
_importTypeFunction
=
ImportType
;
private
static
readonly
LuaNativeFunction
_loadAssemblyFunction
=
LoadAssembly
;
private
static
readonly
LuaNativeFunction
_ctypeFunction
=
CType
;
private
static
readonly
LuaNativeFunction
_enumFromIntFunction
=
EnumFromInt
;
// object to object #
readonly
Dictionary
<
object
,
int
>
_objectsBackMap
=
new
Dictionary
<
object
,
int
>(
new
ReferenceComparer
());
...
...
@@ -77,15 +77,6 @@ namespace NLua
metaFunctions
=
new
MetaFunctions
(
this
);
assemblies
=
new
List
<
Assembly
>();
_importTypeFunction
=
ImportType
;
_loadAssemblyFunction
=
LoadAssembly
;
_registerTableFunction
=
RegisterTable
;
_unregisterTableFunction
=
UnregisterTable
;
_getMethodSigFunction
=
GetMethodSignature
;
_getConstructorSigFunction
=
GetConstructorSignature
;
_ctypeFunction
=
CType
;
_enumFromIntFunction
=
EnumFromInt
;
CreateLuaObjectList
(
luaState
);
CreateIndexingMetaFunction
(
luaState
);
CreateBaseClassMetatable
(
luaState
);
...
...
tests/src/LuaTests.cs
View file @
80fce917
...
...
@@ -1722,7 +1722,7 @@ namespace NLuaTest
lua
.
DoString
(
"TestClass=luanet.import_type('NLuaTest.TestTypes.TestClass')"
);
lua
.
DoString
(
"test_cons=luanet.get_constructor_bysig(TestClass,'System.String')"
);
lua
.
DoString
(
"test=test_cons('test')"
);
TestTypes
.
TestClass
test
=
(
TestTypes
.
TestClass
)
lua
[
"test"
];
var
test
=
(
TestClass
)
lua
[
"test"
];
Assert
.
AreEqual
(
"test"
,
test
.
getStrVal
());
}
...
...
@@ -2402,7 +2402,7 @@ namespace NLuaTest
}
[
Test
]
public
static
void
TestUseLuaObjectAfterDisposeShouldNotCrash
()
public
void
TestUseLuaObjectAfterDisposeShouldNotCrash
()
{
LuaTable
table
;
LuaFunction
function
;
...
...
@@ -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"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment