Skip to content

Commit

Permalink
Scilab: enum example is consistent with other languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Marchetto committed Sep 6, 2013
1 parent 06617db commit 91e4114
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
13 changes: 0 additions & 13 deletions Examples/scilab/enum/example.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* File : example.c */

#include "example.h"
#include "scilabconst_example.h"
#include <stdio.h>

void enum_test(color c) {
Expand All @@ -15,15 +14,3 @@ void enum_test(color c) {
printf("color = Unknown color!\n");
}
}

void scilabconst_enum_test(fruit f) {
if (f == APPLE) {
printf("fruit = APPLE\n");
} else if (f == ORANGE) {
printf("fruit = ORANGE\n");
} else if (f == LEMON) {
printf("fruit = LEMON\n");
} else {
printf("fruit = Unknown fruit!\n");
}
}
6 changes: 3 additions & 3 deletions Examples/scilab/enum/example.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

%{
#include "example.h"
#include "scilabconst_example.h"
%}

/* Forces to wrap enums as Scilab variables (instead of functions) */
%scilabconst(1);

%include "example.h"

%scilabconst(1);

%include "scilabconst_example.h"
26 changes: 7 additions & 19 deletions Examples/scilab/enum/runme.sci
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@ lines(0);
exec loader.sce;
SWIG_Init();

printf("\nTesting use of enums wrapped as Scilab functions\n");
printf("\nTesting use of enums (wrapped as Scilab variables)\n");

printf("*** color ***\n");
printf(" RED = %i\n", RED_get());
printf(" BLUE = %i\n", BLUE_get());
printf(" GREEN = %i\n", GREEN_get());
printf(" RED = %i\n", RED);
printf(" BLUE = %i\n", BLUE);
printf(" GREEN = %i\n", GREEN);

enum_test(RED_get());
enum_test(BLUE_get());
enum_test(GREEN_get());
enum_test(RED);
enum_test(BLUE);
enum_test(GREEN);
enum_test(int32(1234));

printf("\nTesting use of enums wrapped as Scilab variables\n");

printf("*** fruit ***\n");
printf(" APPLE = %i\n", APPLE);
printf(" ORANGE = %i\n", ORANGE);
printf(" LEMON = %i\n", LEMON);

scilabconst_enum_test(APPLE);
scilabconst_enum_test(ORANGE);
scilabconst_enum_test(LEMON);
scilabconst_enum_test(int32(1234));

exit
3 changes: 0 additions & 3 deletions Examples/scilab/enum/scilabconst_example.h

This file was deleted.

0 comments on commit 91e4114

Please sign in to comment.