* Bug #14022 fixed - getscilabkeywords() was KO (+gateway what() added). 35/17235/3
Charlotte HECQUET [Wed, 23 Sep 2015 07:59:58 +0000 (09:59 +0200)]
Change-Id: I5ebde683894a7abf2f6aeb2818956ee55bbc943d

13 files changed:
scilab/CHANGES_6.0.X
scilab/modules/ast/src/cpp/symbol/libraries.cpp
scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/includes/core_gw.hxx
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_what.cpp [new file with mode: 0644]
scilab/modules/io/tests/nonreg_tests/bug_14022.dia.ref [new file with mode: 0644]
scilab/modules/io/tests/nonreg_tests/bug_14022.tst [new file with mode: 0644]
scilab/modules/types/etc/types.start
scilab/modules/types/macros/buildmacros.sce

index 45be4c0..e543915 100644 (file)
@@ -53,6 +53,8 @@ Scilab Bug Fixes
 
 * Bug #14020 fixed - Incorrect carriage return ascii code.
 
+* Bug #14022 fixed - getscilabkeywords() was KO (+gateway what() added).
+
 * Bug #14023 fixed - It was not possible to concatenate cells.
 
 * Bug #14025 fixed - head_comments did not take into account compiled functions.
index 3d3b9ad..4347780 100644 (file)
@@ -277,7 +277,10 @@ int Libraries::librarieslist(std::list<std::wstring>& lst)
 {
     for (auto lib : libs)
     {
-        lst.push_back(lib.first.getName());
+        if (lib.second->empty() == false)
+        {
+            lst.push_back(lib.first.getName());
+        }
     }
 
     return static_cast<int>(lst.size());
index 0d33220..857715c 100644 (file)
@@ -103,6 +103,7 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_funcprot.cpp \
        sci_gateway/cpp/sci_mode.cpp \
        sci_gateway/cpp/sci_typename.cpp \
+       sci_gateway/cpp/sci_what.cpp \
        sci_gateway/cpp/sci_where.cpp \
        sci_gateway/cpp/sci_getmemory.cpp \
        sci_gateway/cpp/sci_errclear.cpp \
index 503473a..fdb7767 100644 (file)
@@ -278,6 +278,7 @@ am__objects_5 = sci_gateway/cpp/libscicore_la-core_gw.lo \
        sci_gateway/cpp/libscicore_la-sci_funcprot.lo \
        sci_gateway/cpp/libscicore_la-sci_mode.lo \
        sci_gateway/cpp/libscicore_la-sci_typename.lo \
+       sci_gateway/cpp/libscicore_la-sci_what.lo \
        sci_gateway/cpp/libscicore_la-sci_where.lo \
        sci_gateway/cpp/libscicore_la-sci_getmemory.lo \
        sci_gateway/cpp/libscicore_la-sci_errclear.lo \
@@ -776,6 +777,7 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_funcprot.cpp \
        sci_gateway/cpp/sci_mode.cpp \
        sci_gateway/cpp/sci_typename.cpp \
+       sci_gateway/cpp/sci_what.cpp \
        sci_gateway/cpp/sci_where.cpp \
        sci_gateway/cpp/sci_getmemory.cpp \
        sci_gateway/cpp/sci_errclear.cpp \
@@ -1281,6 +1283,9 @@ sci_gateway/cpp/libscicore_la-sci_mode.lo:  \
 sci_gateway/cpp/libscicore_la-sci_typename.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_what.lo:  \
+       sci_gateway/cpp/$(am__dirstamp) \
+       sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/cpp/libscicore_la-sci_where.lo:  \
        sci_gateway/cpp/$(am__dirstamp) \
        sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
@@ -1369,6 +1374,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_sciargs.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_typename.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_warning.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_what.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_where.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_who.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_with_module.Plo@am__quote@
@@ -2004,6 +2010,13 @@ sci_gateway/cpp/libscicore_la-sci_typename.lo: sci_gateway/cpp/sci_typename.cpp
 @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_typename.lo `test -f 'sci_gateway/cpp/sci_typename.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_typename.cpp
 
+sci_gateway/cpp/libscicore_la-sci_what.lo: sci_gateway/cpp/sci_what.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_what.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_what.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_what.lo `test -f 'sci_gateway/cpp/sci_what.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_what.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_what.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_what.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_what.cpp' object='sci_gateway/cpp/libscicore_la-sci_what.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_what.lo `test -f 'sci_gateway/cpp/sci_what.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_what.cpp
+
 sci_gateway/cpp/libscicore_la-sci_where.lo: sci_gateway/cpp/sci_where.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_where.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_where.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_where.lo `test -f 'sci_gateway/cpp/sci_where.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_where.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_where.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_where.Plo
index 0dc1952..b891f78 100644 (file)
@@ -58,6 +58,7 @@ CPP_GATEWAY_PROTOTYPE(sci_ieee);
 CPP_GATEWAY_PROTOTYPE(sci_funcprot);
 CPP_GATEWAY_PROTOTYPE(sci_mode);
 CPP_GATEWAY_PROTOTYPE(sci_typename);
+CPP_GATEWAY_PROTOTYPE(sci_what);
 CPP_GATEWAY_PROTOTYPE(sci_where);
 CPP_GATEWAY_PROTOTYPE(sci_getmemory);
 CPP_GATEWAY_PROTOTYPE(sci_errclear);
index 02c0ba5..42402a5 100644 (file)
@@ -51,6 +51,7 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"typename", &sci_typename, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"funcprot", &sci_funcprot, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"mode", &sci_mode, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"what", &sci_what, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"where", &sci_where, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"getmemory", &sci_getmemory, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(types::Function::createFunction(L"errclear", &sci_errclear, MODULE_NAME));
index a160fcf..575ee7f 100644 (file)
     <ClCompile Include="sci_debug.cpp" />
     <ClCompile Include="sci_typename.cpp" />
     <ClCompile Include="sci_warning.cpp" />
+    <ClCompile Include="sci_what.cpp" />
     <ClCompile Include="sci_where.cpp" />
     <ClCompile Include="sci_who.cpp" />
     <ClCompile Include="sci_with_module.cpp" />
index 03b47d0..3e1f833 100644 (file)
     <ClCompile Include="sci_recursionlimit.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="sci_what.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_what.cpp b/scilab/modules/core/sci_gateway/cpp/sci_what.cpp
new file mode 100644 (file)
index 0000000..60227a0
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2015 - Scilab Enterprises - Charlotte HECQUET
+ *
+ * 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 "string.hxx"
+#include "scilabWrite.hxx"
+#include "configvariable.hxx"
+
+extern "C"
+{
+#include "localization.h"
+#include "Scierror.h"
+#include "commandwords.h"
+#include "getfunctionsname.h"
+#include "sciprint.h"
+#include "freeArrayOfString.h"
+}
+
+void printVarList(const char* title, const char* const* vars, int size)
+{
+    int w = ConfigVariable::getConsoleWidth();
+    int times = std::max(w / 24, 1);
+    sciprint("\n");
+    sciprint(_("%s:\n"), title);
+    sciprint("\n");
+    for (int i = 0; i < size; i++)
+    {
+        sciprint("%+24s ", vars[i]);
+        if ((i + 1) % times == 0)
+        {
+            sciprint("\n");
+        }
+    }
+    sciprint("\n");
+}
+
+const char fname[] = "what";
+types::Function::ReturnValue sci_what(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    char **pOutStringFctTmp = NULL;
+    int sizeFct = 0;
+    char **pOutStringCmdTmp = NULL;
+    int sizeCmd = 0;
+
+    // Check input arguments
+    if (in.size() != 0)
+    {
+        Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), fname, 0);
+        return types::Function::Error;
+    }
+
+    // Check output arguments
+    if (_iRetCount != 1 && _iRetCount != 2)
+    {
+        Scierror(78, _("%s: Wrong number of output argument(s): %d to %d expected.\n"), fname, 1, 2);
+        return types::Function::Error;
+    }
+
+    // Retrieve list of functions and list of keywords
+    pOutStringFctTmp = getFunctionsName(&sizeFct);
+    pOutStringCmdTmp = getcommandkeywords(&sizeCmd);
+
+    if (_iRetCount == 1)
+    {
+        // Print functions
+        printVarList("Internal Functions", pOutStringFctTmp, sizeFct);
+        // Print keywords
+        printVarList("Commands", pOutStringCmdTmp, sizeCmd);
+    }
+    else
+    {
+        // Scilab functions in first output argument
+        types::String* pOutStringFct = new types::String(sizeFct, 1);
+        pOutStringFct->set(pOutStringFctTmp);
+        out.push_back(pOutStringFct);
+
+        // Scilab commands in second output argument
+        types::String* pOutStringCmd = new types::String(sizeCmd, 1);
+        pOutStringCmd->set(pOutStringCmdTmp);
+        out.push_back(pOutStringCmd);
+    }
+
+    freeArrayOfString(pOutStringFctTmp, sizeFct);
+    freeArrayOfString(pOutStringCmdTmp, sizeCmd);
+    return types::Function::OK;
+}
diff --git a/scilab/modules/io/tests/nonreg_tests/bug_14022.dia.ref b/scilab/modules/io/tests/nonreg_tests/bug_14022.dia.ref
new file mode 100644 (file)
index 0000000..03f887e
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14022 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=14022
+//
+// <-- Short Description -->
+// getscilabkeywords() is k.o
+assert_checkequal(execstr("kw=getscilabkeywords()", "errcatch"), 0);
diff --git a/scilab/modules/io/tests/nonreg_tests/bug_14022.tst b/scilab/modules/io/tests/nonreg_tests/bug_14022.tst
new file mode 100644 (file)
index 0000000..70c7853
--- /dev/null
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14022 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=14022
+//
+// <-- Short Description -->
+// getscilabkeywords() is k.o
+
+assert_checkequal(execstr("kw=getscilabkeywords()", "errcatch"), 0);
index a52eb29..10a5263 100644 (file)
@@ -11,4 +11,4 @@
 
 //Load  functions libraries
 // =============================================================================
-load('SCI/modules/types/macros/lib');
+//load('SCI/modules/types/macros/lib');
index bd1b344..6562355 100644 (file)
@@ -8,5 +8,5 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
-genlib("typeslib","SCI/modules/types/macros",%f,%t);
+//genlib("typeslib","SCI/modules/types/macros",%f,%t);