Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / classtreemacros.h
bloba4aecd0ffc095378607ab53946aa84fd51f16cd2
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 closest to the one level recursion needed is to start from two sets of symmetric macros.
27 * One set ends in "1", the other ends in "2".
30 /* Define the class heierarcy in macros:
32 #include "classtree1.h"
33 #include "classtree2.h"
35 #include "Shapes_Ast_decls.h"
36 #include "Shapes_Kernel_decls.h"
38 #include "SimplePDF_decls.h"
40 /* Define convenient macros for looping.
42 #define SINGLELOOP1_( Sb, M, T ) M( T )
43 #define SINGLELOOP1( Sa, M ) Sa( SINGLELOOP1_,, M )
44 #define DOUBLELOOP1__( M, Ta, Tb ) M( Ta, Tb )
45 #define DOUBLELOOP1_( Sb, M, Ta ) Sb( DOUBLELOOP1__, M, Ta )
46 #define DOUBLELOOP1( Sa, Sb, M ) Sa( DOUBLELOOP1_, Sb, M )
48 #define SINGLELOOP2_( Sb, M, T ) M( T )
49 #define SINGLELOOP2( Sa, M ) Sa( SINGLELOOP2_,, M )
50 #define DOUBLELOOP2__( M, Ta, Tb ) M( Ta, Tb )
51 #define DOUBLELOOP2_( Sb, M, Ta ) Sb( DOUBLELOOP2__, M, Ta )
52 #define DOUBLELOOP2( Sa, Sb, M ) Sa( DOUBLELOOP2_, Sb, M )
54 /* Define a macro that only uses the first argument,
55 * resulting in a macro that calls another macro for each class.
57 #define FORALLCLASSESM( M ) SINGLELOOP1( CLASSTREE1_ROOT, M )
59 /* Define a macro that calls another macro with a given first argument,
60 * varying the second argument over all classes.
62 #define FORALLCLASSESMT( M, T ) CLASSTREE2_ROOT( DOUBLELOOP2__, M, T )
65 /* Declare all the Lang::Value children classes
67 #define DECLARECLASS_( T ) class T;
68 namespace Shapes
70 namespace Lang
72 FORALLCLASSESM( DECLARECLASS_ )
76 #define QUICKTYPECASE( T ) case Kernel::TYPEID_ ## T :
77 #define DUMMYANDREF( T ) T *, const RefCountPtr< T > &
79 #if DISPATCHSTYLE != DISPATCHSTYLE_NONE
80 #include "operatorside.h"
81 #else
82 #include "operatorside_none.h"
83 #endif
86 /* Now define macros to be used in the Value derivatives.
89 #if DISPATCHSTYLE == DISPATCHSTYLE_NONE
90 #include "dispatch_none.h"
91 #elif DISPATCHSTYLE == DISPATCHSTYLE_VOID
92 #include "dispatch_void.h"
93 #elif DISPATCHSTYLE == DISPATCHSTYLE_VTBL
94 #include "dispatch_vtbl.h"
95 #elif DISPATCHSTYLE == DISPATCHSTYLE_CASE
96 #include "dispatch_case.h"
97 #else
98 #error DISPATCHSTYLE switch out of range
99 #endif
102 #define GETTYPEIDDECL virtual Kernel::QuickTypeID getTypeID( ) const;
104 /* To be used in each value type:
107 #define DISPATCHBASEDECL UNARYDISPATCHBASEDECL BINARYDISPATCHBASEDECL
108 #define DISPATCHBASEIMPL UNARYDISPATCHBASEIMPL BINARYDISPATCHBASEIMPL
109 #define DISPATCHDECL UNARYDISPATCHDECL BINARYDISPATCHDECL GETTYPEIDDECL
110 #define DISPATCHIMPL( Ts ) UNARYDISPATCHIMPL( Ts ) BINARYDISPATCHIMPL( Ts )