]> git.mxchange.org Git - simgear.git/blob - simgear/nasal/cppbind/nasal_traits.hxx
cppbind: rework to allow binding nearly everything.
[simgear.git] / simgear / nasal / cppbind / nasal_traits.hxx
1 ///@file
2 /// Type traits used for converting from and to Nasal types
3 ///
4 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Library General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Library General Public License for more details.
15 //
16 // You should have received a copy of the GNU Library General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
19
20 #ifndef SG_NASAL_TRAITS_HXX_
21 #define SG_NASAL_TRAITS_HXX_
22
23 #include <boost/type_traits/integral_constant.hpp>
24
25 namespace nasal
26 {
27   template<class T>
28   struct is_vec2: public boost::integral_constant<bool, false> {};
29
30 #define SG_MAKE_TRAIT(templ,type,attr)\
31   template templ\
32   struct attr< type >:\
33     public boost::integral_constant<bool, true> {};
34
35 #ifdef SGVec2_H
36   SG_MAKE_TRAIT(<class T>, SGVec2<T>, is_vec2)
37 #endif
38
39 #ifdef OSG_VEC2B
40   SG_MAKE_TRAIT(<>, osg::Vec2b, is_vec2)
41 #endif
42
43 #ifdef OSG_VEC2D
44   SG_MAKE_TRAIT(<>, osg::Vec2d, is_vec2)
45 #endif
46
47 #ifdef OSG_VEC2F
48   SG_MAKE_TRAIT(<>, osg::Vec2f, is_vec2)
49 #endif
50
51 #ifdef OSG_VEC2S
52   SG_MAKE_TRAIT(<>, osg::Vec2s, is_vec2)
53 #endif
54
55 #undef SG_MAKE_TRAIT
56
57 } // namespace nasal
58 #endif /* SG_NASAL_TRAITS_HXX_ */