<?xml version="1.0" encoding="UTF-8"?>
<!--
*
* Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2010 - 2011 - Calixte DENIZET <calixte@contrib.scilab.org>
*
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
*
*
-->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:lang="en" xml:id="jinvoke_db">
    <refnamediv>
        <refname>jinvoke_db</refname>
        <refpurpose>Invoke a method of a Java object in using Java direct buffers</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            ret = jinvoke_db(object, methodName [, varName_1 [, varName_2...]])
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Parameters</title>
        <variablelist>
            <varlistentry>
                <term>object</term>
                <listitem>
                    <para>A mlist typed _JObj or _JClass or a Scilab variable</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>methodName</term>
                <listitem>
                    <para>A string giving the method name</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>varName_i</term>
                <listitem>
                    <para>A string giving a Scilab variable name as argument</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            Invoke the Java method (static or not) called methodName of the given object. A pointer on the Scilab variable named varNamei is got and a direct buffer is created.
            <emphasis role="bold">Take care: you should not keep any reference on a direct buffer. You have a direct access to the Scilab memory so if for one reason a Scilab variable is moved or destroyed, you risk to read or to write where you would not do it ! To avoid any problems, the limit of each buffer is set to 0.</emphasis>
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
               c = jcompile("TestDirectBuffer",["import java.nio.DoubleBuffer;";
                                                "public class TestDirectBuffer {";
                                                "public static void increment(DoubleBuffer x) {";
                                                "for (int i = 0; i < x.capacity(); i++) x.put(i, x.get(i) + 1);";
                                                "}";
                                                "}"])
               a = 1:10000;
               b = a + 1; // only used to compare with the following...
               jinvoke_db(c, "increment", "a");
               and(a==b)

               jremove c;
      ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="jinvoke">jinvoke</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.5.0</revnumber>
                <revremark>
                    Function introduced. Based on the 'JIMS' module. The main difference in the behavior compared to the JIMS module is that <link linkend="jautoUnwrap">jautoUnwrap</link> is enabled by default.
                </revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>

