-----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Friday 05 March 2004 11:23, Tom Schindl wrote:
> Hi,
>
> how can I create an instance of a Perl-class in XS.

I don't know (dont even understand the question properly). However, I could 
not define a C++ class in XS because apparently  "class" is considered some 
keyword. :/ Does "CLASS" workaround this?

You should probably call new() from XS. See perldoc perlcall for some info.

Cheers,

Tels

>
>
> 1. Both defined in XS:
> ======================
> Soccer.xs:
> -----------------------8<-----------------------
> MODULE = Soccer               PACKAGE = Soccer::Team
>
> Team *
> new(CLASS)
>      char *CLASS
>    CODE:
>      .......
>    OUTPUT:
>      RETVAL
>
> Player *
> Team::getPlayer(p_id)
>      int p_id
>    CODE
>      ## create a new player new Soccer::Player(p_id)
>      ## how is this done?????
>
>
> MODULE = Soccer               PACKAGE = Soccer::Player
>
> Player *
> new(CLASS,p_id)
>      char *CLASS
>      int p_id
>    CODE:
>      .......
>    OUTPUT:
>      RETVAL
> -----------------------8<-----------------------
>
>
> 2. 1 defined in XS 1 defined in Perl:
> =======================================
> Soccer.xs:
> -----------------------8<-----------------------
> MODULE = Soccer               PACKAGE = Soccer::Team
>
> Team *
> new(CLASS)
>      char *CLASS
>    CODE:
>      .......
>    OUTPUT:
>      RETVAL
>
> Player *
> Team::getPlayer(p_id)
>      int p_id
>    CODE
>      ## create a new player new Soccer::Player(p_id)
>      ## how is this done?????
> -----------------------8<-----------------------
>
> Soccer.pm:
> -----------------------8<-----------------------
> package Soccer::Player;
>
> sub new {
>    my $class = shift;
>    my $p_id  = shift;
>
>    return bless { id => $p_id }, $class;
> }
> -----------------------8<-----------------------

- -- 
 Signed on Fri Mar  5 15:40:17 2004 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Die deutsche Zensoren  - - - - - - - - - - - - - - - - - - - - - - - - -
 - - - - - - - - - - - - - - - - - - - - - - - - - - Dummköpfe - - - - - -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - - - - - - - - - - - -." Heinrich Heine

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.

iQEVAwUBQEiRy3cLPEOTuEwVAQG6qwf+KiNgJPormADVBhrPK7Yxd8WHgCcb0Ofl
iTzXwv9jL6zOGYwTAhwlY5uxgHAOfBixjkmvEFhqDyPfPNsxDG7isNEIGZVw3dNk
sofLaKhJyiLhKX+X+lTm6+aQFzpn/dzOVhp2EtRSysWWO0qFZUXnrhbjOVydsU/q
YfTekKBzMUgNS9Bdb72H1aT8uxfkatkuYlitE+ZUF4u0jxBI1RXnrzcUw4IZOZFH
5E4xgJZhvqLaQ10ScjZFA/C93HtCor31KhXL1swzCnJYuxvqLM/+DThKK3V0MqFy
cjh2OSC3fPUi3b5d2/BM6iYcPsqr2oQRXvztqeMzyiWuZOSX4OYEkA==
=38is
-----END PGP SIGNATURE-----

Reply via email to