/tags/rel-1-3-15/SWIG/Examples/test-suite/java_typemaps_typewrapper.i
Swig | 57 lines | 43 code | 13 blank | 1 comment | 0 complexity | b2690b733e78c75a7008dd09a58a0ca0 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1/* Contrived example to test the Java specific directives on the type wrapper classes */
2
3%module java_typemaps_typewrapper
4
5
6%typemap(javaimports) SWIGTYPE * "import java.math.*;";
7%typemap(javacode) Farewell * %{
8 public static $javaclassname CreateNullPointer() {
9 return new $javaclassname();
10 }
11 public void saybye(BigDecimal num_times) {
12 // BigDecimal requires the java.math library
13 }
14%}
15%typemap(javaclassmodifiers) Farewell * "public final";
16
17%typemap(javaimports) Greeting * %{
18import java.util.*; // for EventListener
19import java.lang.*; // for Exception
20%};
21
22%typemap(javabase) Greeting * "Exception";
23%typemap(javainterfaces) Greeting * "EventListener";
24%typemap(javacode) Greeting * %{
25 // Pure Java code generated using %typemap(javacode)
26 public static $javaclassname CreateNullPointer() {
27 return new $javaclassname();
28 }
29
30 public void sayhello() {
31 $javaclassname.cheerio(new $javaclassname());
32 }
33
34 public static void cheerio(EventListener e) {
35 }
36%}
37
38// Create a new getCPtr() function which takes Java null
39%typemap(javagetcptr) Farewell * %{
40 public static long getCPtr($javaclassname obj) {
41 return (obj == null) ? 0 : obj.swigCPtr;
42 }
43%}
44
45// Make the pointer constructor public
46%typemap(javaptrconstructormodifiers) Farewell * "public";
47
48
49%{
50class Greeting {};
51class Farewell {};
52%}
53
54%inline %{
55 Greeting* solong(Farewell* f) { return NULL; }
56%}
57