Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: XS Modules: Dependencies

by esskar (Deacon)
on Aug 22, 2005 at 22:19 UTC ( #485783=note: print w/replies, xml ) Need Help??


in reply to Re: XS Modules: Dependencies
in thread XS Modules: Dependencies

Yes, i know that. But XS is actually needed since i want to write a OO interface to a (non trivial) Win32 C API.
(and for sure, i know how to walk! :) )
so for now i have the following code

Foo-Bar/typemap
TYPEMAP PBar T_PTROBJ
Foo-Bar/Bar.xs
typedef struct __Bar { // ... } Bar, *PBar; MODULE = Foo::Bar PACKAGE = Foo::Bar PBar new(class); const char* class PREINIT: PBar retval; CODE: New(0, retval, 1, Bar); RETVAL = retval; OUTPUT: RETVAL
Foo-Bar-Builder/typemap
TYPEMAP PBarBuilder T_PTROBJ PBar T_PTROBJ
Foo-Bar-Builder/Builder.xs
typedef struct __BarBuilder { // ... } BarBuilder, *PBarBuilder; MODULE = Foo::Bar::Builder PACKAGE = Foo::Bar::Builder PBarBuilder new(class); const char* class PREINIT: PBarBuilder retval; CODE: New(0, retval, 1, BarBuilder); RETVAL = retval; OUTPUT: RETVAL MODULE = Foo::Bar::Builder PACKAGE = Foo::Bar::BuilderPtr PBar create(void); PREINIT: PBar retval; CODE: RETVAL = retval; OUTPUT: RETVAL

so, the question is: do i have to call Foo::Bar::new inside Foo::Bar::Builder::create? or do i have to reimplement the new function of Foo::Bar::new inside Foo::Bar::Builder, or what?
so, the Foo::Bar::new is now defined inside the Foo/Bar/Bar.dll, and the C compiler does not know, where to find it. I guess it does not help to link against Foo\Bar\Bar.lib, since the dll just exports
1    0 00001000 _boot_Foo__Bar
2    1 00001000 boot_Foo__Bar
Get the point?

Replies are listed 'Best First'.
Re^3: XS Modules: Dependencies
by diotalevi (Canon) on Aug 23, 2005 at 13:32 UTC

    It looks like you're doing too much in XS and not enough in perl. Why can't you have your C-allocating routines just return a numified pointer and let perl do all of its own OO stuff? I also feel like I'm getting lost somewhere in your confused code. I'd really like to point you at Simon Cozen's Embedding and Extending Perl book. Or Damian Conway's Object Oriented Perl.

    sub new { my ( $class ) = @_; my $c_ptr = Foo::Bar::_new_or_whatever(); return bless \ $c_ptr, $class; }
      just do it. i have both in my book shelf. :)
      and thanks, i will give it a try

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://485783]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2023-02-08 07:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?