From dd5e75f99e37fc8e407da6fc003fcfa56b802752 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 26 Nov 2015 13:39:56 +0100 Subject: Add typedef ExtensionManager::ExtMap --- src/base.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/base.cpp') diff --git a/src/base.cpp b/src/base.cpp index 67b136ec8..c268c7493 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -147,10 +147,10 @@ bool ExtensionManager::Register(ExtensionItem* item) void ExtensionManager::BeginUnregister(Module* module, std::vector >& list) { - std::map >::iterator i = types.begin(); + ExtMap::iterator i = types.begin(); while (i != types.end()) { - std::map >::iterator me = i++; + ExtMap::iterator me = i++; ExtensionItem* item = me->second; if (item->creator == module) { @@ -162,7 +162,7 @@ void ExtensionManager::BeginUnregister(Module* module, std::vector >::iterator i = types.find(name); + ExtMap::iterator i = types.find(name); if (i == types.end()) return NULL; return i->second; -- cgit v1.2.3 From cdb764f2de7ee27c97708dfe44f1e6b905c571db Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 26 Nov 2015 13:50:28 +0100 Subject: Fix FORMAT_INTERNAL handling in LocalIntExt::serialize() and LocalStringExt::serialize() --- src/base.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/base.cpp') diff --git a/src/base.cpp b/src/base.cpp index c268c7493..b007a1098 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -238,7 +238,7 @@ LocalStringExt::~LocalStringExt() std::string LocalStringExt::serialize(SerializeFormat format, const Extensible* container, void* item) const { - if (item && format == FORMAT_USER) + if ((item) && (format != FORMAT_NETWORK)) return *static_cast(item); return ""; } @@ -254,7 +254,7 @@ LocalIntExt::~LocalIntExt() std::string LocalIntExt::serialize(SerializeFormat format, const Extensible* container, void* item) const { - if (format != FORMAT_USER) + if (format == FORMAT_NETWORK) return ""; return ConvToStr(reinterpret_cast(item)); } -- cgit v1.2.3 From f330428223ff90eeae3e22e8de20e5aea1188061 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 26 Nov 2015 13:53:01 +0100 Subject: Add LocalIntExt and LocalStringExt::unserialize() for non-FORMAT_NETWORK --- include/extensible.h | 2 ++ src/base.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'src/base.cpp') diff --git a/include/extensible.h b/include/extensible.h index 11d6acbc9..5ac4fa9da 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -201,6 +201,7 @@ class CoreExport LocalStringExt : public SimpleExtItem LocalStringExt(const std::string& key, ExtensibleType exttype, Module* owner); virtual ~LocalStringExt(); std::string serialize(SerializeFormat format, const Extensible* container, void* item) const; + void unserialize(SerializeFormat format, Extensible* container, const std::string& value); }; class CoreExport LocalIntExt : public LocalExtItem @@ -209,6 +210,7 @@ class CoreExport LocalIntExt : public LocalExtItem LocalIntExt(const std::string& key, ExtensibleType exttype, Module* owner); virtual ~LocalIntExt(); std::string serialize(SerializeFormat format, const Extensible* container, void* item) const; + void unserialize(SerializeFormat format, Extensible* container, const std::string& value); intptr_t get(const Extensible* container) const; intptr_t set(Extensible* container, intptr_t value); void unset(Extensible* container) { set(container, 0); } diff --git a/src/base.cpp b/src/base.cpp index b007a1098..496b23ef5 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -243,6 +243,12 @@ std::string LocalStringExt::serialize(SerializeFormat format, const Extensible* return ""; } +void LocalStringExt::unserialize(SerializeFormat format, Extensible* container, const std::string& value) +{ + if (format != FORMAT_NETWORK) + set(container, value); +} + LocalIntExt::LocalIntExt(const std::string& Key, ExtensibleType exttype, Module* mod) : LocalExtItem(Key, exttype, mod) { @@ -259,6 +265,12 @@ std::string LocalIntExt::serialize(SerializeFormat format, const Extensible* con return ConvToStr(reinterpret_cast(item)); } +void LocalIntExt::unserialize(SerializeFormat format, Extensible* container, const std::string& value) +{ + if (format != FORMAT_NETWORK) + set(container, ConvToInt(value)); +} + intptr_t LocalIntExt::get(const Extensible* container) const { return reinterpret_cast(get_raw(container)); -- cgit v1.2.3