forum-msg-id-137075-edit
Original date:2022-09-28 20:14:48 Edited by: Icy_Viking Subject: Re: Preliminary libffi progress
It looks like you're allocating the structures to memory and then passing the pointer around. Raylib is passing structures by value. Does this work? Have you tried it with Raylib? Are you using 32-bit or 64-bit Euphoria?
I tried it with Raylib on OEU 4.1 Windows 32-bit. I get a full list of messages with no error but it seems to open a window and close it immediatly after instead of waiting for the user to close the window.
I have the same issue.
Alright, I did some testing using 32-bit Euphoria 4.1 and Raylib. I think the problem might be that libffi isn't setting the return value memory to NULL before making the call, and since I told it C_BOOL was an unsigned int (4-bytes) it was returning the garbage in the upper three bytes of the value, so I'd see something like 0x43542100 come back for "false" which Euphoria rightfully treated as non-zero "true" so the the while loop exited right away. I changed C_BOOL to char value (one byte) instead and that seems to have helped. I also fixed the incorrect ifdef for x86 detection and added a couple more examples that utilize various structure-by-value functions.
-Greg
Excellent work Greg! It works! I can help to finish the Raylib wrapper if you'd like. I'd of course push updates to my local repository then you can merge them later if you wanna. I'll be playing around with the examples and seeing what FFI can do.
EDIT: Here's my fork of Greg's repoistory, I'll be using it as a playground for testing/coding for now: https://github.com/gAndy50/libffi-euphoria
Hopefully this will help Greg as well.
Not Categorized, Please Help
|
- history, backlinks
- Last modified in September by Icy_Viking