add Inline::SWIG test case
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8209 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b79d86f02e
commit
bdec822db6
3 changed files with 43 additions and 0 deletions
7
Examples/perl5/inline/Makefile
Normal file
7
Examples/perl5/inline/Makefile
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
all:
|
||||
|
||||
run:
|
||||
perl runme.pl
|
||||
|
||||
clean:
|
||||
rm -fr _Inline *~
|
||||
2
Examples/perl5/inline/README
Normal file
2
Examples/perl5/inline/README
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
This example requires the Inline::SWIG package.
|
||||
|
||||
34
Examples/perl5/inline/runme.pl
Normal file
34
Examples/perl5/inline/runme.pl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use Inline SWIG => <<"END_CODE", SWIG_ARGS => '-c++ -shadow', CC => 'g++', LD=>'g++';
|
||||
class Foo {
|
||||
public:
|
||||
int meaning() { return 42; };
|
||||
};
|
||||
END_CODE
|
||||
|
||||
my $o = new Foo();
|
||||
print $o->meaning(),"\n";
|
||||
|
||||
use Inline SWIG => ' ', SWIG_INTERFACE => <<"END_CODE", SWIG_ARGS => '-c++', CC => "g++", LD => "g++";
|
||||
%include std_string.i
|
||||
%inline {
|
||||
template <class Type>
|
||||
class Bar {
|
||||
Type _val;
|
||||
public:
|
||||
Bar(Type v) : _val(v) {}
|
||||
Type meaning() { return _val; }
|
||||
};
|
||||
}
|
||||
%template(Bar_i) Bar<int>;
|
||||
%template(Bar_d) Bar<double>;
|
||||
%template(Bar_s) Bar<std::string>;
|
||||
END_CODE
|
||||
|
||||
my $o = new Bar_i(1);
|
||||
print $o->meaning(),"\n";
|
||||
|
||||
my $o = new Bar_d(2);
|
||||
print $o->meaning(),"\n";
|
||||
|
||||
my $o = new Bar_s("hello");
|
||||
print $o->meaning(),"\n";
|
||||
Loading…
Add table
Add a link
Reference in a new issue