-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ccall() for symengine and other libs #2196
Conversation
c95c515
to
8e56a9d
Compare
8e56a9d
to
27034bc
Compare
@anutosh491 It seems to work, but there is a catch. $ cat integration_tests/symbolics_07.py
from lpython import ccall, CPtr
import os
@ccall(header="symengine/cwrapper.h", py_mod="symengine", py_mod_path=f"{os.environ['CONDA_PREFIX']}/lib")
def basic_new_heap() -> CPtr:
pass
@ccall(header="symengine/cwrapper.h", py_mod="symengine", py_mod_path=f"{os.environ['CONDA_PREFIX']}/lib")
def basic_const_pi(x: CPtr) -> None:
pass
@ccall(header="symengine/cwrapper.h", py_mod="symengine", py_mod_path=f"{os.environ['CONDA_PREFIX']}/lib")
def basic_str(x: CPtr) -> str:
pass
def main0():
x: CPtr = basic_new_heap()
basic_const_pi(x)
s: str = basic_str(x)
print(s)
# assert s == "pi"
main0() $ python integration_tests/symbolics_07.py
b'pi' $ lpython integration_tests/symbolics_07.py --enable-symengine --backend c
pi The outputs by |
27034bc
to
754e608
Compare
I went through the example above and I think we get the |
754e608
to
f6eab9c
Compare
Good catch @anutosh491! Thank you. I fixed it in lpython.py: Decode ctypes strings before returning. |
Ready. |
Yes , this seems to be the correct way to address this . Thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this looks great.
Thank you.
This can also be used in the LLVM and C backends when linking. Right now we ignore it and one has to link by hand, which is fine.
No description provided.