From bdec822db6180a1ffeecc93ab9410d9339f88340 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 4 Jan 2006 10:54:41 +0000 Subject: [PATCH] add Inline::SWIG test case git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8209 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/perl5/inline/Makefile | 7 +++++++ Examples/perl5/inline/README | 2 ++ Examples/perl5/inline/runme.pl | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Examples/perl5/inline/Makefile create mode 100644 Examples/perl5/inline/README create mode 100644 Examples/perl5/inline/runme.pl diff --git a/Examples/perl5/inline/Makefile b/Examples/perl5/inline/Makefile new file mode 100644 index 000000000..4ac085ec3 --- /dev/null +++ b/Examples/perl5/inline/Makefile @@ -0,0 +1,7 @@ +all: + +run: + perl runme.pl + +clean: + rm -fr _Inline *~ diff --git a/Examples/perl5/inline/README b/Examples/perl5/inline/README new file mode 100644 index 000000000..33be94973 --- /dev/null +++ b/Examples/perl5/inline/README @@ -0,0 +1,2 @@ +This example requires the Inline::SWIG package. + diff --git a/Examples/perl5/inline/runme.pl b/Examples/perl5/inline/runme.pl new file mode 100644 index 000000000..6ae230210 --- /dev/null +++ b/Examples/perl5/inline/runme.pl @@ -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 Bar { + Type _val; + public: + Bar(Type v) : _val(v) {} + Type meaning() { return _val; } + }; +} +%template(Bar_i) Bar; +%template(Bar_d) Bar; +%template(Bar_s) Bar; +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";