Update procedures
[shapes.git] / source / dispatch_vtbl.h
blobc53c3952cb9edf7014af2fd3d36ba056db6e7eb1
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #define UNARYDISPATCHBASEDECL virtual RefCountPtr< const Lang::Value > unaryDispatch( RefCountPtr< const Lang::Value > self, const ::Shapes::Ast::UnaryExpr * op ) const = 0;
21 #define UNARYDISPATCHBASEIMPL
23 #define UNARYDISPATCHDECL virtual RefCountPtr< const Lang::Value > unaryDispatch( RefCountPtr< const Lang::Value > self, const ::Shapes::Ast::UnaryExpr * op ) const;
25 #define UNARYDISPATCHIMPL( T ) \
26 RefCountPtr< const Lang::Value > ::Shapes::Lang::T::unaryDispatch( RefCountPtr< const Lang::Value > self, const ::Shapes::Ast::UnaryExpr * op ) const \
28 RefCountPtr< const ::Shapes::Lang::T > typedSelf = self.down_cast< const ::Shapes::Lang::T >( ); \
29 if( typedSelf == NullPtr< const ::Shapes::Lang::T >( ) ) \
31 throw Exceptions::InternalError( strrefdup( "Downcast in unaryDispatch failed." ) ); \
33 return op->op( typedSelf ); \
39 #define BINARYDISPATCH1BASEDECL_ virtual RefCountPtr< const Lang::Value > binaryDispatch1( RefCountPtr< const Lang::Value > self, RefCountPtr< const Lang::Value > other, const ::Shapes::Ast::BinaryInfixExpr * op ) const = 0;
40 #define BINARYDISPATCH2BASEDECL_( To ) virtual RefCountPtr< const Lang::Value > binaryDispatch2( RefCountPtr< const ::Shapes::Lang::To > other, RefCountPtr< const Lang::Value > self, const ::Shapes::Ast::BinaryInfixExpr * op ) const = 0;
42 #define BINARYDISPATCHBASEDECL BINARYDISPATCH1BASEDECL_ FORALLCLASSESM( BINARYDISPATCH2BASEDECL_ )
44 #define BINARYDISPATCHBASEIMPL
47 #define BINARYDISPATCH1DECL_ virtual RefCountPtr< const Lang::Value > binaryDispatch1( RefCountPtr< const Lang::Value > self, RefCountPtr< const Lang::Value > other, const ::Shapes::Ast::BinaryInfixExpr * op ) const;
49 #define BINARYDISPATCH1IMPL_( Ts ) \
50 RefCountPtr< const Lang::Value > ::Shapes::Ts::binaryDispatch1( RefCountPtr< const Lang::Value > self, RefCountPtr< const Lang::Value > other, const ::Shapes::Ast::BinaryInfixExpr * op ) const \
52 RefCountPtr< const ::Shapes::Lang::Ts > typedSelf = self.down_cast< const ::Shapes::Lang::Ts >( ); \
53 if( typedSelf == NullPtr< const ::Shapes::Lang::Ts >( ) ) \
55 throw Exceptions::InternalError( strrefdup( "Downcast in binaryDispatch1 failed." ) ); \
57 return other->binaryDispatch2( typedSelf, other, op ); \
61 #define BINARYDISPATCH2DECL_( To ) virtual RefCountPtr< const Lang::Value > binaryDispatch2( RefCountPtr< const ::Shapes::Lang::To > other, RefCountPtr< const Lang::Value > self, const ::Shapes::Ast::BinaryInfixExpr * op ) const;
63 #define BINARYDISPATCH2IMPL_( Ts, To ) \
64 RefCountPtr< const Lang::Value > ::Shapes::Lang::Ts::binaryDispatch2( RefCountPtr< const ::Shapes::Lang::To > other, RefCountPtr< const Lang::Value > self, const ::Shapes::Ast::BinaryInfixExpr * op ) const \
66 RefCountPtr< const ::Shapes::Lang::Ts > typedSelf = self.down_cast< const ::Shapes::Lang::Ts >( ); \
67 if( typedSelf == NullPtr< const ::Shapes::Lang::Ts >( ) ) \
69 throw Exceptions::InternalError( strrefdup( "Downcast in binaryDispatch2 failed." ) ); \
71 return op->op( other, typedSelf ); \
74 #define BINARYDISPATCHDECL BINARYDISPATCH1DECL_ FORALLCLASSESM( BINARYDISPATCH2DECL_ )
75 #define BINARYDISPATCHIMPL( Ts ) BINARYDISPATCH1IMPL_( Ts ) FORALLCLASSESMT( BINARYDISPATCH2IMPL_, Ts )