a better way to deal with constants and enums and some change about the doc

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11515 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2009-08-08 13:25:29 +00:00
commit b1a384dc3c
10 changed files with 223 additions and 255 deletions

View file

@ -24,10 +24,5 @@
%constant int iconst = 37;
%constant double fconst = 3.14;
%inline %{
void constant_test(const int x) {
printf("%i", x);
}
%}

View file

@ -1,24 +1,23 @@
// loader the *.so
exec loader.sce;
exec example.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);
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());
try
printf("EXTERN = %s (Arg! This should not printf(anything)\n", EXTERN);
printf("EXTERN = %s (Arg! This should not printf(anything)\n", EXTERN_get());
catch
printf("EXTERN is not defined (good)\n");
end
try
printf("FOO = %i (Arg! This should not printf(anything)\n", FOO);
printf("FOO = %i (Arg! This should not printf(anything)\n", FOO_get());
catch
printf("FOO is not defined (good)\n");
end

View file

@ -5,12 +5,12 @@
void enum_test(color c) {
if (c == RED) {
sciprint("color = RED, ");
printf("color = RED\n");
} else if (c == BLUE) {
sciprint("color = BLUE, ");
printf("color = BLUE\n ");
} else if (c == GREEN) {
sciprint("color = GREEN, ");
printf("color = GREEN\n");
} else {
sciprint("color = Unknown color!, ");
printf("color = Unknown color!\n");
}
}

View file

@ -1,21 +1,19 @@
// loader the *.so
exec loader.sce;
exec example.sce;
// Print out the value of some enums
printf("*** color ***\n");
printf(" RED = %i\n", color.RED);
printf(" BLUE = %i\n", color.BLUE);
printf(" GREEN = %i\n", color.GREEN);
printf(" RED = %i\n", RED_get());
printf(" BLUE = %i\n", BLUE_get());
printf(" GREEN = %i\n", GREEN_get());
printf("\nTesting use of enums with functions\n");
enum_test(color.RED);
enum_test(color.BLUE);
enum_test(color.GREEN);
enum_test(1234);
enum_test(RED_get());
enum_test(BLUE_get());
enum_test(GREEN_get());
enum_test(int32(1234));
exit

View file

@ -1,8 +1,7 @@
exec loader.sce
exec enums.sce
bar1(foo1.CSP_ITERATION_BWD)
bar2(foo3.ABCDE)
bar3(foo3.FGHJI)
bar1(CSP_ITERATION_BWD_get())
bar2(ABCDE_get())
bar3(FGHJI_get())
exit

View file

@ -1,7 +1,6 @@
exec loader.sce;
exec li_math.sce;
x = fmod(M_PI, M_1_PI)
x = fmod(M_PI_get(), M_1_PI_get())
exit

View file

@ -1,7 +1,7 @@
exec loader.sce
initArray();
x_get()
y_get()
if x_get() <> int32([0,1,2,3,4,5,6,7,8,9]) then pause, end
if y_get() <> [0/7,1/7,2/7,3/7,4/7,5/7,6/7] then pase, end
exit