Test object identity with shared_ptr_converter.
[luabind.git] / luabind / detail / implicit_cast.hpp
blobe30eeb372b707c1872faffcf72ee79e0a463f819
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_IMPLICIT_CAST_HPP_INCLUDED
25 #define LUABIND_IMPLICIT_CAST_HPP_INCLUDED
27 #include <luabind/config.hpp>
28 #include <luabind/typeid.hpp>
30 namespace luabind { namespace detail
32 class class_rep;
34 // returns -1 if there exists no implicit cast from the given class_rep
35 // to T. If there exists an implicit cast to T, the number of steps times 2
36 // is returned and pointer_offset is filled with the number of bytes
37 // the pointer have to be offseted to perform the cast
38 // the reason why we return the number of cast-steps times two, instead of
39 // just the number of steps is to be consistent with the function matchers. They
40 // have to give one matching-point extra to match const functions. There may be
41 // two functions that match their parameters exactly, but there is one const
42 // function and one non-const function, then (if the this-pointer is non-const)
43 // both functions will match. To avoid amiguaties, the const version will get
44 // one penalty point to make the match-selector select the non-const version. It
45 // the this-pointer is const, there's no problem, since the non-const function
46 // will not match at all.
48 LUABIND_API int implicit_cast(const class_rep*, type_id const&, int&);
52 #endif // LUABIND_IMPLICIT_CAST_HPP_INCLUDED