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
25726c61
"vscode:/vscode.git/clone" did not exist on "7fff34ca883be28941325a6e3c89f532e6f9aac4"
Commit
25726c61
authored
Oct 10, 2014
by
Vinicius Jarina
Browse files
Minor cleanup.
parent
8f41eff7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Core/NLua/Extensions/GeneralExtensions.cs
View file @
25726c61
...
...
@@ -63,7 +63,7 @@ namespace NLua.Extensions
public
static
bool
HasMethod
(
this
Type
t
,
string
name
)
{
var
op
=
t
.
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
Static
);
return
op
.
Count
(
m
=>
m
.
Name
==
name
)
>
0
;
return
op
.
Any
(
m
=>
m
.
Name
==
name
);
}
public
static
bool
HasAdditionOpertator
(
this
Type
t
)
...
...
Core/NLua/Method/LuaMethodWrapper.cs
View file @
25726c61
...
...
@@ -54,14 +54,14 @@ namespace NLua.Method
class
LuaMethodWrapper
{
internal
LuaNativeFunction
invokeFunction
;
private
ObjectTranslator
_Translator
;
private
MethodBase
_Method
;
private
MethodCache
_LastCalledMethod
=
new
MethodCache
();
private
string
_MethodName
;
private
MemberInfo
[]
_Members
;
private
ExtractValue
_ExtractTarget
;
private
object
_Target
;
private
BindingFlags
_BindingType
;
ObjectTranslator
_Translator
;
MethodBase
_Method
;
MethodCache
_LastCalledMethod
=
new
MethodCache
();
string
_MethodName
;
MemberInfo
[]
_Members
;
ExtractValue
_ExtractTarget
;
object
_Target
;
bool
_IsStatic
;
/*
* Constructs the wrapper for a known MethodBase instance
...
...
@@ -77,11 +77,7 @@ namespace NLua.Method
_Method
=
method
;
_MethodName
=
method
.
Name
;
if
(
method
.
IsStatic
)
_BindingType
=
BindingFlags
.
Static
;
else
_BindingType
=
BindingFlags
.
Instance
;
_IsStatic
=
method
.
IsStatic
;
}
/*
...
...
@@ -97,8 +93,8 @@ namespace NLua.Method
if
(
targetType
!=
null
)
_ExtractTarget
=
translator
.
typeChecker
.
GetExtractor
(
targetType
);
_
BindingType
=
b
inding
Type
;
_Members
=
targetType
.
UnderlyingSystemType
.
GetMember
(
methodName
,
MemberTypes
.
Method
,
bindingType
|
BindingFlags
.
Public
);
_
IsStatic
=
(
bindingType
&
BindingFlags
.
Static
)
=
=
B
inding
Flags
.
Static
;
_Members
=
targetType
.
UnderlyingSystemType
.
GetMember
(
methodName
,
MemberTypes
.
Method
,
bindingType
|
BindingFlags
.
Public
);
}
/// <summary>
...
...
@@ -125,7 +121,7 @@ namespace NLua.Method
if
(!
LuaLib
.
LuaCheckStack
(
luaState
,
5
))
throw
new
LuaException
(
"Lua stack overflow"
);
bool
isStatic
=
(
_BindingType
&
BindingFlags
.
Static
)
==
BindingFlags
.
Static
;
bool
isStatic
=
_Is
Static
;
SetPendingException
(
null
);
if
(
methodToCall
==
null
)
{
// Method from name
...
...
@@ -169,7 +165,7 @@ namespace NLua.Method
throw
new
LuaException
(
string
.
Format
(
"argument number {0} is invalid"
,(
i
+
1
)));
}
if
(
(
_BindingType
&
BindingFlags
.
Static
)
==
BindingFlags
.
Static
)
if
(
_Is
Static
)
_Translator
.
Push
(
luaState
,
method
.
Invoke
(
null
,
_LastCalledMethod
.
args
));
else
{
if
(
method
.
IsConstructor
)
...
...
Core/NLua/ObjectTranslator.cs
View file @
25726c61
...
...
@@ -502,7 +502,7 @@ namespace NLua
try
{
var
method
=
klass
.
GetMethod
(
methodName
,
BindingFlags
.
Public
|
BindingFlags
.
Static
|
BindingFlags
.
Instance
|
BindingFlags
.
FlattenHierarchy
,
null
,
signature
,
null
);
BindingFlags
.
Instance
|
BindingFlags
.
FlattenHierarchy
,
signature
);
PushFunction
(
luaState
,
new
LuaNativeFunction
((
new
LuaMethodWrapper
(
this
,
target
,
klass
,
method
)).
invokeFunction
));
}
catch
(
Exception
e
)
{
ThrowError
(
luaState
,
e
);
...
...
Core/NLua/ProxyType.cs
View file @
25726c61
...
...
@@ -73,9 +73,9 @@ namespace NLua
return
proxy
.
GetMember
(
name
,
bindingAttr
);
}
public
MethodInfo
GetMethod
(
string
name
,
BindingFlags
bindingAttr
,
Binder
binder
,
Type
[]
types
,
ParameterModifier
[]
modifiers
)
public
MethodInfo
GetMethod
(
string
name
,
BindingFlags
bindingAttr
,
Type
[]
signature
)
{
return
proxy
.
GetMethod
(
name
,
bindingAttr
,
binder
,
types
,
modifiers
);
return
proxy
.
GetMethod
(
name
,
bindingAttr
,
null
,
signature
,
null
);
}
}
}
\ No newline at end of file
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