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

Minor cleanup.

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