Commit 25726c61 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Minor cleanup.

parent 8f41eff7
...@@ -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)
......
...@@ -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 = bindingType; _IsStatic = (bindingType & BindingFlags.Static) == BindingFlags.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 = _IsStatic;
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 (_IsStatic)
_Translator.Push (luaState, method.Invoke (null, _LastCalledMethod.args)); _Translator.Push (luaState, method.Invoke (null, _LastCalledMethod.args));
else { else {
if (method.IsConstructor) if (method.IsConstructor)
......
...@@ -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);
......
...@@ -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
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