?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. // https://github.com/vinniefalco/LuaBridge
  2. // Copyright 2020, Dmitry Tarakanov
  3. // Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
  4. // SPDX-License-Identifier: MIT
  5.  
  6. #pragma once
  7.  
  8. namespace luabridge {
  9.  
  10. namespace detail {
  11.  
  12. /**
  13.  * A unique key for a type name in a metatable.
  14.  */
  15. inline const void* getTypeKey()
  16. {
  17. #ifdef _NDEBUG
  18.     static char value;
  19.     return &value;
  20. #else
  21.     return reinterpret_cast<void*>(0x71);
  22. #endif
  23. }
  24.  
  25. /**
  26.  * The key of a const table in another metatable.
  27.  */
  28. inline const void* getConstKey()
  29. {
  30. #ifdef _NDEBUG
  31.     static char value;
  32.     return &value;
  33. #else
  34.     return reinterpret_cast<void*>(0xc07);
  35. #endif
  36. }
  37.  
  38. /**
  39.  * The key of a class table in another metatable.
  40.  */
  41. inline const void* getClassKey()
  42. {
  43. #ifdef _NDEBUG
  44.     static char value;
  45.     return &value;
  46. #else
  47.     return reinterpret_cast<void*>(0xc1a);
  48. #endif
  49. }
  50.  
  51. /**
  52.  * The key of a propget table in another metatable.
  53.  */
  54. inline const void* getPropgetKey()
  55. {
  56. #ifdef _NDEBUG
  57.     static char value;
  58.     return &value;
  59. #else
  60.     return reinterpret_cast<void*>(0x6e7);
  61. #endif
  62. }
  63.  
  64. /**
  65.  * The key of a propset table in another metatable.
  66.  */
  67. inline const void* getPropsetKey()
  68. {
  69. #ifdef _NDEBUG
  70.     static char value;
  71.     return &value;
  72. #else
  73.     return reinterpret_cast<void*>(0x5e7);
  74. #endif
  75. }
  76.  
  77. /**
  78.  * The key of a static table in another metatable.
  79.  */
  80. inline const void* getStaticKey()
  81. {
  82. #ifdef _NDEBUG
  83.     static char value;
  84.     return &value;
  85. #else
  86.     return reinterpret_cast<void*>(0x57a);
  87. #endif
  88. }
  89.  
  90. /**
  91.  * The key of a parent table in another metatable.
  92.  */
  93. inline const void* getParentKey()
  94. {
  95. #ifdef _NDEBUG
  96.     static char value;
  97.     return &value;
  98. #else
  99.     return reinterpret_cast<void*>(0xdad);
  100. #endif
  101. }
  102.  
  103. /**
  104.     Get the key for the static table in the Lua registry.
  105.     The static table holds the static data members, static properties, and
  106.     static member functions for a class.
  107. */
  108. template<class T>
  109. void const* getStaticRegistryKey()
  110. {
  111.     static char value;
  112.     return &value;
  113. }
  114.  
  115. /** Get the key for the class table in the Lua registry.
  116.     The class table holds the data members, properties, and member functions
  117.     of a class. Read-only data and properties, and const member functions are
  118.     also placed here (to save a lookup in the const table).
  119. */
  120. template<class T>
  121. void const* getClassRegistryKey()
  122. {
  123.     static char value;
  124.     return &value;
  125. }
  126.  
  127. /** Get the key for the const table in the Lua registry.
  128.     The const table holds read-only data members and properties, and const
  129.     member functions of a class.
  130. */
  131. template<class T>
  132. void const* getConstRegistryKey()
  133. {
  134.     static char value;
  135.     return &value;
  136. }
  137.  
  138. } // namespace detail
  139.  
  140. } // namespace luabridge
  141.