From d19f4c1dbdd2f1f451d03551abb0e5ebf4d455be Mon Sep 17 00:00:00 2001 From: Florent Monjalet Date: Sun, 29 Nov 2015 22:03:11 +0100 Subject: MemStruct: big refactor in process Doc is currently incoherent, impl will also be completed --- example/jitter/memstruct.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'example/jitter/memstruct.py') diff --git a/example/jitter/memstruct.py b/example/jitter/memstruct.py index 645c019e..6e8e13af 100644 --- a/example/jitter/memstruct.py +++ b/example/jitter/memstruct.py @@ -36,15 +36,15 @@ class ListNode(PinnedStruct): ] def get_next(self): - if self.next == 0: + if self.next.val == 0: return None - return self.deref_next + return self.next.deref def get_data(self, data_type=None): if data_type is not None: - return self.deref_data.cast(data_type) + return self.data.deref.cast(data_type) else: - return self.deref_data + return self.data.deref class LinkedList(PinnedStruct): @@ -60,12 +60,12 @@ class LinkedList(PinnedStruct): """Returns the head ListNode instance""" if self.head == 0: return None - return self.deref_head + return self.head.deref def get_tail(self): if self.tail == 0: return None - return self.deref_tail + return self.tail.deref def push(self, data): # Allocate a new node @@ -112,7 +112,7 @@ class LinkedList(PinnedStruct): if not self.empty(): cur = self.get_head() while cur is not None: - yield cur.deref_data + yield cur.data.deref cur = cur.get_next() @@ -123,9 +123,9 @@ class DataArray(PinnedStruct): ("val1", Num("B")), ("val2", Num("B")), # Ptr can also be instanciated with a PinnedField as an argument, a special - # PinnedStruct containing only one field named "value" will be created, so + # PinnedStruct containing only one field named "val" will be created, so # that Ptr can point to a PinnedStruct instance. Here, - # data_array.deref_array.value will allow to access an Array + # data_array.array.deref.val will allow to access an Array ("arrayptr", Ptr("