Update procedures
[shapes.git] / source / classtreemacros.h
blobdca4c30ccf7faf515be9ed6254773c6c1396afcb
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 #pragma once
21 #define DISPATCHSTYLE_NONE 0
22 #define DISPATCHSTYLE_VOID 1
23 #define DISPATCHSTYLE_VTBL 2
24 #define DISPATCHSTYLE_CASE 3
26 /* The dispatch style is selected by the configure script.
28 #include "../config.h"
30 /* The closest to the one level recursion needed is to start from two sets of symmetric macros.
31 * One set ends in "1", the other ends in "2".
34 /* Define the class heierarcy in macros:
36 #include "classtree1.h"
37 #include "classtree2.h"
39 #include "Shapes_Ast_decls.h"
40 #include "Shapes_Kernel_decls.h"
42 #include "SimplePDF_decls.h"
44 /* Define convenient macros for looping.
46 #define SINGLELOOP1_( Sb, M, T ) M( T )
47 #define SINGLELOOP1( Sa, M ) Sa( SINGLELOOP1_,, M )
48 #define DOUBLELOOP1__( M, Ta, Tb ) M( Ta, Tb )
49 #define DOUBLELOOP1_( Sb, M, Ta ) Sb( DOUBLELOOP1__, M, Ta )
50 #define DOUBLELOOP1( Sa, Sb, M ) Sa( DOUBLELOOP1_, Sb, M )
52 #define SINGLELOOP2_( Sb, M, T ) M( T )
53 #define SINGLELOOP2( Sa, M ) Sa( SINGLELOOP2_,, M )
54 #define DOUBLELOOP2__( M, Ta, Tb ) M( Ta, Tb )
55 #define DOUBLELOOP2_( Sb, M, Ta ) Sb( DOUBLELOOP2__, M, Ta )
56 #define DOUBLELOOP2( Sa, Sb, M ) Sa( DOUBLELOOP2_, Sb, M )
58 /* Define a macro that only uses the first argument,
59 * resulting in a macro that calls another macro for each class.
61 #define FORALLCLASSESM( M ) SINGLELOOP1( CLASSTREE1_ROOT, M )
63 /* Define a macro that calls another macro with a given first argument,
64 * varying the second argument over all classes.
66 #define FORALLCLASSESMT( M, T ) CLASSTREE2_ROOT( DOUBLELOOP2__, M, T )
69 /* Declare all the Lang::Value children classes
71 #define DECLARECLASS_( T ) class T;
72 namespace Shapes
74 namespace Lang
76 FORALLCLASSESM( DECLARECLASS_ )
80 #define QUICKTYPECASE( T ) case Kernel::TYPEID_ ## T :
81 #define DUMMYANDREF( T ) T *, const RefCountPtr< T > &
83 #if DISPATCHSTYLE != DISPATCHSTYLE_NONE
84 #include "operatorside.h"
85 #else
86 #include "operatorside_none.h"
87 #endif
90 /* Now define macros to be used in the Value derivatives.
93 #if DISPATCHSTYLE == DISPATCHSTYLE_NONE
94 #include "dispatch_none.h"
95 #elif DISPATCHSTYLE == DISPATCHSTYLE_VOID
96 #include "dispatch_void.h"
97 #elif DISPATCHSTYLE == DISPATCHSTYLE_VTBL
98 #include "dispatch_vtbl.h"
99 #elif DISPATCHSTYLE == DISPATCHSTYLE_CASE
100 #include "dispatch_case.h"
101 #else
102 #error DISPATCHSTYLE switch out of range
103 #endif
106 #define GETTYPEIDDECL virtual Kernel::QuickTypeID getTypeID( ) const;
108 /* To be used in each value type:
111 #define DISPATCHBASEDECL UNARYDISPATCHBASEDECL BINARYDISPATCHBASEDECL
112 #define DISPATCHBASEIMPL UNARYDISPATCHBASEIMPL BINARYDISPATCHBASEIMPL
113 #define DISPATCHDECL UNARYDISPATCHDECL BINARYDISPATCHDECL GETTYPEIDDECL
114 #define DISPATCHIMPL( Ts ) UNARYDISPATCHIMPL( Ts ) BINARYDISPATCHIMPL( Ts )