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

Remove `uniform_type_info::as_message`

parent cf73d125
......@@ -37,10 +37,6 @@ public:
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 {
return native_ == &tinfo || *native_ == tinfo;
}
......
......@@ -170,7 +170,7 @@ public:
/// Returns a vector with all known (announced) types.
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
= uniform_value{}) const = 0;
......@@ -209,9 +209,6 @@ public:
/// @pre `instance` has the type of `this`.
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.
uint16_t type_nr() const {
return type_nr_;
......
......@@ -70,7 +70,7 @@ void message::deserialize(deserializer& source) {
auto uval = uti->create();
uti->deserialize(uval->val, &source);
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) {
......
......@@ -382,10 +382,6 @@ public:
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) {
return *reinterpret_cast<const T*>(ptr);
}
......@@ -436,17 +432,14 @@ public:
const char* name() const override {
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 {
return deref(lhs) == deref(rhs);
}
uniform_value create(const uniform_value& other) const override {
return create_impl<T>(other);
}
private:
inline static const T& deref(const void* ptr) {
return *reinterpret_cast<const T*>(ptr);
......@@ -476,6 +469,7 @@ public:
}
}
}
uniform_value create(const uniform_value& other) const override {
auto res = create_impl<message>(other);
if (! other) {
......@@ -486,12 +480,11 @@ public:
}
return res;
}
message as_message(void* ptr) const override {
return *cast(ptr);
}
const char* name() const override {
return name_.c_str();
}
void serialize(const void* ptr, serializer* sink) const override {
auto& msg = *cast(ptr);
CAF_ASSERT(msg.size() == elements_.size());
......@@ -499,6 +492,7 @@ public:
elements_[i]->serialize(msg.at(i), sink);
}
}
void deserialize(void* ptr, deserializer* source) const override {
message_builder mb;
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