develooper Front page | perl.perl5.porters | Postings from October 2000

Re: INTERFACE and INTERFACE_MACRO explanation

Thread Previous | Thread Next
From:
Brendan O'Dea
Date:
October 11, 2000 15:49
Subject:
Re: INTERFACE and INTERFACE_MACRO explanation
Message ID:
20001012094154.A21503@compusol.com.au
On Wed, Oct 11, 2000 at 04:33:32PM +0100, Alan Burlison wrote:
>Can anyone make head or tail of the explanation of INTERFACE and
>INTERFACE_MACRO in perlxs.pod?  I've read and reread it several times
>and it still doesn't entirely make sense.  what on earth is "symbolic" -
>a reserved xsubpp word or just a placeholder?  Could someone translate?

`symbolic' appears to be a placeholder.  For example, if you had:

    int foo(int, char*);
    int bar(int, char*);
    int baz(int, char*);

then:

    MODULE = Foo  PACKAGE = Foo

    int
    whatever(b, c)
	int b
	char *c
	INTERFACE:
	    foo bar baz

would declare a single XS_Foo_whatever function and create three CVs in
the bootstrap, each of which would contain a pointer to the C function:

    cv = newXS("Foo::foo", XS_Foo_whatever, file);
    XSINTERFACE_FUNC_SET(cv, foo);

Within XS_Foo_whatever, the function pointer is extracted from the CV
and called:

    dXSFUNCTION(int); /* int (*XSFUNCTION)() */
    XSFUNCTION = XSINTERFACE_FUNC(int, cv, XSANY.any_dptr);
    RETVAL = XSFUNCTION(b, c);

INTERFACE_MACRO allows you to use a different method to extract/store
the C function pointer than the defaults of XSINTERFACE_FUNC and
XSINTERFACE_FUNC_SET as seen above.

This mechanism appears to work in 5.005, but doesn't compile under 5.6.0
as the current CV is not visible within XS_Foo_whatever as `cv'.

Regards,
-- 
Brendan O'Dea                                        bod@compusol.com.au
Compusol Pty. Limited                  (NSW, Australia)  +61 2 9810 3633

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About