Thread XS Modul in C++ nicht übersetzbar (16 answers)
Opened by sesth at 2005-02-01 13:50

sesth
 2005-02-01 20:13
#51478 #51478
User since
2005-02-01
181 Artikel
BenutzerIn
[default_avatar]
[quote=esskar,01.02.2005, 18:34]poste mal dein zeugs, dann test ich es![/quote]
Hier kommt mein Code, allerdings wird er beim Upload trotz der Code-Tags verändert bzw. verkürzt. Gibt es im Forum noch andere Möglichkeiten Code zu posten (Upload o.ä.)?

Makefile.pl
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use 5.008004;
use ExtUtils::MakeMaker;

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'MyPackage',
VERSION_FROM => 'lib/MyPackage.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/MyPackage.pm', # retrieve abstract from module
AUTHOR => 'A. U. Thor <a.u.thor@a.galaxy.far.far.away>') : ()),
LIBS => [''], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
INC => '-I.', # e.g., '-I. -I/usr/include/other'
CCFLAGS &nbsp
; => '-TP',
XSOPT => '-C++',
TYPEMAPS => ['perlobject.map' ],
# Un-comment this if you add C files to link with later:
# OBJECT => '$(O_FILES)', # link all the C files too
);


MyPackage.xs
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifdef cplusplus
}
#endif

#include <iostream.h>

class MyClass {
public:
MyClass(char * my_favorite_argument) {
cout << "I'm constructin' my bad self ... " << my_favorite_argument << "\n";
}
~MyClass() { cout << "Destruction is a way of life for me.\n"; }
};

MODULE = MyPackage PACKAGE = MyPackage

MyClass *
MyClass::new(char * my_favorite_argument)

void
MyClass::DESTROY()


Typemap
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
TYPEMAP
MyClass * O_OBJECT

OUTPUT
# The Perl object is blessed into 'CLASS', which should be a
# char* having the name of the package for the blessing.
O_OBJECT
sv_setref_pv( $arg, CLASS, (void*)$var );

INPUT
O_OBJECT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
$var = ($type)SvIV((SV*)SvRV( $arg ));
else{
warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
XSRETURN_UNDEF;
}


Die Datei "perlobject.map" kann man im Makefile.pl auskommentieren, der Fehler kommt trotzdem.

Gruß
Thomas
Gruß
Thomas

View full thread XS Modul in C++ nicht übersetzbar