← 输入框|github.com|刷新
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion integration_tests/bindc_09.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def main() -> None:
p_c_pointer(pointer(foo), foo_ptr)
bar(foo_ptr)
print(foo.value, foo.value.name)
assert foo.value == Value.FIVE
# Does not work: https://github.com/lcompilers/lpython/issues/2123
# assert foo.value == Value.FIVE

p_c_pointer(pointer(fooc), foo_ptr)
barc(foo_ptr)
Expand Down
7 changes: 1 addition & 6 deletions src/runtime/lpython/lpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,14 +729,9 @@ def c_p_pointer(cptr, targettype, targetshape=None):
newa = ctypes.cast(cptr, targettype_ptr)
return newa
else:
if py_is_dataclass(targettype):
if cptr.value is None:
return None
return ctypes.cast(cptr, ctypes.py_object).value

targettype_ptr = ctypes.POINTER(targettype_ptr)
newa = ctypes.cast(cptr, targettype_ptr)
if is_ctypes_Structure(targettype):
if is_dataclass(targettype):
# return after wrapping newa inside PointerToStruct
return PointerToStruct(newa)
return newa
Expand Down