Skip to content

Commit

Permalink
Use new method in the ObjCache. Closed #116.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bystroushaak committed Oct 13, 2019
1 parent 45c5995 commit 6839c6f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/tinySelf/vm/primitives/os/primitive_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def __init__(self, value, obj_map=None, path=""):
self.value = value
self.path = path

if PrimitiveFileObject._OBJ_CACHE.map is not None:
self._slot_values = PrimitiveFileObject._OBJ_CACHE.slots
if PrimitiveFileObject._OBJ_CACHE.is_set:
PrimitiveFileObject._OBJ_CACHE.restore(self)
return

add_primitive_fn(self, "close", close_file, [])
Expand All @@ -110,8 +110,7 @@ def __init__(self, value, obj_map=None, path=""):
add_primitive_fn(self, "seek:", seek_to, ["pos"])
add_primitive_fn(self, "closed?", is_closed, [])

if PrimitiveFileObject._OBJ_CACHE.map is None:
PrimitiveFileObject._OBJ_CACHE.store(self)
PrimitiveFileObject._OBJ_CACHE.store(self)

def __str__(self):
status = ", closed" if self.value.closed else ""
Expand Down
7 changes: 3 additions & 4 deletions src/tinySelf/vm/primitives/os/primitive_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ def __init__(self, value, obj_map=None):
assert isinstance(value, RSocket)
self.value = value

if PrimitiveSocketObject._OBJ_CACHE.map is not None:
self._slot_values = PrimitiveSocketObject._OBJ_CACHE.slots
if PrimitiveSocketObject._OBJ_CACHE.is_set:
PrimitiveSocketObject._OBJ_CACHE.restore(self)
return

add_primitive_fn(self, "recv:", socket_recv, ["size"])
add_primitive_fn(self, "sendAll:", socket_sendall, ["data"])
add_primitive_fn(self, "close", socket_close, [])

if PrimitiveSocketObject._OBJ_CACHE.map is None:
PrimitiveSocketObject._OBJ_CACHE.store(self)
PrimitiveSocketObject._OBJ_CACHE.store(self)

def __str__(self):
return "PrimitiveSocket()"
Expand Down
7 changes: 3 additions & 4 deletions src/tinySelf/vm/primitives/primitive_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,16 @@ def __init__(self, value, obj_map=None):

self.value = value

if PrimitiveDictObject._OBJ_CACHE.map is not None:
self._slot_values = PrimitiveDictObject._OBJ_CACHE.slots
if PrimitiveDictObject._OBJ_CACHE.is_set:
PrimitiveDictObject._OBJ_CACHE.restore(self)
return

add_primitive_fn(self, "at:", dict_at, ["index"])
add_primitive_fn(self, "clone", dict_clone, [])
add_primitive_fn(self, "length", dict_length, [])
add_primitive_fn(self, "at:Put:", dict_at_key_put_obj, ["key", "obj"])

if PrimitiveDictObject._OBJ_CACHE.map is None:
PrimitiveDictObject._OBJ_CACHE.store(self)
PrimitiveDictObject._OBJ_CACHE.store(self)

def __str__(self):
return "dict()"
Expand Down
4 changes: 2 additions & 2 deletions src/tinySelf/vm/primitives/primitive_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def __init__(self, value, obj_map=None):
assert isinstance(value, list)
self.value = value

if PrimitiveListObject._OBJ_CACHE.map is not None:
self._slot_values = PrimitiveListObject._OBJ_CACHE.slots
if PrimitiveListObject._OBJ_CACHE.is_set:
PrimitiveListObject._OBJ_CACHE.restore(self)
return

add_primitive_fn(self, "at:", list_at, ["index"])
Expand Down

0 comments on commit 6839c6f

Please sign in to comment.