Re: Phix+EuGTK

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

Question: is there a way to retrieve a class instance if all you have is the handle?

No. There is a table of fields in builtins\structs.e, but it's private, you'd need to faff about with struct_dx() and field_dx() to decipher it, and the delete_routine()'d reference you're after has been given over to your application, and trying to replicate a "fake copy" would no doubt end in tears.

Here's what I'd do:

class window nullable 
    integer handle  
    function get_handle() return handle end function  
end class  
 
integer hdict = new_dict("handle lookup") 
 
function new_window(integer handle) 
    window w = new({handle}) 
    setd(w.get_handle(),w,hdict) 
    return w 
end function 
 
function get_by_handle(integer handle) 
    return getd(handle,hdict) 
end function 
 
function destroy_window(window w) 
    deld(w.get_handle(),hdict) 
    delete(w) 
    return null 
end function 
 
window w = new_window(17) 
 
?w 
?get_by_handle(17) 
 
w = destroy_window(w) 

PS Here's a bugfix to builtins/structs.e, line 536, in case you need it:

--16/12/20: [struct(0)/class(0) and similar should return false, not crash] 
--      elsif s=NULL then 
        elsif s=NULL and rid!=0 then 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu