Xcos gateways: fix 'opar' in model2blk() and pass blocks_link 50/17050/1
Paul Bignier [Tue, 21 Jul 2015 08:23:38 +0000 (10:23 +0200)]
 * sci_model2blk.cpp forgot to set 'oparsz' values

Change-Id: I7b590cbb242d4e0df6ad6f5669360bede9680522

scilab/modules/scicos/sci_gateway/cpp/sci_model2blk.cpp
scilab/modules/xcos/tests/unit_tests/blocks_link.dia.ref

index 670651d..769a91a 100644 (file)
@@ -989,6 +989,8 @@ types::Function::ReturnValue sci_model2blk(types::typed_list &in, int _iRetCount
             {
                 d = pIT->getAs<types::Double>();
                 const int size = d->getSize();
+                Block.oparsz[i] = d->getRows();
+                Block.oparsz[Block.nopar + i] = d->getCols();
                 const double* const r = d->get();
                 if (d->isComplex() == false)
                 {
@@ -1029,29 +1031,59 @@ types::Function::ReturnValue sci_model2blk(types::typed_list &in, int _iRetCount
                 switch (pIT->getType())
                 {
                     case types::InternalType::ScilabInt8:
+                    {
                         Block.opartyp[i] = 81;
-                        ret = alloc_and_set(pIT->getAs<types::Int8>(), &Block.oparptr[i]);
+                        types::Int8* pI8 = pIT->getAs<types::Int8>();
+                        ret = alloc_and_set(pI8, &Block.oparptr[i]);
+                        Block.oparsz[i] = pI8->getRows();
+                        Block.oparsz[Block.nopar + i] = pI8->getCols();
                         break;
+                    }
                     case types::InternalType::ScilabInt16:
+                    {
                         Block.opartyp[i] = 82;
-                        ret = alloc_and_set(pIT->getAs<types::Int16>(), &Block.oparptr[i]);
+                        types::Int16* pI16 = pIT->getAs<types::Int16>();
+                        ret = alloc_and_set(pI16, &Block.oparptr[i]);
+                        Block.oparsz[i] = pI16->getRows();
+                        Block.oparsz[Block.nopar + i] = pI16->getCols();
                         break;
+                    }
                     case types::InternalType::ScilabInt32:
+                    {
                         Block.opartyp[i] = 84;
-                        ret = alloc_and_set(pIT->getAs<types::Int32>(), &Block.oparptr[i]);
+                        types::Int32* pI32 = pIT->getAs<types::Int32>();
+                        ret = alloc_and_set(pI32, &Block.oparptr[i]);
+                        Block.oparsz[i] = pI32->getRows();
+                        Block.oparsz[Block.nopar + i] = pI32->getCols();
                         break;
+                    }
                     case types::InternalType::ScilabUInt8:
+                    {
                         Block.opartyp[i] = 811;
-                        ret = alloc_and_set(pIT->getAs<types::UInt8>(), &Block.oparptr[i]);
+                        types::UInt8* pUI8 = pIT->getAs<types::UInt8>();
+                        ret = alloc_and_set(pUI8, &Block.oparptr[i]);
+                        Block.oparsz[i] = pUI8->getRows();
+                        Block.oparsz[Block.nopar + i] = pUI8->getCols();
                         break;
+                    }
                     case types::InternalType::ScilabUInt16:
+                    {
                         Block.opartyp[i] = 812;
-                        ret = alloc_and_set(pIT->getAs<types::UInt16>(), &Block.oparptr[i]);
+                        types::UInt16* pUI16 = pIT->getAs<types::UInt16>();
+                        ret = alloc_and_set(pUI16, &Block.oparptr[i]);
+                        Block.oparsz[i] = pUI16->getRows();
+                        Block.oparsz[Block.nopar + i] = pUI16->getCols();
                         break;
+                    }
                     case types::InternalType::ScilabUInt32:
+                    {
                         Block.opartyp[i] = 814;
-                        ret = alloc_and_set(pIT->getAs<types::UInt32>(), &Block.oparptr[i]);
+                        types::UInt32* pUI32 = pIT->getAs<types::UInt32>();
+                        ret = alloc_and_set(pUI32, &Block.oparptr[i]);
+                        Block.oparsz[i] = pUI32->getRows();
+                        Block.oparsz[Block.nopar + i] = pUI32->getCols();
                         break;
+                    }
                     default :
                         ret = false;
                         break;
index 3d01e60..3c1c277 100644 (file)
 // <-- Short Description -->
 // Check that the simulation function should exists.
 defaultlibs = ["Branching",
-               "Linear",
-               "Misc",
-               "Sources",
-               "Events",
-               "Integerop",
-               "Matrixop",
-               "Nonlinear",
-               "Sinks",
-               "Threshold"];
+"Linear",
+"Misc",
+"Sources",
+"Events",
+"Integerop",
+"Matrixop",
+"Nonlinear",
+"Sinks",
+"Threshold"];
 defaultlibs  = defaultlibs + "lib";
 notTested = ["SUPER_f", "DSUPER", ..              // Specific blocks
-             "IN_f", "OUT_f", "INIMPL_f", "OUTIMPL_f",..
-             "CLKIN_f", "CLKINV_f", "CLKOUT_f", "CLKOUTV_f",..
-             "VirtualCLK0",..
-             "SPLIT_f", "CLKSPLIT_f",..
-             "TEXT_f", "PAL_f", "DEBUG", "DEBUG_SCICOS"..
-             "SIGNUM", "MAXMIN", "ABS_VALUE", ..    // buggy blocks
-             "PENDULUM_ANIM", "BPLATFORM", "MBLOCK", ..
-             "TKSCALE", "BARXY", ..
-             "SLIDER_f", "WFILE_f", ..            // Deprecated blocks
-             "MPBLOCK", "fortran_block", ..       // blocks with code generation
-             "CBLOCK", "scifunc_block", "scifunc_block_m"];
+"IN_f", "OUT_f", "INIMPL_f", "OUTIMPL_f",..
+"CLKIN_f", "CLKINV_f", "CLKOUT_f", "CLKOUTV_f",..
+"VirtualCLK0",..
+"SPLIT_f", "CLKSPLIT_f",..
+"TEXT_f", "PAL_f", "DEBUG", "DEBUG_SCICOS"..
+"SIGNUM", "MAXMIN", "ABS_VALUE", ..    // buggy blocks
+"PENDULUM_ANIM", "BPLATFORM", "MBLOCK", ..
+"TKSCALE", "BARXY", ..
+"SLIDER_f", "WFILE_f", "func_block" ..  // Deprecated blocks
+"MPBLOCK", "fortran_block", ..       // blocks with code generation
+"CBLOCK", "scifunc_block", "scifunc_block_m"];
 invalidFunctions = unique(gsort(["csuper", "junk", ..
-                "clkfrom", "clkgoto", ..
-                "goto", "from", "gotomo", "frommo", ..
-                "limpsplit", "sampleclk", ..
-                "gototagvisibility", "clkgototagvisibility", "gototagvisibilitymo"]));
+"clkfrom", "clkgoto", ..
+"goto", "from", "gotomo", "frommo", ..
+"limpsplit", "sampleclk", ..
+"gototagvisibility", "clkgototagvisibility", "gototagvisibilitymo"]));
 funcprot(0);
 ilib_verbose(0);
 // Stubbing the x_mdialog method
@@ -49,19 +49,19 @@ function [result]=x_mdialog(title, labelsv, labelsh, default_inputs_vector)
         default_inputs_vector = labelsh;
         result = x_dialog(labelsv, default_inputs_vector);
     elseif rhs == 4 then
-        vSize = size(labelsv, '*');
-        hSize = size(labelsh, '*');
+        vSize = size(labelsv, "*");
+        hSize = size(labelsh, "*");
         if size(default_inputs_vector) <> [vSize, hSize] then
-            mprintf("%s\nError: dialog wrong size.", cmd); bugmes();quit;end;
+        mprintf("%s\nError: dialog wrong size.", cmd); bugmes();quit;end;
         result = default_inputs_vector;
     else
-        mprintf("%s\nError: dialog wrong size.", cmd); bugmes();quit;end;
+    mprintf("%s\nError: dialog wrong size.", cmd); bugmes();quit;end;
 endfunction
 // Stubbing the x_dialog method
 // checking it's arguments size only
 function [result]=x_dialog(labels, default_inputs_vector)
     if(or(size(labels) <> size(default_inputs_vector))) then
-        mprintf("%s\nError: dialog wrong size.", cmd); bugmes();quit;end;
+    mprintf("%s\nError: dialog wrong size.", cmd); bugmes();quit;end;
     result = default_inputs_vector;
 endfunction
 // Stubbing the dialog method
@@ -72,7 +72,7 @@ endfunction
 // Stubbing the edit_curv method
 function [xx, yy, ok, gc] = edit_curv(xx, yy,  axis, args, gc)
     ok = %T;
-    if ~exists("gc", 'l') then
+    if ~exists("gc", "l") then
         rect=[0 0 1 1];
         axisdata=[2 10 2 10];
         gc = list(rect, axisdata);
@@ -104,20 +104,20 @@ for i = 1:size(defaultlibs,"*")
         interfunction = macros(j);
         // Not tested blocks (Xcos customs)
         if or(interfunction == notTested) then
-          continue;
+            continue;
         end
         // Check for signature
         vars=macrovar(evstr(interfunction));
         if or([size(vars(1)) <> [3 1] , size(vars(2)) <> [3 1]]) then
-          continue;
+            continue;
         end
         // New Scilab instance
         cmd = "scs_m=" + interfunction + "(""define"", [], []);";
         if execstr(cmd, "errcatch")<>0 then
-            mprintf("%s\n",cmd); bugmes();quit;end
+        mprintf("%s\n",cmd); bugmes();quit;end
         cmd = "scs_m=" + interfunction + "(""set"", scs_m, []);";
         if execstr(cmd, "errcatch")<>0 then
-            mprintf("%s\n",cmd); bugmes();quit;end
+        mprintf("%s\n",cmd); bugmes();quit;end
         // calling the model2blk will locate the funptr are error on
         if ~or(scs_m.model.sim == invalidFunctions) then
             model2blk(configure(scs_m.model));