The great merge

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2002-11-30 22:01:28 +00:00
commit 12a43edc2d
1508 changed files with 125983 additions and 44037 deletions

View file

@ -0,0 +1,11 @@
*.class
*.java
*_wrap.c
*_wrap.cxx
example.dll
example.dsw
example.ncb
example.opt
example.plg
Release
Debug

View file

@ -0,0 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../swig
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
all:: java
java::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
clean::
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View 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");
}
}

View 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);

View file

@ -0,0 +1,13 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
%pragma make_default
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -0,0 +1,37 @@
<html>
<head>
<title>SWIG:Examples:java:enum</title>
</head>
<body bgcolor="#ffffff">
<tt>SWIG/Examples/java/enum/</tt>
<hr>
<H2>Wrapping enumerations</H2>
<tt>$Header$</tt><br>
<p>
This example tests SWIG's ability to wrap enumerations. By default, SWIG
converts enumeration specifications into integer constants. Further use
of enumerated types are handled as integers.
<ul>
<li><a href="example.h">example.h</a>. Header file containing some enums.
<li><a href="example.i">example.i</a>. Interface file.
<li><a href="main.java">main.java</a>. Sample Java program.
</ul>
<h2>Notes</h2>
<ul>
<li>SWIG allows arbitrary integers to be passed as enum values. However,
the result of passing an integer not corresponding to any of the values
specified in the <tt>enum</tt> specification is undefined.
</ul>
<hr>
</body>
</html>

View file

@ -0,0 +1,39 @@
public class main {
static {
try {
System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// Print out the value of some enums
System.out.println("*** color ***");
System.out.println(" RED = " + example.RED);
System.out.println(" BLUE = " + example.BLUE);
System.out.println(" GREEN = " + example.GREEN);
System.out.println("\n*** Foo::speed ***");
System.out.println(" Foo::IMPULSE = " + Foo.IMPULSE);
System.out.println(" Foo::WARP = " + Foo.WARP);
System.out.println(" Foo::LUDICROUS = " + Foo.LUDICROUS);
System.out.println("\nTesting use of enums with functions\n");
example.enum_test(example.RED, Foo.IMPULSE);
example.enum_test(example.BLUE, Foo.WARP);
example.enum_test(example.GREEN, Foo.LUDICROUS);
example.enum_test(1234,5678);
System.out.println( "\nTesting use of enum with class method" );
Foo f = new Foo();
f.enum_test(Foo.IMPULSE);
f.enum_test(Foo.WARP);
f.enum_test(Foo.LUDICROUS);
}
}