[opengtl-commits] [420] allow access to vectors elements using x,y,z,w accessors |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 420
Author: cyrille
Date: 2008-10-01 08:38:54 +0200 (Wed, 01 Oct 2008)
Log Message:
-----------
allow access to vectors elements using x,y,z,w accessors
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-09-30 21:59:02 UTC (rev 419)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-10-01 06:38:54 UTC (rev 420)
@@ -236,6 +236,25 @@
} else {
return parseMemberArrayExpression( new AST::StructAccessorExpression( _expression , index ), _constantExpression);
}
+ } else if( _expression->type()->dataType() == Type::VECTOR ) {
+ int index = -1;
+ GTL_DEBUG(name);
+ if( name == "x" ) {
+ index = 0;
+ } else if( name == "y" ) {
+ index = 1;
+ } else if( name == "z" ) {
+ index = 2;
+ } else if( name == "w" ) {
+ index = 3;
+ }
+ if( index == -1 )
+ {
+ GTL_DEBUG("unexpected");
+ reportUnexpected( d->currentToken );
+ } else {
+ return new AST::ArrayAccessorExpression( _expression, new AST::NumberExpression<int>( index ) );
+ }
} else {
GTL_DEBUG("unexpected");
reportUnexpected( d->currentToken );