private int getConstructorSignatureInternal(LuaCore.lua_State luaState) { IReflect klass = null; int udata = LuaLib.luanet_checkudata(luaState, 1, "luaNet_class"); if (udata != -1) { klass = (IReflect)objects [udata]; } if (klass.IsNull()) { throwError(luaState, "get_constructor_bysig: first arg is invalid type reference"); } var signature = new Type[LuaLib.lua_gettop(luaState) - 1]; for (int i = 0; i < signature.Length; i++) { signature [i] = FindType(LuaLib.lua_tostring(luaState, i + 2).ToString()); } try { ConstructorInfo constructor = klass.UnderlyingSystemType.GetConstructor(signature); pushFunction(luaState, new LuaCore.lua_CFunction((new LuaMethodWrapper(this, null, klass, constructor)).invokeFunction)); } catch (Exception e) { throwError(luaState, e); LuaLib.lua_pushnil(luaState); } return(1); }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { _Translator = translator; _MethodName = methodName; _TargetType = targetType; if (!targetType.IsNull()) { _ExtractTarget = translator.typeChecker.getExtractor(targetType); } _BindingType = bindingType; //CP: Removed NonPublic binding search and added IgnoreCase _Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | BindingFlags.Public | BindingFlags.IgnoreCase /*|BindingFlags.NonPublic*/); }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { _Translator = translator; _Target = target; _TargetType = targetType; if(!targetType.IsNull()) _ExtractTarget = translator.typeChecker.getExtractor(targetType); _Method = method; _MethodName = method.Name; if(method.IsStatic) _BindingType = BindingFlags.Static; else _BindingType = BindingFlags.Instance; }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { invokeFunction = new LuaCore.lua_CFunction(this.call); _Translator = translator; _Target = target; if (!targetType.IsNull()) { _ExtractTarget = translator.typeChecker.getExtractor(targetType); } _Method = method; _MethodName = method.Name; if (method.IsStatic) { _BindingType = BindingFlags.Static; } else { _BindingType = BindingFlags.Instance; } }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { _Translator = translator; _MethodName = methodName; _TargetType = targetType; if(!targetType.IsNull()) _ExtractTarget = translator.typeChecker.getExtractor(targetType); _BindingType = bindingType; //CP: Removed NonPublic binding search and added IgnoreCase _Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | BindingFlags.Public | BindingFlags.IgnoreCase/*|BindingFlags.NonPublic*/); }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { invokeFunction = new LuaCore.lua_CFunction (this.call); _Translator = translator; _Target = target; if (!targetType.IsNull ()) _ExtractTarget = translator.typeChecker.getExtractor (targetType); _Method = method; _MethodName = method.Name; if (method.IsStatic) _BindingType = BindingFlags.Static; else _BindingType = BindingFlags.Instance; }