Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / dispatch_case.h
blobe92a9eaa520823aa362a0323552e8f74f49d6920
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 UNARYDISPATCHCASE( T )\
20 case ::Shapes::Kernel::TYPEID_ ## T : \
22 RefCountPtr< const ::Shapes::Lang::T > arg = self.down_cast< const ::Shapes::Lang::T >( ); \
23 if( arg == NullPtr< const ::Shapes::Lang::T >( ) ) \
25 throw Exceptions::InternalError( strrefdup( "Downcast in unary dispatch failed, " #T ) ); \
27 return op->op( arg, dyn ); \
29 break;
31 #define UNARYDISPATCHBASEDECL static RefCountPtr< const Lang::Value > unaryDispatch( RefCountPtr< const Lang::Value > self, const Kernel::PassedDyn & dyn, const Shapes::Ast::UnaryExpr * op );
33 #define UNARYDISPATCHBASEIMPL \
34 RefCountPtr< const Lang::Value > \
35 Lang::Value::unaryDispatch( RefCountPtr< const Lang::Value > self, const Kernel::PassedDyn & dyn, const Shapes::Ast::UnaryExpr * op ) \
37 switch( self->getTypeID( ) )\
39 SINGLELOOP1( CLASSTREE1_ROOT, UNARYDISPATCHCASE ); \
40 default:\
41 throw Exceptions::InternalError( strrefdup( "QuickTypeID out of range in unary dispatch." ) ); \
45 #define UNARYDISPATCHDECL
47 #define UNARYDISPATCHIMPL( T )
50 #define BINARYDISPATCHCASE_LEVEL1( T1 )\
51 case ::Shapes::Kernel::TYPEID_ ## T1 : \
53 RefCountPtr< const ::Shapes::Lang::T1 > arg1 = self.down_cast< const ::Shapes::Lang::T1 >( ); \
54 if( arg1 == NullPtr< const ::Shapes::Lang::T1 >( ) ) \
56 throw Exceptions::InternalError( strrefdup( "Downcast in binary dispatch level 1 failed, " #T1 ) ); \
58 return binaryDispatch2( arg1, other, dyn, op ); \
60 break;
62 #define BINARYDISPATCH2CASE_LEVEL2( T2 )\
63 case ::Shapes::Kernel::TYPEID_ ## T2 : \
65 RefCountPtr< const ::Shapes::Lang::T2 > arg2 = other.down_cast< const ::Shapes::Lang::T2 >( ); \
66 if( arg2 == NullPtr< const ::Shapes::Lang::T2 >( ) ) \
68 throw Exceptions::InternalError( strrefdup( "Downcast in binary dispatch level 2 failed, " #T2 ) ); \
70 return op->op( arg1, arg2, dyn ); \
72 break;
74 #define BINARYDISPATCH2CASE_LEVEL1( T1 )\
75 RefCountPtr< const Lang::Value > \
76 Lang::Value::binaryDispatch2( RefCountPtr< const ::Shapes::Lang::T1 > arg1, RefCountPtr< const Lang::Value > other, const Kernel::PassedDyn & dyn, const ::Shapes::Ast::BinaryInfixExpr * op ) \
78 switch( other->getTypeID( ) ) \
79 { \
80 SINGLELOOP2( CLASSTREE2_ROOT, BINARYDISPATCH2CASE_LEVEL2 ); \
81 default: \
82 throw Exceptions::InternalError( strrefdup( "QuickTypeID out of range in binary dispatch level 2." ) ); \
83 } \
87 #define BINARYDISPATCH2DECL( T ) static RefCountPtr< const Lang::Value > binaryDispatch2( RefCountPtr< const ::Shapes::Lang::T > self, RefCountPtr< const Lang::Value > other, const Kernel::PassedDyn & dyn, const ::Shapes::Ast::BinaryInfixExpr * op );
89 #define BINARYDISPATCHBASEDECL \
90 static RefCountPtr< const Lang::Value > binaryDispatch1( RefCountPtr< const Lang::Value > self, RefCountPtr< const Lang::Value > other, const Kernel::PassedDyn & dyn, const ::Shapes::Ast::BinaryInfixExpr * op ); \
91 SINGLELOOP1( CLASSTREE1_ROOT, BINARYDISPATCH2DECL )
93 #define BINARYDISPATCHBASEIMPL \
94 RefCountPtr< const Lang::Value > \
95 Lang::Value::binaryDispatch1( RefCountPtr< const Lang::Value > self, RefCountPtr< const Lang::Value > other, const Kernel::PassedDyn & dyn, const ::Shapes::Ast::BinaryInfixExpr * op ) \
97 switch( self->getTypeID( ) )\
99 SINGLELOOP1( CLASSTREE1_ROOT, BINARYDISPATCHCASE_LEVEL1 ); \
100 default:\
101 throw Exceptions::InternalError( strrefdup( "QuickTypeID out of range in binary dispatch level 1." ) ); \
104 SINGLELOOP1( CLASSTREE1_ROOT, BINARYDISPATCH2CASE_LEVEL1 )
106 #define BINARYDISPATCHDECL
108 #define BINARYDISPATCHIMPL( Ts )