Use immutable structs?
Closed this issue · 7 comments
My understanding is that arrays of non-isbits
types aren't compatible with the C layout. I'm pretty sure #45 is running afoul of this, as replacing SDL2.Point
with struct SDLPoint x::Cint; y::Cint end
fixes their example.
I'm fairly new to Julia, so apologies in advance if I'm missing something obvious here.
I generated the bindings automatically using Clang.jl so I'm not exactly why it's using a mutable struct there. To be honest I don't really understand the difference (I find the manual a bit confusing).
@cmcaine re-generated the bindings with more up-to-date SDL and Clang but it seems to have done the same :
https://github.com/cmcaine/LibSDL2.jl/blob/master/gen/bindings/libsdl2_types.jl#L1706
That said if you think that's wrong I'm fine with correcting it.
Ah, I hadn't read the first post yet, yeah, that's an issue 👍
We can easily make them all immutable structs or fairly easily maintain a list of which to be mutable or immutable.
A quick grep through the headers for plural argument names turns up Color
, Rect
, FRect
, Point
, FPoint
, and MessageBoxButtonData
being used as array inputs. Event
is used as an array output by PeepEvents
. So these at least should probably be immutable.
Alright, I'll try to merge the new bindings. Where do you configure these things @cmcaine ?
Love how GitHub mangles emails. I sent that from my phone, so I don't even know why it has hard breaks.
Anyway, I also have this little if statement that selects whether to use the system SDL or LibSDL2.jll. I don't know if you'd want to keep that or not.
I mostly had that for speed, but it doesn't matter so much on v1.5 (or 1.6?).