Re: sdl2 and ffi

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

What are you doing here?

18 object event = allocate_struct(event)

I'm not sure that going to work. I had discussed the current "correct" approach here: https://openeuphoria.org/forum/137153.wc

ChrisB said...

Whats the ffi.e equivalent of allocate, as in

atom rect = allocate(16)
poke4(rect,{50,50,100,100})

The prototype currently works like this:

-- RECT structure (windef.h) 
-- https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-rect 
constant C_RECT = define_c_type({ 
    C_LONG, -- left 
    C_LONG, -- top 
    C_LONG, -- right 
    C_LONG  -- bottom 
}) 
 
atom rect = allocate_struct( C_RECT ) 
poke_type( rect, C_RECT, {50,50,100,100} ) 

But I'd like to rename define_c_type() to define_c_struct() and then add define_c_union(), and then re-implement define_c_type() for "raw" types (like C_STRING as a copy of C_POINTER).

-- RECT structure (windef.h) 
-- https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-rect 
constant C_RECT = define_c_struct({ 
    {C_LONG,"left"}, 
    {C_LONG,"top"}, 
    {C_LONG,"right"}, 
    {C_LONG,"bottom"} 
}, "RECT") 
 
atom rect = allocate_struct( C_RECT, {50,50,100,100} ) 
? peek_member( rect, "RECT.left" ) -- prints 50 
? peek_member( rect, "RECT" ) -- prints {50,50,100,100} 

Thoughts/opinions on this design 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