Skip to content

Commit

Permalink
bindings/java: handle null value for hash table properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik Oldsberg committed Apr 25, 2015
1 parent 03cab9d commit 6bbd82c
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions bindings/java/standard_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,19 +792,24 @@ def transform_to_jni(self):
C.Decl(self.inner_value.c_type, self.inner_value.c_name),
inner_transforms.declarations,
], [
C.Assign(self.jni_name, C.Env.new('HashMap')),
C.ExceptionCheck.default(self),
C.Call('g_hash_table_iter_init', '&' + it, self.c_name),
C.While(C.Call('g_hash_table_iter_next', '&' + it, '(void **) &' + self.inner_key.c_name, '(void **) &' + self.inner_value.c_name),
inner_transforms.conversion,
C.Env.method(self.jni_name, ('HashMap', 'put'), self.inner_key.jni_name, self.inner_value.jni_name),
C.Assign(self.jni_name, 'NULL'),
C.If(self.c_name, [
C.Assign(self.jni_name, C.Env.new('HashMap')),
C.ExceptionCheck.default(self),
C.Env('DeleteLocalRef', self.inner_key.jni_name) if self.inner_value.has_local_ref else [],
C.Env('DeleteLocalRef', self.inner_value.jni_name) if self.inner_value.has_local_ref else [],
inner_transforms.cleanup,
)
C.Call('g_hash_table_iter_init', '&' + it, self.c_name),
C.While(C.Call('g_hash_table_iter_next', '&' + it, '(void **) &' + self.inner_key.c_name, '(void **) &' + self.inner_value.c_name),
inner_transforms.conversion,
C.Env.method(self.jni_name, ('HashMap', 'put'), self.inner_key.jni_name, self.inner_value.jni_name),
C.ExceptionCheck.default(self),
C.Env('DeleteLocalRef', self.inner_key.jni_name) if self.inner_value.has_local_ref else [],
C.Env('DeleteLocalRef', self.inner_value.jni_name) if self.inner_value.has_local_ref else [],
inner_transforms.cleanup,
),
]),
], self.transfer_ownership and [
C.Call('g_hash_table_unref', self.c_name),
C.If(self.c_name, [
C.Call('g_hash_table_unref', self.c_name),
]),
])


Expand Down

0 comments on commit 6bbd82c

Please sign in to comment.