add support for Enums
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11288 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4e9cbd8a7c
commit
ed84d6b162
19 changed files with 865 additions and 222 deletions
16
Examples/scilab/enum/example.c
Normal file
16
Examples/scilab/enum/example.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void enum_test(color c) {
|
||||
if (c == RED) {
|
||||
sciprint("color = RED, ");
|
||||
} else if (c == BLUE) {
|
||||
sciprint("color = BLUE, ");
|
||||
} else if (c == GREEN) {
|
||||
sciprint("color = GREEN, ");
|
||||
} else {
|
||||
sciprint("color = Unknown color!, ");
|
||||
}
|
||||
}
|
||||
6
Examples/scilab/enum/example.h
Normal file
6
Examples/scilab/enum/example.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* File : example.h */
|
||||
|
||||
typedef enum { RED, BLUE, GREEN } color;
|
||||
|
||||
void enum_test(color c);
|
||||
|
||||
11
Examples/scilab/enum/example.i
Normal file
11
Examples/scilab/enum/example.i
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
|
||||
%include "example.h"
|
||||
|
||||
15
Examples/scilab/enum/makefile
Normal file
15
Examples/scilab/enum/makefile
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.c
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_clean
|
||||
rm -f *.sce *.so lib*lib.c
|
||||
|
||||
check: all
|
||||
22
Examples/scilab/enum/runme.sci
Normal file
22
Examples/scilab/enum/runme.sci
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
|
||||
// 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("\nTesting use of enums with functions\n");
|
||||
|
||||
enum_test(color.RED);
|
||||
enum_test(color.BLUE);
|
||||
enum_test(color.GREEN);
|
||||
enum_test(1234);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue