コード例 #1
0
        private object GetIndex(CodeContext context, object index)
        {
            if (index is string strIndex)
            {
                PythonTypeSlot dts;
                if (_dt.TryLookupSlot(context, strIndex, out dts))
                {
                    if (dts is PythonTypeUserDescriptorSlot uds)
                    {
                        return(uds.Value);
                    }

                    return(dts);
                }
            }

            throw PythonOps.KeyError(index.ToString());
        }
コード例 #2
0
ファイル: Super.cs プロジェクト: CookieEaters/FireHTTP
        private bool TryLookupInBase(CodeContext context, PythonType pt, string name, object self, out object value) {
            PythonTypeSlot dts;

            if (pt.OldClass == null) {
                // new-style class, or reflected type, lookup slot
                if (pt.TryLookupSlot(context, name, out dts) && 
                    dts.TryGetValue(context, self, DescriptorContext, out value)) {
                    return true;
                }
            } else {
                // old-style class, lookup attribute                
                OldClass dt = pt.OldClass;

                if (PythonOps.TryGetBoundAttr(context, dt, name, out value)) {
                    value = OldClass.GetOldStyleDescriptor(context, value, self, DescriptorContext);
                    return true;
                }
            }
            value = null;
            return false;
        }
コード例 #3
0
ファイル: UserTypeOps.cs プロジェクト: octavioh/ironruby
 private static bool LookupValue(PythonType dt, object instance, SymbolId name, out object value) {
     PythonTypeSlot dts;
     if (dt.TryLookupSlot(DefaultContext.Default, name, out dts) &&
         dts.TryGetValue(DefaultContext.Default, instance, dt, out value)) {
         return true;
     }
     value = null;
     return false;
 }
コード例 #4
0
ファイル: PythonType.cs プロジェクト: octavioh/ironruby
        public static object Get__doc__(CodeContext/*!*/ context, PythonType self) {
            PythonTypeSlot pts;
            object res;
            if (self.TryLookupSlot(context, Symbols.Doc, out pts) &&
                pts.TryGetValue(context, null, self, out res)) {
                return res;
            } else if (self.IsSystemType) {
                return PythonTypeOps.GetDocumentation(self.UnderlyingSystemType);
            }

            return null;
        }