Initial revision
[luabind.git] / luabind / config.hpp
blob9fc90c1d58cd5efd0b080c0180b86fbeeff4afcb
1 // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
24 #ifndef LUABIND_CONFIG_HPP_INCLUDED
25 #define LUABIND_CONFIG_HPP_INCLUDED
27 #include <boost/config.hpp>
29 #if defined (BOOST_MSVC) && (BOOST_MSVC <= 1200)
31 #define LUABIND_MSVC_TYPENAME
33 #define for if (false) {} else for
35 #include <cstring>
37 namespace std
39 using ::strlen;
40 using ::strcmp;
41 using ::type_info;
44 #else
46 #define LUABIND_MSVC_TYPENAME typename
48 #endif
50 // the maximum number of arguments of functions that's
51 // registered
52 #ifndef LUABIND_MAX_ARITY
53 #define LUABIND_MAX_ARITY 4
54 #endif
56 // the maximum number of classes one class
57 // can derive from
58 // max bases must at least be 1
59 #ifndef LUABIND_MAX_BASES
60 #define LUABIND_MAX_BASES 4
61 #endif
63 // LUABIND_NO_ERROR_CHECKING
64 // define this to remove all error checks
65 // this will improve performance and memory
66 // footprint.
67 // if it is defined matchers will only be called on
68 // overloaded functions, functions that's
69 // not overloaded will be called directly. The
70 // parameters on the lua stack are assumed
71 // to match those of the function.
72 // exceptions will still be catched when there's
73 // no error checking.
75 // LUABIND_DONT_COPY_STRINGS
76 // define this if you only pass static constant strings to
77 // the def() methods. It will make luabind expect the
78 // strings to exist as long as the program is running.
79 // Luabind will not copy the strings in this case.
81 // LUABIND_NOT_THREADSAFE
82 // this define will make luabind non-thread safe. That is,
83 // it will rely on a static variable. You can still have
84 // multiple lua states and use coroutines, but only
85 // one of your real threads may run lua code.
87 // If you don't want to use the rtti supplied by C++
88 // you can supply your own type-info structure with the
89 // LUABIND_TYPE_INFO define. Your type-info structure
90 // must be copyable and it must be able to compare itself
91 // against other type-info structures. You supply the compare
92 // function through the LUABIND_TYPE_INFO_EQUAL()
93 // define. It should compare the two type-info structures
94 // it is given and return true if they represent the same type
95 // and false otherwise. You also have to supply a function
96 // to generate your type-info structure. You do this through
97 // the LUABIND_TYPEID() define. It takes a type as it's
98 // parameter. That is, a compile time parameter. To use it
99 // you probably have to make a traits class with specializations
100 // for all classes that you have type-info for.
102 #ifndef LUABIND_TYPE_INFO
103 #define LUABIND_TYPE_INFO const std::type_info*
104 #define LUABIND_TYPEID(t) &typeid(t)
105 #define LUABIND_TYPE_INFO_EQUAL(i1, i2) *i1 == *i2
106 #define LUABIND_INVALID_TYPE_INFO &typeid(detail::null_type)
107 #endif
109 // LUABIND_NO_EXCEPTIONS
110 // this define will disable all usage of try, catch and throw in
111 // luabind. This will in many cases disable runtime-errors, such
112 // as invalid casts, when calling lua-functions that fails or
113 // returns values that cannot be converted by the given policy.
114 // Luabind requires that no function called directly or indirectly
115 // by luabind throws an exception (throwing exceptions through
116 // C code has undefined behavior, lua is written in C).
118 #endif // LUABIND_CONFIG_HPP_INCLUDED