Re: Structures in 4.0?

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...

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.

jimcbrown said...

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.

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu