public CheckType(ObjectTranslator translator) { this.translator = translator; // rationale for TypeHandle: http://stackoverflow.com/a/126507 _casters = new Dictionary <RuntimeTypeHandle, Caster>(18) { { typeof(object).TypeHandle, new Caster(isObject, asObject) }, { typeof(sbyte).TypeHandle, new Caster(isSbyte, asSbyte) }, { typeof(byte).TypeHandle, new Caster(isByte, asByte) }, { typeof(short).TypeHandle, new Caster(isShort, asShort) }, { typeof(ushort).TypeHandle, new Caster(isUshort, asUshort) }, { typeof(int).TypeHandle, new Caster(isInt, asInt) }, { typeof(uint).TypeHandle, new Caster(isUint, asUint) }, { typeof(long).TypeHandle, new Caster(isLong, asLong) }, { typeof(ulong).TypeHandle, new Caster(isUlong, asUlong) }, { typeof(double).TypeHandle, new Caster(isDouble, asDouble) }, { typeof(char).TypeHandle, new Caster(isChar, asChar) }, { typeof(float).TypeHandle, new Caster(isFloat, asFloat) }, { typeof(decimal).TypeHandle, new Caster(isDecimal, asDecimal) }, { typeof(bool).TypeHandle, new Caster(isBoolean, asBoolean) }, { typeof(string).TypeHandle, new Caster(isString, asString) }, { typeof(LuaFunction).TypeHandle, new Caster(isFunction, asFunction) }, { typeof(LuaTable).TypeHandle, new Caster(isTable, asTable) }, { typeof(LuaUserData).TypeHandle, new Caster(isUserData, asUserData) }, { typeof(LuaString).TypeHandle, new Caster(isString, asLString) }, }; extractNetObject = asNetObject; }
public CheckType(ObjectTranslator translator) { this.translator = translator; extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject)); extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte)); extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte)); extractValues.Add(typeof(short).TypeHandle.Value.ToInt64(), new ExtractValue(getAsShort)); extractValues.Add(typeof(ushort).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUshort)); extractValues.Add(typeof(int).TypeHandle.Value.ToInt64(), new ExtractValue(getAsInt)); extractValues.Add(typeof(uint).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUint)); extractValues.Add(typeof(long).TypeHandle.Value.ToInt64(), new ExtractValue(getAsLong)); extractValues.Add(typeof(ulong).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUlong)); extractValues.Add(typeof(double).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDouble)); extractValues.Add(typeof(char).TypeHandle.Value.ToInt64(), new ExtractValue(getAsChar)); extractValues.Add(typeof(float).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFloat)); extractValues.Add(typeof(decimal).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDecimal)); extractValues.Add(typeof(bool).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBoolean)); extractValues.Add(typeof(string).TypeHandle.Value.ToInt64(), new ExtractValue(getAsString)); extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction)); extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable)); extractValues.Add(typeof(LuaUserData).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUserdata)); extractNetObject = new ExtractValue(getAsNetObject); }
public CheckType(ObjectTranslator translator) { this.translator = translator; extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject)); extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte)); extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte)); extractValues.Add(typeof(short).TypeHandle.Value.ToInt64(), new ExtractValue(getAsShort)); extractValues.Add(typeof(ushort).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUshort)); extractValues.Add(typeof(int).TypeHandle.Value.ToInt64(), new ExtractValue(getAsInt)); extractValues.Add(typeof(uint).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUint)); extractValues.Add(typeof(long).TypeHandle.Value.ToInt64(), new ExtractValue(getAsLong)); extractValues.Add(typeof(ulong).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUlong)); extractValues.Add(typeof(double).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDouble)); extractValues.Add(typeof(char).TypeHandle.Value.ToInt64(), new ExtractValue(getAsChar)); extractValues.Add(typeof(float).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFloat)); extractValues.Add(typeof(decimal).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDecimal)); extractValues.Add(typeof(bool).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBoolean)); extractValues.Add(typeof(string).TypeHandle.Value.ToInt64(), new ExtractValue(getAsString)); extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction)); extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable)); extractValues.Add(typeof(Vector3).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector3)); extractValues.Add(typeof(Vector2).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector2)); extractValues.Add(typeof(Quaternion).TypeHandle.Value.ToInt64(), new ExtractValue(getAsQuaternion)); extractValues.Add(typeof(Color).TypeHandle.Value.ToInt64(), new ExtractValue(getAsColor)); extractValues.Add(typeof(Vector4).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector4)); extractValues.Add(typeof(Ray).TypeHandle.Value.ToInt64(), new ExtractValue(getAsRay)); extractValues.Add(typeof(Bounds).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBounds)); extractNetObject = new ExtractValue(getAsNetObject); }
public CheckType(ObjectTranslator translator) { this.translator = translator; extractValues.Add(GetExtractDictionaryKey(typeof(object)), new ExtractValue(GetAsObject)); extractValues.Add(GetExtractDictionaryKey(typeof(sbyte)), new ExtractValue(GetAsSbyte)); extractValues.Add(GetExtractDictionaryKey(typeof(byte)), new ExtractValue(GetAsByte)); extractValues.Add(GetExtractDictionaryKey(typeof(short)), new ExtractValue(GetAsShort)); extractValues.Add(GetExtractDictionaryKey(typeof(ushort)), new ExtractValue(GetAsUshort)); extractValues.Add(GetExtractDictionaryKey(typeof(int)), new ExtractValue(GetAsInt)); extractValues.Add(GetExtractDictionaryKey(typeof(uint)), new ExtractValue(GetAsUint)); extractValues.Add(GetExtractDictionaryKey(typeof(long)), new ExtractValue(GetAsLong)); extractValues.Add(GetExtractDictionaryKey(typeof(ulong)), new ExtractValue(GetAsUlong)); extractValues.Add(GetExtractDictionaryKey(typeof(double)), new ExtractValue(GetAsDouble)); extractValues.Add(GetExtractDictionaryKey(typeof(char)), new ExtractValue(GetAsChar)); extractValues.Add(GetExtractDictionaryKey(typeof(float)), new ExtractValue(GetAsFloat)); extractValues.Add(GetExtractDictionaryKey(typeof(decimal)), new ExtractValue(GetAsDecimal)); extractValues.Add(GetExtractDictionaryKey(typeof(bool)), new ExtractValue(GetAsBoolean)); extractValues.Add(GetExtractDictionaryKey(typeof(string)), new ExtractValue(GetAsString)); extractValues.Add(GetExtractDictionaryKey(typeof(char[])), new ExtractValue(GetAsCharArray)); extractValues.Add(GetExtractDictionaryKey(typeof(LuaFunction)), new ExtractValue(GetAsFunction)); extractValues.Add(GetExtractDictionaryKey(typeof(LuaTable)), new ExtractValue(GetAsTable)); extractValues.Add(typeof(Dictionary <object, object>), GetAsDictionary); extractValues.Add(GetExtractDictionaryKey(typeof(LuaUserData)), new ExtractValue(GetAsUserdata)); extractNetObject = new ExtractValue(GetAsNetObject); }
public CheckType(Lua interpreter) { this.interpreter = interpreter; // rationale for TypeHandle: http://stackoverflow.com/a/126507 _casters = new Dictionary <RuntimeTypeHandle, Caster>(21) { { typeof(object).TypeHandle, new Caster(isObject, asObject) }, { typeof(sbyte).TypeHandle, new Caster(isSbyte, asSbyte) }, { typeof(byte).TypeHandle, new Caster(isByte, asByte) }, { typeof(short).TypeHandle, new Caster(isShort, asShort) }, { typeof(ushort).TypeHandle, new Caster(isUshort, asUshort) }, { typeof(int).TypeHandle, new Caster(isInt, asInt) }, { typeof(uint).TypeHandle, new Caster(isUint, asUint) }, { typeof(long).TypeHandle, new Caster(isLong, asLong) }, { typeof(ulong).TypeHandle, new Caster(isUlong, asUlong) }, { typeof(double).TypeHandle, new Caster(isDouble, asDouble) }, { typeof(char).TypeHandle, new Caster(isChar, asChar) }, { typeof(float).TypeHandle, new Caster(isFloat, asFloat) }, { typeof(decimal).TypeHandle, new Caster(isDecimal, asDecimal) }, { typeof(bool).TypeHandle, new Caster(isBoolean, asBoolean) }, { typeof(string).TypeHandle, new Caster(isString, asString) }, { typeof(LuaValue).TypeHandle, new Caster(isObject, asLuaValue) }, { typeof(LuaFunction).TypeHandle, new Caster(isFunction, asFunction) }, { typeof(LuaTable).TypeHandle, new Caster(isTable, asTable) }, { typeof(LuaUserData).TypeHandle, new Caster(isUserData, asUserData) }, { typeof(LuaString).TypeHandle, new Caster(isString, asLString) }, { typeof(LuaThread).TypeHandle, new Caster(isThread, asThread) }, // update the constructor when you add more }; extractNetObject = asNetObject; }
public CheckType(ObjectTranslator translator) { _translator = translator; _extractValues.Add(typeof(object), GetAsObject); _extractValues.Add(typeof(sbyte), GetAsSbyte); _extractValues.Add(typeof(byte), GetAsByte); _extractValues.Add(typeof(short), GetAsShort); _extractValues.Add(typeof(ushort), GetAsUshort); _extractValues.Add(typeof(int), GetAsInt); _extractValues.Add(typeof(uint), GetAsUint); _extractValues.Add(typeof(long), GetAsLong); _extractValues.Add(typeof(ulong), GetAsUlong); _extractValues.Add(typeof(double), GetAsDouble); _extractValues.Add(typeof(char), GetAsChar); _extractValues.Add(typeof(float), GetAsFloat); _extractValues.Add(typeof(decimal), GetAsDecimal); _extractValues.Add(typeof(bool), GetAsBoolean); _extractValues.Add(typeof(string), GetAsString); _extractValues.Add(typeof(char[]), GetAsCharArray); _extractValues.Add(typeof(byte[]), GetAsByteArray); _extractValues.Add(typeof(LuaFunction), GetAsFunction); _extractValues.Add(typeof(LuaTable), GetAsTable); _extractValues.Add(typeof(LuaUserData), GetAsUserdata); _extractNetObject = GetAsNetObject; }
internal object getAsType(IntPtr luaState, int stackPos, Type paramType) { ExtractValue value2 = this.typeChecker.checkType(luaState, stackPos, paramType); if (value2 != null) { return(value2(luaState, stackPos)); } return(null); }
/* * Gets an object from the Lua stack with the desired type, if it matches, otherwise * returns null. */ internal object getAsType(IntPtr luaState, int stackPos, Type paramType) { ExtractValue extractor = typeChecker.checkType(luaState, stackPos, paramType); if (extractor != null) { return(extractor(luaState, stackPos)); } return(null); }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { this.translator=translator; this.methodName=methodName; this.targetType=targetType; if(targetType!=null) extractTarget=translator.typeChecker.getExtractor(targetType); this.bindingType=bindingType; members=targetType.UnderlyingSystemType.GetMember(methodName,MemberTypes.Method,bindingType|BindingFlags.Public|BindingFlags.NonPublic); }
/// <summary>Gets an object from the Lua stack with the desired type, if it matches, otherwise returns null.</summary> internal object getAsType(lua.State L, int index, Type paramType) { Debug.Assert(interpreter.IsSameLua(L)); ExtractValue extractor = typeChecker.checkType(L, index, paramType); if (extractor == null) { return(null); } return(extractor(L, index)); }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, ProxyType targetType, MethodBase method) { InvokeFunction = Call; _translator = translator; _target = target; _extractTarget = translator.typeChecker.GetExtractor(targetType); _method = method; _methodName = method.Name; _isStatic = method.IsStatic; }
/// <summary>Constructs the wrapper for a known method name</summary><exception cref="NullReferenceException">All arguments are required</exception> public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { Debug.Assert(translator != null && targetType != null && methodName != null); _Translator = translator; _MethodName = methodName; _ExtractTarget = translator.typeChecker.getExtractor(targetType); _BindingType = bindingType; _Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | luanet.LuaBindingFlags); }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { this.translator = translator; this.methodName = methodName; this.targetType = targetType; if (targetType != null) { extractTarget = translator.typeChecker.getExtractor(targetType); } this.bindingType = bindingType; members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | BindingFlags.Public | BindingFlags.NonPublic); }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { this.translator=translator; this.target=target; this.targetType=targetType; if(targetType!=null) extractTarget=translator.typeChecker.getExtractor(targetType); this.method=method; this.methodName=method.Name; if(method.IsStatic) { bindingType=BindingFlags.Static; } else { bindingType=BindingFlags.Instance; } }
public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { this._Translator = translator; this._MethodName = methodName; this._TargetType = targetType; if (targetType != null) { this._ExtractTarget = translator.typeChecker.getExtractor(targetType); } this._BindingType = bindingType; this._Members = targetType.get_UnderlyingSystemType().GetMember(methodName, 8, bindingType | 16 | 1); }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper (ObjectTranslator translator, object target, ProxyType targetType, MethodBase method) { invokeFunction = new LuaNativeFunction (this.Call); _Translator = translator; _Target = target; if (targetType != null) _ExtractTarget = translator.typeChecker.GetExtractor (targetType); _Method = method; _MethodName = method.Name; _IsStatic = method.IsStatic; }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, ProxyType targetType, string methodName, BindingFlags bindingType) { InvokeFunction = Call; _translator = translator; _methodName = methodName; _extractTarget = translator.typeChecker.GetExtractor(targetType); _isStatic = (bindingType & BindingFlags.Static) == BindingFlags.Static; _members = GetMethodsRecursively(targetType.UnderlyingSystemType, methodName, bindingType | BindingFlags.Public); }
public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { this._LastCalledMethod = new MethodCache(); this._Translator = translator; this._MethodName = methodName; this._TargetType = targetType; if (targetType != null) { this._ExtractTarget = translator.typeChecker.getExtractor(targetType); } this._BindingType = bindingType; this._Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, (bindingType | BindingFlags.Public) | BindingFlags.IgnoreCase); }
/// <summary>Constructs the wrapper for a known MethodBase instance</summary> public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { _Translator = translator; _Target = target; if (targetType != null) { _ExtractTarget = translator.typeChecker.getExtractor(targetType); } _Method = method; _MethodName = method.Name; _BindingType = method.IsStatic ? BindingFlags.Static : BindingFlags.Instance; }
// This extraction the Action URL form the login webpage. // it is used for further requests. // The URL is from the College object public string PostURL(string URL) { SendMessage(this, new Information("Webpage Location = " + URL)); CISWebRequest myWebRequest = new CISWebRequest(); string result = myWebRequest.RetrieveHTMLPage(URL); // get the page // Extract From result the POST Action URL "https://www.ctc.edu/cgi-bin/rq160/" // and return it to the caller. ExtractValue EV = new ExtractValue(); return(EV.FromJavaScript(result, StrAction, "\"", "\"")); }
/// <summary> /// Constructs the wrapper for a known method name /// </summary> /// <param name="translator"></param> /// <param name="targetType"></param> /// <param name="methodName"></param> /// <param name="bindingType"></param> public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { invokeFunction = new LuaNativeFunction(this.Call); _Translator = translator; _MethodName = methodName; if (targetType != null) _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*/); }
//private readonly HeaderColumn Phone; public Course(string RawHTML, string InstructorName, string CourseName, string ItemNumber, string YRQ, string QuarterName, ExcelClassSettings ExcelClassSettings) { SchoolHeaders = new OptionHeaders(); StrInstructorName = InstructorName; StrCourseName = CourseName; StrItemNumber = ItemNumber; StrYRQ = YRQ; StrQuarterName = QuarterName; // Set to export blnExport = true; if (RawHTML != "") { ExtractValue EV = new ExtractValue(); StrTitle = EV.FromJavaScript(RawHTML, "title", "'", "'"); StrSection = EV.FromJavaScript(RawHTML, "sect", "'", "'"); StrCredits = EV.FromJavaScript(RawHTML, "credit", "'", "'"); StrRoom = EV.FromJavaScript(RawHTML, "room", "'", "'"); StrStartTime = EV.FromJavaScript(RawHTML, "strtTime", "'", "'"); StrEndTime = EV.FromJavaScript(RawHTML, "endTime", "'", "'"); StrDays = EV.FromJavaScript(RawHTML, "days", "'", "'"); StrStartDate = EV.FromJavaScript(RawHTML, "strtDate", "'", "'"); StrTenthDate = EV.FromJavaScript(RawHTML, "tenDay", "'", "'"); StrOpt1Header = EV.FromJavaScript(RawHTML, "optHead1", "'", "'"); StrOpt2Header = EV.FromJavaScript(RawHTML, "optHead2", "'", "'"); StrOpt3Header = EV.FromJavaScript(RawHTML, "optHead3", "'", "'"); StrOptWlHeader = EV.FromJavaScript(RawHTML, "optWLHead", "'", "'"); if (SaveOptionHeader) { ExcelClassSettings.HeaderNames.Header1 = StrOpt1Header; ExcelClassSettings.HeaderNames.Header2 = StrOpt2Header; ExcelClassSettings.HeaderNames.Header3 = StrOpt3Header; ExcelClassSettings.HeaderNames.WaitListHeader = StrOptWlHeader; SaveOptionHeader = false; } int Count = Convert.ToInt32(EV.FromJavaScript(RawHTML, "totStu", "'", "'")); myStudents = new Student[Count]; Count = Convert.ToInt32(EV.FromJavaScript(RawHTML, "totStuWl", "'", "'")); myWaitlist = new Student[Count]; // Extract all students from RawHTML ProcessStudentsFromHTML(RawHTML, ExcelClassSettings.HeaderNames); } }
/// <summary>Constructs the wrapper for a known method name</summary> public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { _Translator = translator; _MethodName = methodName; if (targetType != null) { _ExtractTarget = translator.typeChecker.getExtractor(targetType); } _BindingType = bindingType; // bug: targetType may be null? todo: inspect code that uses _Members and this constructor _Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | luanet.LuaBindingFlags); }
/* * 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 method name */ public LuaMethodWrapper(ObjectTranslator translator, ProxyType targetType, string methodName, BindingFlags bindingType) { invokeFunction = new LuaNativeFunction(this.Call); _Translator = translator; _MethodName = methodName; if (targetType != null) { _ExtractTarget = translator.typeChecker.GetExtractor(targetType); } _IsStatic = (bindingType & BindingFlags.Static) == BindingFlags.Static; _Members = GetMethodsRecursively(targetType.UnderlyingSystemType, methodName, bindingType | BindingFlags.Public); }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, ProxyType targetType, MethodBase method) { invokeFunction = new LuaNativeFunction(this.Call); _Translator = translator; _Target = target; if (targetType != null) { _ExtractTarget = translator.typeChecker.GetExtractor(targetType); } _Method = method; _MethodName = method.Name; _IsStatic = method.IsStatic; }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, ProxyType targetType, string methodName, BindingFlags bindingType) { invokeFunction = new LuaNativeFunction(this.Call); _Translator = translator; _MethodName = methodName; if (targetType != null) { _ExtractTarget = translator.typeChecker.GetExtractor(targetType); } _BindingType = bindingType; _Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | BindingFlags.Public); }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { invokeFunction = new LuaNativeFunction(this.Call); _Translator = translator; _MethodName = methodName; if (targetType != null) { _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 LuaNativeFunction (this.Call); _Translator = translator; _Target = target; if (targetType != null) _ExtractTarget = translator.typeChecker.GetExtractor (targetType); _Method = method; _MethodName = method.Name; if (method.IsStatic) _BindingType = BindingFlags.Static; else _BindingType = BindingFlags.Instance; }
bool _IsParamsArray(lua.State L, int index, ParameterInfo param, out ExtractValue extractValue) { Debug.Assert(interpreter.IsSameLua(L)); extractValue = null; if (param.GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0) { switch (lua.type(L, index)) { case LUA.T.NONE: Debug.WriteLine("_IsParamsArray: Could not retrieve lua type."); return(false); case LUA.T.TABLE: extractValue = typeChecker.getExtractor(typeof(LuaTable)); if (extractValue != null) { return(true); } break; default: Type elementType = param.ParameterType.GetElementType(); if (elementType == null) { break; // not an array; invalid ParamArrayAttribute } try { extractValue = typeChecker.checkType(L, index, elementType); if (extractValue != null) { return(true); } } catch (LuaInternalException) { throw; } catch (Exception ex) { Debug.WriteLine(String.Format("_IsParamsArray: checkType({0}) threw exception: {1}", elementType.FullName, ex.ToString())); } break; } } Debug.WriteLine("Type wasn't Params object."); return(false); }
public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { this._Translator = translator; this._Target = target; this._TargetType = targetType; if (targetType != null) { this._ExtractTarget = translator.typeChecker.getExtractor(targetType); } this._Method = method; this._MethodName = method.get_Name(); if (method.get_IsStatic()) { this._BindingType = 8; } else { this._BindingType = 4; } }
/* * Constructs the wrapper for a known MethodBase instance */ public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { this.translator = translator; this.target = target; this.targetType = targetType; if (targetType != null) { extractTarget = translator.typeChecker.getExtractor(targetType); } this.method = method; this.methodName = method.Name; if (method.IsStatic) { bindingType = BindingFlags.Static; } else { bindingType = BindingFlags.Instance; } }
public LuaMethodWrapper(ObjectTranslator translator, object target, IReflect targetType, MethodBase method) { this._LastCalledMethod = new MethodCache(); this._Translator = translator; this._Target = target; this._TargetType = targetType; if (targetType != null) { this._ExtractTarget = translator.typeChecker.getExtractor(targetType); } this._Method = method; this._MethodName = method.Name; if (method.IsStatic) { this._BindingType = BindingFlags.Static; } else { this._BindingType = BindingFlags.Instance; } }
public CheckType(ObjectTranslator translator) { this.translator=translator; extractSbyte=new ExtractValue(this.getAsSbyte); extractByte=new ExtractValue(this.getAsByte); extractShort=new ExtractValue(this.getAsShort); extractUshort=new ExtractValue(this.getAsUshort); extractInt=new ExtractValue(this.getAsInt); extractUint=new ExtractValue(this.getAsUint); extractLong=new ExtractValue(this.getAsLong); extractUlong=new ExtractValue(this.getAsUlong); extractDouble=new ExtractValue(this.getAsDouble); extractChar=new ExtractValue(this.getAsChar); extractFloat=new ExtractValue(this.getAsFloat); extractDecimal=new ExtractValue(this.getAsDecimal); extractBoolean=new ExtractValue(this.getAsBoolean); extractString=new ExtractValue(this.getAsString); extractFunction=new ExtractValue(this.getAsFunction); extractTable=new ExtractValue(this.getAsTable); extractUserdata=new ExtractValue(this.getAsUserdata); extractObject=new ExtractValue(this.getAsObject); }
public CheckType(ObjectTranslator translator) { this.translator = translator; extractSbyte = new ExtractValue(this.getAsSbyte); extractByte = new ExtractValue(this.getAsByte); extractShort = new ExtractValue(this.getAsShort); extractUshort = new ExtractValue(this.getAsUshort); extractInt = new ExtractValue(this.getAsInt); extractUint = new ExtractValue(this.getAsUint); extractLong = new ExtractValue(this.getAsLong); extractUlong = new ExtractValue(this.getAsUlong); extractDouble = new ExtractValue(this.getAsDouble); extractChar = new ExtractValue(this.getAsChar); extractFloat = new ExtractValue(this.getAsFloat); extractDecimal = new ExtractValue(this.getAsDecimal); extractBoolean = new ExtractValue(this.getAsBoolean); extractString = new ExtractValue(this.getAsString); extractFunction = new ExtractValue(this.getAsFunction); extractTable = new ExtractValue(this.getAsTable); extractUserdata = new ExtractValue(this.getAsUserdata); extractObject = new ExtractValue(this.getAsObject); extractNetObject = new ExtractValue(this.getAsNetObject); }
/* * 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; } }
public CheckType (ObjectTranslator translator) { this.translator = translator; extractValues.Add(GetExtractDictionaryKey(typeof(object)), new ExtractValue(GetAsObject)); extractValues.Add(GetExtractDictionaryKey(typeof(sbyte)), new ExtractValue(GetAsSbyte)); extractValues.Add(GetExtractDictionaryKey(typeof(byte)), new ExtractValue(GetAsByte)); extractValues.Add(GetExtractDictionaryKey(typeof(short)), new ExtractValue(GetAsShort)); extractValues.Add(GetExtractDictionaryKey(typeof(ushort)), new ExtractValue(GetAsUshort)); extractValues.Add(GetExtractDictionaryKey(typeof(int)), new ExtractValue(GetAsInt)); extractValues.Add(GetExtractDictionaryKey(typeof(uint)), new ExtractValue(GetAsUint)); extractValues.Add(GetExtractDictionaryKey(typeof(long)), new ExtractValue(GetAsLong)); extractValues.Add(GetExtractDictionaryKey(typeof(ulong)), new ExtractValue(GetAsUlong)); extractValues.Add(GetExtractDictionaryKey(typeof(double)), new ExtractValue(GetAsDouble)); extractValues.Add(GetExtractDictionaryKey(typeof(char)), new ExtractValue(GetAsChar)); extractValues.Add(GetExtractDictionaryKey(typeof(float)), new ExtractValue(GetAsFloat)); extractValues.Add(GetExtractDictionaryKey(typeof(decimal)), new ExtractValue(GetAsDecimal)); extractValues.Add(GetExtractDictionaryKey(typeof(bool)), new ExtractValue(GetAsBoolean)); extractValues.Add(GetExtractDictionaryKey(typeof(string)), new ExtractValue(GetAsString)); extractValues.Add(GetExtractDictionaryKey(typeof(char[])), new ExtractValue (GetAsCharArray)); extractValues.Add(GetExtractDictionaryKey(typeof(LuaFunction)), new ExtractValue(GetAsFunction)); extractValues.Add(GetExtractDictionaryKey(typeof(LuaTable)), new ExtractValue(GetAsTable)); extractValues.Add(GetExtractDictionaryKey(typeof(LuaUserData)), new ExtractValue(GetAsUserdata)); extractNetObject = new ExtractValue (GetAsNetObject); }
internal Array TableToArray(LuaState luaState, ExtractValue extractValue, Type paramArrayType, int startIndex, int count) { return(metaFunctions.TableToArray(luaState, extractValue, paramArrayType, ref startIndex, count)); }
private bool IsParamsArray (LuaState luaState, int currentLuaParam, ParameterInfo currentNetParam, out ExtractValue extractValue) { extractValue = null; if (currentNetParam.GetCustomAttributes (typeof(ParamArrayAttribute), false).Length > 0) { LuaTypes luaType; try { luaType = LuaLib.LuaType (luaState, currentLuaParam); } catch (Exception ex) { Debug.WriteLine ("Could not retrieve lua type while attempting to determine params Array Status."); Debug.WriteLine (ex.Message); extractValue = null; return false; } if (luaType == LuaTypes.Table) { try { extractValue = translator.typeChecker.GetExtractor (typeof(LuaTable)); } catch (Exception/* ex*/) { Debug.WriteLine ("An error occurred during an attempt to retrieve a LuaTable extractor while checking for params array status."); } if (extractValue != null) { return true; } } else { var paramElementType = currentNetParam.ParameterType.GetElementType (); try { extractValue = translator.typeChecker.CheckLuaType (luaState, currentLuaParam, paramElementType); } catch (Exception/* ex*/) { Debug.WriteLine (string.Format ("An error occurred during an attempt to retrieve an extractor ({0}) while checking for params array status.", paramElementType.FullName)); } if (extractValue != null) { return true; } } } Debug.WriteLine ("Type wasn't Params object."); return false; }
/// <summary> /// CP: Fix for operator overloading failure /// Returns true if the type is set and assigns the extract value /// </summary> /// <param name="luaState"></param> /// <param name="currentLuaParam"></param> /// <param name="currentNetParam"></param> /// <param name="extractValue"></param> /// <returns></returns> private bool IsTypeCorrect (LuaState luaState, int currentLuaParam, ParameterInfo currentNetParam, out ExtractValue extractValue) { try { return (extractValue = translator.typeChecker.CheckLuaType (luaState, currentLuaParam, currentNetParam.ParameterType)) != null; } catch { extractValue = null; Debug.WriteLine ("Type wasn't correct"); return false; } }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper (ObjectTranslator translator, ProxyType targetType, string methodName, BindingFlags bindingType) { invokeFunction = new LuaNativeFunction (this.Call); _Translator = translator; _MethodName = methodName; if (targetType != null) _ExtractTarget = translator.typeChecker.GetExtractor (targetType); _IsStatic = (bindingType & BindingFlags.Static) == BindingFlags.Static; _Members = GetMethodsRecursively (targetType.UnderlyingSystemType, methodName, bindingType | BindingFlags.Public); }
/* * Constructs the wrapper for a known method name */ public LuaMethodWrapper (ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) { invokeFunction = new LuaNativeFunction (this.Call); _Translator = translator; _MethodName = methodName; if (targetType != null) _ExtractTarget = translator.typeChecker.GetExtractor (targetType); _BindingType = bindingType; _Members = targetType.UnderlyingSystemType.GetMember (methodName, MemberTypes.Method, bindingType | BindingFlags.Public); }
/* * 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*/); }
private bool _IsTypeCorrect(IntPtr luaState, int currentLuaParam, ParameterInfo currentNetParam, out ExtractValue extractValue) { try { ExtractValue value2; extractValue = value2 = this.translator.typeChecker.checkType(luaState, currentLuaParam, currentNetParam.ParameterType); return (value2 != null); } catch { extractValue = null; return false; } }