Ver código fonte

test_info::id: make the family-like fallback work across boundaries

Michele Caini 6 anos atrás
pai
commit
7cfd3957de

+ 2 - 1
TODO

@@ -20,11 +20,12 @@
 * sparse set: there exists an alternative to paginated sparse arrays?
 * see warning (vs2017 only): d:\a\entt\entt\src\entt\entity\registry.hpp(108)
 * remove duktape example (and eventually provide a new one)?
+* meta: rebind meta types from any across boundaries (eg conv corner case across boundary)
 * registry
   - ::assure -> pool_type<T> &
   - ::group improve, reduce code
 
 * Mission: get rid of named types
-  - make family-like fallback for type_info::id work across boundaries
+  - add tests for type_info fallback and type_info specializations
   - update doc: dispatcher, emitter, registry, meta, across boundaries
   - review and suppress warnings, if any

+ 6 - 4
src/entt/config/config.h

@@ -53,10 +53,12 @@
 #endif
 
 
-#if defined _MSC_VER
-#   define ENTT_PRETTY_FUNCTION __FUNCSIG__
-#elif defined __GNUC__
-#   define ENTT_PRETTY_FUNCTION __PRETTY_FUNCTION__
+#ifndef ENTT_STANDARD_CPP
+#   if defined _MSC_VER
+#      define ENTT_PRETTY_FUNCTION __FUNCSIG__
+#   elif defined __GNUC__
+#      define ENTT_PRETTY_FUNCTION __PRETTY_FUNCTION__
+#   endif
 #endif
 
 

+ 5 - 8
src/entt/core/type_info.hpp

@@ -3,6 +3,7 @@
 
 
 #include "../config/config.h"
+#include "../core/attribute.h"
 #include "hashed_string.hpp"
 
 
@@ -14,18 +15,14 @@ namespace entt {
  * @tparam Type Type for which to generate an identifier.
  */
 template<typename Type, typename = void>
-struct type_info {
+struct ENTT_API type_info {
     /**
      * @brief Returns the numeric representation of a given type.
      * @return The numeric representation of the given type.
      */
-#if defined _MSC_VER
+#if defined ENTT_PRETTY_FUNCTION
     static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
-        return entt::hashed_string{__FUNCSIG__};
-    }
-#elif defined __GNUC__
-    static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT {
-        return entt::hashed_string{__PRETTY_FUNCTION__};
+        return entt::hashed_string{ENTT_PRETTY_FUNCTION};
     }
 #else
     static ENTT_ID_TYPE id() ENTT_NOEXCEPT;
@@ -41,7 +38,7 @@ struct type_info {
 namespace internal {
 
 
-struct type_id_generator {
+struct ENTT_API type_id_generator {
     static ENTT_ID_TYPE next() ENTT_NOEXCEPT {
         static ENTT_ID_TYPE value{};
         return value++;

+ 1 - 1
test/lib/dispatcher/types.h

@@ -7,4 +7,4 @@ struct message {
 
 struct event {};
 
-#endif // ENTT_LIB_DISPATCHER_TYPES_H
+#endif

+ 1 - 1
test/lib/emitter/types.h

@@ -13,4 +13,4 @@ struct message {
 
 struct event {};
 
-#endif // ENTT_LIB_EMITTER_TYPES_H
+#endif

+ 3 - 5
test/lib/meta/types.h

@@ -1,16 +1,14 @@
 #ifndef ENTT_LIB_META_TYPES_H
 #define ENTT_LIB_META_TYPES_H
 
-#include <entt/core/attribute.h>
-
-struct ENTT_API position {
+struct position {
     int x{};
     int y{};
 };
 
-struct ENTT_API velocity {
+struct velocity {
     double dx{};
     double dy{};
 };
 
-#endif // ENTT_LIB_META_TYPES_H
+#endif

+ 3 - 5
test/lib/registry/types.h

@@ -1,16 +1,14 @@
 #ifndef ENTT_LIB_REGISTRY_TYPES_H
 #define ENTT_LIB_REGISTRY_TYPES_H
 
-#include <entt/core/attribute.h>
-
-struct ENTT_API position {
+struct position {
     int x;
     int y;
 };
 
-struct ENTT_API velocity {
+struct velocity {
     double dx;
     double dy;
 };
 
-#endif // ENTT_LIB_REGISTRY_TYPES_H
+#endif

+ 1 - 1
test/plugin/dispatcher/types.h

@@ -7,4 +7,4 @@ struct message {
 
 struct event {};
 
-#endif // ENTT_PLUGIN_DISPATCHER_TYPES_H
+#endif

+ 1 - 1
test/plugin/emitter/types.h

@@ -13,4 +13,4 @@ struct message {
 
 struct event {};
 
-#endif // ENTT_PLUGIN_EMITTER_TYPES_H
+#endif

+ 1 - 1
test/plugin/meta/types.h

@@ -18,4 +18,4 @@ struct userdata {
     entt::meta_any any;
 };
 
-#endif // ENTT_PLUGIN_META_TYPES_H
+#endif

+ 1 - 1
test/plugin/registry/types.h

@@ -11,4 +11,4 @@ struct velocity {
     double dy;
 };
 
-#endif // ENTT_PLUGIN_REGISTRY_TYPES_H
+#endif