Skip to content

Get C strings passing from Python to C #671

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

Closed
wants to merge 4 commits into from
Closed

Conversation

certik
Copy link
Contributor

@certik certik commented Jun 21, 2022

In all CPython, LLVM, C backends, we need some way to pass strings into a function implemented in C.

I got stuck doing it in CPython already, I can't figure out a natural way to do it.

There might be a way via CPtr.

@czgdp1807
Copy link
Collaborator

Well I can try for LPython. Don't know if we should expect it to work for CPython. The reason being, CPython doesn't compile, rather it interprets so linking object files never comes into the picture.

@czgdp1807
Copy link
Collaborator

I am opening a new PR for this. Will add you as a co-author there.

@certik
Copy link
Contributor Author

certik commented Jun 22, 2022

CPython calls into linked C codes, that already works, see our tests in integration_tests. The ccall decorator does it, see ltypes.py.

It works for ints, pointers, etc. But not strings yet, that's what we need to get working. I am doing CPython first, so that we know what syntax will work, and then we implement it in LPython. It works in LFortran already, so ASR and backends have the feature, but we need to hook it up in AST->ASR.

@czgdp1807
Copy link
Collaborator

Well if you want to continue here, then please feel free to do so.

@czgdp1807
Copy link
Collaborator

Note that LPython already compiles the new test (with strings) and hence everything is already working there. What needs to be done is to make CPython work.

@certik
Copy link
Contributor Author

certik commented Jun 22, 2022

Yes, CPython is the hard work here. :)

@certik
Copy link
Contributor Author

certik commented Jun 22, 2022

Closing this in favor of #674.

@certik certik closed this Jun 22, 2022
@certik certik deleted the c22 branch June 22, 2022 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants