Inheritance: PythonTypeSlot, IDynamicMetaObjectProvider, ICodeFormattable
コード例 #1
0
 public bool __eq__(object other) {
     BuiltinMethodDescriptor bmd = other as BuiltinMethodDescriptor;
     if (bmd == null) {
         return false;
     }
     if (PythonOps.Id(__objclass__) != PythonOps.Id(bmd.__objclass__)) {
         return false;
     }
     return __name__ == bmd.__name__;
 }
コード例 #2
0
ファイル: BuiltinMethodInfo.cs プロジェクト: TerabyteX/main
        public BuiltinMethodInfo(BuiltinMethodDescriptor method, ProjectState projectState)
            : base(ClrModule.GetPythonType(typeof(BuiltinMethodDescriptor)), projectState)
        {
            // TODO: get return information, parameters, members
            _method = method;

            var function = PythonOps.GetBuiltinMethodDescriptorTemplate(method);
            _returnTypes = Utils.GetReturnTypes(function, projectState);
            _doc = null;
        }
コード例 #3
0
        public int __cmp__(object other) {
            BuiltinMethodDescriptor bmd = other as BuiltinMethodDescriptor;
            if (bmd == null) {
                throw PythonOps.TypeError("instancemethod.__cmp__(x,y) requires y to be a 'instancemethod', not a {0}", PythonTypeOps.GetName(other));
            }

            long result = PythonOps.Id(__objclass__) - PythonOps.Id(bmd.__objclass__);
            if (result != 0) {
                return (result > 0) ? 1 : -1;
            }
            
            return StringOps.Compare(__name__, bmd.__name__);
        }
コード例 #4
0
        internal static PythonTypeSlot/*!*/ GetFinalSlotForFunction(BuiltinFunction/*!*/ func) {
            if ((func.FunctionType & FunctionType.Method) != 0) {
                BuiltinMethodDescriptor desc;
                lock (_methodCache) {
                    if (!_methodCache.TryGetValue(func, out desc)) {
                        _methodCache[func] = desc = new BuiltinMethodDescriptor(func);
                    }

                    return desc;
                }
            }

            if (func.Targets[0].IsDefined(typeof(ClassMethodAttribute), true)) {
                lock (_classMethodCache) {
                    ClassMethodDescriptor desc;
                    if (!_classMethodCache.TryGetValue(func, out desc)) {
                        _classMethodCache[func] = desc = new ClassMethodDescriptor(func);
                    }

                    return desc;
                }
            }

            return func;
        }
コード例 #5
0
ファイル: DictionaryInfo.cs プロジェクト: TerabyteX/main
 internal DictionaryGetMethod(BuiltinMethodDescriptor method, ProjectState projectState, DictionaryInfo myDict)
     : base(method, projectState)
 {
     _myDict = myDict;
 }
コード例 #6
0
 public MetaBuiltinMethodDescriptor(Expression/*!*/ expression, BindingRestrictions/*!*/ restrictions, BuiltinMethodDescriptor/*!*/ value)
     : base(expression, BindingRestrictions.Empty, value) {
     Assert.NotNull(value);
 }