Commit 2a83c142 authored by Dominik Charousset's avatar Dominik Charousset

Remove `uniform_type_info::as_message`

parent cf73d125
...@@ -37,10 +37,6 @@ public: ...@@ -37,10 +37,6 @@ public:
return name_.c_str(); return name_.c_str();
} }
message as_message(void* instance) const override {
return make_message(deref(instance));
}
bool equal_to(const std::type_info& tinfo) const override { bool equal_to(const std::type_info& tinfo) const override {
return native_ == &tinfo || *native_ == tinfo; return native_ == &tinfo || *native_ == tinfo;
} }
......
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
/// Returns a vector with all known (announced) types. /// Returns a vector with all known (announced) types.
static std::vector<const uniform_type_info*> instances(); static std::vector<const uniform_type_info*> instances();
/// Creates a copy of `other`. /// Creates a copy of `other` or a new instance if `other == nullptr`.
virtual uniform_value create(const uniform_value& other virtual uniform_value create(const uniform_value& other
= uniform_value{}) const = 0; = uniform_value{}) const = 0;
...@@ -209,9 +209,6 @@ public: ...@@ -209,9 +209,6 @@ public:
/// @pre `instance` has the type of `this`. /// @pre `instance` has the type of `this`.
virtual void deserialize(void* instance, deserializer* source) const = 0; virtual void deserialize(void* instance, deserializer* source) const = 0;
/// Returns `instance` encapsulated as an `message`.
virtual message as_message(void* instance) const = 0;
/// Returns a unique number for builtin types or 0. /// Returns a unique number for builtin types or 0.
uint16_t type_nr() const { uint16_t type_nr() const {
return type_nr_; return type_nr_;
......
...@@ -70,7 +70,7 @@ void message::deserialize(deserializer& source) { ...@@ -70,7 +70,7 @@ void message::deserialize(deserializer& source) {
auto uval = uti->create(); auto uval = uti->create();
uti->deserialize(uval->val, &source); uti->deserialize(uval->val, &source);
source.end_object(); source.end_object();
*this = uti->as_message(uval->val); *this = *reinterpret_cast<message*>(uval->val);
} }
void message::reset(raw_ptr new_ptr, bool add_ref) { void message::reset(raw_ptr new_ptr, bool add_ref) {
......
...@@ -382,10 +382,6 @@ public: ...@@ -382,10 +382,6 @@ public:
return create_impl<T>(other); return create_impl<T>(other);
} }
message as_message(void* instance) const override {
return make_message(deref(instance));
}
static inline const T& deref(const void* ptr) { static inline const T& deref(const void* ptr) {
return *reinterpret_cast<const T*>(ptr); return *reinterpret_cast<const T*>(ptr);
} }
...@@ -436,17 +432,14 @@ public: ...@@ -436,17 +432,14 @@ public:
const char* name() const override { const char* name() const override {
return static_name(); return static_name();
} }
message as_message(void* instance) const override {
return make_message(deref(instance));
}
protected:
bool equals(const void* lhs, const void* rhs) const override { bool equals(const void* lhs, const void* rhs) const override {
return deref(lhs) == deref(rhs); return deref(lhs) == deref(rhs);
} }
uniform_value create(const uniform_value& other) const override { uniform_value create(const uniform_value& other) const override {
return create_impl<T>(other); return create_impl<T>(other);
} }
private: private:
inline static const T& deref(const void* ptr) { inline static const T& deref(const void* ptr) {
return *reinterpret_cast<const T*>(ptr); return *reinterpret_cast<const T*>(ptr);
...@@ -476,6 +469,7 @@ public: ...@@ -476,6 +469,7 @@ public:
} }
} }
} }
uniform_value create(const uniform_value& other) const override { uniform_value create(const uniform_value& other) const override {
auto res = create_impl<message>(other); auto res = create_impl<message>(other);
if (! other) { if (! other) {
...@@ -486,12 +480,11 @@ public: ...@@ -486,12 +480,11 @@ public:
} }
return res; return res;
} }
message as_message(void* ptr) const override {
return *cast(ptr);
}
const char* name() const override { const char* name() const override {
return name_.c_str(); return name_.c_str();
} }
void serialize(const void* ptr, serializer* sink) const override { void serialize(const void* ptr, serializer* sink) const override {
auto& msg = *cast(ptr); auto& msg = *cast(ptr);
CAF_ASSERT(msg.size() == elements_.size()); CAF_ASSERT(msg.size() == elements_.size());
...@@ -499,6 +492,7 @@ public: ...@@ -499,6 +492,7 @@ public:
elements_[i]->serialize(msg.at(i), sink); elements_[i]->serialize(msg.at(i), sink);
} }
} }
void deserialize(void* ptr, deserializer* source) const override { void deserialize(void* ptr, deserializer* source) const override {
message_builder mb; message_builder mb;
for (size_t i = 0; i < elements_.size(); ++i) { for (size_t i = 0; i < elements_.size(); ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment