api_scilab: struct() are not supported even if mapped as mlist() 75/19075/1
Clément DAVID [Thu, 9 Feb 2017 15:12:21 +0000 (16:12 +0100)]
Change-Id: Id0c8871f62f050da3b0e94737ff50db0242e3c9a

scilab/modules/api_scilab/src/cpp/api_stack_list.cpp

index f56c363..6d50ef5 100644 (file)
@@ -23,6 +23,7 @@
 #include "listundefined.hxx"
 #include "tlist.hxx"
 #include "mlist.hxx"
+#include "struct.hxx"
 #include "pointer.hxx"
 #include "polynom.hxx"
 #include "gatewaystruct.hxx"
@@ -102,13 +103,23 @@ SciErr getListItemNumber(void* _pvCtx, int* _piAddress, int* _piNbItem)
         return sciErr;
     }
 
+    types::InternalType* pIT = (types::InternalType*)_piAddress;
     types::List* pL = (types::List*)_piAddress;
     switch (iType)
     {
         case sci_list :
-        case sci_mlist :
         case sci_tlist :
             *_piNbItem = pL->getSize();
+        case sci_mlist :
+            // an mlist can also be a struct in Scilab 5 do not manage it in this API
+            if (pIT->isStruct())
+            {
+                *_piNbItem = 0;
+            }
+            else
+            {
+                *_piNbItem = pL->getSize();
+            }
             break;
         default :
             addErrorMessage(&sciErr, API_ERROR_INVALID_LIST_TYPE, _("%s: Invalid argument type, %s expected"), "getListItemNumber", _("list"));