Scilab: add %feature scilab:const (constants are wrapped by Scilab variables)

This commit is contained in:
Simon Marchetto 2013-08-28 17:00:23 +02:00
commit 2cf606c638
10 changed files with 159 additions and 17 deletions

View file

@ -24,5 +24,17 @@
%constant int iconst = 37;
%constant double fconst = 3.14;
/* Now constants are wrapped to Scilab variables */
%scilabconst(1);
#define ICONST2 12
#define FCONST2 4.60
#define CCONST3 'a'
#define CCONST4 '\n'
#define SCONST3 "Hello World"
#define SCONST4 "\"Hello World\""
%constant int iconst2 = 73;
%constant double fconst2 = 6.28;

View file

@ -1,15 +1,17 @@
lines(0);
exec loader.sce;
SWIG_Init();
printf("ICONST = %i (should be 42)\n", ICONST_get());
printf("FCONST = %f (should be 2.1828)\n", FCONST_get());
printf("CCONST = %c (should be ''x'')\n", CCONST_get());
printf("CCONST2 = %s (this should be on a new line)\n", CCONST2_get());
printf("SCONST = %s (should be ''Hello World'')\n", SCONST_get());
printf("SCONST2 = %s (should be "'""Hello World"""')\n", SCONST2_get());
printf("EXPR = %f (should be 48.5484)\n", EXPR_get());
printf("iconst = %i (should be 37)\n", iconst_get());
printf("fconst = %f (should be 3.14)\n", fconst_get());
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("CCONST_get() = ''%c'' (should be ''x'')\n", CCONST_get());
printf("CCONST2_get() = %s (this should be on a new line)\n", CCONST2_get());
printf("SCONST_get() = ''%s'' (should be ''Hello World'')\n", SCONST_get());
printf("SCONST2_get() = ''%s'' (should be "'""Hello World"""')\n", SCONST2_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 3.14)\n", fconst_get());
try
printf("EXTERN = %s (Arg! This should not printf(anything)\n", EXTERN_get());
@ -22,4 +24,14 @@ catch
printf("FOO is not defined (good)\n");
end
printf("\nNow constants are wrapped by Scilab variables (feature scilab:const):\n");
printf("ICONST2 = %i (should be 12)\n", ICONST2);
printf("FCONST2 = %3.2f (should be 4.60)\n", FCONST2);
printf("CCONST3 = ''%c'' (should be ''a'')\n", CCONST3);
printf("CCONST4 = %s (this should be on a new line)\n", CCONST4);
printf("SCONST3 = ''%s'' (should be ''Hello World'')\n", SCONST3);
printf("SCONST4 = ''%s'' (should be "'""Hello World"""')\n", SCONST4);
printf("iconst2 = %i (should be 73)\n", iconst2);
printf("fconst2 = %3.2f (should be 6.28)\n", fconst2);
exit