add support for constants
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11251 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
25f17ae463
commit
4e9cbd8a7c
15 changed files with 470 additions and 142 deletions
27
Examples/scilab/constants/example.i
Normal file
27
Examples/scilab/constants/example.i
Normal file
|
|
@ -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;
|
||||
|
||||
|
||||
15
Examples/scilab/constants/makefile
Normal file
15
Examples/scilab/constants/makefile
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.i
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_clean
|
||||
rm -f *.sce *.so lib*lib.c
|
||||
|
||||
check: all
|
||||
32
Examples/scilab/constants/runme.sci
Normal file
32
Examples/scilab/constants/runme.sci
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
|
||||
//loader the *.so
|
||||
exec loader.sce;
|
||||
|
||||
printf("ICONST = %i (should be 42)\n", ICONST());
|
||||
printf("FCONST = %f (should be 2.1828)\n", FCONST());
|
||||
printf("CCONST = %c (should be x)\n", CCONST());
|
||||
printf("CCONST2 = %s (this should be on a new line)\n", CCONST2());
|
||||
printf("SCONST = %s (should be Hello World)\n", SCONST());
|
||||
printf("SCONST2 = %s (should be Hello World)\n", SCONST2());
|
||||
printf("EXPR = %f (should be 48.5484)\n", EXPR());
|
||||
printf("iconst = %i (should be 37)\n", iconst());
|
||||
printf("fconst = %f (should be 3.14)\n", fconst());
|
||||
|
||||
try
|
||||
printf("EXTERN = %s (Arg! This should not printf(anything)\n", EXTERN());
|
||||
catch
|
||||
printf("EXTERN is not defined (good)\n");
|
||||
|
||||
try
|
||||
printf("FOO = %i (Arg! This should not printf(anything)\n", FOO());
|
||||
catch
|
||||
printf("FOO is not defined (good)\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue