[opengtl-commits] [717] guess the type of the element of the coumpound expression, based on their value

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 717
Author:   cyrille
Date:     2009-04-09 16:19:19 +0200 (Thu, 09 Apr 2009)

Log Message:
-----------
guess the type of the element of the coumpound expression, based on their value

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/tests/stdlib/vecmatop.ctl
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp


Modified: trunk/OpenGTL/OpenCTL/tests/stdlib/vecmatop.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/stdlib/vecmatop.ctl	2009-04-09 14:10:17 UTC (rev 716)
+++ trunk/OpenGTL/OpenCTL/tests/stdlib/vecmatop.ctl	2009-04-09 14:19:19 UTC (rev 717)
@@ -16,27 +16,27 @@
   
   // Test vectors
   Test::checkNearEqualVec( mult_f_f3( 1.5, x ), { 1.5, 3.0, 4.5 }, errorcount );
-  Test::checkNearEqualVec( add_f3_f3( x, y ), { 5, 7, 9 }, errorcount );
-  Test::checkNearEqualVec( sub_f3_f3( x, y ), { -3, -3, -3 }, errorcount );
-  Test::checkNearEqualVec( cross_f3_f3( x, y ), { -3, 6, -3 }, errorcount );
+  Test::checkNearEqualVec( add_f3_f3( x, y ), { 5.0, 7.0, 9.0 }, errorcount );
+  Test::checkNearEqualVec( sub_f3_f3( x, y ), { -3.0, -3.0, -3.0 }, errorcount );
+  Test::checkNearEqualVec( cross_f3_f3( x, y ), { -3.0, 6.0, -3.0 }, errorcount );
   Test::checkNearEqual( dot_f3_f3( x, y ), 32, errorcount );
   Test::checkNearEqual( length_f3( x ), 3.74166, errorcount );
   Test::checkNearEqual( length_f3( y ), 8.77496, errorcount );
   
   // Test matrixes
   Test::checkNearEqualMat( mult_f_f33( 1.5, A), { { 1.5, 3.0, 4.5 }, { 6, 7.5, 9 }, { 10.5, 12, 13.5 } }, errorcount);
-  Test::checkNearEqualMat( mult_f_f44( 2.0, C), { { 2, 4, 6, 8 }, { 10, 12, 14, 16 }, { 18, 20, 22, 24 }, { 26, 28, 30, 32 } }, errorcount);
-  Test::checkNearEqualMat( add_f33_f33( A, B), { { 11, 13, 15 }, { 17, 19, 21 }, { 23, 25, 27 } }, errorcount);
-  Test::checkNearEqualMat( add_f44_f44( C, D), { { 18, 20, 22, 24 }, { 26, 28, 30, 32 }, { 34, 36, 38, 40 }, { 42, 44, 46, 48 } }, errorcount);
+  Test::checkNearEqualMat( mult_f_f44( 2.0, C), { { 2.0, 4.0, 6.0, 8.0 }, { 10.0, 12.0, 14.0, 16.0 }, { 18.0, 20.0, 22.0, 24.0 }, { 26.0, 28.0, 30.0, 32.0 } }, errorcount);
+  Test::checkNearEqualMat( add_f33_f33( A, B), { { 11.0, 13.0, 15.0 }, { 17.0, 19.0, 21.0 }, { 23.0, 25.0, 27.0 } }, errorcount);
+  Test::checkNearEqualMat( add_f44_f44( C, D), { { 18.0, 20.0, 22.0, 24.0 }, { 26.0, 28.0, 30.0, 32.0 }, { 34.0, 36.0, 38.0, 40.0 }, { 42.0, 44.0, 46.0, 48.0 } }, errorcount);
   
-  Test::checkNearEqualMat( mult_f33_f33(A,B), { { 84, 90, 96 }, { 201, 216, 231 }, { 318, 342, 366} }, errorcount );
-  Test::checkNearEqualMat( mult_f44_f44(C,D), { { 250, 260, 270, 280 }, { 618, 644, 670, 696 }, { 986, 1028, 1070, 1112 }, { 1354, 1412, 1470, 1528 } }, errorcount );
+  Test::checkNearEqualMat( mult_f33_f33(A,B), { { 84.0, 90.0, 96.0 }, { 201.0, 216.0, 231.0 }, { 318.0, 342.0, 366.0} }, errorcount );
+  Test::checkNearEqualMat( mult_f44_f44(C,D), { { 250.0, 260.0, 270.0, 280.0 }, { 618.0, 644.0, 670.0, 696.0 }, { 986.0, 1028.0, 1070.0, 1112.0 }, { 1354.0, 1412.0, 1470.0, 1528.0 } }, errorcount );
 
   Test::checkNearEqualMat( invert_f33(E), { { 0.25, 0.25, -0.5 }, { 0.5, -0.5, 0.0 }, {-0.25, 0.25, 0.5 } }, errorcount );
   Test::checkNearEqualMat( invert_f44(F), { { 0.33333, 0.33333, -0.66667, -0.33333 }, {0.66667,-0.33333, -0.33333, -0.66667}, {-0.33333, 0.16667, 0.66667, 0.33333 }, {-0.16667, -0.16667, 0.33333, 0.66667 } }, errorcount );
   
   // Test vectors+matrixes
-  Test::checkNearEqualVec( mult_f3_f33( x, A ), { 30, 36, 42 }, errorcount );
+  Test::checkNearEqualVec( mult_f3_f33( x, A ), { 30.0, 36.0, 42.0 }, errorcount );
   Test::checkNearEqualVec( mult_f3_f44( x, C ), {  0.70833, 0.80556, 0.90278 }, errorcount );
   
   

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2009-04-09 14:10:17 UTC (rev 716)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2009-04-09 14:19:19 UTC (rev 717)
@@ -351,7 +351,7 @@
   bool autoType = false;
   if( not _type )
   {
-    _type = GTLCore::TypesManager::getArray(GTLCore::Type::Float); // TODO: delay the selection of the type of te coumpound to later
+    _type = GTLCore::TypesManager::getArray(GTLCore::Type::Float); // The real type is guessed later
     autoType = true;
   }
   GTL_DEBUG( *_type );
@@ -384,8 +384,7 @@
       if( subtype->dataType() != Type::STRUCTURE and subtype->dataType() != Type::ARRAY )
       {
         if(autoType) {
-          subtype = _type;
-          _type = GTLCore::TypesManager::getArray(_type);
+          subtype = 0;
         } else {
           GTL_DEBUG("unexpected");
           reportUnexpected( d->currentToken );
@@ -401,6 +400,12 @@
       deleteAll( expressions_ );
       return 0;
     }
+    if(autoType)
+    {
+      subtype = expression->type();
+      _type = GTLCore::TypesManager::getArray(subtype);
+      autoType = false;
+    }
     expression = d->compiler->convertCenter()->createConvertExpression( expression, subtype );
     if( not expression )
     {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/