示例#1
0
文件: celldict.py 项目: Mu-L/pypy
    def copy(self, w_dict):
        strategy = self.space.fromcache(BytesDictStrategy)
        str_dict = strategy.unerase(strategy.get_empty_storage())

        d = self.unerase(w_dict.dstorage)
        for key, cell in d.iteritems():
            str_dict[key] = unwrap_cell(self.space, cell)
        return W_DictObject(strategy.space, strategy, strategy.erase(str_dict))
示例#2
0
 def getdict(w_self, space): # returning a dict-proxy!
     from pypy.objspace.std.dictproxyobject import DictProxyStrategy
     from pypy.objspace.std.dictmultiobject import W_DictObject
     if w_self.lazyloaders:
         w_self._cleanup_()    # force un-lazification
     strategy = space.fromcache(DictProxyStrategy)
     storage = strategy.erase(w_self)
     return W_DictObject(space, strategy, storage)
示例#3
0
def attach_dict_strategy(space):
    # this is needed for modules which do e.g. "isinstance(w_obj,
    # W_DictMultiObject)", like _hpy_universal. Make sure that the
    # annotator sees a concrete class, like W_DictObject, else lots of
    # operations are blocked.
    from pypy.objspace.std.dictmultiobject import W_DictObject, ObjectDictStrategy
    strategy = ObjectDictStrategy(space)
    storage = strategy.get_empty_storage()
    w_obj = W_DictObject(space, strategy, storage)
示例#4
0
文件: jsondict.py 项目: Mu-L/pypy
def from_values_and_jsonmap(space, values_w, jsonmap):
    if not objectmodel.we_are_translated():
        assert len(values_w) == len(jsonmap.get_keys_in_order())
        assert len(values_w) != 0
    debug.make_sure_not_resized(values_w)
    strategy = jsonmap.strategy_instance
    if strategy is None:
        jsonmap.strategy_instance = strategy = JsonDictStrategy(space, jsonmap)
    storage = strategy.erase(values_w)
    return W_DictObject(space, strategy, storage)
示例#5
0
文件: mapdict.py 项目: sota/pypy-old
    def getdict(self, space):
        w_dict = self._get_mapdict_map().read(self, "dict", SPECIAL)
        if w_dict is not None:
            assert isinstance(w_dict, W_DictMultiObject)
            return w_dict

        strategy = space.fromcache(MapDictStrategy)
        storage = strategy.erase(self)
        w_dict = W_DictObject(space, strategy, storage)
        flag = self._get_mapdict_map().write(self, "dict", SPECIAL, w_dict)
        assert flag
        return w_dict
示例#6
0
 def get_impl(self):
     strategy = self.StrategyClass(self.fakespace)
     storage = strategy.get_empty_storage()
     w_dict = self.fakespace.allocate_instance(W_DictObject, None)
     W_DictObject.__init__(w_dict, self.fakespace, strategy, storage)
     return w_dict
示例#7
0
 def newdict(self, module=False, instance=False):
     return W_DictObject.allocate_and_init_instance(self,
                                                    module=module,
                                                    instance=instance)
示例#8
0
文件: jsondict.py 项目: Mu-L/pypy
 def copy(self, w_dict):
     storage = self._make_unicode_dict(w_dict)
     strategy = self.space.fromcache(UnicodeDictStrategy)
     return W_DictObject(strategy.space, strategy, storage)
示例#9
0
文件: kwargsdict.py 项目: Mu-L/pypy
 def copy(self, w_dict):
     dstorage = self.unerase(w_dict.dstorage)
     return W_DictObject(self.space, self, self.get_empty_storage())
示例#10
0
文件: kwargsdict.py 项目: Mu-L/pypy
 def copy(self, w_dict):
     dstorage = self.unerase(w_dict.dstorage)
     return W_DictObject(self.space, self,
             self.erase((dstorage[0][:], dstorage[1][:])))