From 7b041b123cb067d247a727bb3a4563bb2fc575eb Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 4 Apr 2017 11:33:22 -0700 Subject: [core, darwin] Object identity for MGLSource*, MGLStyleLayer* All `MGLSource` pointers referencing the same logical source will now be object identical; similarly for `MGLStyleLayer`. --- include/mbgl/style/layer.hpp | 6 ++++++ include/mbgl/style/source.hpp | 6 ++++++ include/mbgl/util/any.hpp | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 include/mbgl/util/any.hpp (limited to 'include') diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 670faa8254..fa88b30dbc 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -118,6 +119,11 @@ public: // Private implementation const std::unique_ptr baseImpl; + // For use in SDK bindings, which store a reference to a platform-native peer + // object here, so that separately-obtained references to this object share + // identical platform-native peers. + any peer; + friend std::string layoutKey(const Layer&); }; diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp index 0e6e32b112..f2dfb6a896 100644 --- a/include/mbgl/style/source.hpp +++ b/include/mbgl/style/source.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -64,6 +65,11 @@ public: class Impl; const std::unique_ptr baseImpl; + // For use in SDK bindings, which store a reference to a platform-native peer + // object here, so that separately-obtained references to this object share + // identical platform-native peers. + any peer; + protected: const SourceType type; Source(SourceType, std::unique_ptr); diff --git a/include/mbgl/util/any.hpp b/include/mbgl/util/any.hpp new file mode 100644 index 0000000000..eea64b188a --- /dev/null +++ b/include/mbgl/util/any.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace mbgl { + +using linb::any; +using linb::any_cast; + +} // namespace mbgl -- cgit v1.2.1