FFI still a bit lost

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FFI still a bit lost

Niko Schwarz
Ok, I found out that the function I really want to runs is this:

DNSServiceErrorType DNSSD_API DNSServiceBrowse
    (
    DNSServiceRef                       *sdRef,
    DNSServiceFlags                     flags,
    uint32_t                            interfaceIndex,
    const char                          *regtype,
    const char                          *domain,    /* may be NULL */
    DNSServiceBrowseReply               callBack,
    void                                *context    /* may be NULL */
    );

Things that confuse me:

(a) renamed standard types
DNSServiceBrowseReply is defined as "int32", squeak calls that "long".

So I did this: subclassing "ExternalType", overwriting new and inserting ^ self long

(b) DNSServiceBrowseReply - the callback

I'm supposed to give a function where I'll be called back when the result is there, so as you see DNSServiceBrowse is non-blocking - no idea what the Squeak VM does when suddenly a dll knocks on its door without using a semaphore (how could I?)

(c) How to point to a callback function? Does this finally mean I need to drop FFI and write an external plugin?
The Callback function is supposed to have this shape:
typedef void (DNSSD_API *DNSServiceBrowseReply)
    (
    DNSServiceRef                       sdRef,
    DNSServiceFlags                     flags,
    uint32_t                            interfaceIndex,
    DNSServiceErrorType                 errorCode,
    const char                          *serviceName,
    const char                          *regtype,
    const char                          *replyDomain,
    void                                *context
    );

Note that DNSSD_API is not defined anywhere (seems to be C coding tradition or something like that, wonder how c compilers react to that).

But I doubt that the dll can find that function inside squeak, can it? And if so - how to "declare" it? ExternalFunction seems to be rather made to reference *existing* dll-methods rather than creating "virtual" new ones.

niko

--


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl

Reply | Threaded
Open this post in threaded view
|

Re: FFI still a bit lost

Bert Freudenberg-3

Am 10.07.2006 um 18:38 schrieb Niko Schwarz:
> But I doubt that the dll can find that function inside squeak, can  
> it? And if so - how to "declare" it? ExternalFunction seems to be  
> rather made to reference *existing* dll-methods rather than  
> creating "virtual" new ones.

Right. You need a real plugin for that.

- Bert -