Re: sdl2 and ffi

new topic     » goto parent     » topic index » view thread      » older message » newer message
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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu