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
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
...
@@ -63,7 +63,7 @@ namespace NLua.Extensions
public
static
bool
HasMethod
(
this
Type
t
,
string
name
)
public
static
bool
HasMethod
(
this
Type
t
,
string
name
)
{
{
var
op
=
t
.
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
Static
);
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
)
public
static
bool
HasAdditionOpertator
(
this
Type
t
)
...
...
Core/NLua/Method/LuaMethodWrapper.cs
View file @
25726c61
...
@@ -54,14 +54,14 @@ namespace NLua.Method
...
@@ -54,14 +54,14 @@ namespace NLua.Method
class
LuaMethodWrapper
class
LuaMethodWrapper
{
{
internal
LuaNativeFunction
invokeFunction
;
internal
LuaNativeFunction
invokeFunction
;
private
ObjectTranslator
_Translator
;
ObjectTranslator
_Translator
;
private
MethodBase
_Method
;
MethodBase
_Method
;
private
MethodCache
_LastCalledMethod
=
new
MethodCache
();
MethodCache
_LastCalledMethod
=
new
MethodCache
();
private
string
_MethodName
;
string
_MethodName
;
private
MemberInfo
[]
_Members
;
MemberInfo
[]
_Members
;
private
ExtractValue
_ExtractTarget
;
ExtractValue
_ExtractTarget
;
private
object
_Target
;
object
_Target
;
private
BindingFlags
_BindingType
;
bool
_IsStatic
;
/*
/*
* Constructs the wrapper for a known MethodBase instance
* Constructs the wrapper for a known MethodBase instance
...
@@ -77,11 +77,7 @@ namespace NLua.Method
...
@@ -77,11 +77,7 @@ namespace NLua.Method
_Method
=
method
;
_Method
=
method
;
_MethodName
=
method
.
Name
;
_MethodName
=
method
.
Name
;
_IsStatic
=
method
.
IsStatic
;
if
(
method
.
IsStatic
)
_BindingType
=
BindingFlags
.
Static
;
else
_BindingType
=
BindingFlags
.
Instance
;
}
}
/*
/*
...
@@ -97,8 +93,8 @@ namespace NLua.Method
...
@@ -97,8 +93,8 @@ namespace NLua.Method
if
(
targetType
!=
null
)
if
(
targetType
!=
null
)
_ExtractTarget
=
translator
.
typeChecker
.
GetExtractor
(
targetType
);
_ExtractTarget
=
translator
.
typeChecker
.
GetExtractor
(
targetType
);
_
BindingType
=
b
inding
Type
;
_
IsStatic
=
(
bindingType
&
BindingFlags
.
Static
)
=
=
B
inding
Flags
.
Static
;
_Members
=
targetType
.
UnderlyingSystemType
.
GetMember
(
methodName
,
MemberTypes
.
Method
,
bindingType
|
BindingFlags
.
Public
);
_Members
=
targetType
.
UnderlyingSystemType
.
GetMember
(
methodName
,
MemberTypes
.
Method
,
bindingType
|
BindingFlags
.
Public
);
}
}
/// <summary>
/// <summary>
...
@@ -125,7 +121,7 @@ namespace NLua.Method
...
@@ -125,7 +121,7 @@ namespace NLua.Method
if
(!
LuaLib
.
LuaCheckStack
(
luaState
,
5
))
if
(!
LuaLib
.
LuaCheckStack
(
luaState
,
5
))
throw
new
LuaException
(
"Lua stack overflow"
);
throw
new
LuaException
(
"Lua stack overflow"
);
bool
isStatic
=
(
_BindingType
&
BindingFlags
.
Static
)
==
BindingFlags
.
Static
;
bool
isStatic
=
_Is
Static
;
SetPendingException
(
null
);
SetPendingException
(
null
);
if
(
methodToCall
==
null
)
{
// Method from name
if
(
methodToCall
==
null
)
{
// Method from name
...
@@ -169,7 +165,7 @@ namespace NLua.Method
...
@@ -169,7 +165,7 @@ namespace NLua.Method
throw
new
LuaException
(
string
.
Format
(
"argument number {0} is invalid"
,(
i
+
1
)));
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
));
_Translator
.
Push
(
luaState
,
method
.
Invoke
(
null
,
_LastCalledMethod
.
args
));
else
{
else
{
if
(
method
.
IsConstructor
)
if
(
method
.
IsConstructor
)
...
...
Core/NLua/ObjectTranslator.cs
View file @
25726c61
...
@@ -502,7 +502,7 @@ namespace NLua
...
@@ -502,7 +502,7 @@ namespace NLua
try
{
try
{
var
method
=
klass
.
GetMethod
(
methodName
,
BindingFlags
.
Public
|
BindingFlags
.
Static
|
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
));
PushFunction
(
luaState
,
new
LuaNativeFunction
((
new
LuaMethodWrapper
(
this
,
target
,
klass
,
method
)).
invokeFunction
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
ThrowError
(
luaState
,
e
);
ThrowError
(
luaState
,
e
);
...
...
Core/NLua/ProxyType.cs
View file @
25726c61
...
@@ -73,9 +73,9 @@ namespace NLua
...
@@ -73,9 +73,9 @@ namespace NLua
return
proxy
.
GetMember
(
name
,
bindingAttr
);
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