Have just one Scilab constants example

Same example as other languages, but using %scilabconst(1)
This commit is contained in:
William S Fulton 2014-09-02 20:29:45 +01:00
commit d3a54e50f8
8 changed files with 30 additions and 145 deletions

View file

@ -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;

View file

@ -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