* Bug #14038 fixed - Encoded integers were no longer accepted for list extraction. 53/17153/4
Charlotte HECQUET [Wed, 2 Sep 2015 14:14:53 +0000 (16:14 +0200)]
Change-Id: Id2c3af749258a548597071222fb8e4c10deb6672

scilab/CHANGES_6.0.X
scilab/modules/ast/src/cpp/types/types_tools.cpp
scilab/modules/ast/tests/nonreg_tests/bug_14038.dia.ref [new file with mode: 0644]
scilab/modules/ast/tests/nonreg_tests/bug_14038.tst [new file with mode: 0644]

index 2d65e69..0753caf 100644 (file)
@@ -37,6 +37,8 @@ Scilab Bug Fixes
 
 * Bug #14036 fixed - tag and user_data properties were not displayed and not documented for light entity.
 
+* Bug #14038 fixed - Encoded integers were no longer accepted for list extraction.
+
 * Bug #14040 fixed - graphic property setting fails when using array of handles
 
 * Bug #14049 fixed - genlib hangs if an unexpected endfunction occurs.
index bcbee3c..c05a6e3 100644 (file)
@@ -40,6 +40,19 @@ double getIndex(T* val)
     return static_cast<double>(p[0]);
 }
 
+template<typename T>
+Double* convertIndex(T* pI)
+{
+    int size = pI->getSize();
+    Double* pCurrentArg = new Double(1, size);
+    double* pdbl = pCurrentArg->get();
+    for (int l = 0; l < size; l++)
+    {
+        pdbl[l] = static_cast<double>(pI->get(l));
+    }
+    return pCurrentArg;
+}
+
 double getIndex(InternalType* val)
 {
     switch (val->getType())
@@ -589,6 +602,52 @@ int checkIndexesArguments(InternalType* _pRef, typed_list* _pArgsIn, typed_list*
             }
             pCurrentArg = pDbl;
         }
+        else if (pIT->isInt())
+        {
+            switch (pIT->getType())
+            {
+                case InternalType::ScilabInt8:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<Int8>());
+                    break;
+                }
+                case InternalType::ScilabInt16:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<Int16>());
+                    break;
+                }
+                case InternalType::ScilabInt32:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<Int32>());
+                    break;
+                }
+                case InternalType::ScilabInt64:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<Int64>());
+                    break;
+                }
+                case InternalType::ScilabUInt8:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<UInt8>());
+                    break;
+                }
+                case InternalType::ScilabUInt16:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<UInt16>());
+                    break;
+                }
+                case InternalType::ScilabUInt32:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<UInt32>());
+                    break;
+                }
+                case InternalType::ScilabUInt64:
+                {
+                    pCurrentArg = convertIndex(pIT->getAs<UInt64>());
+                    break;
+                }
+            }
+        }
 
         if (bDeleteNeeded)
         {
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_14038.dia.ref b/scilab/modules/ast/tests/nonreg_tests/bug_14038.dia.ref
new file mode 100644 (file)
index 0000000..fafc470
--- /dev/null
@@ -0,0 +1,53 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14038 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14038
+//
+// <-- Short Description -->
+// Encoded integers are no longer accepted for list extraction
+L=list(%pi,12,%s,14);
+// Signed, one input argument
+assert_checkequal(L(int8(1)), L(1));
+assert_checkequal(L(int16(1)), L(1));
+assert_checkequal(L(int32(1)), L(1));
+assert_checkequal(L(int64(1)), L(1));
+// Unsigned, one input argument
+assert_checkequal(L(uint8(1)), L(1));
+assert_checkequal(L(uint16(1)), L(1));
+assert_checkequal(L(uint32(1)), L(1));
+assert_checkequal(L(uint64(1)), L(1));
+[ref1, ref2] = L([1, 2]);
+// Signed, two input arguments
+[res1, res2] = L([int8(1), int8(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([int16(1), int16(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([int32(1), int32(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([int64(1), int64(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+// Unsigned, two input arguments
+[res1, res2] = L([uint8(1), uint8(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([uint16(1), uint16(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([uint32(1), uint32(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([uint64(1), uint64(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_14038.tst b/scilab/modules/ast/tests/nonreg_tests/bug_14038.tst
new file mode 100644 (file)
index 0000000..9389934
--- /dev/null
@@ -0,0 +1,55 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14038 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14038
+//
+// <-- Short Description -->
+// Encoded integers are no longer accepted for list extraction
+
+L=list(%pi,12,%s,14);
+// Signed, one input argument
+assert_checkequal(L(int8(1)), L(1));
+assert_checkequal(L(int16(1)), L(1));
+assert_checkequal(L(int32(1)), L(1));
+assert_checkequal(L(int64(1)), L(1));
+// Unsigned, one input argument
+assert_checkequal(L(uint8(1)), L(1));
+assert_checkequal(L(uint16(1)), L(1));
+assert_checkequal(L(uint32(1)), L(1));
+assert_checkequal(L(uint64(1)), L(1));
+
+[ref1, ref2] = L([1, 2]);
+// Signed, two input arguments
+[res1, res2] = L([int8(1), int8(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([int16(1), int16(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([int32(1), int32(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([int64(1), int64(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+// Unsigned, two input arguments
+[res1, res2] = L([uint8(1), uint8(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([uint16(1), uint16(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([uint32(1), uint32(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);
+[res1, res2] = L([uint64(1), uint64(2)]);
+assert_checkequal(res1, ref1);
+assert_checkequal(res2, ref2);