errclear plugged. 14/13514/3
Cedric Delamarre [Thu, 23 Jan 2014 09:12:50 +0000 (10:12 +0100)]
cos("e");
errclear()
lasterror()

cos("e");
errclear(246)
lasterror()

cos("e");
errclear(999)
lasterror()

Change-Id: Ic8ded9026b2f16db312c0e0a30c7ee34d77a2d3b

scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/includes/gw_core.h
scilab/modules/core/sci_gateway/cpp/core_gw.cpp
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj.filters
scilab/modules/core/sci_gateway/cpp/sci_errclear.cpp [new file with mode: 0644]

index d2f746d..f60bcd2 100644 (file)
@@ -164,7 +164,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mode.cpp \
        sci_gateway/cpp/sci_typename.cpp \
        sci_gateway/cpp/sci_where.cpp \
-       sci_gateway/cpp/sci_getmemory.cpp
+       sci_gateway/cpp/sci_getmemory.cpp \
+       sci_gateway/cpp/sci_errclear.cpp
 
 libscicore_la_CPPFLAGS = \
 -I$(srcdir)/includes/ \
index ccc7b8d..b95c817 100644 (file)
@@ -308,7 +308,8 @@ am__objects_5 = sci_gateway/cpp/libscicore_la-core_gw.lo \
        sci_gateway/cpp/libscicore_la-sci_mode.lo \
        sci_gateway/cpp/libscicore_la-sci_typename.lo \
        sci_gateway/cpp/libscicore_la-sci_where.lo \
-       sci_gateway/cpp/libscicore_la-sci_getmemory.lo
+       sci_gateway/cpp/libscicore_la-sci_getmemory.lo \
+       sci_gateway/cpp/libscicore_la-sci_errclear.lo
 am_libscicore_la_OBJECTS = $(am__objects_4) $(am__objects_5)
 libscicore_la_OBJECTS = $(am_libscicore_la_OBJECTS)
 libscicore_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
@@ -846,7 +847,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_mode.cpp \
        sci_gateway/cpp/sci_typename.cpp \
        sci_gateway/cpp/sci_where.cpp \
-       sci_gateway/cpp/sci_getmemory.cpp
+       sci_gateway/cpp/sci_getmemory.cpp \
+       sci_gateway/cpp/sci_errclear.cpp
 
 libscicore_la_CPPFLAGS = -I$(srcdir)/includes/ -I$(srcdir)/src/c/ \
        -I$(srcdir)/src/cpp/ \
@@ -1476,6 +1478,9 @@ sci_gateway/cpp/libscicore_la-sci_where.lo:  \
 sci_gateway/cpp/libscicore_la-sci_getmemory.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_errclear.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscicore.la: $(libscicore_la_OBJECTS) $(libscicore_la_DEPENDENCIES) $(EXTRA_libscicore_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(libscicore_la_LINK) $(am_libscicore_la_rpath) $(libscicore_la_OBJECTS) $(libscicore_la_LIBADD) $(LIBS)
@@ -1510,6 +1515,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_banner.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clear.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clearglobal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_errclear.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_error.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_exists.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_exit.Plo@am__quote@
@@ -2347,6 +2353,13 @@ sci_gateway/cpp/libscicore_la-sci_getmemory.lo: sci_gateway/cpp/sci_getmemory.cp
 @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) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_getmemory.lo `test -f 'sci_gateway/cpp/sci_getmemory.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getmemory.cpp
 
+sci_gateway/cpp/libscicore_la-sci_errclear.lo: sci_gateway/cpp/sci_errclear.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_errclear.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_errclear.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_errclear.lo `test -f 'sci_gateway/cpp/sci_errclear.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_errclear.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_errclear.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_errclear.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_errclear.cpp' object='sci_gateway/cpp/libscicore_la-sci_errclear.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) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_errclear.lo `test -f 'sci_gateway/cpp/sci_errclear.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_errclear.cpp
+
 .f.o:
        $(AM_V_F77)$(F77COMPILE) -c -o $@ $<
 
index c2afe2a..b147ae6 100644 (file)
@@ -57,5 +57,6 @@ CPP_GATEWAY_PROTOTYPE(sci_mode);
 CPP_GATEWAY_PROTOTYPE(sci_typename);
 CPP_GATEWAY_PROTOTYPE(sci_where);
 CPP_GATEWAY_PROTOTYPE(sci_getmemory);
+CPP_GATEWAY_PROTOTYPE(sci_errclear);
 
 #endif /* __CORE_GW_HXX__ */
index 4e09c02..9e85bdd 100644 (file)
@@ -26,7 +26,7 @@ int C2F(sci_resume)(char *fname, unsigned long fname_len);
 int C2F(sci_return)(char *fname, unsigned long fname_len);
 int C2F(sci_isdef)(char *fname, unsigned long fname_len);
 int C2F(sci_errcatch)(char *fname, unsigned long fname_len);
-int C2F(sci_errclear)(char *fname, unsigned long fname_len);
+//int C2F(sci_errclear)(char *fname, unsigned long fname_len); -> C++
 int C2F(sci_iserror)(char *fname, unsigned long fname_len);
 C_GATEWAY_PROTOTYPE(C2F(sci_predef));
 int C2F(sci_clearfun)(char *fname, unsigned long fname_len);
index 14ab867..778cd57 100644 (file)
@@ -56,5 +56,6 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"mode", &sci_mode, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"where", &sci_where, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"getmemory", &sci_getmemory, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"errclear", &sci_errclear, MODULE_NAME));
     return 1;
 }
index 7d33568..f7dc29f 100644 (file)
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="sci_errclear.cpp" />
     <ClCompile Include="sci_format.cpp" />
     <ClCompile Include="sci_funcprot.cpp" />
     <ClCompile Include="sci_getmemory.cpp" />
index 11d6639..43fbf49 100644 (file)
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="sci_where.cpp">
-    <Filter>Source Files</Filter>
+      <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="sci_getmemory.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_errclear.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\banner.hxx">
     <Library Include="..\..\..\..\bin\libintl.lib" />
     <Library Include="..\..\..\..\bin\libxml2.lib" />
   </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_errclear.cpp b/scilab/modules/core/sci_gateway/cpp/sci_errclear.cpp
new file mode 100644 (file)
index 0000000..bb2d9dc
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "core_gw.hxx"
+#include "configvariable.hxx"
+#include "double.hxx"
+#include "function.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+#include "localization.h"
+}
+/*--------------------------------------------------------------------------*/
+types::Function::ReturnValue sci_errclear(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    /* Check the number of input argument */
+    if (in.size() > 1)
+    {
+        Scierror(999, _("%s: Wrong number of input arguments: %d or %d expected.\n"), "errclear" , 0, 1);
+        return types::Function::Error;
+    }
+
+    /* Check the number of output argument */
+    if (_iRetCount != 1)
+    {
+        Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "errclear", 0);
+        return types::Function::Error;
+    }
+
+    if (in.size() == 0)
+    {
+        ConfigVariable::clearLastError();
+    }
+    else
+    {
+        if (in[0]->isDouble() == false)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: Scalar expected.\n"), "errclear", 1);
+            return types::Function::Error;
+        }
+
+        types::Double* pDblIn = in[0]->getAs<types::Double>();
+
+        if (pDblIn->isScalar() == false)
+        {
+            Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), "errclear", 1);
+            return types::Function::Error;
+        }
+
+        int iScilabError = (int)pDblIn->get(0);
+        if (pDblIn->get(0) != (double)iScilabError)
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: An integer value expected.\n"), "errclear", 1);
+            return types::Function::Error;
+        }
+
+        if(iScilabError == ConfigVariable::getLastErrorNumber())
+        {
+            ConfigVariable::clearLastError();
+        }
+    }
+
+    return types::Function::OK;
+}
+/*--------------------------------------------------------------------------*/