Re: Structures in 4.0?
- Posted by jimcbrown (admin) Oct 02, 2009
- 1640 views
The ability to pass a C struct by value (rather than via a pointer) would be a huge boon to the current C interface. So would being able to take a C struct as a return value (rather than a pointer to said struct).
Yes, that would be nice. Seems like it would have to be integrated into the interpreter somehow. All the structure routines I've used or written reference the memory pointer.
It would. But we already have custom assembly code to manipulate the stack at arbiturary sizes. IOW, the hard part is already done, we just need to find a way to allow eu code to take advantage of it.
A native struct library should also be able to tell us the sizes of native C types (e.g. sizeof(int), sizeof(char), sizeof(short), sizeof(long)) rather than having us assume that it will always be 4, 1, 2, 4, etc.
Decoding the C_* constants is pretty simple.
Well, the size of a long will change on 64bit. Likewise, the size of an int is different on 16bit.
I was stating my preference for having machine_func()s in the interpreter that performed the sizeof() operation, rather than hardcoding constants in Eu code.
function sizeof( atom c_type ) return and_bits( c_type, #FF ) end function function signed( atom c_type ) return right_shift( c_type, #1000000 ) = #01 end function function unsigned( atom c_type ) return right_shift( c_type, #1000000 ) = #02 end function function isfloat( atom c_type ) return right_shift( c_type, #1000000 ) = #03 end function
-Greg