The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1508 changed files with 125983 additions and 44037 deletions
9
SWIG/Examples/pike/enum/.cvsignore
Normal file
9
SWIG/Examples/pike/enum/.cvsignore
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*.dll
|
||||
*.dsw
|
||||
*.ncb
|
||||
*.opt
|
||||
*.plg
|
||||
Release
|
||||
Debug
|
||||
19
SWIG/Examples/pike/enum/Makefile
Normal file
19
SWIG/Examples/pike/enum/Makefile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile pike_clean
|
||||
|
||||
check: all
|
||||
37
SWIG/Examples/pike/enum/example.cxx
Normal file
37
SWIG/Examples/pike/enum/example.cxx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void Foo::enum_test(speed s) {
|
||||
if (s == IMPULSE) {
|
||||
printf("IMPULSE speed\n");
|
||||
} else if (s == WARP) {
|
||||
printf("WARP speed\n");
|
||||
} else if (s == LUDICROUS) {
|
||||
printf("LUDICROUS speed\n");
|
||||
} else {
|
||||
printf("Unknown speed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void enum_test(color c, Foo::speed s) {
|
||||
if (c == RED) {
|
||||
printf("color = RED, ");
|
||||
} else if (c == BLUE) {
|
||||
printf("color = BLUE, ");
|
||||
} else if (c == GREEN) {
|
||||
printf("color = GREEN, ");
|
||||
} else {
|
||||
printf("color = Unknown color!, ");
|
||||
}
|
||||
if (s == Foo::IMPULSE) {
|
||||
printf("speed = IMPULSE speed\n");
|
||||
} else if (s == Foo::WARP) {
|
||||
printf("speed = WARP speed\n");
|
||||
} else if (s == Foo::LUDICROUS) {
|
||||
printf("speed = LUDICROUS speed\n");
|
||||
} else {
|
||||
printf("speed = Unknown speed!\n");
|
||||
}
|
||||
}
|
||||
13
SWIG/Examples/pike/enum/example.h
Normal file
13
SWIG/Examples/pike/enum/example.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* File : example.h */
|
||||
|
||||
enum color { RED, BLUE, GREEN };
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo() { }
|
||||
enum speed { IMPULSE, WARP, LUDICROUS };
|
||||
void enum_test(speed s);
|
||||
};
|
||||
|
||||
void enum_test(color c, Foo::speed s);
|
||||
|
||||
11
SWIG/Examples/pike/enum/example.i
Normal file
11
SWIG/Examples/pike/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"
|
||||
|
||||
27
SWIG/Examples/pike/enum/runme.pike
Normal file
27
SWIG/Examples/pike/enum/runme.pike
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
int main()
|
||||
{
|
||||
write("*** color ***\n");
|
||||
write(" RED = " + .example.RED + "\n");
|
||||
write(" BLUE = " + .example.BLUE + "\n");
|
||||
write(" GREEN = " + .example.GREEN + "\n");
|
||||
|
||||
write("\n*** Foo::speed ***\n");
|
||||
write(" Foo_IMPULSE = " + .example.Foo.IMPULSE + "\n");
|
||||
write(" Foo_WARP = " + .example.Foo.WARP + "\n");
|
||||
write(" Foo_LUDICROUS = " + .example.Foo.LUDICROUS + "\n");
|
||||
|
||||
write("\nTesting use of enums with functions\n\n");
|
||||
|
||||
.example.enum_test(.example.RED, .example.Foo.IMPULSE);
|
||||
.example.enum_test(.example.BLUE, .example.Foo.WARP);
|
||||
.example.enum_test(.example.GREEN, .example.Foo.LUDICROUS);
|
||||
|
||||
write("\nTesting use of enum with class method\n");
|
||||
.example.Foo f = .example.Foo();
|
||||
|
||||
f->enum_test(.example.Foo.IMPULSE);
|
||||
f->enum_test(.example.Foo.WARP);
|
||||
f->enum_test(.example.Foo.LUDICROUS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue