Re: sdl2 and ffi
- Posted by ghaberek (admin) Nov 16, 2022
- 2695 views
SDPringle said...
You guys are making cool stuff! The data structures that must exist could open the door to making validating data as well.
-- you could write a function like this: is_struct(RECT, x) -- returns true iff x has four members and each member falls within the range of the respective c types type rect(object x) return is_struct(RECT, x) end type
That would help when storing structure values in a sequence but we can't do much about inferring a structure's type while in memory. A structure of int[4] could look the same as short[8] or char[16] and we wouldn't be able to tell by just looking at it. (This is how unions work and it's what allows for things like type punning). I'm still considering how to go about this for implementing structs and classes later. Suggestions are welcome.
-Greg