* Bug 15876 fixed: now struct and cells are reported native in browsevar 22/20622/6
Stéphane Mottelet [Fri, 16 Nov 2018 17:56:46 +0000 (18:56 +0100)]
http://bugzilla.scilab.org/show_bug.cgi?id=15876

Also repairs the display of macros and simplifies the terminology, i.e.
only "User function" are reported.

Screenshot:

http://bugzilla.scilab.org/attachment.cgi?id=4844

Change-Id: I2c48a185cd9fdda706e11cce30758915a83e4eed

scilab/modules/ast/src/cpp/symbol/variables.cpp
scilab/modules/types/src/java/org/scilab/modules/types/ScilabTypeEnumDescription.java
scilab/modules/ui_data/locales/fr_FR.po
scilab/modules/ui_data/src/cpp/BrowseVarManager.cpp
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/BrowseVar.java
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/utils/UiDataMessages.java
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SwingScilabVariableBrowser.java

index d83addd..f1da237 100644 (file)
@@ -430,9 +430,7 @@ int Variables::getVarsToVariableBrowser(std::list<Variable*>& lst)
         if (var.second->empty() == false)
         {
             types::InternalType* pIT = var.second->top()->m_pIT;
-            if (pIT &&
-                    pIT->isMacro() == false &&
-                    pIT->isMacroFile() == false &&
+            if (pIT && pIT->isMacroFile() == false &&
                     pIT->isFunction() == false)
             {
                 lst.push_back(var.second);
index 4e7b318..4620d83 100644 (file)
@@ -42,9 +42,8 @@ public class ScilabTypeEnumDescription {
                 case sci_strings:
                     return Messages.gettext("String");
                 case sci_u_function:
-                    return Messages.gettext("User function");
                 case sci_c_function:
-                    return Messages.gettext("Compiled function");
+                    return Messages.gettext("User function");
                 case sci_lib:
                     return Messages.gettext("Function library");
                 case sci_list:
@@ -53,6 +52,10 @@ public class ScilabTypeEnumDescription {
                     return Messages.gettext("Tlist");
                 case sci_mlist:
                     return Messages.gettext("Mlist");
+                case sci_struct:
+                    return Messages.gettext("Struct");
+                case sci_cell:
+                    return Messages.gettext("Cell");
                 case sci_pointer:
                     return Messages.gettext("Pointer");
                 case sci_implicit_poly:
index 2813e51..e4b00fb 100644 (file)
@@ -147,8 +147,8 @@ msgstr "Handles graphiques"
 msgid "String"
 msgstr "Chaîne"
 
-msgid "Un-compiled function"
-msgstr "Fonction non compilée"
+msgid "User function"
+msgstr "Fonction utilisateur"
 
 msgid "Compiled function"
 msgstr "Fonction compilée"
index 26b22d1..cca5d09 100644 (file)
@@ -45,14 +45,17 @@ extern "C"
 #include "freeArrayOfString.h"
 #include "os_string.h"
 #include "api_scilab.h"
+#include "sci_types.h"
+#include "sciprint.h"
 }
 
 #define N_A             "N/A"
 #define EMPTY_MATRIX    "[ ]"
+#define EMPTY_CELL      "{}"
+#define EMPTY_LIST      "()"
 #define LOCAL_STR       "local"
 #define GLOBAL_STR      "global"
 #define INHERITED_STR   "inherited"
-#define STRUCT_STR      "st"
 #define NEG_INF_STR     "-Inf"
 #define INF_STR         "Inf"
 #define NAN_STR         "NaN"
@@ -143,27 +146,36 @@ void SetBrowseVarData()
             pstAllVariableVisibility[i] = os_strdup(LOCAL_STR);
         }
 
-        // type
+        // type with Scilab < 6 compatibility (structs and cells have type 17)
         err = getVarType(NULL, (int*)pIT, &piAllVariableTypes[i]);
-        if (!err.iErr)
-        {
-            piAllVariableBytes[i] = 0;
-            err = getVarDimension(NULL, (int*)pIT, &nbRows, &nbCols);
-        }
 
-        if (err.iErr)
+        if (pIT->isArrayOf() || pIT->isSparse())
         {
-            pstAllVariableSizes[i] = os_strdup(N_A);
+            int nbRows = pIT->getAs<types::GenericType>()->getRows();
+            int nbCols = pIT->getAs<types::GenericType>()->getCols();
+            piAllVariableNbRows[i] = nbRows;
+            piAllVariableNbCols[i] = nbCols;                
+            if (nbRows*nbCols == 0)
+            {
+                pstAllVariableSizes[i] = pIT->isCell() ? os_strdup(EMPTY_CELL) : os_strdup(EMPTY_MATRIX);                
+            }
+            else if (pIT->isArrayOf())
+            {
+                pstAllVariableSizes[i] = valueToDisplay(pIT);
+            }
+            else
+            {
+                std::string sizeString = std::to_string(nbRows) + "x" + std::to_string(nbCols);
+                pstAllVariableSizes[i] =  os_strdup(sizeString.data());
+            }
         }
-        else if (nbRows * nbCols == 0)
+        else if (pIT->isMList() || pIT->isTList() || pIT->isList() )
         {
-            pstAllVariableSizes[i] = os_strdup(EMPTY_MATRIX);
+            pstAllVariableSizes[i] = pIT->getAs<types::List>()->getSize() == 0 ? os_strdup(EMPTY_LIST) : os_strdup(N_A);
         }
         else
         {
-            pstAllVariableSizes[i] = valueToDisplay(pIT);
-            piAllVariableNbRows[i] = nbRows;
-            piAllVariableNbCols[i] = nbCols;
+            pstAllVariableSizes[i] =  os_strdup(N_A);
         }
 
         if (piAllVariableTypes[i] == sci_ints)
@@ -203,7 +215,13 @@ void SetBrowseVarData()
         }
         else if (pIT->isStruct())
         {
-            pstAllVariableListTypes[i] = os_strdup(STRUCT_STR);
+            piAllVariableTypes[i] = sci_struct;
+            pstAllVariableListTypes[i] = os_strdup("");
+        }
+        else if (pIT->isCell())
+        {
+            piAllVariableTypes[i] = sci_cell;
+            pstAllVariableListTypes[i] = os_strdup("");
         }
         else
         {
@@ -222,36 +240,6 @@ void SetBrowseVarData()
         ++i;
     }
 
-    for (auto lib : lstLibs)
-    {
-        //get top level value
-        symbol::ScopedLibrary* sl = lib->top();
-
-        // get name
-        pstAllVariableNames[i] = wide_string_to_UTF8(lib->getSymbol().getName().data());
-
-        // get visibility
-        if (sl->m_iLevel != iLevel)
-        {
-            pstAllVariableVisibility[i] = os_strdup(INHERITED_STR);
-        }
-        else
-        {
-            pstAllVariableVisibility[i] = os_strdup(LOCAL_STR);
-        }
-        //type
-        piAllVariableTypes[i] = sci_lib;
-
-        piAllVariableBytes[i] = 0;
-        pstAllVariableSizes[i] = os_strdup(N_A);
-        piAllVariableIntegerTypes[i] = -1;
-        pstAllVariableListTypes[i] = os_strdup("");
-        piAllVariableFromUser[i] = FALSE;
-        piAllVariableNbRows[i] = 1;
-        piAllVariableNbCols[i] = 1;
-
-        ++i;
-    }
     // Launch Java Variable Browser through JNI
     BrowseVar::setVariableBrowserData(getScilabJavaVM(),
                                       pstAllVariableNames, iLocalVariablesUsed,
index a922b08..6d1b6ee 100644 (file)
@@ -68,6 +68,7 @@ public class BrowseVar {
     private static final ImageIcon LIST_ICON = new ImageIcon(FindIconHelper.findIcon("list"));
     private static final ImageIcon TLIST_ICON = new ImageIcon(FindIconHelper.findIcon("tlist"));
     private static final ImageIcon MLIST_ICON = new ImageIcon(FindIconHelper.findIcon("mlist"));
+    private static final ImageIcon CELL_ICON = new ImageIcon(FindIconHelper.findIcon("cell"));
     private static final ImageIcon USER_ICON = new ImageIcon(FindIconHelper.findIcon("user"));
     private static final ImageIcon FPTR_ICON = new ImageIcon(FindIconHelper.findIcon("fptr"));
 
@@ -109,7 +110,10 @@ public class BrowseVar {
             case 16:
                 return TLIST_ICON;
             case 17:
+            case 18:
                 return MLIST_ICON;
+            case 19:
+                return CELL_ICON;
             case 128:
                 return USER_ICON;
             case 130:
index 033c793..a6f84d9 100644 (file)
@@ -46,8 +46,8 @@ public final class UiDataMessages {
     public static final String INTEGER = Messages.gettext("Integer");
     public static final String GRAPHIC_HANDLES = Messages.gettext("Graphic handles");
     public static final String STRING = Messages.gettext("String");
-    public static final String UNCOMPILED_FUNC = Messages.gettext("Un-compiled function");
-    public static final String COMPILED_FUNC = Messages.gettext("Compiled function");
+    public static final String UNCOMPILED_FUNC = Messages.gettext("User function");
+    public static final String COMPILED_FUNC = Messages.gettext("User function");
     public static final String FUNCTIONLIB = Messages.gettext("Function library");
     public static final String LIST = Messages.gettext("List");
     public static final String TLIST = Messages.gettext("Tlist");
index 1ab5d65..f7ff746 100644 (file)
@@ -78,7 +78,6 @@ import org.scilab.modules.ui_data.actions.SparseBoolFilteringAction;
 import org.scilab.modules.ui_data.actions.SparseFilteringAction;
 import org.scilab.modules.ui_data.actions.StringFilteringAction;
 import org.scilab.modules.ui_data.actions.TListFilteringAction;
-import org.scilab.modules.ui_data.actions.UncompiledFunctionFilteringAction;
 import org.scilab.modules.ui_data.datatable.SwingTableModel;
 import org.scilab.modules.ui_data.utils.UiDataMessages;
 import org.scilab.modules.ui_data.variableeditor.actions.ExportToCsvAction;
@@ -116,7 +115,6 @@ public final class SwingScilabVariableBrowser extends SwingScilabDockablePanel i
     private CheckBoxMenuItem filterIntegerCheckBox;
     private CheckBoxMenuItem filterGraphicHandlesCheckBox;
     private CheckBoxMenuItem filterStringCheckBox;
-    private CheckBoxMenuItem filterUncompiledFuncCheckBox;
     private CheckBoxMenuItem filtercompiledFuncCheckBox;
     private CheckBoxMenuItem filterFunctionLibCheckBox;
     private CheckBoxMenuItem filterListCheckBox;
@@ -493,9 +491,6 @@ public final class SwingScilabVariableBrowser extends SwingScilabDockablePanel i
         filterGraphicHandlesCheckBox.setChecked(true);
         filterMenu.add(filterGraphicHandlesCheckBox);
 
-        filterUncompiledFuncCheckBox = UncompiledFunctionFilteringAction.createCheckBoxMenu();
-        filterMenu.add(filterUncompiledFuncCheckBox);
-
         filtercompiledFuncCheckBox = CompiledFunctionFilteringAction.createCheckBoxMenu();
         filterMenu.add(filtercompiledFuncCheckBox);
 
@@ -586,10 +581,6 @@ public final class SwingScilabVariableBrowser extends SwingScilabDockablePanel i
             filteredValues.add(ScilabTypeEnum.sci_handles);
         }
 
-        if (!filterUncompiledFuncCheckBox.isChecked()) {
-            filteredValues.add(ScilabTypeEnum.sci_u_function);
-        }
-
         if (!filtercompiledFuncCheckBox.isChecked()) {
             filteredValues.add(ScilabTypeEnum.sci_c_function);
         }