diff options
Diffstat (limited to 'Examples/perl5/constants2')
| -rw-r--r-- | Examples/perl5/constants2/Makefile | 18 | ||||
| -rw-r--r-- | Examples/perl5/constants2/example.i | 27 | ||||
| -rw-r--r-- | Examples/perl5/constants2/runme.pl | 16 |
3 files changed, 61 insertions, 0 deletions
diff --git a/Examples/perl5/constants2/Makefile b/Examples/perl5/constants2/Makefile new file mode 100644 index 0000000..4ba4b25 --- /dev/null +++ b/Examples/perl5/constants2/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = -const +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static + +clean:: + $(MAKE) -f $(TOP)/Makefile perl5_clean + +check: all diff --git a/Examples/perl5/constants2/example.i b/Examples/perl5/constants2/example.i new file mode 100644 index 0000000..4f7b1a4 --- /dev/null +++ b/Examples/perl5/constants2/example.i @@ -0,0 +1,27 @@ +/* File : example.i */ +%module example + +/* A few preprocessor macros */ + +#define ICONST 42 +#define FCONST 2.1828 +#define CCONST 'x' +#define CCONST2 '\n' +#define SCONST "Hello World" +#define SCONST2 "\"Hello World\"" + +/* This should work just fine */ +#define EXPR ICONST + 3*(FCONST) + +/* This shouldn't do anything */ +#define EXTERN extern + +/* Neither should this (BAR isn't defined) */ +#define FOO (ICONST + BAR) + +/* The following directives also produce constants */ + +%constant int iconst = 37; +%constant double fconst = 3.14; + + diff --git a/Examples/perl5/constants2/runme.pl b/Examples/perl5/constants2/runme.pl new file mode 100644 index 0000000..d16f3b3 --- /dev/null +++ b/Examples/perl5/constants2/runme.pl @@ -0,0 +1,16 @@ +# file: runme.pl + +use example; + +print "ICONST = ", example::ICONST, " (should be 42)\n"; +print "FCONST = ", example::FCONST, " (should be 2.1828)\n"; +print "CCONST = ", example::CCONST, " (should be 'x')\n"; +print "CCONST2 = ", example::CCONST2," (this should be on a new line)\n"; +print "SCONST = ", example::SCONST, " (should be 'Hello World')\n"; +print "SCONST2 = ", example::SCONST2, " (should be '\"Hello World\"')\n"; +print "EXPR = ", example::EXPR, " (should be 48.5484)\n"; +print "iconst = ", example::iconst, " (should be 37)\n"; +print "fconst = ", example::fconst, " (should be 3.14)\n"; + + + |
