diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-13 14:55:49 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-27 11:29:45 -0700 |
commit | 9951ad78c80e144c166a7d476cad7ffdf84332a9 (patch) | |
tree | 9f5498a9a3c23b62dc928288e72081e99f958f46 /src/strings/rstring.py | |
parent | 749fec734c4583153fb2dbc80f1d21db2c2ab457 (diff) | |
download | tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.gz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.bz2 tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.xz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.zip |
Debug debugging
Diffstat (limited to 'src/strings/rstring.py')
-rw-r--r-- | src/strings/rstring.py | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/strings/rstring.py b/src/strings/rstring.py index 8021ec2..fd26801 100644 --- a/src/strings/rstring.py +++ b/src/strings/rstring.py @@ -1,6 +1,4 @@ class RString(object): - ''' print a RString - ''' __slots__ = ('_value') name = 'tmwa::strings::RString' enabled = True @@ -8,12 +6,40 @@ class RString(object): def __init__(self, value): self._value = value + def to_string(self): + v = self._value + e = v['maybe_end'] + if e: + b = v['u']['begin'] + d = e - b + return b.lazy_string(length=d) + else: + r = v['u']['owned'].dereference() + b = r['body'] + b = b[0].address + d = r['size'] + return b.lazy_string(length=d) + def children(self): - yield 'count', self._value['owned'].dereference()['count'] + v = self._value + if v['maybe_end']: + pass + else: + yield 'count', v['u']['owned'].dereference()['count'] - def to_string(self): - r = self._value['owned'].dereference() - b = r['body'] - b = b.cast(b.type.target().pointer()) - d = r['size'] - return b.lazy_string(length=d) + str256 = '0123456789abcdef' * 16 + + tests = [ + ('tmwa::RString(""_s)', '""'), + ('tmwa::RString(tmwa::ZString(""_s))', '""'), + ('tmwa::RString("Hello"_s)', '"Hello"'), + ('tmwa::RString(tmwa::ZString("Hello"_s))', '"Hello" = {count = 0}'), + ('tmwa::RString("' + str256[:-2] + '"_s)', '"' + str256[:-2] + '"'), + ('tmwa::RString(tmwa::ZString("' + str256[:-2] + '"_s))', '"' + str256[:-2] + '" = {count = 0}'), + ('tmwa::RString("' + str256[:-1] + '"_s)', '"' + str256[:-1] + '"'), + ('tmwa::RString(tmwa::ZString("' + str256[:-1] + '"_s))', '"' + str256[:-1] + '" = {count = 0}'), + ('tmwa::RString("' + str256 + '"_s)', '"' + str256 + '"'), + ('tmwa::RString(tmwa::ZString("' + str256 + '"_s))', '"' + str256 + '" = {count = 0}'), + ('tmwa::RString("' + str256 + 'x"_s)', '"' + str256 + 'x"'), + ('tmwa::RString(tmwa::ZString("' + str256 + 'x"_s))', '"' + str256 + 'x" = {count = 0}'), + ] |