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
4
SWIG/Examples/php4/enum/BUILD.sh
Executable file
4
SWIG/Examples/php4/enum/BUILD.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#! /bin/sh -e
|
||||
|
||||
${SWIG:=swig} -php4 -phpfull -c++ -noproxy -withcxx example.cxx example.i
|
||||
phpize && ./configure && make clean && make
|
||||
17
SWIG/Examples/php4/enum/Makefile.old
Normal file
17
SWIG/Examples/php4/enum/Makefile.old
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = php_example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
SWIGOPT = -noproxy
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'\
|
||||
php4_cpp
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o core *~ *.so *.php
|
||||
|
||||
check: all
|
||||
37
SWIG/Examples/php4/enum/example.cxx
Normal file
37
SWIG/Examples/php4/enum/example.cxx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
#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/php4/enum/example.h
Normal file
13
SWIG/Examples/php4/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);
|
||||
|
||||
12
SWIG/Examples/php4/enum/example.i
Normal file
12
SWIG/Examples/php4/enum/example.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
|
||||
%include "example.h"
|
||||
|
||||
32
SWIG/Examples/php4/enum/runme.php4
Normal file
32
SWIG/Examples/php4/enum/runme.php4
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
# Print out the value of some enums
|
||||
print "*** color ***";
|
||||
print " RED =" . RED;
|
||||
print " BLUE =" . BLUE;
|
||||
print " GREEN =" . GREEN;
|
||||
|
||||
print "\n*** Foo::speed ***";
|
||||
print " Foo_IMPULSE =" . Foo_IMPULSE;
|
||||
print " Foo_WARP =" . Foo_WARP;
|
||||
print " Foo_LUDICROUS =" . Foo_LUDICROUS;
|
||||
|
||||
print "\nTesting use of enums with functions\n";
|
||||
|
||||
enum_test(RED, Foo_IMPULSE);
|
||||
enum_test(BLUE, Foo_WARP);
|
||||
enum_test(GREEN, Foo_LUDICROUS);
|
||||
enum_test(1234,5678);
|
||||
|
||||
print "\nTesting use of enum with class method\n";
|
||||
$f = new_Foo();
|
||||
|
||||
Foo_enum_test($f,Foo_IMPULSE);
|
||||
Foo_enum_test($f,Foo_WARP);
|
||||
Foo_enum_test($f,Foo_LUDICROUS);
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue