diff --git a/Examples/scilab/check.list b/Examples/scilab/check.list index cbaca3098..0bcf457c2 100644 --- a/Examples/scilab/check.list +++ b/Examples/scilab/check.list @@ -7,7 +7,6 @@ funcptr matrix matrix2 pointer -scilab_const simple std_list std_vector diff --git a/Examples/scilab/constants/example.i b/Examples/scilab/constants/example.i index 3b45011af..1172a4edc 100644 --- a/Examples/scilab/constants/example.i +++ b/Examples/scilab/constants/example.i @@ -1,14 +1,30 @@ /* File : example.i */ %module example -#define ICONST 42 -#define FCONST 2.1828 -#define SCONST "Hello World" +/* Wraps enums and constants as Scilab variables (instead of functions) */ +%scilabconst(1); -// Constants expressions are also accepted -#define EXPR ICONST + 3*FCONST +/* 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 */ -// SWIG also offers to define constants %constant int iconst = 37; -%constant double fconst = 42.2; +%constant double fconst = 3.14; + diff --git a/Examples/scilab/constants/runme.sci b/Examples/scilab/constants/runme.sci index cfccb7f1e..0c05472e8 100644 --- a/Examples/scilab/constants/runme.sci +++ b/Examples/scilab/constants/runme.sci @@ -3,12 +3,12 @@ ilib_verbose(0); exec loader.sce; example_Init(); -printf("\nConstants are wrapped by functions:\n"); -printf("ICONST_get() = %i (should be 42)\n", ICONST_get()); -printf("FCONST_get() = %5.4f (should be 2.1828)\n", FCONST_get()); -printf("SCONST_get() = ''%s'' (should be ''Hello World'')\n", SCONST_get()); -printf("EXPR_get() = %5.4f (should be 48.5484)\n", EXPR_get()); -printf("iconst_get() = %i (should be 37)\n", iconst_get()); -printf("fconst_get() = %3.2f (should be 42.20)\n", fconst_get()); +printf("\nTest constants\n"); +printf("ICONST = %i (should be 42)\n", ICONST); +printf("FCONST = %5.4f (should be 2.1828)\n", FCONST); +printf("SCONST = ''%s'' (should be ''Hello World'')\n", SCONST); +printf("EXPR = %5.4f (should be 48.5484)\n", EXPR); +printf("iconst = %i (should be 37)\n", iconst); +printf("fconst = %3.2f (should be 3.14)\n", fconst); exit diff --git a/Examples/scilab/scilab_const/Makefile b/Examples/scilab/scilab_const/Makefile deleted file mode 100644 index b0545d804..000000000 --- a/Examples/scilab/scilab_const/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean diff --git a/Examples/scilab/scilab_const/example.cxx b/Examples/scilab/scilab_const/example.cxx deleted file mode 100644 index 6785e57ac..000000000 --- a/Examples/scilab/scilab_const/example.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/* File : example.c */ - -#include "example.h" -#include - -void Foo::enum_test(speed s) { - if (s == IMPULSE) { - printf("IMPULSE speed\n"); - } else if (s == WARP) { - printf("WARP speed\n"); - } else if (s == LUDICROUS) { - printf("LUDICROUS speed\n"); - } else { - printf("Unknown speed\n"); - } -} - -void enum_test(color c, Foo::speed s) { - if (c == RED) { - printf("color = RED, "); - } else if (c == BLUE) { - printf("color = BLUE, "); - } else if (c == GREEN) { - printf("color = GREEN, "); - } else { - printf("color = Unknown color!, "); - } - if (s == Foo::IMPULSE) { - printf("speed = IMPULSE speed\n"); - } else if (s == Foo::WARP) { - printf("speed = WARP speed\n"); - } else if (s == Foo::LUDICROUS) { - printf("speed = LUDICROUS speed\n"); - } else { - printf("speed = Unknown speed!\n"); - } -} diff --git a/Examples/scilab/scilab_const/example.h b/Examples/scilab/scilab_const/example.h deleted file mode 100644 index d3ba50594..000000000 --- a/Examples/scilab/scilab_const/example.h +++ /dev/null @@ -1,20 +0,0 @@ -/* File : example.h */ - -// Constants -#define ICONST 42 -#define FCONST 2.1828 -#define SCONST "Hello World" - -#define EXPR ICONST + 3 * FCONST - -// Enums -enum color { RED, BLUE, GREEN }; - -class Foo { - public: - Foo() { } - enum speed { IMPULSE, WARP, LUDICROUS }; - void enum_test(speed s); -}; - -void enum_test(enum color c, Foo::speed s); diff --git a/Examples/scilab/scilab_const/example.i b/Examples/scilab/scilab_const/example.i deleted file mode 100644 index d8162035a..000000000 --- a/Examples/scilab/scilab_const/example.i +++ /dev/null @@ -1,15 +0,0 @@ -/* File : example.i */ - -%module example - -%{ -#include "example.h" -%} - -/* Wraps enums and constants as Scilab variables (instead of functions) */ -%scilabconst(1); - -%include "example.h" - -%constant int iconst = 37; -%constant double fconst = 42.2; diff --git a/Examples/scilab/scilab_const/runme.sci b/Examples/scilab/scilab_const/runme.sci deleted file mode 100644 index 1b460b834..000000000 --- a/Examples/scilab/scilab_const/runme.sci +++ /dev/null @@ -1,43 +0,0 @@ -lines(0); -ilib_verbose(0); -exec loader.sce; -example_Init(); - -printf("\nTest %%scilab_const(1) feature: constants and enums are wrapped as Scilab variables\n"); - -printf("\nTest enums\n"); -printf("*** color ***\n"); -printf(" RED = %i\n", RED); -printf(" BLUE = %i\n", BLUE); -printf(" GREEN = %i\n", GREEN); - -printf("\n*** Foo::speed ***\n") -printf(" Foo_IMPULSE = %i\n", Foo_IMPULSE); -printf(" Foo_WARP = %i\n", Foo_WARP); -printf(" Foo_LUDICROUS = %i\n", Foo_LUDICROUS); - -printf("\nTest enums as argument of functions\n"); - -enum_test(RED, Foo_IMPULSE); -enum_test(BLUE, Foo_WARP); -enum_test(GREEN, Foo_LUDICROUS); -enum_test(1234, 5678); - -printf("\nTest enums as argument of class methods\n"); - -f = new_Foo(); -Foo_enum_test(f, Foo_IMPULSE); -Foo_enum_test(f, Foo_WARP); -Foo_enum_test(f, Foo_LUDICROUS); -delete_Foo(f); - -printf("\nTest constants\n"); - -printf("ICONST = %i (should be 42)\n", ICONST); -printf("FCONST = %5.4f (should be 2.1828)\n", FCONST); -printf("SCONST = ''%s'' (should be ''Hello World'')\n", SCONST); -printf("EXPR = %5.4f (should be 48.5484)\n", EXPR); -printf("iconst = %i (should be 37)\n", iconst); -printf("fconst = %3.2f (should be 42.20)\n", fconst); - -exit