-
Notifications
You must be signed in to change notification settings - Fork 26
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
Generate bindings via cl-autowrap
#12
Comments
Thanks, will try it later. |
@nagy could also try doing something similar with https://github.com/borodust/claw |
Thanks all for the recommendation. The key issue is that |
Thank you @longlene for the investigation.
Do you have an example of such a case? |
@nagy |
I was investigating this a bit more and found the following. When I create a test file typedef struct Vector3 {
float x;
float y;
float z;
} Vector3;
typedef struct Camera3D {
Vector3 position;
Vector3 target;
Vector3 up;
float fovy;
int projection;
} Camera3D;
typedef Camera3D Camera;
void SetCameraMode(Camera camera, int mode);
void UpdateCamera(Camera *camera); I can use the tool from https://github.com/rpav/c2ffi to generate something that comes close to
As you can see this already generated something that comes close to what is written in I have not used it yet, but it looks like https://common-lisp.net/project/cffi/manual/html_node/Groveller-ASDF-Integration.html All we would need to do is to prepare a parsed version of raylib, such that asdf can integrate it. |
Sorry for the late response. I think we can not read and write a struct in both lisp and c at the same time. |
Hello, cl-autowrap does support return-by-value if that's what you're having trouble with. I'm testing using it now but I wanted to make sure I'm not misunderstanding what the issue being discussed here is. For what it's worth, switching to autowrap will require users to re-write significant amount of code for a decent sized project since allocation/deallocation needs to be done manually and return values for functions using call-by-value needs to passed in as the first argument to the function. Here's the relevant quote from the cl-autowrap readme:
|
Hi, @kiran-kp return-by-value is not the point, the question is that: We did can define functions at the same time, but they can not be called at the same time. |
Thanks for responding. I'm not sure I follow though. Neither of the functions you listed take a pointer to the camera and it's member at the same time and I'm not sure I understand what could go wrong if it did. |
Separately though, I've been trying out cl-autowrap for raylib and there seems to be issues with how typedefs are handled. I'm specifically having issues with Texture/Texture2D and am investigating a fix. |
@kiran-kp |
I think you are correct, I understand it the same way.
You could not define a variable using the I don't think we would loose any functionality. In my experiments, the generated code was almost identical with the one that we are currently having. |
If I'm understanding the problem correctly, something like this should work:
It would be nice to have the setf forms be generated by a macro and I'm playing around with something for that so I'll update when I have it working. I've given up on cl-autowrap for what it's worth. It's very buggy and does not look like it's maintained anymore. I'll continue discussion of this in #15 if you decide to close this issue. |
I have come to some of its limits also lately. Namely it hat troubles for me supporting variadic lists. However, it does support a graceful failure mode, meaning that it can try to translate functions and when it cannot, it does not fail. This could allow us to at least use what it was able to figure out correctly and only leave us to keep the implementations that it cant translate. Only of course if we decide to proceed with this. |
It seems like the
raylib.lisp
file is a rather manually written binding file to raylib.Would it make to you to generate these via https://github.com/rpav/cl-autowrap ?
If you want I can draft something out.
The text was updated successfully, but these errors were encountered: