[opengtl-commits] [186] * add the two currently wrapped member of "region" to the structure |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 186
Author: cyrille
Date: 2008-06-10 20:35:42 +0200 (Tue, 10 Jun 2008)
Log Message:
-----------
* add the two currently wrapped member of "region" to the structure
* start refactoring to transform the MemberArray / Accessor into the AST
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type.h
trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp
trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
Added Paths:
-----------
trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.h
trunk/OpenGTL/OpenShiva/tests/parse/region.shiva
Added: trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp 2008-06-10 18:35:42 UTC (rev 186)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "AccessorExpression.h"
+
+#include <llvm/Constants.h>
+#include <llvm/Instructions.h>
+
+#include "../CodeGenerator_p.h"
+#include "../ExpressionResult_p.h"
+#include "../VariableNG_p.h"
+#include "../Type.h"
+
+using namespace GTLCore::AST;
+
+//------------------- StructAccessorExpression -------------------//
+
+GTLCore::ExpressionResult AccessorExpression::generateValue( GenerationContext& _gc, llvm::BasicBlock* _bb ) const
+{
+ return GTLCore::ExpressionResult( new llvm::LoadInst( pointer( _gc, _bb ), "", _bb) );
+}
+
+//------------------- StructAccessorExpression -------------------//
+
+StructAccessorExpression::StructAccessorExpression(AccessorExpression* _accessorExpression, int _index) : m_accessorExpression(_accessorExpression), m_index(_index)
+{
+}
+
+llvm::Value* StructAccessorExpression::pointer(GenerationContext& _gc, llvm::BasicBlock* _bb) const
+{
+ std::vector<llvm::Value*> indexes;
+ indexes.push_back( _gc.codeGenerator()->integerToConstant(0));
+ indexes.push_back( _gc.codeGenerator()->integerToConstant(m_index));
+ return new llvm::GetElementPtrInst( m_accessorExpression->pointer( _gc, _bb) , indexes.begin(), indexes.end(), "", _bb);
+}
+
+bool StructAccessorExpression::isConstant() const
+{
+ return m_accessorExpression->isConstant();
+}
+
+const GTLCore::Type* StructAccessorExpression::type() const
+{
+ return (*m_accessorExpression->type()->structDataMembers())[ m_index].type();
+}
+
+//------------------- ArrayAccessorExpression -------------------//
+
+ArrayAccessorExpression::ArrayAccessorExpression(AccessorExpression * _accessorExpression, Expression* _index) : m_accessorExpression(_accessorExpression), m_index(_index)
+{
+}
+
+llvm::Value* ArrayAccessorExpression::pointer(GenerationContext& _gc, llvm::BasicBlock* _bb) const
+{
+ llvm::Value* index = m_index->generateValue(_gc, _bb).value();
+ return _gc.codeGenerator()->accessArrayValue(_bb, m_accessorExpression->pointer( _gc, _bb) , index);
+}
+
+bool ArrayAccessorExpression::isConstant() const
+{
+ return m_accessorExpression->isConstant();
+}
+
+const GTLCore::Type* ArrayAccessorExpression::type() const
+{
+ return m_accessorExpression->type()->arrayType();
+}
+
+//------------------- VariableAccessorExpression -------------------//
+
+VariableAccessorExpression::VariableAccessorExpression( GTLCore::VariableNG* _variable ) : m_variable(_variable)
+{
+}
+
+llvm::Value* VariableAccessorExpression::pointer(GenerationContext& _gc, llvm::BasicBlock* bb) const
+{
+ return m_variable->pointer();
+}
+
+bool VariableAccessorExpression::isConstant() const
+{
+ return m_variable->constant();
+}
+
+const GTLCore::Type* VariableAccessorExpression::type() const
+{
+ return m_variable->type();
+}
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.h (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.h 2008-06-10 18:35:42 UTC (rev 186)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _AST_ACCESSOR_EXPRESSION_H_
+#define _AST_ACCESSOR_EXPRESSION_H_
+
+#include "Expression.h"
+
+namespace GTLCore {
+
+ namespace AST {
+ class AccessorExpression : public Expression {
+ public:
+ virtual GTLCore::ExpressionResult generateValue( GenerationContext& _gc, llvm::BasicBlock* bb ) const;
+ public:
+ virtual llvm::Value* pointer(GenerationContext& _gc, llvm::BasicBlock* _bb) const = 0;
+ };
+ class StructAccessorExpression : public AccessorExpression {
+ public:
+ StructAccessorExpression(AccessorExpression* _accessorExpression, int _index);
+ virtual bool isConstant() const;
+ virtual const GTLCore::Type* type() const;
+ protected:
+ virtual llvm::Value* pointer(GenerationContext& _gc, llvm::BasicBlock* bb) const;
+ private:
+ AccessorExpression * m_accessorExpression;
+ int m_index;
+ };
+ class ArrayAccessorExpression : public AccessorExpression {
+ public:
+ ArrayAccessorExpression(AccessorExpression * _accessorExpression, Expression* _index);
+ virtual bool isConstant() const;
+ virtual const GTLCore::Type* type() const;
+ protected:
+ virtual llvm::Value* pointer(GenerationContext& _gc, llvm::BasicBlock* bb) const;
+ private:
+ AccessorExpression * m_accessorExpression;
+ Expression* m_index;
+ };
+ class VariableAccessorExpression : public AccessorExpression {
+ public:
+ VariableAccessorExpression(GTLCore::VariableNG* _variable );
+ virtual bool isConstant() const;
+ virtual const GTLCore::Type* type() const;
+ protected:
+ virtual llvm::Value* pointer(GenerationContext& _gc, llvm::BasicBlock* bb) const;
+ private:
+ GTLCore::VariableNG* m_variable;
+ };
+ }
+}
+
+#endif
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt 2008-06-10 18:35:42 UTC (rev 186)
@@ -11,7 +11,6 @@
Buffer.cpp
Debug.cpp
ErrorMessage.cpp
- ErrorMessages_p.cpp
Function.cpp
Parameter.cpp
PixelDescription.cpp
@@ -21,6 +20,7 @@
TypeManager.cpp
Value.cpp
# Internal files
+ AST/AccessorExpression.cpp
AST/BinaryExpression.cpp
AST/CoumpoundExpression.cpp
AST/Expression.cpp
@@ -30,6 +30,7 @@
AST/UnaryExpression.cpp
CodeGenerator_p.cpp
CompilerBase_p.cpp
+ ErrorMessages_p.cpp
ExpressionResult_p.cpp
Function_p.cpp
FunctionCaller_p.cpp
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-06-10 18:35:42 UTC (rev 186)
@@ -30,8 +30,10 @@
#include "ErrorMessage.h"
#include "ExpressionResult_p.h"
#include "Type.h"
+#include "Type_p.h"
#include "Value.h"
+#include "AST/AccessorExpression.h"
#include "AST/BinaryExpression.h"
#include "AST/CoumpoundExpression.h"
#include "AST/Expression.h"
@@ -143,21 +145,22 @@
}
}
-GTLCore::MemberArray* ParserBase::parseMemberArrayExpression(bool _constantExpression)
+parseMemberArrayExpressionResult ParserBase::parseMemberArrayExpression(AST::AccessorExpression* _expression, bool _constantExpression)
{
+ parseMemberArrayExpressionResult result;
if( d->currentToken.type == GTLCore::Token::DOT )
{
getNextToken();
if( d->currentToken.type == GTLCore::Token::SIZE )
{
getNextToken(); // eat size
- return GTLCore::MemberArray::createSize();
+ result.memberArray = GTLCore::MemberArray::createSize();
} else if( isOfType( d->currentToken, GTLCore::Token::IDENTIFIER ) ) {
GTLCore::String name = d->currentToken.string;
getNextToken();
-
- return new GTLCore::MemberArray( GTLCore::ScopedName("", name),
- parseMemberArrayExpression( _constantExpression) );
+ result.expression = new AST::StructAccessorExpression( _expression , _expression->type()->d->memberToIndex( name ) );
+ result.memberArray = new GTLCore::MemberArray( GTLCore::ScopedName("", name),
+ parseMemberArrayExpression( result.expression , _constantExpression).memberArray );
}
} else if( d->currentToken.type == GTLCore::Token::STARTBOXBRACKET )
{
@@ -166,11 +169,17 @@
if( isOfType( d->currentToken, GTLCore::Token::ENDBOXBRACKET ) )
{
getNextToken();
- return new GTLCore::MemberArray( expr,
- parseMemberArrayExpression( _constantExpression) );
+ result.expression = new AST::ArrayAccessorExpression( _expression , expr );
+ result.memberArray = new GTLCore::MemberArray( expr,
+ parseMemberArrayExpression( result.expression, _constantExpression).memberArray );
}
+ } else if( d->currentToken.type == GTLCore::Token::STARTBRACKET )
+ {
+ GTL_ASSERT(false);
+ } else {
+ result.memberArray = GTLCore::MemberArray::createEmpty();
}
- return GTLCore::MemberArray::createEmpty();
+ return result;
}
std::list< AST::Expression* > ParserBase::parseArraySize(bool _constantExpression)
@@ -972,21 +981,20 @@
return 0;
}
} else {
- memberArray = parseMemberArrayExpression(_constantExpression);
- // TODO chech the validity of memberArray
- }
- GTLCore::VariableNG* var = getVariable( name );
- if( var )
- {
- return new AST::VariableExpression( var, memberArray );
- } else {
- delete memberArray;
- AST::Expression* stdconst = d->compiler->standardConstant( name.name() );
- if( stdconst )
+ GTLCore::VariableNG* var = getVariable( name );
+ memberArray = parseMemberArrayExpression(new AST::VariableAccessorExpression( var ) , _constantExpression).memberArray;
+ if( var )
{
- return stdconst;
+ return new AST::VariableExpression( var, memberArray );
} else {
- reportError( "Unknown variable: " + name.toString(), d->currentToken );
+ delete memberArray;
+ AST::Expression* stdconst = d->compiler->standardConstant( name.name() );
+ if( stdconst )
+ {
+ return stdconst;
+ } else {
+ reportError( "Unknown variable: " + name.toString(), d->currentToken );
+ }
}
}
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h 2008-06-10 18:35:42 UTC (rev 186)
@@ -39,7 +39,20 @@
class Expression;
class CoumpoundExpression;
class Statement;
+ class AccessorExpression;
};
+ /**
+ * Temporary structure to hold the AST path and the MemberArray path for structure
+ * and array access
+ */
+ struct parseMemberArrayExpressionResult {
+ GTLCore::MemberArray* memberArray;
+ AST::AccessorExpression* expression;
+ };
+ /**
+ * @internal
+ * This is the base class for OpenGTL's Parser.
+ */
class ParserBase {
public:
ParserBase(CompilerBase* _compiler, LexerBase* _lexer);
@@ -90,7 +103,7 @@
* or not
*/
std::list< AST::Expression* > parseArraySize(bool _constantExpression);
- GTLCore::MemberArray* parseMemberArrayExpression(bool _constantExpression);
+ parseMemberArrayExpressionResult parseMemberArrayExpression(AST::AccessorExpression* _expression, bool _constantExpression);
/**
* Parse coumpound expression ( { 1, 2, { 4, 5, 6 } } )
*/
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-06-10 18:35:42 UTC (rev 186)
@@ -129,22 +129,6 @@
d->setType(llvm::StructType::get(types));
}
-Type::Type(const GTLCore::String& _structName, const std::vector<Type::StructDataMember>& _members, const std::vector<Type::StructFunctionMember>& _functionMembers) : d(new Private)
-{
- d->dataType = STRUCTURE;
- d->structName = _structName;
- d->arrayType = 0;
- d->structFunctionMembers = new std::vector<StructFunctionMember>( _functionMembers );
- d->structDataMembers = new std::vector<StructDataMember>( _members );
- std::vector< const llvm::Type * > types;
- for(std::vector<StructDataMember>::iterator it = d->structDataMembers->begin();
- it != d->structDataMembers->end(); ++it)
- {
- types.push_back(it->type()->d->type());
- }
- d->setType( llvm::StructType::get(types));
-}
-
Type::Type(const Type* _arrayType) : d(new Private)
{
d->dataType = ARRAY;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-06-10 18:35:42 UTC (rev 186)
@@ -29,6 +29,10 @@
class Program;
}
+namespace OpenShiva {
+ class Types;
+}
+
namespace GTLCore {
class Parameter;
namespace AST {
@@ -49,6 +53,8 @@
friend class OpenCTL::Program;
friend class CodeGenerator;
friend class VariableNG;
+ friend class OpenShiva::Types;
+ friend class ParserBase;
public:
enum DataType {
UNDEFINED,
@@ -130,11 +136,6 @@
*/
Type(const GTLCore::String& _structName, const std::vector<Type::StructDataMember>& _members);
/**
- * @internal
- * Define a wrapped objects with function member.
- */
- Type(const GTLCore::String& _structName, const std::vector<Type::StructDataMember>& _members, const std::vector<Type::StructFunctionMember>& _functionMembers);
- /**
* Define an array.
*/
Type(const Type* _arrayType);
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp 2008-06-10 18:35:42 UTC (rev 186)
@@ -128,3 +128,25 @@
GTL_ASSERT(m_type == 0);
m_type = _type;
}
+
+void Type::Private::addFunctionMember( const StructFunctionMember& sfm)
+{
+ GTL_ASSERT( dataType == Type::STRUCTURE );
+ if( not structFunctionMembers ) structFunctionMembers = new std::vector<Type::StructFunctionMember>();
+ structFunctionMembers->push_back( sfm );
+}
+
+int Type::Private::memberToIndex(const GTLCore::String& name)
+{
+ GTL_ASSERT(structDataMembers);
+ int count = 0;
+ for( std::vector<GTLCore::Type::StructDataMember>::const_iterator it = structDataMembers->begin();
+ it != structDataMembers->end(); ++it, ++count)
+ {
+ if( it->name() == name)
+ {
+ return count;
+ }
+ }
+ return -1;
+}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h 2008-06-10 18:35:42 UTC (rev 186)
@@ -70,6 +70,8 @@
Private( Type::DataType _dataType );
Private( const llvm::Type* _type ) : m_type(_type) {}
const llvm::Type * type() const { return m_type; }
+ void addFunctionMember( const StructFunctionMember& );
+ int memberToIndex(const GTLCore::String&);
private:
void setType( const llvm::Type* _type);
const llvm::Type* m_type;
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.cpp 2008-06-10 18:35:42 UTC (rev 186)
@@ -26,9 +26,12 @@
#include "GTLCore/Type.h"
#include "GTLCore/Type_p.h"
#include "GTLCore/Macros.h"
+#include "GTLCore/Parameter.h"
#include "GTLCore/TypeManager.h"
#include "GTLCore/TypeManager_p.h"
+#include "GTLCore/Value.h"
+
#include "Debug.h"
using namespace OpenShiva;
@@ -41,12 +44,10 @@
{
static std::vector<GTLCore::Type::StructDataMember> s_imageDataMembers;
static std::vector<GTLCore::Type::StructDataMember> s_pixelDataMembers;
- static std::vector<GTLCore::Type::StructDataMember> s_regionDataMembers;
};
std::vector<GTLCore::Type::StructDataMember> Types::Private::s_imageDataMembers;
std::vector<GTLCore::Type::StructDataMember> Types::Private::s_pixelDataMembers;
-std::vector<GTLCore::Type::StructDataMember> Types::Private::s_regionDataMembers;
void Types::fillTypeManager( GTLCore::TypeManager* _typeManager, const GTLCore::PixelDescription& _pixelDescription, const GTLCore::Type* _referenceDepth )
{
@@ -58,16 +59,41 @@
"image" + GTLCore::String::number( i ), Private::s_imageDataMembers );
_typeManager->d->createStructure(
"pixel" + GTLCore::String::number( i ), Private::s_pixelDataMembers );
- _typeManager->d->createStructure(
- "region" + GTLCore::String::number( i ), Private::s_regionDataMembers );
}
_typeManager->d->createStructure( "image", Private::s_imageDataMembers );
_typeManager->d->createStructure( "pixel", Private::s_pixelDataMembers );
- _typeManager->d->createStructure( "region", Private::s_regionDataMembers );
+ createRegionType( _typeManager );
}
+GTLCore::Type::StructFunctionMember createTypeMember(const GTLCore::String& _name, const GTLCore::String& _symbolName, const GTLCore::Type* retType, int count, ...)
+{
+ std::vector<GTLCore::Parameter> arguments;
+ va_list argp;
+ va_start(argp, count);
+ for(int i = 0; i < count; ++i)
+ {
+ const GTLCore::Type* type = va_arg(argp, const GTLCore::Type*);
+ arguments.push_back(GTLCore::Parameter("", type, false, false, GTLCore::Value() ) );
+ }
+ va_end(argp);
+ return GTLCore::Type::StructFunctionMember( _name, _symbolName, retType, arguments);
+}
+void Types::createRegionType( GTLCore::TypeManager* _typeManager )
+{
+ static std::vector<GTLCore::Type::StructDataMember> regionDataMembers;
+ static std::vector<GTLCore::Type::StructFunctionMember> regionFunctionMembers;
+ regionDataMembers.push_back( GTLCore::Type::StructDataMember( "x", GTLCore::Type::Integer32) );
+ regionDataMembers.push_back( GTLCore::Type::StructDataMember( "y", GTLCore::Type::Integer32) );
+ regionDataMembers.push_back( GTLCore::Type::StructDataMember( "width", GTLCore::Type::Integer32) );
+ regionDataMembers.push_back( GTLCore::Type::StructDataMember( "height", GTLCore::Type::Integer32) );
+ const GTLCore::Type* type = _typeManager->d->createStructure( "region", regionDataMembers);
+ type->d->addFunctionMember( createTypeMember( "intersect", "_Z21region_wrap_intersectP10RegionWrapPKS_", GTLCore::Type::Void, 1, type ) );
+ type->d->addFunctionMember( createTypeMember( "union", "_Z17region_wrap_unionP10RegionWrapPKS_", GTLCore::Type::Void, 1, type ) );
+}
+
+
STATIC_INITIALISATION(OpenShivaTypes)
{
@@ -75,10 +101,9 @@
Types::Private::s_imageDataMembers.push_back( GTLCore::Type::StructDataMember( "image", GTLCore::Type::Pointer) );
}
{ // Region
- Types::Private::s_regionDataMembers.push_back( GTLCore::Type::StructDataMember( "x", GTLCore::Type::Integer32) );
- Types::Private::s_regionDataMembers.push_back( GTLCore::Type::StructDataMember( "y", GTLCore::Type::Integer32) );
- Types::Private::s_regionDataMembers.push_back( GTLCore::Type::StructDataMember( "width", GTLCore::Type::Integer32) );
- Types::Private::s_regionDataMembers.push_back( GTLCore::Type::StructDataMember( "height", GTLCore::Type::Integer32) );
+ // Structure
+ // Members
+// Types::Private::s_regionFunctionMembers.push_back( createTypeMember("intersect", "",
}
{ // Pixel
// Types::Private::s_pixelDataMembers.push_back( GTLCore::Type::StructDataMember( "pixel", GTLCore::Type::Pointer, -1) );
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h 2008-06-10 18:35:42 UTC (rev 186)
@@ -45,6 +45,8 @@
static void fillTypeManager( GTLCore::TypeManager*, const GTLCore::PixelDescription& _pixelDescription, const GTLCore::Type* _referenceDepth );
public:
struct Private;
+ private:
+ static void createRegionType( GTLCore::TypeManager* _typeManager );
};
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp 2008-06-10 18:35:42 UTC (rev 186)
@@ -39,7 +39,6 @@
float r_x2 = reg->x + reg->width;
float r_y2 = reg->y + reg->height;
-
if( self->x > reg->x) self->x = reg->x;
if( self->y > reg->y) self->y = reg->y;
self->width = ( ( s_x2 > r_x2 ) ? s_x2 : r_x2 ) - reg->x;
Modified: trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt 2008-06-07 06:11:56 UTC (rev 185)
+++ trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt 2008-06-10 18:35:42 UTC (rev 186)
@@ -2,6 +2,7 @@
set( TESTS_FILES
kernel.shiva
for.shiva
+ region.shiva
)
FOREACH( TEST_FILE ${TESTS_FILES} )
Added: trunk/OpenGTL/OpenShiva/tests/parse/region.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/region.shiva (rev 0)
+++ trunk/OpenGTL/OpenShiva/tests/parse/region.shiva 2008-06-10 18:35:42 UTC (rev 186)
@@ -0,0 +1,10 @@
+kernel MyKernel
+{
+ void evaluatePixel(input image source1, output pixel result)
+ {
+ region r;
+ region r2;
+ r.union(r2);
+ r.intersect(r2);
+ }
+}