Re: Phix+EuGTK

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

This works

This works on windoze:

constant LIB = open_dll(iff(platform()=LINUX?"libgtk-3.so.0":"libgtk-3-0.dll")), 
         LIBGOBJECT = open_dll(iff(platform()=LINUX?"libgobject-2.0.so.0?":"libgobject-2.0-0.dll")) 
 
... 
 
  procedure connect(string sig, object fn, data=0, closure=0, integer flags=0)  
--  integer rid  
--  sig = allocate_string(sig)  
    if string(fn) then  
      integer rid = routine_id(fn)   
      if rid <= 0 then  
        crash("Can't locate function -> %s",{fn})  
      end if 
      integer cb = call_back(rid)  
      if cb < 1 then     
          crash("Invalid callback for -> %s",{fn})  
      end if  
      fn = cb 
    end if  
--  if string(data) then data = allocate_string(data) end if  
    sigid = c_func(define_c_func(LIBGOBJECT,"g_signal_connect_data",{P,P,P,P,P,I},I),  
            {this.handle,sig,fn,data,closure,flags})  
  end procedure  

Linux is generally lax about .so names, as long as an open_dll has succeeded somewhere, it'll hunt things down. (I've seen lnx/OE code use open_dll("") before now.)
However Winderrs kicks up a right old fuss at the slightest slip-up. (Though some dlls re-export some of their imports, sometimes.)
You don't need allocate_string() if it's already a string (though you do if it's a d/qword sequence of 4/8 bytes per 8-bit char).
I figured it was probably best to only overwrite fn once it was no longer needed for the the error message. Everything else stayed the same.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu