Commit 3ca7cf83 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Revert "RegisterOperatorsFunctions support base class"

parent 56ca73db
...@@ -62,8 +62,8 @@ namespace NLua.Extensions ...@@ -62,8 +62,8 @@ 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 (name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy); var op = t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
return op != null; return op.Any (m => m.Name == name);
} }
public static bool HasAdditionOpertator (this Type t) public static bool HasAdditionOpertator (this Type t)
...@@ -410,4 +410,4 @@ namespace NLua.Extensions ...@@ -410,4 +410,4 @@ namespace NLua.Extensions
yield return input.Substring (start); yield return input.Substring (start);
} }
} }
} }
\ No newline at end of file
...@@ -1167,7 +1167,7 @@ namespace NLua ...@@ -1167,7 +1167,7 @@ namespace NLua
} }
Type type = target.GetType (); Type type = target.GetType ();
var operators = type.GetMethods (operation, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy); var operators = type.GetMethods (operation, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
foreach (var op in operators) { foreach (var op in operators) {
bool isOk = translator.MatchParameters (luaState, op, ref validOperator); bool isOk = translator.MatchParameters (luaState, op, ref validOperator);
...@@ -1393,4 +1393,4 @@ namespace NLua ...@@ -1393,4 +1393,4 @@ namespace NLua
return isParamArray; return isParamArray;
} }
} }
} }
\ No newline at end of file
...@@ -141,16 +141,10 @@ namespace NLua.Method ...@@ -141,16 +141,10 @@ namespace NLua.Method
SetPendingException (null); SetPendingException (null);
if (methodToCall == null) { // Method from name if (methodToCall == null) { // Method from name
if (isStatic) { if (isStatic)
targetObject = null; targetObject = null;
} else { else
targetObject = _ExtractTarget (luaState, 1); targetObject = _ExtractTarget (luaState, 1);
if (targetObject == null || targetObject.Equals(null)) {
_Translator.ThrowError (luaState, String.Format ("instance method '{0}' requires a non null target object", _MethodName));
LuaLib.LuaPushNil (luaState);
return 1;
}
}
if (_LastCalledMethod.cachedMethod != null) { // Cached? if (_LastCalledMethod.cachedMethod != null) { // Cached?
int numStackToSkip = isStatic ? 0 : 1; // If this is an instance invoe we will have an extra arg on the stack for the targetObject int numStackToSkip = isStatic ? 0 : 1; // If this is an instance invoe we will have an extra arg on the stack for the targetObject
...@@ -213,6 +207,12 @@ namespace NLua.Method ...@@ -213,6 +207,12 @@ namespace NLua.Method
// System.Diagnostics.Debug.WriteLine("cache miss on " + methodName); // System.Diagnostics.Debug.WriteLine("cache miss on " + methodName);
// If we are running an instance variable, we can now pop the targetObject from the stack // If we are running an instance variable, we can now pop the targetObject from the stack
if (!isStatic) { if (!isStatic) {
if (targetObject == null) {
_Translator.ThrowError (luaState, String.Format ("instance method '{0}' requires a non null target object", _MethodName));
LuaLib.LuaPushNil (luaState);
return 1;
}
LuaLib.LuaRemove (luaState, 1); // Pops the receiver LuaLib.LuaRemove (luaState, 1); // Pops the receiver
} }
...@@ -264,11 +264,6 @@ namespace NLua.Method ...@@ -264,11 +264,6 @@ namespace NLua.Method
} else { } else {
if (!methodToCall.IsStatic && !methodToCall.IsConstructor && targetObject == null) { if (!methodToCall.IsStatic && !methodToCall.IsConstructor && targetObject == null) {
targetObject = _ExtractTarget (luaState, 1); targetObject = _ExtractTarget (luaState, 1);
if (targetObject == null || targetObject.Equals(null)) {
_Translator.ThrowError (luaState, String.Format ("instance method '{0}' requires a non null target object", _MethodName));
LuaLib.LuaPushNil (luaState);
return 1;
}
LuaLib.LuaRemove (luaState, 1); // Pops the receiver LuaLib.LuaRemove (luaState, 1); // Pops the receiver
} }
......
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