private Expression MakeBodyHelper(Type type, MemberGroup members) { if (!_isStatic) { MakeOperatorGetMemberBody(type, "GetCustomMember"); } Expression error; TrackerTypes memberType = GetMemberType(members, out error); if (error != null) { AddToBody(Rule.MakeError(error)); return(Body); } switch (memberType) { case TrackerTypes.TypeGroup: case TrackerTypes.Type: MakeTypeBody(type, members); break; case TrackerTypes.Method: // turn into a MethodGroup MakeGenericBodyWorker(type, ReflectionCache.GetMethodGroup(StringName, members), _instance ?? Rule.Parameters[0]); break; case TrackerTypes.Event: case TrackerTypes.Field: case TrackerTypes.Property: case TrackerTypes.Constructor: case TrackerTypes.Custom: MakeGenericBody(type, members); break; case TrackerTypes.All: // no members were found if (!_isStatic) { MakeOperatorGetMemberBody(type, "GetBoundMember"); } MakeMissingMemberRuleForGet(type); break; default: throw new InvalidOperationException(memberType.ToString()); } return(Body); }
private void MakeSuccessfulMemberAccess(GetMemberInfo getMemInfo, DynamicMetaObject self, DynamicMetaObject propSelf, Type selfType, MemberGroup members, TrackerTypes memberType) { switch (memberType) { case TrackerTypes.TypeGroup: case TrackerTypes.Type: MakeTypeBody(getMemInfo, selfType, members); break; case TrackerTypes.Method: // turn into a MethodGroup MakeGenericBodyWorker(getMemInfo, selfType, ReflectionCache.GetMethodGroup(getMemInfo.Name, members), self); break; case TrackerTypes.Event: case TrackerTypes.Field: case TrackerTypes.Property: case TrackerTypes.Constructor: case TrackerTypes.Custom: MakeGenericBody(getMemInfo, selfType, members, propSelf); break; case TrackerTypes.All: // no members were found if (self != null) { MakeOperatorGetMemberBody(getMemInfo, propSelf, selfType, "GetBoundMember"); } MakeMissingMemberRuleForGet(getMemInfo, self, selfType); break; default: throw new InvalidOperationException(memberType.ToString()); } }
/// <summary> /// /// </summary> /// <param name="trackerType"></param> public static Tracker Create(TrackerTypes trackerType) { IntPtr ptr; switch (trackerType) { case TrackerTypes.Boosting: ptr = NativeMethods.tracking_Tracker_create("BOOSTING"); break; case TrackerTypes.GOTURN: ptr = NativeMethods.tracking_Tracker_create("GOTURN"); break; case TrackerTypes.TLD: ptr = NativeMethods.tracking_Tracker_create("TLD"); break; case TrackerTypes.KCF: ptr = NativeMethods.tracking_Tracker_create("KCF"); break; case TrackerTypes.MedianFlow: ptr = NativeMethods.tracking_Tracker_create("MEDIANFLOW"); break; case TrackerTypes.MIL: ptr = NativeMethods.tracking_Tracker_create("MIL"); break; default: throw new ArgumentOutOfRangeException(trackerType.ToString(), trackerType, null); } return(new Tracker(ptr)); }
internal static PythonTypeSlot /*!*/ GetSlot(MemberGroup group, string name, bool privateBinding) { if (group.Count == 0) { return(null); } group = FilterNewSlots(group); TrackerTypes tt = GetMemberType(group); switch (tt) { case TrackerTypes.Method: bool checkStatic = false; List <MemberInfo> mems = new List <MemberInfo>(); foreach (MemberTracker mt in group) { MethodTracker metht = (MethodTracker)mt; mems.Add(metht.Method); checkStatic |= metht.IsStatic; } Type declType = group[0].DeclaringType; MemberInfo[] memArray = mems.ToArray(); FunctionType ft = GetMethodFunctionType(declType, memArray, checkStatic); return(GetFinalSlotForFunction(GetBuiltinFunction(declType, group[0].Name, name, ft, memArray))); case TrackerTypes.Field: return(GetReflectedField(((FieldTracker)group[0]).Field)); case TrackerTypes.Property: return(GetReflectedProperty((PropertyTracker)group[0], group, privateBinding)); case TrackerTypes.Event: return(GetReflectedEvent(((EventTracker)group[0]))); case TrackerTypes.Type: TypeTracker type = (TypeTracker)group[0]; for (int i = 1; i < group.Count; i++) { type = TypeGroup.UpdateTypeEntity(type, (TypeTracker)group[i]); } if (type is TypeGroup) { return(new PythonTypeUserDescriptorSlot(type, true)); } return(new PythonTypeUserDescriptorSlot(DynamicHelpers.GetPythonTypeFromType(type.Type), true)); case TrackerTypes.Constructor: return(GetConstructorFunction(group[0].DeclaringType, privateBinding)); case TrackerTypes.Custom: return(((PythonCustomTracker)group[0]).GetSlot()); default: // if we have a new slot in the derived class filter out the // members from the base class. throw new InvalidOperationException(String.Format("Bad member type {0} on {1}.{2}", tt.ToString(), group[0].DeclaringType, name)); } }
private void MakeSuccessfulMemberAccess(GetMemberInfo getMemInfo, Expression self, Expression propSelf, Type type, MemberGroup members, TrackerTypes memberType) { switch (memberType) { case TrackerTypes.TypeGroup: case TrackerTypes.Type: MakeTypeBody(getMemInfo, type, members); break; case TrackerTypes.Method: // turn into a MethodGroup MakeGenericBodyWorker(getMemInfo, type, ReflectionCache.GetMethodGroup(getMemInfo.Name, members), self); break; case TrackerTypes.Event: case TrackerTypes.Field: case TrackerTypes.Property: case TrackerTypes.Constructor: case TrackerTypes.Custom: MakeGenericBody(getMemInfo, type, members, propSelf); break; case TrackerTypes.All: // no members were found if (self != null) { MakeOperatorGetMemberBody(getMemInfo, propSelf, type, "GetBoundMember"); } MakeMissingMemberRuleForGet(getMemInfo, type); break; default: throw new InvalidOperationException(memberType.ToString()); } }