Skip to content

Commit 15bc071

Browse files
author
vbuell
committed
last minute fix for arrays and their unit tests
1 parent e0ecee0 commit 15bc071

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

javaobj.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ def do_classdesc(self, parent=None, ident=0):
208208

209209
if field_type == self.TYPE_ARRAY:
210210
field_type = self.read_and_exec_opcode(ident=ident+1, expect=[self.TC_STRING, self.TC_REFERENCE])
211-
if field_type is not None:
212-
field_type = "array of " + field_type
213-
else:
214-
field_type = "array of None"
211+
# if field_type is not None:
212+
# field_type = "array of " + field_type
213+
# else:
214+
# field_type = "array of None"
215215
elif field_type == self.TYPE_OBJECT:
216216
field_type = self.read_and_exec_opcode(ident=ident+1, expect=[self.TC_STRING, self.TC_REFERENCE])
217217

@@ -317,7 +317,6 @@ def do_array(self, parent=None, ident=0):
317317
(size, ) = self._readStruct(">i")
318318
self.print_ident("size: " + str(size), ident)
319319

320-
# for char in classdesc.name:
321320
type_char = classdesc.name[0]
322321
assert type_char == self.TYPE_ARRAY
323322
type_char = classdesc.name[1]
@@ -329,12 +328,11 @@ def do_array(self, parent=None, ident=0):
329328
array.append(res)
330329
else:
331330
for i in range(size):
332-
res = self.read_native(typestr, ident)
331+
res = self.read_native(type_char, ident)
333332
print "Native value:", res
334333
array.append(res)
335-
# raise RuntimeError("Native types aren't supported in arrays")
336334

337-
return None
335+
return array
338336

339337
def do_reference(self, parent=None, ident=0):
340338
(handle, ) = self._readStruct(">L")

tests.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ def test_arrays(self):
116116
print classdesc.fields_names
117117
print classdesc.fields_types
118118

119-
print pobj.childString
120-
print pobj.bool
121-
print pobj.integer
119+
# public String[] stringArr = {"1", "2", "3"};
120+
# public int[] integerArr = {1,2,3};
121+
# public boolean[] boolArr = {true, false, true};
122+
# public TestConcrete[] concreteArr = {new TestConcrete(), new TestConcrete()};
123+
124+
print pobj.stringArr
125+
print pobj.integerArr
126+
print pobj.boolArr
127+
print pobj.concreteArr
122128

123129
if __name__ == '__main__':
124130
unittest.main()

0 commit comments

Comments
 (0)