*** empty log message ***
[luabind.git] / luabind / config.hpp
blobf2fbcab01d1309aa39ef9a1fe04ee0b33aba8b6d
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 #ifdef BOOST_MSVC
30 #define LUABIND_ANONYMOUS_FIX static
31 #else
32 #define LUABIND_ANONYMOUS_FIX
33 #endif
35 #if defined (BOOST_MSVC) && (BOOST_MSVC <= 1200)
37 #define LUABIND_MSVC_TYPENAME
39 #define for if (false) {} else for
41 #include <cstring>
43 namespace std
45 using ::strlen;
46 using ::strcmp;
47 using ::type_info;
50 #else
52 #define LUABIND_MSVC_TYPENAME typename
54 #endif
56 // the maximum number of arguments of functions that's
57 // registered. Must at least be 2
58 #ifndef LUABIND_MAX_ARITY
59 #define LUABIND_MAX_ARITY 5
60 #elif LUABIND_MAX_ARITY <= 1
61 #undef LUABIND_MAX_ARITY
62 #define LUABIND_MAX_ARITY 2
63 #endif
65 // the maximum number of classes one class
66 // can derive from
67 // max bases must at least be 1
68 #ifndef LUABIND_MAX_BASES
69 #define LUABIND_MAX_BASES 4
70 #elif LUABIND_MAX_BASES <= 0
71 #undef LUABIND_MAX_BASES
72 #define LUABIND_MAX_BASES 1
73 #endif
75 // LUABIND_NO_ERROR_CHECKING
76 // define this to remove all error checks
77 // this will improve performance and memory
78 // footprint.
79 // if it is defined matchers will only be called on
80 // overloaded functions, functions that's
81 // not overloaded will be called directly. The
82 // parameters on the lua stack are assumed
83 // to match those of the function.
84 // exceptions will still be catched when there's
85 // no error checking.
87 // LUABIND_DONT_COPY_STRINGS
88 // define this if you only pass static constant strings to
89 // the def() methods. It will make luabind expect the
90 // strings to exist as long as the program is running.
91 // Luabind will not copy the strings in this case.
93 // LUABIND_NOT_THREADSAFE
94 // this define will make luabind non-thread safe. That is,
95 // it will rely on a static variable. You can still have
96 // multiple lua states and use coroutines, but only
97 // one of your real threads may run lua code.
99 // If you don't want to use the rtti supplied by C++
100 // you can supply your own type-info structure with the
101 // LUABIND_TYPE_INFO define. Your type-info structure
102 // must be copyable and it must be able to compare itself
103 // against other type-info structures. You supply the compare
104 // function through the LUABIND_TYPE_INFO_EQUAL()
105 // define. It should compare the two type-info structures
106 // it is given and return true if they represent the same type
107 // and false otherwise. You also have to supply a function
108 // to generate your type-info structure. You do this through
109 // the LUABIND_TYPEID() define. It takes a type as it's
110 // parameter. That is, a compile time parameter. To use it
111 // you probably have to make a traits class with specializations
112 // for all classes that you have type-info for.
114 #ifndef LUABIND_TYPE_INFO
115 #define LUABIND_TYPE_INFO const std::type_info*
116 #define LUABIND_TYPEID(t) &typeid(t)
117 #define LUABIND_TYPE_INFO_EQUAL(i1, i2) *i1 == *i2
118 #define LUABIND_INVALID_TYPE_INFO &typeid(detail::null_type)
119 #endif
121 #define BOOST_LANGBINDING_TYPE_INFO LUABIND_TYPE_INFO
123 // LUABIND_NO_EXCEPTIONS
124 // this define will disable all usage of try, catch and throw in
125 // luabind. This will in many cases disable runtime-errors, such
126 // as invalid casts, when calling lua-functions that fails or
127 // returns values that cannot be converted by the given policy.
128 // Luabind requires that no function called directly or indirectly
129 // by luabind throws an exception (throwing exceptions through
130 // C code has undefined behavior, lua is written in C).
132 // LUABIND_EXPORT
133 // LUABIND_IMPORT
134 // If you're building luabind as a dll on windows with devstudio
135 // you can set LUABIND_EXPORT to __declspec(dllexport)
136 // and LUABIND_IMPORT to __declspec(dllimport)
138 // this define is set if we're currently building a luabind file
139 // select import or export depending on it
140 #ifdef LUABIND_BUILDING
141 #ifdef LUABIND_EXPORT
142 #define LUABIND_API LUABIND_EXPORT
143 #else
144 #define LUABIND_API
145 #endif
146 #else
147 #ifdef LUABIND_IMPORT
148 #define LUABIND_API LUABIND_IMPORT
149 #else
150 #define LUABIND_API
151 #endif
152 #endif
154 #endif // LUABIND_CONFIG_HPP_INCLUDED