SEP #130: Replace obsolete numdiff and derivative with new function numderivative.
SEP #131: Modified matfile2sci to have an new input argument overwrite to overwrite the output file
SEP #132: Remove useless output argument err of add_param function.
+SEP #133: Implement profiling functions to output Scilab values
+SEP #134: Add `%foo_clear` overloading and implement it for External Objects Java
--- /dev/null
+= SEP: add a `%foo_clear` overloading =\r
+\r
+= Abstract =\r
+\r
+Some Scilab features are implemented through a `mlist` object and using the overloading mechanism to call a generic gateway on an operation. This is the case for the `external_object` (and JIMS), `xml` and `hdf5` functionalities. To correctly call a destructor (to release resources, free mapping tables, etc...) a specific gateway is implemented and should be called to avoid memory leaks. This SEP propose to add an overloading `%foo_clear` called on `foo mlist` destruction to avoid the specific gateway thus let the mlist behave as other Scilab values.\r
+\r
+= Requirements =\r
+\r
+A `%foo_clear` function should be called on `foo mlist` destruction by the interpreter. If not defined, no error is produced and nothing is performed instead. This function will take an argument representing the deleted mlist value; \r
+\r
+Atop of this deletion management, Scilab functionalities could be improved to handle this new behavior. For example, `jremove` (from external_object_java), `xmlDelete` (from xml) and `h5close` (from hdf5) could be called on deletion to avoid resource leaks and let the user `clear` the associated mlist. \r
+\r
+== Bugzilla links ==\r
+\r
+The following bugs have been entered on Bugzilla to track similar or related problems/wishlist:\r
+\r
+ * [[https://bugzilla.scilab.org/show_bug.cgi?id=10277]] bug report on clear() overloading\r
+ * [[https://bugzilla.scilab.org/show_bug.cgi?id=10258]] related issue with xmlDelete\r
+ * [[https://bugzilla.scilab.org/show_bug.cgi?id=13398]] original clear() vs xmlDelete report\r
+\r
+== Mailing list threads ==\r
+\r
+http://mailinglists.scilab.org/SEP-add-a-foo-delete-overloading-td4038898.html\r
+\r
+== Other software ==\r
+\r
+\r
+= Examples =\r
+\r
+== Explicit call ==\r
+\r
+{{{#!highlight scilab\r
+\r
+function %foo_clear(o)\r
+ disp("resource deleted")\r
+endfunction\r
+\r
+value = mlist("foo");\r
+clear value\r
+\r
+}}}\r
+\r
+== Implicit call ==\r
+\r
+{{{#!highlight scilab\r
+function %foo_clear(o)\r
+ disp("clear foo");\r
+endfunction\r
+\r
+function do_someting()\r
+ value = mlist("foo");\r
+endfunction\r
+\r
+do_someting(); // %foo_clear will be call at the end of do_something\r
+}}}\r
+\r
+{{{#!highlight scilab\r
+function %foo_clear(o)\r
+ disp("clear foo");\r
+endfunction\r
+\r
+function value = do_someting_and_return()\r
+ value = mlist("foo");\r
+endfunction\r
+\r
+x = do_someting_and_return();\r
+x = 1; //call %foo_clear overload before replace\r
+}}}\r
+\r
+----\r
+CategorySep\r
In summary, the main new features are:
* Webtools utilities added for HTTP protocol, JSON data usage
-* Profiled values are available as Scilab values
+* Profiled values are available as Scilab values
* Values have a cleaner display:
- they are displayed in order on assignement
- strings are quoted
- Octave native text data files can now be read.
- Automatic detection of the input data format implemented.
- `-toStruct` option added, to return results in a structure instead of in the calling environment.
+* `jremove` is optional and `clear` could be used to release Java objects mapped to Scilab.
Help pages:
-----------
* [#15271](http://bugzilla.scilab.org/show_bug.cgi?id=15271): `bitget` needed to be upgraded.
* [#15321](http://bugzilla.scilab.org/show_bug.cgi?id=15321): `lu()` was leaking memory.
* [#15425](http://bugzilla.scilab.org/show_bug.cgi?id=15425): The Kronecker product `a.*.b` failed when `a` or `b` or both are hypermatrices, with one or both being polynomials or rationals.
-* [#15523](http://bugzilla.scilab.org/show_bug.cgi?id=15523): `%ODEOPTIONS(1)=2` didn't work with solvers 'rk' and 'rkf'
+* [#15523](http://bugzilla.scilab.org/show_bug.cgi?id=15523): `%ODEOPTIONS(1)=2` didn't work with solvers 'rk' and 'rkf'
* [#15248](http://bugzilla.scilab.org/show_bug.cgi?id=15248): `lsq()`was leaking memory.
* [#15577](http://bugzilla.scilab.org/show_bug.cgi?id=15577): `edit` did not accept a line number as text, as with `edit linspace 21`.
* [#15668](http://bugzilla.scilab.org/show_bug.cgi?id=15668): `save(filename)` saved all predefined Scilab constants %e %pi etc.. (regression)
-* [#15715](http://bugzilla.scilab.org/show_bug.cgi?id=15715): `%nan` indices crashed Scilab.
+* [#15715](http://bugzilla.scilab.org/show_bug.cgi?id=15715): `%nan` indices crashed Scilab.
* [#15581](http://bugzilla.scilab.org/show_bug.cgi?id=15581): display of complex matrix was ugly.
* [#15680](http://bugzilla.scilab.org/show_bug.cgi?id=15680): `loadmatfile()` could not return variables in a structure instead of into the calling environment.
* [#15812](http://bugzilla.scilab.org/show_bug.cgi?id=15812): On assigning variables the source variable may become become corrupted
* [#16007](http://bugzilla.scilab.org/show_bug.cgi?id=16007): Non-integer index in sparse makes Scilab crash.
* [#16012](http://bugzilla.scilab.org/show_bug.cgi?id=16012): `[struct() struct()]` crashed Scilab.
* [#16013](http://bugzilla.scilab.org/show_bug.cgi?id=16013): Load previously saved environment with "File/Load environment" menu failed.
-* [#16014](http://bugzilla.scilab.org/show_bug.cgi?id=16014): after `x.a=1; x(:)=[]` x.a was an empty list.
+* [#16014](http://bugzilla.scilab.org/show_bug.cgi?id=16014): after `x.a=1; x(:)=[]` x.a was an empty list.
* [#16015](http://bugzilla.scilab.org/show_bug.cgi?id=116015): `intg(a,b,f)` called f(x) with x outside [a,b].
* [#16021](http://bugzilla.scilab.org/show_bug.cgi?id=16021): `tand([-90 90])` answered [Nan Nan] instead of [-Inf, Inf]. `cotd([-90 90])` answered [Nan Nan] instead of [0 0]. `1 ./cosd([-90 90])` answered [Inf -Inf] instead of [Inf Inf].
* [#16067](http://bugzilla.scilab.org/show_bug.cgi?id=16067): The display of matrices of signed integers was misaligned (regression of 6.0.0 vs 5.5.2)
{
public :
MList() : TList() {}
- //Destructor uses ~TList()
+ ~MList();
virtual MList* clone() override
{
{
public :
TList();
- ~TList();
-protected :
+ virtual ~TList();
+
+protected:
TList(TList *_oTListCopyMe) : List(_oTListCopyMe) {}
public :
return;
}
- if (pIT->isList() && pIT->getRef() > 0)
- {
- // Prevent modification of all scilab variable
- // which point to this container when it is used
- // in setfield scilab function.
- // A clone on a container will not clone what it contain.
- pIT = pIT->clone();
- }
-
if (e.getRightExp().isReturnExp())
{
//ReturnExp so, put the value in the previous scope
*
*/
-#include <sstream>
#include "mlist.hxx"
#include "callable.hxx"
-#include "overload.hxx"
#include "configvariable.hxx"
+#include "context.hxx"
#include "exp.hxx"
+#include "overload.hxx"
#include "types_tools.hxx"
+#include <sstream>
#ifndef NDEBUG
#include "inspector.hxx"
namespace types
{
+
+MList::~MList()
+{
+ typed_list in;
+ typed_list out;
+ optional_list opt;
+ IncreaseRef();
+ in.push_back(this);
+
+ try
+ {
+ Overload::generateNameAndCall(L"clear", in, 0, out);
+ }
+ catch (ast::InternalError& /*se*/)
+ {
+ // avoid error message about undefined overload %type_clear
+ ConfigVariable::resetError();
+ // reset where error filled by generateNameAndCall
+ ConfigVariable::resetWhereError();
+ }
+
+ DecreaseRef();
+}
+
bool MList::getMemory(long long* _piSize, long long* _piSizePlusType)
{
*_piSize = 0;
// avoid error message about undefined overload %type_p
ConfigVariable::resetError();
+ // reset where error filled by generateNameAndCall
+ ConfigVariable::resetWhereError();
}
DecreaseRef();
<varlistentry>
<term>a, b, c...</term>
<listitem>
- <para>variables of any type and size, but not protected</para>
+ <para>names of variables of any type and size, but not protected</para>
</listitem>
</varlistentry>
</variablelist>
remove all the variables.
</para>
<para>
- Normally, protected variables are standard libraries and variables with
- the percent prefix.
+ Normally, protected variables are standard libraries and variables with the percent prefix.
</para>
<para>
<note>
</note>
</para>
<para>
- The command <code>clear</code> can kill nonexistent variables, i. e.
- <code>clear</code> kills nonexistent variables as if they exist.
+ If a name <emphasis>Var</emphasis> matches no variable, <literal>clear Var</literal>
+ does nothing silently.
</para>
+ <note>
+ <literal>clear()</literal> can be overloaded for any <literal>mlist("foo")</literal> type,
+ by defining a <literal>%foo_clear()</literal> macro. It will be called either when
+ <literal>clear</literal> is explicitly applied to any mlist of this type, or implicitly
+ when any mlist of this type is deleted when leaving the environment where it has been
+ defined.
+ </note>
</refsection>
<refsection>
<title>Examples</title>
c = 4;
clear(['a' 'b' 'c'])
isdef("a") | isdef("b") | isdef("c") // F
- ]]></programlisting>
+ ]]></programlisting>
+ <programlisting role="example"><![CDATA[
+function %foo_clear(o)
+ disp("deleted");
+endfunction
+
+value = mlist("foo");
+clear value // will print "deleted"
+]]></programlisting>
</refsection>
<refsection role="see also">
<title>See also</title>
<link linkend="predef">predef</link>
</member>
<member>
+ <link linkend="clearglobal">clearglobal</link>
+ </member>
+ <member>
<link linkend="funcprot">funcprot</link>
</member>
<member>
<link linkend="who">who</link>
</member>
+ <member>
+ <link linkend="xmlDelete">xmlDelete</link>
+ </member>
</simplelist>
</refsection>
<refsection>
Assignments like <literal>clear=1</literal> are no longer possible.
</revdescription>
</revision>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <literal>clear</literal> becomes overloadable for any
+ <literal>mlist("foo")</literal>, with <literal>%foo_clear()</literal>.
+ </revdescription>
+ </revision>
</revhistory>
</refsection>
</refentry>
Habituellement, les variables protégées sont les bibliothèques standard et les variables dont le nom commence par le caractère "%".
</para>
<para>
- Notez la syntaxe particulière : <literal>clear a</literal> et non <literal>clear(a)</literal>. Notez aussi que <literal>a=[]</literal> ne supprime pas <literal>a</literal> mais affecte à <literal>a</literal> une matrice vide.
+ Notez la syntaxe particulière : <literal>clear a</literal> et non <literal>clear(a)</literal>.
+ Notez aussi que <literal>a=[]</literal> ne supprime pas <literal>a</literal>
+ mais affecte à <literal>a</literal> une matrice vide.
</para>
+ <para>
+ Si un nom <emphasis>Var</emphasis> ne correspond à aucune variable,
+ <literal>clear Var</literal> sera simplement ignoré.
+ </para>
+ <note>
+ <literal>clear</literal> peut être surchargée pour toute <literal>mlist("foo")</literal>,
+ en définissant la fonction <literal>%foo_clear()</literal>. Celle-ci sera appelée autant
+ lors des appels explicites à <literal>clear</literal>, qu'en quittant l'environnement
+ où la mlist a été définie.
+ </note>
</refsection>
<refsection>
<title>Exemples</title>
clear(['a' 'b' 'c'])
isdef("a") | isdef("b") | isdef("c") // F
]]></programlisting>
+ <programlisting role="example"><![CDATA[
+function %foo_clear(o)
+ disp("deleted");
+endfunction
+
+value = mlist("foo");
+clear value // will print "deleted"
+]]></programlisting>
</refsection>
<refsection role="see also">
<title>Voir aussi</title>
<link linkend="predef">predef</link>
</member>
<member>
+ <link linkend="clearglobal">clearglobal</link>
+ </member>
+ <member>
<link linkend="funcprot">funcprot</link>
</member>
<member>
<link linkend="who">who</link>
</member>
+ <member>
+ <link linkend="xmlDelete">xmlDelete</link>
+ </member>
</simplelist>
</refsection>
<refsection>
<literal>clear=1</literal> ne sont plus possibles.
</revdescription>
</revision>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <literal>clear</literal> devient surchargeable pour toute
+ <literal>mlist("foo")</literal>, avec <literal>%foo_clear</literal>.
+ </revdescription>
+ </revision>
</revhistory>
</refsection>
</refentry>
</note>
</para>
<para>
- コマンド <code>clear</code> は存在しない変数も消去します,
- すなわち,
- <code>clear</code> は存在しない変数を存在するものとして
- 消去します.
+ If a name <emphasis>Var</emphasis> matches no variable, <literal>clear Var</literal>
+ does nothing silently.
</para>
+ <note>
+ <literal>clear()</literal> can be overloaded for any <literal>mlist("foo")</literal> type,
+ by defining a <literal>%foo_clear()</literal> macro. It will be called either when
+ <literal>clear</literal> is explicitly applied to any mlist of this type, or implicitly
+ when any mlist of this type is deleted when leaving the environment where it has been
+ defined.
+ </note>
</refsection>
<refsection>
<title>例</title>
clear(['a' 'b' 'c'])
isdef("a") | isdef("b") | isdef("c") // F
]]></programlisting>
+ <programlisting role="example"><![CDATA[
+function %foo_clear(o)
+ disp("deleted");
+endfunction
+
+value = mlist("foo");
+clear value // will print "deleted"
+]]></programlisting>
</refsection>
<refsection role="see also">
<title>参照</title>
<link linkend="predef">predef</link>
</member>
<member>
+ <link linkend="clearglobal">clearglobal</link>
+ </member>
+ <member>
<link linkend="funcprot">funcprot</link>
</member>
<member>
<link linkend="who">who</link>
</member>
+ <member>
+ <link linkend="xmlDelete">xmlDelete</link>
+ </member>
</simplelist>
</refsection>
<refsection>
Assignments like <literal>clear=1</literal> are no longer possible.
</revdescription>
</revision>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <literal>clear</literal> becomes overloadable for any
+ <literal>mlist("foo")</literal>, with <literal>%foo_clear()</literal>.
+ </revdescription>
+ </revision>
</revhistory>
</refsection>
</refentry>
</refnamediv>
<refsynopsisdiv>
<title>Seqüência de Chamamento</title>
- <synopsis>clear a</synopsis>
+ <synopsis>
+ clear a b c
+ clear('a', 'b', 'c')
+ clear(['a' 'b' 'c'])
+ </synopsis>
</refsynopsisdiv>
<refsection>
+ <title>Parâmetros</title>
+ <variablelist>
+ <varlistentry>
+ <term>a, b, c...</term>
+ <listitem>
+ <para>variables of any type and size, but not protected</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsection>
+ <refsection>
<title>Descrição</title>
<para>Este comando cancela variáveis que não estão protegidas. Ele remove
as variáveis nomeadas do ambiente. Por si só, <literal>clear</literal>
cancela <literal>a</literal> , mas define <literal>a</literal> como uma
matriz vazia.
</para>
+ <para>
+ If a name <emphasis>Var</emphasis> matches no variable, <literal>clear Var</literal>
+ does nothing silently.
+ </para>
+ <note>
+ <literal>clear()</literal> can be overloaded for any <literal>mlist("foo")</literal> type,
+ by defining a <literal>%foo_clear()</literal> macro. It will be called either when
+ <literal>clear</literal> is explicitly applied to any mlist of this type, or implicitly
+ when any mlist of this type is deleted when leaving the environment where it has been
+ defined.
+ </note>
+ </refsection>
+ <refsection>
+ <title>Exemplos</title>
+ <programlisting role="example"><![CDATA[
+a = 2;
+b = 3;
+c = 4;
+clear a
+isdef("a") // F
+isdef("b") // T
+clear("b");
+isdef("b") // F
+
+a = 2;
+b = 3;
+c = 4;
+clear(['a' 'b' 'c'])
+isdef("a") | isdef("b") | isdef("c") // F
+ ]]></programlisting>
+ <programlisting role="example"><![CDATA[
+function %foo_clear(o)
+ disp("deleted");
+endfunction
+
+value = mlist("foo");
+clear value // will print "deleted"
+]]></programlisting>
</refsection>
<refsection>
<title> Ver Também </title>
<link linkend="predef">predef</link>
</member>
<member>
+ <link linkend="clearglobal">clearglobal</link>
+ </member>
+ <member>
<link linkend="funcprot">funcprot</link>
</member>
<member>
<link linkend="who">who</link>
</member>
+ <member>
+ <link linkend="xmlDelete">xmlDelete</link>
+ </member>
</simplelist>
</refsection>
<refsection role="history">
Assignments like <literal>clear=1</literal> are no longer possible.
</revdescription>
</revision>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <literal>clear</literal> becomes overloadable for any
+ <literal>mlist("foo")</literal>, with <literal>%foo_clear()</literal>.
+ </revdescription>
+ </revision>
</revhistory>
</refsection>
</refentry>
<synopsis>
clear a b c
clear('a','b','c')
+ clear(['a' 'b' 'c'])
</synopsis>
</refsynopsisdiv>
<refsection>
<title>Аргументы</title>
<variablelist>
<varlistentry>
- <term>a,b,c...</term>
+ <term>a, b, c...</term>
<listitem>
- <para>переменные любого типа и размера, но не защищённые</para>
+ <para>переменные любого типа и размера, но не защищённые.</para>
</listitem>
</varlistentry>
</variablelist>
</note>
</para>
<para>
- Команда <code>clear</code> может работать с несуществующими переменными, т. е.
- <code>clear</code> уничтожает несуществующие переменные как если бы они существовали.
+ Если имя <emphasis>Var</emphasis> не совпадает ни с одной из переменных, то
+ <literal>clear Var</literal> тихо ничего не делает.
</para>
+ <note>
+ <literal>clear()</literal> может быть перегружена для любого типа <literal>mlist("foo")</literal>,
+ с помощью определения макроса <literal>%foo_clear()</literal>. Он вызывается либо когда
+ <literal>clear</literal> напрямую применяется к любому mlist-списку этого типа, либо неявно,
+ когда любой mlist-список этого типа удалён при выходе из окружения, в котором он был определён.
+ </note>
</refsection>
<refsection>
<title>Примеры</title>
<programlisting role="example"><![CDATA[
-a=2;
-b=3;
-c=4;
+a = 2;
+b = 3;
+c = 4;
clear a
isdef("a") // F
isdef("b") // T
clear("b");
isdef("b") // F
- ]]></programlisting>
+
+a = 2;
+b = 3;
+c = 4;
+clear(['a' 'b' 'c'])
+isdef("a") | isdef("b") | isdef("c") // F
+ ]]></programlisting>
+ <programlisting role="example"><![CDATA[
+function %foo_clear(o)
+ disp("deleted");
+endfunction
+
+value = mlist("foo");
+clear value // будет напечатано "deleted"
+]]></programlisting>
</refsection>
<refsection role="see also">
<title>Смотрите также</title>
<link linkend="predef">predef</link>
</member>
<member>
+ <link linkend="clearglobal">clearglobal</link>
+ </member>
+ <member>
<link linkend="funcprot">funcprot</link>
</member>
<member>
<link linkend="who">who</link>
</member>
+ <member>
+ <link linkend="xmlDelete">xmlDelete</link>
+ </member>
</simplelist>
</refsection>
<refsection role="history">
<revhistory>
<revision>
<revnumber>5.5.0</revnumber>
- <revdescription>Argument can now be a matrix of strings</revdescription>
+ <revdescription>Теперь аргумент может быть матрицей строк</revdescription>
</revision>
<revision>
<revnumber>6.0.0</revnumber>
<revdescription>
- <literal>clear</literal> is now protected:
- Assignments like <literal>clear=1</literal> are no longer possible.
+ Теперь <literal>clear</literal> защищена:
+ такие присвоения, как <literal>clear=1</literal>, более невозможны.
+ </revdescription>
+ </revision>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <literal>clear</literal> становится перегружаемой для любого
+ <literal>mlist("foo")</literal> с помощью <literal>%foo_clear()</literal>.
</revdescription>
</revision>
</revhistory>
src/cpp/convMatrixMethod.cpp \
src/cpp/deff.cpp \
src/cpp/display.cpp \
+ src/cpp/clear.cpp \
src/cpp/doubleExclam_invoke.cpp \
src/cpp/classExtract.cpp \
src/cpp/objectExtract.cpp \
sci_gateway/cpp/sci_percent_EObj_t.cpp \
sci_gateway/cpp/sci_doubleExclam_invoke_.cpp \
sci_gateway/cpp/sci_invoke_lu.cpp \
- sci_gateway/cpp/sci_percent_EObj_disp.cpp
+ sci_gateway/cpp/sci_percent_EObj_disp.cpp \
+ sci_gateway/cpp/sci_percent_EObj_clear.cpp
libsciexternal_objects_la_CFLAGS= \
-I$(srcdir)/includes/ \
src/cpp/libsciexternal_objects_algo_la-convMatrixMethod.lo \
src/cpp/libsciexternal_objects_algo_la-deff.lo \
src/cpp/libsciexternal_objects_algo_la-display.lo \
+ src/cpp/libsciexternal_objects_algo_la-clear.lo \
src/cpp/libsciexternal_objects_algo_la-doubleExclam_invoke.lo \
src/cpp/libsciexternal_objects_algo_la-classExtract.lo \
src/cpp/libsciexternal_objects_algo_la-objectExtract.lo \
sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_t.lo \
sci_gateway/cpp/libsciexternal_objects_la-sci_doubleExclam_invoke_.lo \
sci_gateway/cpp/libsciexternal_objects_la-sci_invoke_lu.lo \
- sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_disp.lo
+ sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_disp.lo \
+ sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo
am_libsciexternal_objects_la_OBJECTS = $(am__objects_3)
libsciexternal_objects_la_OBJECTS = \
$(am_libsciexternal_objects_la_OBJECTS)
sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_4_foo.Plo \
sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_5.Plo \
sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_a_foo.Plo \
+ sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Plo \
sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_d_foo.Plo \
sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_disp.Plo \
sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Plo \
src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-array.Plo \
src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-cast.Plo \
src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-classExtract.Plo \
+ src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Plo \
src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-compile.Plo \
src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-convMatrixMethod.Plo \
src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-deff.Plo \
src/cpp/convMatrixMethod.cpp \
src/cpp/deff.cpp \
src/cpp/display.cpp \
+ src/cpp/clear.cpp \
src/cpp/doubleExclam_invoke.cpp \
src/cpp/classExtract.cpp \
src/cpp/objectExtract.cpp \
sci_gateway/cpp/sci_percent_EObj_t.cpp \
sci_gateway/cpp/sci_doubleExclam_invoke_.cpp \
sci_gateway/cpp/sci_invoke_lu.cpp \
- sci_gateway/cpp/sci_percent_EObj_disp.cpp
+ sci_gateway/cpp/sci_percent_EObj_disp.cpp \
+ sci_gateway/cpp/sci_percent_EObj_clear.cpp
libsciexternal_objects_la_CFLAGS = \
-I$(srcdir)/includes/ \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libsciexternal_objects_algo_la-display.lo: \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libsciexternal_objects_algo_la-clear.lo: \
+ src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libsciexternal_objects_algo_la-doubleExclam_invoke.lo: \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libsciexternal_objects_algo_la-classExtract.lo: \
sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_disp.lo: \
sci_gateway/cpp/$(am__dirstamp) \
sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo: \
+ sci_gateway/cpp/$(am__dirstamp) \
+ sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
libsciexternal_objects.la: $(libsciexternal_objects_la_OBJECTS) $(libsciexternal_objects_la_DEPENDENCIES) $(EXTRA_libsciexternal_objects_la_DEPENDENCIES)
$(AM_V_CXXLD)$(libsciexternal_objects_la_LINK) -rpath $(pkglibdir) $(libsciexternal_objects_la_OBJECTS) $(libsciexternal_objects_la_LIBADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_4_foo.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_5.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_a_foo.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_d_foo.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_disp.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-array.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-cast.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-classExtract.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-compile.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-convMatrixMethod.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-deff.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciexternal_objects_algo_la-display.lo `test -f 'src/cpp/display.cpp' || echo '$(srcdir)/'`src/cpp/display.cpp
+src/cpp/libsciexternal_objects_algo_la-clear.lo: src/cpp/clear.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciexternal_objects_algo_la-clear.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Tpo -c -o src/cpp/libsciexternal_objects_algo_la-clear.lo `test -f 'src/cpp/clear.cpp' || echo '$(srcdir)/'`src/cpp/clear.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Tpo src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/cpp/clear.cpp' object='src/cpp/libsciexternal_objects_algo_la-clear.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciexternal_objects_algo_la-clear.lo `test -f 'src/cpp/clear.cpp' || echo '$(srcdir)/'`src/cpp/clear.cpp
+
src/cpp/libsciexternal_objects_algo_la-doubleExclam_invoke.lo: src/cpp/doubleExclam_invoke.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciexternal_objects_algo_la-doubleExclam_invoke.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-doubleExclam_invoke.Tpo -c -o src/cpp/libsciexternal_objects_algo_la-doubleExclam_invoke.lo `test -f 'src/cpp/doubleExclam_invoke.cpp' || echo '$(srcdir)/'`src/cpp/doubleExclam_invoke.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-doubleExclam_invoke.Tpo src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-doubleExclam_invoke.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_disp.lo `test -f 'sci_gateway/cpp/sci_percent_EObj_disp.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_EObj_disp.cpp
+sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo: sci_gateway/cpp/sci_percent_EObj_clear.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Tpo -c -o sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo `test -f 'sci_gateway/cpp/sci_percent_EObj_clear.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_EObj_clear.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Tpo sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sci_gateway/cpp/sci_percent_EObj_clear.cpp' object='sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciexternal_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libsciexternal_objects_la-sci_percent_EObj_clear.lo `test -f 'sci_gateway/cpp/sci_percent_EObj_clear.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_EObj_clear.cpp
+
mostlyclean-libtool:
-rm -f *.lo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_4_foo.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_5.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_a_foo.Plo
+ -rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_d_foo.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_disp.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-array.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-cast.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-classExtract.Plo
+ -rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-compile.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-convMatrixMethod.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-deff.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_4_foo.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_5.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_a_foo.Plo
+ -rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_clear.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_d_foo.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_disp.Plo
-rm -f sci_gateway/cpp/$(DEPDIR)/libsciexternal_objects_la-sci_percent_EObj_e.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-array.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-cast.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-classExtract.Plo
+ -rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-clear.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-compile.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-convMatrixMethod.Plo
-rm -f src/cpp/$(DEPDIR)/libsciexternal_objects_algo_la-deff.Plo
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_4_foo.cpp" />
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_5.cpp" />
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_a_foo.cpp" />
+ <ClCompile Include="sci_gateway\cpp\sci_percent_EObj_clear.cpp" />
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_disp.cpp" />
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_d_foo.cpp" />
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_e.cpp" />
<ClCompile Include="src\cpp\array.cpp" />
<ClCompile Include="src\cpp\cast.cpp" />
<ClCompile Include="src\cpp\classExtract.cpp" />
+ <ClCompile Include="src\cpp\clear.cpp" />
<ClCompile Include="src\cpp\compile.cpp" />
<ClCompile Include="src\cpp\convMatrixMethod.cpp" />
<ClCompile Include="src\cpp\deff.cpp" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_a_foo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="sci_gateway\cpp\sci_percent_EObj_clear.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="sci_gateway\cpp\sci_percent_EObj_d_foo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\cpp\convMatrixMethod.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\cpp\clear.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="src\cpp\deff.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ItemGroup>
<Xml Include="sci_gateway\external_objects_gateway.xml" />
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
static int getEnvId(char * fname, const int envId, void * pvApiCtx);
+ static int clear(char* fname, const int envId, void* pvApiCtx);
+
static int getsetOptions(char * fname, const int envId, ScilabAbstractOptionsSetter & setter, void * pvApiCtx);
static int addToClasspath(char * fname, const int envId, void * pvApiCtx);
static int getClassName(char * fname, const int envId, void * pvApiCtx);
- static int getEnvironmentName(char * fname, const int envId, void * pvApiCtx);
+ static int getEnvironmentName(char* fname, const int envId, void* pvApiCtx);
static int getEnvironmentInfos(char * fname, const int envId, void * pvApiCtx);
EXTERNAL_OBJECTS_SCILAB_IMPEXP int sci_invoke_lu(char * fname, void* pvApiCtx);
EXTERNAL_OBJECTS_SCILAB_IMPEXP int sci_doubleExclam_invoke_(char * fname, void* pvApiCtx);
EXTERNAL_OBJECTS_SCILAB_IMPEXP int sci_percent_EObj_disp(char * fname, void* pvApiCtx);
+EXTERNAL_OBJECTS_SCILAB_IMPEXP int sci_percent_EObj_clear(char* fname, void* pvApiCtx);
/*--------------------------------------------------------------------------*/
#endif /* __GW_EXTERNAL_OBJECTS_H__ */
/*--------------------------------------------------------------------------*/
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2018 - ESI Group - Clement DAVID
+ *
+ * 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.
+ *
+ */
+
+#include "ScilabGateway.hxx"
+
+extern "C" {
+#include "Scierror.h"
+#include "gw_external_objects.h"
+}
+
+using namespace org_modules_external_objects;
+
+int sci_percent_EObj_clear(char * fname, void* pvApiCtx)
+{
+ try
+ {
+ return ScilabGateway::clear(fname, 0, pvApiCtx);
+ }
+ catch (std::exception & e)
+ {
+ Scierror(999, _("%s: An error occurred: %s"), fname, e.what());
+ return 0;
+ }
+}
<gateway name="sci_invoke_lu" function="invoke_lu" type="0"/>
<gateway name="sci_doubleExclam_invoke_" function="!!_invoke_" type="0"/>
<gateway name="sci_percent_EObj_disp" function="%_EObj_disp" type="0"/>
+ <gateway name="sci_percent_EObj_clear" function="%_EObj_clear" type="0"/>
</module>
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2018 - ESI Group - Clement DAVID
+ *
+ * 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.
+ *
+ */
+
+#include "ScilabGateway.hxx"
+
+namespace org_modules_external_objects
+{
+
+int ScilabGateway::clear(char * fname, const int envId, void * pvApiCtx)
+{
+ SciErr err;
+ int * addr = 0;
+ int row = 0, col = 0;
+ int * id = 0;
+ int eId;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+
+ ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
+ ScilabGatewayOptions & options = env.getGatewayOptions();
+ OptionsHelper::setCopyOccurred(false);
+ ScilabObjects::initialization(env, pvApiCtx);
+ options.setIsNew(false);
+
+ err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+ if (err.iErr)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+ }
+
+ if (!ScilabObjects::isExternalObj(addr, pvApiCtx) && !ScilabObjects::isExternalClass(addr, pvApiCtx))
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: External Object expected."), 1);
+ }
+
+ eId = ScilabObjects::getEnvironmentId(addr, pvApiCtx);
+ if (eId != envId)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Incompatible External Object"));
+ }
+
+ err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id);
+ if (err.iErr)
+ {
+ throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+ }
+
+ env.removeobject(*id);
+
+ PutLhsVar();
+
+ return 0;
+}
+}
<title>Syntax</title>
<synopsis>
jremove()
- jremove(varName_1 [, varName_2, ...])
- jremove varName_1 [varName_2 ...]
- jremove(object_1 [, object_2 ...])
+ jremove(varName_1, varName_2, ...)
+ jremove varName_1 varName_2 ...
+ jremove(object_1 , object_2, ...)
</synopsis>
</refsynopsisdiv>
<refsection>
s = String.new("Hello world");
jremove s;
]]></programlisting>
+ <para/>
+ <programlisting role="example"><![CDATA[
+ jimport java.lang.String;
+
+ s = String.new("Hello world");
+ clear s;
+ ]]></programlisting>
</refsection>
<refsection role="see also">
<title>See also</title>
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>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revremark>
+ This function is optional, as <link linkend="clear">clear</link> or scope
+ closing will now release the associated Java object.
+ </revremark>
+ </revision>
</revhistory>
</refsection>
</refentry>
<title>呼び出し手順</title>
<synopsis>
-
jremove()
-
- jremove(varName_1 [, varName_2, ...])
-
- jremove varName_1 [varName_2 ...]
-
- jremove(object_1 [, object_2 ...])
-
+ jremove(varName_1, varName_2, ...)
+ jremove varName_1 varName_2 ...
+ jremove(object_1 , object_2, ...)
</synopsis>
</refsynopsisdiv>
s = String.new("Hello world");
jremove s;
]]></programlisting>
+ <para/>
+ <programlisting role="example"><![CDATA[
+ jimport java.lang.String;
+ s = String.new("Hello world");
+ clear s;
+ ]]></programlisting>
</refsection>
<refsection role="see also">
</revremark>
</revision>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revremark>
+ This function is optional, as <link linkend="clear">clear</link> or scope
+ closing will now release the associated Java object.
+ </revremark>
+ </revision>
</revhistory>
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2018 - ESI Group - Clement DAVID
+//
+// <-- NO CHECK REF -->
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+
+
+
+
+
+jimport java.lang.System
+
+klass = jcompile("Test", ["public class Test {"
+"static int counter = 0;"
+""
+"public Test() {"
+" counter++;"
+"}"
+""
+"protected void finalize() throws Throwable {"
+" counter--;"
+"}"
+""
+"public static double getClassCounter() {";
+" return counter;";
+"}"
+""
+"public double getCounter() {";
+" return counter;";
+"}"
+""
+"}"]);
+
+//
+// Allocate an object and manipulate it
+//
+
+a = klass.new();
+b = a;
+
+assert_checktrue(a.equals(b));
+assert_checkequal(a.counter, b.counter);
+
+counter = b.counter
+
+clear b
+System.gc();
+sleep(1,"s"); // to let the GC do the job
+
+assert_checkequal(a.counter, counter);
+clear a
+
+//
+// allocate some objects and clear all of them through Scilab mechanism
+//
+
+l = list();
+for i=1:100
+ l($+1) = klass.new();
+end
+
+System.gc();
+sleep(1,"s"); // to let the GC do the job
+
+allocated = klass.new();
+assert_checkequal(allocated.counter, 100+1);
+
+clear l
+System.gc();
+sleep(1,"s"); // to let the GC do the job
+
+assert_checkequal(allocated.counter, 1);
+
+clear allocated
+System.gc();
+sleep(1,"s"); // to let the GC do the job
+
+assert_checkequal(klass.getClassCounter(), 0);
+
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - ESI Group - Clement DAVID
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- NO CHECK REF -->
+//
+// =============================================================================
+
+jimport java.lang.Runtime
+jimport java.lang.String
+runtime = Runtime.getRuntime()
+
+// construct a big java.lang.String object
+LENGTH = 2**18;
+SIZEOF_STR = 36 + LENGTH*2; // per string on the Java side
+function str = alloc()
+ str = jnewInstance(String, int8(grand(1,LENGTH, "unf", 32, 124)));
+endfunction
+
+function F()
+ jimport java.lang.String
+ str = alloc()
+
+ jremove(str)
+ jremove(String)
+endfunction
+
+function G()
+ jimport java.lang.String
+ str = alloc()
+
+ // let the scope cleanup do the job
+ // jremove(str)
+ // jremove(String)
+endfunction
+
+color=1;
+N=100;
+for i=1:N
+ F();
+ times(color,i) = (runtime.totalMemory() - runtime.freeMemory());
+end
+color = color+1;
+for i=1:N
+ G();
+ times(color,i) = (runtime.totalMemory() - runtime.freeMemory());
+end
+color = color+1;
+for i=1:N
+ execstr("str"+string(i)+" = alloc();");
+ clear("str"+string(i));
+ times(color,i) = (runtime.totalMemory() - runtime.freeMemory());
+end
+color = color+1;
+for i=1:N
+ execstr("str"+string(i)+" = alloc();");
+ jremove("str"+string(i));
+ clear("str"+string(i));
+ times(color,i) = (runtime.totalMemory() - runtime.freeMemory());
+end
+color = color+1;
+for i=1:N
+ l = list(alloc());
+ clear("l");
+ times(color,i) = (runtime.totalMemory() - runtime.freeMemory());
+end
+
+// plot(times'); // to debug; this should look like GC-cycles
+M = double(max(times, "c"));
+assert_checktrue(M < (2 * N * SIZEOF_STR));
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2018 - ESI Group - Clement DAVID
+//
+// <-- NO CHECK REF -->
+// <-- CLI SHELL MODE -->
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+global cleared_b_called
+
+a = mlist(["my_type" "name"], "a");
+b = mlist(["my_type" "name"], "b");
+
+// %my_type_clear() will be called with "b"
+function %my_type_clear(v)
+ global cleared_b_called
+ assert_checkequal(cleared_b_called, [])
+ cleared_b_called = 1
+ assert_checkequal(v.name, "b")
+endfunction
+clear b
+assert_checkequal(cleared_b_called, 1)
+
+function foo1()
+ c = mlist(["my_type" "name"], "c");
+ // %my_type_clear() will be called with "c"
+endfunction
+function %my_type_clear(v)
+ assert_checkequal(v.name, "c")
+endfunction
+foo1()
+
+function foo2()
+ ac = a;
+ // %my_type_clear() will not be called
+endfunction
+function %my_type_clear(v)
+ pause
+endfunction
+foo2()
+
+// aa is a reference to a containing the same data
+aa = a;
+
+// %my_type_clear() will be called with "a" only once
+function %my_type_clear(v)
+ global cleared_a_called
+ assert_checkequal(cleared_a_called, [])
+ cleared_a_called = 1
+ assert_checkequal(v.name, "a")
+endfunction
+clear aa
+clear a
+
+