Esempio n. 1
0
        internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value)
        {
            if (instance == null)
            {
                value = new DictProxy(owner);
                return(true);
            }

            PythonType pt = instance as PythonType;

            if (pt != null)
            {
                value = new DictProxy(pt);
                return(true);
            }

            IPythonObject sdo = instance as IPythonObject;

            if (sdo != null && sdo.PythonType.HasDictionary)
            {
                PythonDictionary res = sdo.Dict;
                if (res != null || (res = sdo.SetDict(sdo.PythonType.MakeDictionary())) != null)
                {
                    value = res;
                    return(true);
                }
            }

            value = null;
            return(false);
        }
Esempio n. 2
0
        internal static PythonDictionary GetDictionary(IPythonObject self)
        {
            PythonDictionary dict = self.Dict;

            if (dict == null && self.PythonType.HasDictionary)
            {
                dict = self.SetDict(self.PythonType.MakeDictionary());
            }
            return(dict);
        }
Esempio n. 3
0
 internal static IAttributesCollection GetDictionary(IPythonObject self) {
     IAttributesCollection dict = self.Dict;
     if (dict == null) {
         dict = self.SetDict(PythonDictionary.MakeSymbolDictionary());
     }
     return dict;
 }