Re: cffi.e

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

Oh my, you're not wrong, there was no mechanism to do that at all. Here's a replacement routine for cffi.e, line 1046

global procedure set_struct_field(integer id, atom pStruct, atom_string field, atom_string v) 
    sequence {membernames,details} = get_smembers(id) 
    integer k = iff(string(field)?find(field,membernames):field) 
    integer {?,size,offset} = details[k] 
    if atom(v) then 
    end if 
end procedure 

And likewise there was no way to retrieve, here's a new routine for that, add it just after get_struct_field():

global function get_struct_string(integer id, atom pStruct, string field, integer len) 
    sequence {membernames,details} = get_smembers(id) 
    integer k = find(field,membernames) 
    integer {?,?,offset} = details[k] 
    return peek({pStruct+offset,len}) 
end function 

Note that it is your responsibility to pass short-enough strings to set_struct_field(), and the right length to get_struct_string(), since cffi.e cannot check any of that for you, and likewise add/trim trailing zeroes (or '\0') where needed.
Also note the above are ansi-only, I will add the required widestring handling in a bit, before I move on [if you're not calling set_unicode() the next version will likely crash].

I will also update the docs - I should also note that struct x """...""" end struct use of cffi.e won't play nice with any embedded TCHAR[nnn] and similar fields, should you by any chance happen to be considering that.

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


Quick Links

User menu

Not signed in.

Misc Menu