From 100cb94359bccfd11f8d5af701d6160826fb8a5e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 Dec 2004 23:15:36 +0000 Subject: [PATCH] bit more on javapackage typemap git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6842 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Doc/Manual/Java.html | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/SWIG/Doc/Manual/Java.html b/SWIG/Doc/Manual/Java.html index 7026924f4..aeed5c6c0 100644 --- a/SWIG/Doc/Manual/Java.html +++ b/SWIG/Doc/Manual/Java.html @@ -4494,15 +4494,15 @@ For example: -Assume that the Foo class is part of the Java package wombat.foo but the above interface file is part of the Java package wombat.example. -Without the "javapackage" typemap, SWIG will assume that the Foo class belongs to wombat.example class. +Assume that the Foo class is part of the Java package com.wombat.foo but the above interface file is part of the Java package com.wombat.example. +Without the "javapackage" typemap, SWIG will assume that the Foo class belongs to com.wombat.example class. The corrected interface file looks like:
 // class Foo is handled in a different interface file:
 %import "Foo.i"
-%typemap("javapackage") Foo "wombat.foo";
+%typemap("javapackage") Foo, Foo *, Foo & "com.wombat.foo";
 %feature("director") Example;
 
 %inline {
@@ -4518,7 +4518,10 @@ The corrected interface file looks like:
 

-Practically speaking, you should create a separate SWIG interface file, which is %import-ed into each SWIG interface file, when you have multiple Java packages: +SWIG looks up the package based on the actual type (plain Foo, Foo pointer and Foo reference), so it is important to associate all three types with the desired package. +Practically speaking, you should create a separate SWIG interface file, which is %import-ed into each SWIG interface file, when you have multiple Java packages. +Note the helper macros below, OTHER_PACKAGE_SPEC and ANOTHER_PACKAGE_SPEC, which reduce the amount of extra typing. +"TYPE..." is useful when passing templated types to the macro, since multiargument template types appear to the SWIG preprocessor as multiple macro arguments.

@@ -4526,8 +4529,16 @@ Practically speaking, you should create a separate SWIG interface file, which is %typemap("javapackage") SWIGTYPE, SWIGTYPE *, SWIGTYPE & "package.for.most.classes"; -%typemap("javapackage") Package_2_class_one "package.for.other.classes"; -%typemap("javapackage") Package_3_class_two "package.for.another.set"; +%define OTHER_PACKAGE_SPEC(TYPE...) +%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.other.classes"; +%enddef + +%define ANOTHER_PACKAGE_SPEC(TYPE...) +%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.another.set"; +%enddef + +OTHER_PACKAGE_SPEC(Package_2_class_one) +ANOTHER_PACKAGE_SPEC(Package_3_class_two) /* etc */