removed LUABIND_DONT_COPY_STRINGS
[luabind.git] / luabind / config.hpp
blob5b7e95e98f2a7957930cf4c65f47383054b3deae
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_NOT_THREADSAFE
88 // this define will make luabind non-thread safe. That is,
89 // it will rely on a static variable. You can still have
90 // multiple lua states and use coroutines, but only
91 // one of your real threads may run lua code.
93 // If you don't want to use the rtti supplied by C++
94 // you can supply your own type-info structure with the
95 // LUABIND_TYPE_INFO define. Your type-info structure
96 // must be copyable and it must be able to compare itself
97 // against other type-info structures. You supply the compare
98 // function through the LUABIND_TYPE_INFO_EQUAL()
99 // define. It should compare the two type-info structures
100 // it is given and return true if they represent the same type
101 // and false otherwise. You also have to supply a function
102 // to generate your type-info structure. You do this through
103 // the LUABIND_TYPEID() define. It takes a type as it's
104 // parameter. That is, a compile time parameter. To use it
105 // you probably have to make a traits class with specializations
106 // for all classes that you have type-info for.
108 #ifndef LUABIND_TYPE_INFO
109 #define LUABIND_TYPE_INFO const std::type_info*
110 #define LUABIND_TYPEID(t) &typeid(t)
111 #define LUABIND_TYPE_INFO_EQUAL(i1, i2) *i1 == *i2
112 #define LUABIND_INVALID_TYPE_INFO &typeid(detail::null_type)
113 #include <typeinfo>
114 #endif
116 #define BOOST_LANGBINDING_TYPE_INFO LUABIND_TYPE_INFO
118 // LUABIND_NO_EXCEPTIONS
119 // this define will disable all usage of try, catch and throw in
120 // luabind. This will in many cases disable runtime-errors, such
121 // as invalid casts, when calling lua-functions that fails or
122 // returns values that cannot be converted by the given policy.
123 // Luabind requires that no function called directly or indirectly
124 // by luabind throws an exception (throwing exceptions through
125 // C code has undefined behavior, lua is written in C).
127 // LUABIND_EXPORT
128 // LUABIND_IMPORT
129 // If you're building luabind as a dll on windows with devstudio
130 // you can set LUABIND_EXPORT to __declspec(dllexport)
131 // and LUABIND_IMPORT to __declspec(dllimport)
133 // this define is set if we're currently building a luabind file
134 // select import or export depending on it
135 #ifdef LUABIND_BUILDING
136 #ifdef LUABIND_EXPORT
137 #define LUABIND_API LUABIND_EXPORT
138 #else
139 #define LUABIND_API
140 #endif
141 #else
142 #ifdef LUABIND_IMPORT
143 #define LUABIND_API LUABIND_IMPORT
144 #else
145 #define LUABIND_API
146 #endif
147 #endif
149 #endif // LUABIND_CONFIG_HPP_INCLUDED