From e1513bf81d0516f03dcfebf7a6aeeb9a6a6aa4fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 9 Feb 2003 00:17:33 +0000 Subject: [PATCH] minor fixes/rewording git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4276 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Doc/Manual/Java.html | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/SWIG/Doc/Manual/Java.html b/SWIG/Doc/Manual/Java.html index 494846c87..d93dd3cd4 100644 --- a/SWIG/Doc/Manual/Java.html +++ b/SWIG/Doc/Manual/Java.html @@ -2805,8 +2805,9 @@ int c = example.count('e',"Hello World");

15.7.4 Typemaps for mapping C/C++ types to Java types

-The typemaps available to the Java module include the common typemaps listed in the main typemaps section. There are a number of additional typemaps which can be used with Java. -The most important of these implement the mapping of C/C++ types to Java types. There are three of them: +The typemaps available to the Java module include the common typemaps listed in the main typemaps section. +There are a number of additional typemaps which are necessary for using SWIG with Java. +The most important of these implement the mapping of C/C++ types to Java types:
  @@ -2848,6 +2849,18 @@ The most important of these implement the mapping of C/C++ types to Java types.
+

+If you are writing your own typemaps to handle a particular type, you will normally have to write a collection of them. +The default typemaps are in java.swg and so might be a good place for finding typemaps to base any new ones on. + +

+The "jni", "jtype" and "jstype" typemaps are usually defined together to handle the Java to C/C++ type mapping. +An "in" typemap should be accompanied by a "javain" typemap and likewise an "out" typemap by a "javaout" typemap. +If an "in" typemap is written, a "freearg" and "argout" typemap may also need to be written +as some types have a default "freearg" and/or "argout" typemap which may need overriding. +The "freearg" typemap sometimes releases memory allocated by the "in" typemap. +The "argout" typemap sometimes sets values in function parameters which are passed by reference in Java. +

The default code generated by SWIG for the Java module comes from the typemaps in the java.swg library file which implements the Default primitive type mappings covered earlier. @@ -2967,17 +2980,6 @@ is released afterwards -

-If you are writing your own typemaps to handle a particular type, you will normally have to write a collection of them. -Take a look at the default typemaps in java.swg. -

-The "jni", "jtype" and "jstype" typemaps are usually defined together to handle the Java to C/C++ type mapping. -An "in" typemap is usually accompanied by a "javain" typemap and likewise an "out" typemap with a "javaout" typemap. -If an "in" typemap is written, a "freearg" and "argout" typemap may also need to be written. -as some types have a default "freearg" and/or "argout" typemap which may need overriding. -The "freearg" typemap sometimes releases memory allocated by the "in" typemap. -The "argout" typemap sometimes sets values in function parameters which are passed by reference in Java. -

15.7.5 Java special variables

@@ -3553,6 +3555,10 @@ public: } ... }; + +Vehicle *vehicle_factory() { + return new Ambulance("Very loud"); +} If we execute the following Java code: @@ -3575,8 +3581,8 @@ java.lang.ClassCastException Even though we know from examination of the C++ code that vehicle_factory returns an object of type Ambulance, we are not able to use this knowledge to perform the downcast in Java. -This occurs because the runtime type information is not completely passed from C++ to Java when returning the type from vehicle_factory. -Usually this is not a problem as virtual functions, as in the case of start work. +This occurs because the runtime type information is not completely passed from C++ to Java when returning the type from vehicle_factory(). +Usually this is not a problem as virtual functions do work by default, such as in the case of start(). There are a few solutions to getting downcasts to work.