2 /// Conversion functions to convert C++ types to Nasal types
4 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
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.
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.
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
20 #ifndef SG_TO_NASAL_HXX_
21 #define SG_TO_NASAL_HXX_
23 #include <simgear/nasal/cppbind/detail/to_nasal_helper.hxx>
28 * Convert any supported C++ type to Nasal.
30 * @param c Active Nasal context
31 * @param arg C++ Object to be converted
32 * @tparam T Type of converted object
34 * @throws bad_nasal_cast if conversion is not possible
36 * @note Every type which should be supported needs a function with the
37 * following signature declared (Type needs to be a const reference
38 * for non-integral types):
40 * naRef to_nasal_helper(naContext, Type)
43 naRef to_nasal(naContext c, T arg)
45 return to_nasal_helper(c, arg);
48 template<class T, size_t N>
49 naRef to_nasal(naContext c, const T(&array)[N])
51 return to_nasal_helper(c, array);
55 * Wrapper to get pointer to specific version of to_nasal applicable to given
61 typedef typename boost::call_traits<Var>::param_type param_type;
62 typedef naRef(*type)(naContext, param_type);
66 return &to_nasal<param_type>;
71 #endif /* SG_TO_NASAL_HXX_ */