Java doc update for directorin typemaps and Swig::LocalRefGuard

Motivated by fixes in patch #704

[skip ci]
This commit is contained in:
William S Fulton 2016-11-03 18:48:01 +00:00
commit 108d82a886

View file

@ -6350,11 +6350,24 @@ A typemap for C character strings is:
<div class="code">
<pre>
%typemap(directorin,descriptor="Ljava/lang/String;") char *
%{ $input = jenv-&gt;NewStringUTF($1); %}
%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * %{
$input = 0;
if ($1) {
$input = JCALL1(NewStringUTF, jenv, (const char *)$1);
if (!$input) return $null;
}
Swig::LocalRefGuard $1_refguard(jenv, $input);
%}
</pre>
</div>
<p>
The <tt>Swig::LocalRefGuard</tt> class should be used in directorin typemaps for newly allocated objects.
It is used to control local reference counts ensuring the count is decremented after the call up into Java has completed.
Its destructor simply calls <tt>jenv-&gt;DeleteLocalRef(obj)</tt> on the <tt>obj</tt>
passed in during construction.
</p>
<p>
User-defined types have the default "descriptor" attribute "<code>L$packagepath/$javaclassname;</code>" where <code>$packagepath</code>