constructor_wrapper_base.cpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /************************************************************************************
  2. * *
  3. * Copyright (c) 2014 - 2018 Axel Menzel <info@rttr.org> *
  4. * *
  5. * This file is part of RTTR (Run Time Type Reflection) *
  6. * License: MIT License *
  7. * *
  8. * Permission is hereby granted, free of charge, to any person obtaining *
  9. * a copy of this software and associated documentation files (the "Software"), *
  10. * to deal in the Software without restriction, including without limitation *
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
  12. * and/or sell copies of the Software, and to permit persons to whom the *
  13. * Software is furnished to do so, subject to the following conditions: *
  14. * *
  15. * The above copyright notice and this permission notice shall be included in *
  16. * all copies or substantial portions of the Software. *
  17. * *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
  24. * SOFTWARE. *
  25. * *
  26. *************************************************************************************/
  27. #include "rttr/detail/constructor/constructor_wrapper_base.h"
  28. using namespace std;
  29. static RTTR_CONSTEXPR const char* is_ref_list[] = {"", " &"};
  30. static RTTR_CONSTEXPR const char* is_const_list[] = {"", " const"};
  31. namespace rttr
  32. {
  33. namespace detail
  34. {
  35. /////////////////////////////////////////////////////////////////////////////////////////
  36. constructor_wrapper_base::constructor_wrapper_base() RTTR_NOEXCEPT
  37. {
  38. }
  39. /////////////////////////////////////////////////////////////////////////////////////////
  40. constructor_wrapper_base::~constructor_wrapper_base()
  41. {
  42. }
  43. /////////////////////////////////////////////////////////////////////////////////////////
  44. void constructor_wrapper_base::init() RTTR_NOEXCEPT
  45. {
  46. create_signature_string();
  47. get_instantiated_type();
  48. get_parameter_infos();
  49. }
  50. /////////////////////////////////////////////////////////////////////////////////////////
  51. string_view constructor_wrapper_base::get_signature() const RTTR_NOEXCEPT
  52. {
  53. return m_signature_view;
  54. }
  55. /////////////////////////////////////////////////////////////////////////////////////////
  56. void constructor_wrapper_base::create_signature_string() RTTR_NOEXCEPT
  57. {
  58. if (!m_signature.empty())
  59. return;
  60. if (!get_instantiated_type())
  61. return;
  62. auto param_info_list = get_parameter_infos();
  63. m_signature = get_instantiated_type().get_raw_type().get_name().to_string() + "( ";
  64. auto ref_list = get_is_reference();
  65. auto const_list = get_is_const();
  66. for (const auto& param : param_info_list)
  67. {
  68. m_signature += param.get_type().get_name() + string(is_const_list[const_list[param.get_index()]]) + string(is_ref_list[ref_list[param.get_index()]]);
  69. if (param.get_index() < param_info_list.size() - 1)
  70. m_signature += ", ";
  71. }
  72. if (param_info_list.empty())
  73. m_signature += ")";
  74. else
  75. m_signature += " )";
  76. m_signature_view = m_signature;
  77. }
  78. /////////////////////////////////////////////////////////////////////////////////////////
  79. bool constructor_wrapper_base::is_valid() const RTTR_NOEXCEPT
  80. {
  81. return false;
  82. }
  83. /////////////////////////////////////////////////////////////////////////////////////////
  84. type constructor_wrapper_base::get_declaring_type() const RTTR_NOEXCEPT
  85. {
  86. return get_invalid_type();
  87. }
  88. /////////////////////////////////////////////////////////////////////////////////////////
  89. access_levels constructor_wrapper_base::get_access_level() const RTTR_NOEXCEPT
  90. {
  91. return access_levels::public_access;
  92. }
  93. /////////////////////////////////////////////////////////////////////////////////////////
  94. type constructor_wrapper_base::get_instantiated_type() const RTTR_NOEXCEPT
  95. {
  96. return get_invalid_type();
  97. }
  98. /////////////////////////////////////////////////////////////////////////////////////////
  99. std::vector<bool> constructor_wrapper_base::get_is_reference() const RTTR_NOEXCEPT
  100. {
  101. return std::vector<bool>();
  102. }
  103. /////////////////////////////////////////////////////////////////////////////////////////
  104. std::vector<bool> constructor_wrapper_base::get_is_const() const RTTR_NOEXCEPT
  105. {
  106. return std::vector<bool>();
  107. }
  108. /////////////////////////////////////////////////////////////////////////////////////////
  109. array_range<parameter_info> constructor_wrapper_base::get_parameter_infos() const RTTR_NOEXCEPT
  110. {
  111. return array_range<parameter_info>();
  112. }
  113. /////////////////////////////////////////////////////////////////////////////////////////
  114. variant constructor_wrapper_base::get_metadata(const variant& key) const
  115. {
  116. return variant();
  117. }
  118. /////////////////////////////////////////////////////////////////////////////////////////
  119. variant constructor_wrapper_base::invoke() const
  120. {
  121. return variant();
  122. }
  123. /////////////////////////////////////////////////////////////////////////////////////////
  124. variant constructor_wrapper_base::invoke(argument& arg1) const
  125. {
  126. return variant();
  127. }
  128. /////////////////////////////////////////////////////////////////////////////////////////
  129. variant constructor_wrapper_base::invoke(argument& arg1, argument& arg2) const
  130. {
  131. return variant();
  132. }
  133. /////////////////////////////////////////////////////////////////////////////////////////
  134. variant constructor_wrapper_base::invoke(argument& arg1, argument& arg2, argument& arg3) const
  135. {
  136. return variant();
  137. }
  138. /////////////////////////////////////////////////////////////////////////////////////////
  139. variant constructor_wrapper_base::invoke(argument& arg1, argument& arg2, argument& arg3, argument& arg4) const
  140. {
  141. return variant();
  142. }
  143. /////////////////////////////////////////////////////////////////////////////////////////
  144. variant constructor_wrapper_base::invoke(argument& arg1, argument& arg2, argument& arg3, argument& arg4,
  145. argument& arg5) const
  146. {
  147. return variant();
  148. }
  149. /////////////////////////////////////////////////////////////////////////////////////////
  150. variant constructor_wrapper_base::invoke(argument& arg1, argument& arg2, argument& arg3, argument& arg4,
  151. argument& arg5, argument& arg6) const
  152. {
  153. return variant();
  154. }
  155. /////////////////////////////////////////////////////////////////////////////////////////
  156. variant constructor_wrapper_base::invoke_variadic(std::vector<argument>& args) const
  157. {
  158. return variant();
  159. }
  160. /////////////////////////////////////////////////////////////////////////////////////////
  161. void constructor_wrapper_base::visit(visitor& visitor, const constructor& ctor) const RTTR_NOEXCEPT
  162. {
  163. }
  164. /////////////////////////////////////////////////////////////////////////////////////////
  165. } // end namespace detail
  166. } // end namespace rttr