From 360aad676ba92ca443083da298b766628f6a3bfb Mon Sep 17 00:00:00 2001 From: mental Date: Wed, 15 Mar 2006 03:22:23 +0000 Subject: [PATCH] shared_ptr -> ptr_shared --- ChangeLog | 21 +++++++ src/debug/event.h | 12 ++-- src/debug/gc-heap.h | 2 +- src/debug/heap.h | 2 +- src/debug/logger.cpp | 8 +-- src/debug/simple-event.h | 6 +- src/debug/sysv-heap.h | 2 +- src/jabber_whiteboard/deserializer.cpp | 6 +- src/jabber_whiteboard/message-utilities.cpp | 2 +- src/jabber_whiteboard/message-utilities.h | 4 +- src/jabber_whiteboard/node-tracker-observer.h | 8 +-- src/jabber_whiteboard/serializer.cpp | 8 +-- src/jabber_whiteboard/serializer.h | 8 +-- src/sp-object.cpp | 12 ++-- src/util/share.cpp | 6 +- src/util/share.h | 56 +++++++++--------- src/xml/attribute-record.h | 4 +- src/xml/comment-node.h | 2 +- src/xml/composite-node-observer.cpp | 8 +-- src/xml/composite-node-observer.h | 8 +-- src/xml/event.cpp | 16 ++--- src/xml/event.h | 16 ++--- src/xml/log-builder.cpp | 8 +-- src/xml/log-builder.h | 8 +-- src/xml/node-observer.h | 8 +-- src/xml/repr-io.cpp | 10 ++-- src/xml/simple-node.cpp | 58 +++++++++---------- src/xml/simple-node.h | 2 +- src/xml/simple-session.cpp | 8 +-- src/xml/simple-session.h | 8 +-- src/xml/text-node.h | 2 +- 31 files changed, 175 insertions(+), 154 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c7519736..dbebc8778 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2006-03-14 MenTaLguY + + * src/debug/event.h, src/debug/gc-heap.h, src/debug/heap.h, + src/debug/logger.cpp, src/debug/simple-event.h, + src/debug/sysv-heap.h, src/jabber_whiteboard/deserializer.cpp, + src/jabber_whiteboard/message-utilities.cpp, + src/jabber_whiteboard/message-utilities.h, + src/jabber_whiteboard/node-tracker-observer.h, + src/jabber_whiteboard/serializer.cpp, + src/jabber_whiteboard/serializer.h, + src/sp-object.cpp, src/util/share.cpp, src/util/share.h, + src/xml/attribute-record.h, src/xml/comment-node.h, + src/xml/composite-node-observer.cpp, src/xml/composite-node-observer.h, + src/xml/event.cpp, src/xml/event.h, src/xml/log-builder.cpp, + src/xml/log-builder.h, src/xml/node-observer.h, src/xml/repr-io.cpp, + src/xml/simple-node.cpp, src/xml/simple-node.h, + src/xml/simple-session.cpp, src/xml/simple-session.h, + src/xml/text-node.h: + + shared_ptr -> ptr_shared + 2006-03-13 Peter Moulder * src/svg/svg-color.cpp (sp_svg_write_color): More readable colour diff --git a/src/debug/event.h b/src/debug/event.h index 8232f890d..fdc50f225 100644 --- a/src/debug/event.h +++ b/src/debug/event.h @@ -37,23 +37,23 @@ public: struct PropertyPair { public: PropertyPair() {} - PropertyPair(Util::shared_ptr n, Util::shared_ptr v) + PropertyPair(Util::ptr_shared n, Util::ptr_shared v) : name(n), value(v) {} - PropertyPair(char const *n, Util::shared_ptr v) + PropertyPair(char const *n, Util::ptr_shared v) : name(Util::share_string(n)), value(v) {} - PropertyPair(Util::shared_ptr n, char const *v) + PropertyPair(Util::ptr_shared n, char const *v) : name(n), value(Util::share_string(v)) {} PropertyPair(char const *n, char const *v) : name(Util::share_string(n)), value(Util::share_string(v)) {} - Util::shared_ptr name; - Util::shared_ptr value; + Util::ptr_shared name; + Util::ptr_shared value; }; static Category category() { return OTHER; } - virtual Util::shared_ptr name() const=0; + virtual Util::ptr_shared name() const=0; virtual unsigned propertyCount() const=0; virtual PropertyPair property(unsigned property) const=0; }; diff --git a/src/debug/gc-heap.h b/src/debug/gc-heap.h index 75a60158e..4d0343f12 100644 --- a/src/debug/gc-heap.h +++ b/src/debug/gc-heap.h @@ -23,7 +23,7 @@ public: int features() const { return SIZE_AVAILABLE | USED_AVAILABLE | GARBAGE_COLLECTED; } - Util::shared_ptr name() const { + Util::ptr_shared name() const { return Util::share_static_string("libgc"); } Heap::Stats stats() const { diff --git a/src/debug/heap.h b/src/debug/heap.h index ef563030f..f3cc250a5 100644 --- a/src/debug/heap.h +++ b/src/debug/heap.h @@ -36,7 +36,7 @@ public: virtual int features() const=0; - virtual Util::shared_ptr name() const=0; + virtual Util::ptr_shared name() const=0; virtual Stats stats() const=0; virtual void force_collect()=0; }; diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 3acd95ff5..a3f6899ef 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -25,7 +25,7 @@ bool Logger::_category_mask[Event::N_CATEGORIES]; namespace { -static void write_escaped_value(std::ostream &os, Util::shared_ptr value) { +static void write_escaped_value(std::ostream &os, Util::ptr_shared value) { for ( char const *current=value ; *current ; ++current ) { switch (*current) { case '&': @@ -57,7 +57,7 @@ static void write_indent(std::ostream &os, unsigned depth) { static std::ofstream log_stream; static bool empty_tag=false; -typedef std::vector, GC::Alloc, GC::MANUAL> > TagStack; +typedef std::vector, GC::Alloc, GC::MANUAL> > TagStack; static TagStack &tag_stack() { static TagStack stack; return stack; @@ -136,7 +136,7 @@ void Logger::init() { } void Logger::_start(Event const &event) { - Util::shared_ptr name=event.name(); + Util::ptr_shared name=event.name(); if (empty_tag) { log_stream << ">\n"; @@ -161,7 +161,7 @@ void Logger::_start(Event const &event) { } void Logger::_skip() { - tag_stack().push_back(Util::shared_ptr()); + tag_stack().push_back(Util::ptr_shared()); } void Logger::_finish() { diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 90eed3a0e..3695eaa6a 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -21,17 +21,17 @@ namespace Debug { template class SimpleEvent : public Event { public: - SimpleEvent(Util::shared_ptr name) : _name(name) {} + SimpleEvent(Util::ptr_shared name) : _name(name) {} SimpleEvent(char const *name) : _name(Util::share_string(name)) {} static Category category() { return C; } - Util::shared_ptr name() const { return _name; } + Util::ptr_shared name() const { return _name; } unsigned propertyCount() const { return 0; } PropertyPair property(unsigned property) const { return PropertyPair(); } private: - Util::shared_ptr _name; + Util::ptr_shared _name; }; } diff --git a/src/debug/sysv-heap.h b/src/debug/sysv-heap.h index 840afac32..82fe9b769 100644 --- a/src/debug/sysv-heap.h +++ b/src/debug/sysv-heap.h @@ -23,7 +23,7 @@ public: int features() const; - Util::shared_ptr name() const { + Util::ptr_shared name() const { return Util::share_static_string("standard malloc()"); } Stats stats() const; diff --git a/src/jabber_whiteboard/deserializer.cpp b/src/jabber_whiteboard/deserializer.cpp index 2df35e8ab..0e207122f 100644 --- a/src/jabber_whiteboard/deserializer.cpp +++ b/src/jabber_whiteboard/deserializer.cpp @@ -284,7 +284,7 @@ Deserializer::deserializeEventChgContent(Glib::ustring const& msg) { // 1. Extract required attributes: node ID. If we do not know these, return. std::string id; - Util::shared_ptr oldval, newval; + Util::ptr_shared oldval, newval; Node buf; buf.tag = MESSAGE_ID; @@ -344,7 +344,7 @@ Deserializer::deserializeEventChgAttr(Glib::ustring const& msg) // 2. Extract optional attributes: new value. If we do not find it in the message, // assume there is no new value. buf.tag = MESSAGE_NEWVAL; - Util::shared_ptr newval; + Util::ptr_shared newval; if (MessageUtilities::findTag(buf, msg)) { newval = Util::share_string(buf.data.c_str()); } else { @@ -354,7 +354,7 @@ Deserializer::deserializeEventChgAttr(Glib::ustring const& msg) // 3. Extract optional attributes: old value. If we do not find it in the message, // assume that there is no old value. buf.tag = MESSAGE_OLDVAL; - Util::shared_ptr oldval; + Util::ptr_shared oldval; if (MessageUtilities::findTag(buf, msg)) { oldval = Util::share_string(buf.data.c_str()); } else { diff --git a/src/jabber_whiteboard/message-utilities.cpp b/src/jabber_whiteboard/message-utilities.cpp index 2812e303b..c10521b61 100644 --- a/src/jabber_whiteboard/message-utilities.cpp +++ b/src/jabber_whiteboard/message-utilities.cpp @@ -297,7 +297,7 @@ MessageUtilities::objectDeleteMessage(Glib::ustring* msgbuf, XMLNodeTracker* xmt } void -MessageUtilities::contentChangeMessage(Glib::ustring& msgbuf, std::string const nodeid, Util::shared_ptr old_value, Util::shared_ptr new_value) +MessageUtilities::contentChangeMessage(Glib::ustring& msgbuf, std::string const nodeid, Util::ptr_shared old_value, Util::ptr_shared new_value) { if (!nodeid.empty()) { // diff --git a/src/jabber_whiteboard/message-utilities.h b/src/jabber_whiteboard/message-utilities.h index 8fbefac18..c6d464f08 100644 --- a/src/jabber_whiteboard/message-utilities.h +++ b/src/jabber_whiteboard/message-utilities.h @@ -27,7 +27,7 @@ namespace Inkscape { namespace Util { template -class shared_ptr; +class ptr_shared; } @@ -47,7 +47,7 @@ public: static void newObjectMessage(ustring* msgbuf, KeyToNodeMap& newidsbuf, NodeToKeyMap& newnodesbuf, NewChildObjectMessageList& childmsgbuf, XMLNodeTracker* xmt, Inkscape::XML::Node const* node, bool only_collect_nodes = false, bool collect_children = true); static void objectChangeMessage(ustring* msgbuf, XMLNodeTracker* xmt, std::string const id, gchar const* key, gchar const* oldval, gchar const* newval, bool is_interactive); static void objectDeleteMessage(ustring* msgbuf, XMLNodeTracker* xmt, Inkscape::XML::Node const& parent, Inkscape::XML::Node const& child, Inkscape::XML::Node const* prev); - static void contentChangeMessage(ustring& msgbuf, std::string const nodeid, Util::shared_ptr old_value, Util::shared_ptr new_value); + static void contentChangeMessage(ustring& msgbuf, std::string const nodeid, Util::ptr_shared old_value, Util::ptr_shared new_value); static void childOrderChangeMessage(ustring& msgbuf, std::string const childid, std::string const oldprevid, std::string const newprevid); // Message parsing utilities diff --git a/src/jabber_whiteboard/node-tracker-observer.h b/src/jabber_whiteboard/node-tracker-observer.h index a3260d8a0..86aa5c304 100644 --- a/src/jabber_whiteboard/node-tracker-observer.h +++ b/src/jabber_whiteboard/node-tracker-observer.h @@ -45,12 +45,12 @@ public: XML::Node *old_prev, XML::Node *new_prev)=0; virtual void notifyContentChanged(XML::Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content)=0; + Util::ptr_shared old_content, + Util::ptr_shared new_content)=0; virtual void notifyAttributeChanged(XML::Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value)=0; + Util::ptr_shared old_value, + Util::ptr_shared new_value)=0; // ...but we do provide node tracking facilities diff --git a/src/jabber_whiteboard/serializer.cpp b/src/jabber_whiteboard/serializer.cpp index eb5278047..094944257 100644 --- a/src/jabber_whiteboard/serializer.cpp +++ b/src/jabber_whiteboard/serializer.cpp @@ -91,11 +91,11 @@ Serializer::_newObjectEventHelper(XML::Node& node, XML::Node& child, XML::Node* Inkscape::Util::List attrlist = child.attributeList(); for(; attrlist; attrlist++) { - this->notifyAttributeChanged(child, attrlist->key, Util::shared_ptr(), attrlist->value); + this->notifyAttributeChanged(child, attrlist->key, Util::ptr_shared(), attrlist->value); } if (child.content()) { - this->notifyContentChanged(child, Util::shared_ptr(), Util::share_string(child.content())); + this->notifyContentChanged(child, Util::ptr_shared(), Util::share_string(child.content())); } this->_attributes_scanned.insert(childid); @@ -188,7 +188,7 @@ Serializer::notifyChildOrderChanged(XML::Node& node, XML::Node& child, XML::Node } void -Serializer::notifyContentChanged(XML::Node& node, Util::shared_ptr old_content, Util::shared_ptr new_content) +Serializer::notifyContentChanged(XML::Node& node, Util::ptr_shared old_content, Util::ptr_shared new_content) { // 1. Find the ID of the node, or generate it if it does not exist. std::string nodeid = this->_findOrGenerateNodeID(node); @@ -221,7 +221,7 @@ Serializer::notifyContentChanged(XML::Node& node, Util::shared_ptr old_con } void -Serializer::notifyAttributeChanged(XML::Node& node, GQuark name, Util::shared_ptr old_value, Util::shared_ptr new_value) +Serializer::notifyAttributeChanged(XML::Node& node, GQuark name, Util::ptr_shared old_value, Util::ptr_shared new_value) { // 1. Find the ID of the node that has had an attribute modified, or generate it if it // does not exist. diff --git a/src/jabber_whiteboard/serializer.h b/src/jabber_whiteboard/serializer.h index 16889c571..2884d43d3 100644 --- a/src/jabber_whiteboard/serializer.h +++ b/src/jabber_whiteboard/serializer.h @@ -39,12 +39,12 @@ public: XML::Node *old_prev, XML::Node *new_prev); void notifyContentChanged(XML::Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content); + Util::ptr_shared old_content, + Util::ptr_shared new_content); void notifyAttributeChanged(XML::Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value); + Util::ptr_shared old_value, + Util::ptr_shared new_value); void synthesizeChildNodeAddEvents(); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 5f6bf779f..9068c4ba2 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -227,16 +227,16 @@ sp_object_finalize(GObject *object) namespace { -Inkscape::Util::shared_ptr stringify(SPObject *obj) { +Inkscape::Util::ptr_shared stringify(SPObject *obj) { char *temp=g_strdup_printf("%p", obj); - Inkscape::Util::shared_ptr result=Inkscape::Util::share_string(temp); + Inkscape::Util::ptr_shared result=Inkscape::Util::share_string(temp); g_free(temp); return result; } -Inkscape::Util::shared_ptr stringify(unsigned n) { +Inkscape::Util::ptr_shared stringify(unsigned n) { char *temp=g_strdup_printf("%u", n); - Inkscape::Util::shared_ptr result=Inkscape::Util::share_string(temp); + Inkscape::Util::ptr_shared result=Inkscape::Util::share_string(temp); g_free(temp); return result; } @@ -252,7 +252,7 @@ public: static Category category() { return REFCOUNT; } - Inkscape::Util::shared_ptr name() const { + Inkscape::Util::ptr_shared name() const { if ( _type == REF) { return Inkscape::Util::share_static_string("sp-object-ref"); } else { @@ -272,7 +272,7 @@ public: } private: - Inkscape::Util::shared_ptr _object; + Inkscape::Util::ptr_shared _object; unsigned _refcount; Type _type; }; diff --git a/src/util/share.cpp b/src/util/share.cpp index 7f2d09bf6..2f693fac9 100644 --- a/src/util/share.cpp +++ b/src/util/share.cpp @@ -1,5 +1,5 @@ /* - * Inkscape::Util::shared_ptr - like T const *, but stronger + * Inkscape::Util::ptr_shared - like T const *, but stronger * * Authors: * MenTaLguY @@ -15,12 +15,12 @@ namespace Inkscape { namespace Util { -shared_ptr share_string(char const *string) { +ptr_shared share_string(char const *string) { g_return_val_if_fail(string != NULL, share_unsafe(NULL)); return share_string(string, std::strlen(string)); } -shared_ptr share_string(char const *string, std::size_t length) { +ptr_shared share_string(char const *string, std::size_t length) { g_return_val_if_fail(string != NULL, share_unsafe(NULL)); char *new_string=new (GC::ATOMIC) char[length+1]; std::memcpy(new_string, string, length); diff --git a/src/util/share.h b/src/util/share.h index 93cef7a02..3a2b73561 100644 --- a/src/util/share.h +++ b/src/util/share.h @@ -1,5 +1,5 @@ /* - * Inkscape::Util::shared_ptr - like T const *, but stronger + * Inkscape::Util::ptr_shared - like T const *, but stronger * * Authors: * MenTaLguY @@ -19,12 +19,12 @@ namespace Inkscape { namespace Util { template -class shared_ptr { +class ptr_shared { public: - shared_ptr() : _obj(NULL) {} + ptr_shared() : _obj(NULL) {} template - shared_ptr(shared_ptr const &other) : _obj(other._obj) {} + ptr_shared(ptr_shared const &other) : _obj(other._obj) {} T const *pointer() const { return _obj; } @@ -37,98 +37,98 @@ public: T const *operator->() const { return _obj; } T const &operator[](int i) const { return _obj[i]; } - shared_ptr operator+(int i) const { + ptr_shared operator+(int i) const { return share_unsafe(_obj+i); } - shared_ptr operator-(int i) const { + ptr_shared operator-(int i) const { return share_unsafe(_obj-i); } - shared_ptr &operator+=(int i) const { + ptr_shared &operator+=(int i) const { _obj += i; return *this; } - shared_ptr &operator-=(int i) const { + ptr_shared &operator-=(int i) const { _obj -= i; return *this; } template - std::ptrdiff_t operator-(shared_ptr const &other) { + std::ptrdiff_t operator-(ptr_shared const &other) { return _obj - other._obj; } template - shared_ptr &operator=(shared_ptr const &other) { + ptr_shared &operator=(ptr_shared const &other) { _obj = other._obj; return *this; } template - bool operator==(shared_ptr const &other) const { + bool operator==(ptr_shared const &other) const { return _obj == other._obj; } template - bool operator!=(shared_ptr const &other) const { + bool operator!=(ptr_shared const &other) const { return _obj != other._obj; } template - bool operator>(shared_ptr const &other) const { + bool operator>(ptr_shared const &other) const { return _obj > other._obj; } template - bool operator<(shared_ptr const &other) const { + bool operator<(ptr_shared const &other) const { return _obj < other._obj; } - static shared_ptr share_unsafe(T const *obj) { - return shared_ptr(obj); + static ptr_shared share_unsafe(T const *obj) { + return ptr_shared(obj); } protected: - explicit shared_ptr(T const *obj) : _obj(obj) {} + explicit ptr_shared(T const *obj) : _obj(obj) {} private: T const *_obj; }; template -inline shared_ptr share(T const *obj) { +inline ptr_shared share(T const *obj) { return share_unsafe(obj ? new T(*obj) : NULL); } -shared_ptr share_string(char const *string); -shared_ptr share_string(char const *string, std::size_t length); +ptr_shared share_string(char const *string); +ptr_shared share_string(char const *string, std::size_t length); template -inline shared_ptr reshare(T const *obj) { - return shared_ptr::share_unsafe(obj); +inline ptr_shared reshare(T const *obj) { + return ptr_shared::share_unsafe(obj); } template -inline shared_ptr share_unsafe(T const *obj) { - return shared_ptr::share_unsafe(obj); +inline ptr_shared share_unsafe(T const *obj) { + return ptr_shared::share_unsafe(obj); } -inline shared_ptr share_static_string(char const *string) { +inline ptr_shared share_static_string(char const *string) { return share_unsafe(string); } template -inline shared_ptr static_cast_shared(shared_ptr const &ref) { +inline ptr_shared static_cast_shared(ptr_shared const &ref) { return reshare(static_cast(ref.pointer())); } template -inline shared_ptr dynamic_cast_shared(shared_ptr const &ref) { +inline ptr_shared dynamic_cast_shared(ptr_shared const &ref) { return reshare(dynamic_cast(ref.pointer())); } template -inline shared_ptr reinterpret_cast_shared(shared_ptr const &ref) { +inline ptr_shared reinterpret_cast_shared(ptr_shared const &ref) { return reshare(reinterpret_cast(ref.pointer())); } diff --git a/src/xml/attribute-record.h b/src/xml/attribute-record.h index 30d8576d0..bfae19e21 100644 --- a/src/xml/attribute-record.h +++ b/src/xml/attribute-record.h @@ -13,11 +13,11 @@ namespace Inkscape { namespace XML { struct AttributeRecord : public Inkscape::GC::Managed<> { - AttributeRecord(GQuark k, Inkscape::Util::shared_ptr v) + AttributeRecord(GQuark k, Inkscape::Util::ptr_shared v) : key(k), value(v) {} GQuark key; - Inkscape::Util::shared_ptr value; + Inkscape::Util::ptr_shared value; // accept default copy constructor and assignment operator }; diff --git a/src/xml/comment-node.h b/src/xml/comment-node.h index e41a36b59..c439d0d54 100644 --- a/src/xml/comment-node.h +++ b/src/xml/comment-node.h @@ -23,7 +23,7 @@ namespace Inkscape { namespace XML { struct CommentNode : public SimpleNode { - explicit CommentNode(Util::shared_ptr content) + explicit CommentNode(Util::ptr_shared content) : SimpleNode(g_quark_from_static_string("comment")) { setContent(content); diff --git a/src/xml/composite-node-observer.cpp b/src/xml/composite-node-observer.cpp index b564da78d..bb68ba9c4 100644 --- a/src/xml/composite-node-observer.cpp +++ b/src/xml/composite-node-observer.cpp @@ -66,7 +66,7 @@ void CompositeNodeObserver::notifyChildOrderChanged(Node &node, Node &child, void CompositeNodeObserver::notifyContentChanged( Node &node, - Util::shared_ptr old_content, Util::shared_ptr new_content + Util::ptr_shared old_content, Util::ptr_shared new_content ) { _startIteration(); for ( ObserverRecordList::iterator iter=_active.begin() ; @@ -81,7 +81,7 @@ void CompositeNodeObserver::notifyContentChanged( void CompositeNodeObserver::notifyAttributeChanged( Node &node, GQuark name, - Util::shared_ptr old_value, Util::shared_ptr new_value + Util::ptr_shared old_value, Util::ptr_shared new_value ) { _startIteration(); for ( ObserverRecordList::iterator iter=_active.begin() ; @@ -130,13 +130,13 @@ public: } } - void notifyContentChanged(Node &node, Util::shared_ptr old_content, Util::shared_ptr new_content) { + void notifyContentChanged(Node &node, Util::ptr_shared old_content, Util::ptr_shared new_content) { if (vector.content_changed) { vector.content_changed(&node, old_content, new_content, data); } } - void notifyAttributeChanged(Node &node, GQuark name, Util::shared_ptr old_value, Util::shared_ptr new_value) { + void notifyAttributeChanged(Node &node, GQuark name, Util::ptr_shared old_value, Util::ptr_shared new_value) { if (vector.attr_changed) { vector.attr_changed(&node, g_quark_to_string(name), old_value, new_value, false, data); } diff --git a/src/xml/composite-node-observer.h b/src/xml/composite-node-observer.h index 4acde0b4c..7b5a24d53 100644 --- a/src/xml/composite-node-observer.h +++ b/src/xml/composite-node-observer.h @@ -51,12 +51,12 @@ public: Node *old_prev, Node *new_prev); void notifyContentChanged(Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content); + Util::ptr_shared old_content, + Util::ptr_shared new_content); void notifyAttributeChanged(Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value); + Util::ptr_shared old_value, + Util::ptr_shared new_value); private: unsigned _iterating; diff --git a/src/xml/event.cpp b/src/xml/event.cpp index dd7167874..d91dd681f 100644 --- a/src/xml/event.cpp +++ b/src/xml/event.cpp @@ -114,15 +114,15 @@ public: } void notifyAttributeChanged(Node &node, GQuark name, - Inkscape::Util::shared_ptr old_value, - Inkscape::Util::shared_ptr new_value) + Inkscape::Util::ptr_shared old_value, + Inkscape::Util::ptr_shared new_value) { node.setAttribute(g_quark_to_string(name), new_value); } void notifyContentChanged(Node &node, - Inkscape::Util::shared_ptr old_value, - Inkscape::Util::shared_ptr new_value) + Inkscape::Util::ptr_shared old_value, + Inkscape::Util::ptr_shared new_value) { node.setContent(new_value); } @@ -458,8 +458,8 @@ public: } void notifyAttributeChanged(Node &node, GQuark name, - Inkscape::Util::shared_ptr old_value, - Inkscape::Util::shared_ptr new_value) + Inkscape::Util::ptr_shared old_value, + Inkscape::Util::ptr_shared new_value) { if (new_value) { g_warning("Event: Set attribute %s to \"%s\" on %s", g_quark_to_string(name), new_value.pointer(), node_to_string(node).c_str()); @@ -469,8 +469,8 @@ public: } void notifyContentChanged(Node &node, - Inkscape::Util::shared_ptr old_value, - Inkscape::Util::shared_ptr new_value) + Inkscape::Util::ptr_shared old_value, + Inkscape::Util::ptr_shared new_value) { if (new_value) { g_warning("Event: Set content of %s to \"%s\"", node_to_string(node).c_str(), new_value.pointer()); diff --git a/src/xml/event.h b/src/xml/event.h index 56fdb8bb6..59dbe7c7b 100644 --- a/src/xml/event.h +++ b/src/xml/event.h @@ -96,15 +96,15 @@ private: class EventChgAttr : public Event { public: EventChgAttr(Node *repr, GQuark k, - Inkscape::Util::shared_ptr ov, - Inkscape::Util::shared_ptr nv, + Inkscape::Util::ptr_shared ov, + Inkscape::Util::ptr_shared nv, Event *next) : Event(repr, next), key(k), oldval(ov), newval(nv) {} GQuark key; - Inkscape::Util::shared_ptr oldval; - Inkscape::Util::shared_ptr newval; + Inkscape::Util::ptr_shared oldval; + Inkscape::Util::ptr_shared newval; private: Event *_optimizeOne(); @@ -115,13 +115,13 @@ private: class EventChgContent : public Event { public: EventChgContent(Node *repr, - Inkscape::Util::shared_ptr ov, - Inkscape::Util::shared_ptr nv, + Inkscape::Util::ptr_shared ov, + Inkscape::Util::ptr_shared nv, Event *next) : Event(repr, next), oldval(ov), newval(nv) {} - Inkscape::Util::shared_ptr oldval; - Inkscape::Util::shared_ptr newval; + Inkscape::Util::ptr_shared oldval; + Inkscape::Util::ptr_shared newval; private: Event *_optimizeOne(); diff --git a/src/xml/log-builder.cpp b/src/xml/log-builder.cpp index 97451075a..e8b7c707e 100644 --- a/src/xml/log-builder.cpp +++ b/src/xml/log-builder.cpp @@ -48,16 +48,16 @@ void LogBuilder::setChildOrder(Node &node, Node &child, } void LogBuilder::setContent(Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content) + Util::ptr_shared old_content, + Util::ptr_shared new_content) { _log = new Inkscape::XML::EventChgContent(&node, old_content, new_content, _log); _log = _log->optimizeOne(); } void LogBuilder::setAttribute(Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value) + Util::ptr_shared old_value, + Util::ptr_shared new_value) { _log = new Inkscape::XML::EventChgAttr(&node, name, old_value, new_value, _log); _log = _log->optimizeOne(); diff --git a/src/xml/log-builder.h b/src/xml/log-builder.h index dc68a4f4a..478bf295f 100644 --- a/src/xml/log-builder.h +++ b/src/xml/log-builder.h @@ -39,12 +39,12 @@ public: Node *old_prev, Node *new_prev); void setContent(Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content); + Util::ptr_shared old_content, + Util::ptr_shared new_content); void setAttribute(Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value); + Util::ptr_shared old_value, + Util::ptr_shared new_value); private: Event *_log; diff --git a/src/xml/node-observer.h b/src/xml/node-observer.h index e50a41dd8..584505e4e 100644 --- a/src/xml/node-observer.h +++ b/src/xml/node-observer.h @@ -43,12 +43,12 @@ public: Node *old_prev, Node *new_prev)=0; virtual void notifyContentChanged(Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content)=0; + Util::ptr_shared old_content, + Util::ptr_shared new_content)=0; virtual void notifyAttributeChanged(Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value)=0; + Util::ptr_shared old_value, + Util::ptr_shared new_value)=0; }; } diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 884bb3360..c3222e4ae 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -585,7 +585,7 @@ repr_quote_write (Writer &out, const gchar * val) namespace { typedef std::map LocalNameMap; -typedef std::map, Inkscape::compare_quark_ids> NSMap; +typedef std::map, Inkscape::compare_quark_ids> NSMap; gchar const *qname_local_name(Glib::QueryQuark qname) { static LocalNameMap local_name_map; @@ -604,7 +604,7 @@ gchar const *qname_local_name(Glib::QueryQuark qname) { } void add_ns_map_entry(NSMap &ns_map, Glib::QueryQuark prefix) { - using Inkscape::Util::shared_ptr; + using Inkscape::Util::ptr_shared; using Inkscape::Util::share_unsafe; static const Glib::QueryQuark xml_prefix("xml"); @@ -619,7 +619,7 @@ void add_ns_map_entry(NSMap &ns_map, Glib::QueryQuark prefix) { g_warning("No namespace known for normalized prefix %s", g_quark_to_string(prefix)); } } else { - ns_map.insert(NSMap::value_type(prefix, shared_ptr())); + ns_map.insert(NSMap::value_type(prefix, ptr_shared())); } } } @@ -648,7 +648,7 @@ void populate_ns_map(NSMap &ns_map, Node &repr) { void sp_repr_write_stream_root_element (Node *repr, Writer &out, gboolean add_whitespace, gchar const *default_ns) { - using Inkscape::Util::shared_ptr; + using Inkscape::Util::ptr_shared; g_assert(repr != NULL); Glib::QueryQuark xml_prefix=g_quark_from_static_string("xml"); @@ -664,7 +664,7 @@ sp_repr_write_stream_root_element (Node *repr, Writer &out, gboolean add_whitesp for ( NSMap::iterator iter=ns_map.begin() ; iter != ns_map.end() ; ++iter ) { Glib::QueryQuark prefix=(*iter).first; - shared_ptr ns_uri=(*iter).second; + ptr_shared ns_uri=(*iter).second; if (prefix.id()) { if ( prefix != xml_prefix ) { diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index d83e5d54b..17339271f 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -28,7 +28,7 @@ namespace XML { namespace { -Util::shared_ptr stringify_node(Node const &node) { +Util::ptr_shared stringify_node(Node const &node) { gchar *string; switch (node.type()) { case ELEMENT_NODE: { @@ -51,14 +51,14 @@ Util::shared_ptr stringify_node(Node const &node) { default: string = g_strdup_printf("unknown(%p)", &node); } - Util::shared_ptr result=Util::share_string(string); + Util::ptr_shared result=Util::share_string(string); g_free(string); return result; } -Util::shared_ptr stringify_unsigned(unsigned n) { +Util::ptr_shared stringify_unsigned(unsigned n) { gchar *string = g_strdup_printf("%u", n); - Util::shared_ptr result=Util::share_string(string); + Util::ptr_shared result=Util::share_string(string); g_free(string); return result; } @@ -75,7 +75,7 @@ public: static Category category() { return XML; } - Util::shared_ptr name() const { + Util::ptr_shared name() const { return Util::share_static_string("add-child"); } unsigned propertyCount() const { return 3; } @@ -92,8 +92,8 @@ public: } } private: - Util::shared_ptr _parent; - Util::shared_ptr _child; + Util::ptr_shared _parent; + Util::ptr_shared _child; unsigned _position; }; @@ -106,7 +106,7 @@ public: static Category category() { return XML; } - Util::shared_ptr name() const { + Util::ptr_shared name() const { return Util::share_static_string("remove-child"); } unsigned propertyCount() const { return 2; } @@ -121,8 +121,8 @@ public: } } private: - Util::shared_ptr _parent; - Util::shared_ptr _child; + Util::ptr_shared _parent; + Util::ptr_shared _child; }; class DebugSetChildPosition : public Debug::Event { @@ -140,7 +140,7 @@ public: static Category category() { return XML; } - Util::shared_ptr name() const { + Util::ptr_shared name() const { return Util::share_static_string("set-child-position"); } unsigned propertyCount() const { return 3; } @@ -157,21 +157,21 @@ public: } } private: - Util::shared_ptr _parent; - Util::shared_ptr _child; + Util::ptr_shared _parent; + Util::ptr_shared _child; unsigned _position; }; class DebugSetContent : public Debug::Event { public: DebugSetContent(Node const &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content) + Util::ptr_shared old_content, + Util::ptr_shared new_content) : _node(stringify_node(node)), _content(new_content) {} static Category category() { return XML; } - Util::shared_ptr name() const { + Util::ptr_shared name() const { if (_content) { return Util::share_static_string("set-content"); } else { @@ -196,22 +196,22 @@ public: } } private: - Util::shared_ptr _node; - Util::shared_ptr _content; + Util::ptr_shared _node; + Util::ptr_shared _content; }; class DebugSetAttribute : public Debug::Event { public: DebugSetAttribute(Node const &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value) + Util::ptr_shared old_value, + Util::ptr_shared new_value) : _node(stringify_node(node)), _name(Util::share_unsafe(g_quark_to_string(name))), _value(new_value) {} static Category category() { return XML; } - Util::shared_ptr name() const { + Util::ptr_shared name() const { if (_value) { return Util::share_static_string("set-attribute"); } else { @@ -239,12 +239,12 @@ public: } private: - Util::shared_ptr _node; - Util::shared_ptr _name; - Util::shared_ptr _value; + Util::ptr_shared _node; + Util::ptr_shared _name; + Util::ptr_shared _value; }; -using Inkscape::Util::shared_ptr; +using Inkscape::Util::ptr_shared; using Inkscape::Util::share_string; using Inkscape::Util::share_unsafe; using Inkscape::Util::share_static_string; @@ -366,8 +366,8 @@ bool SimpleNode::matchAttributeName(gchar const *partial_name) const { } void SimpleNode::setContent(gchar const *content) { - shared_ptr old_content=_content; - shared_ptr new_content = ( content ? share_string(content) : shared_ptr() ); + ptr_shared old_content=_content; + ptr_shared new_content = ( content ? share_string(content) : ptr_shared() ); Debug::EventTracker tracker( *this, old_content, new_content @@ -402,9 +402,9 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const is_in Debug::EventTracker<> tracker; - shared_ptr old_value=( existing ? existing->value : shared_ptr() ); + ptr_shared old_value=( existing ? existing->value : ptr_shared() ); - shared_ptr new_value=shared_ptr(); + ptr_shared new_value=ptr_shared(); if (value) { new_value = share_string(value); tracker.set(*this, key, old_value, new_value); diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h index f1cf78680..367516ee7 100644 --- a/src/xml/simple-node.h +++ b/src/xml/simple-node.h @@ -140,7 +140,7 @@ private: Inkscape::Util::MutableList _attributes; - Inkscape::Util::shared_ptr _content; + Inkscape::Util::ptr_shared _content; unsigned _child_count; mutable bool _cached_positions_valid; diff --git a/src/xml/simple-session.cpp b/src/xml/simple-session.cpp index c8d873fd2..d5c17a540 100644 --- a/src/xml/simple-session.cpp +++ b/src/xml/simple-session.cpp @@ -88,8 +88,8 @@ void SimpleSession::notifyChildOrderChanged(Node &parent, } void SimpleSession::notifyContentChanged(Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content) + Util::ptr_shared old_content, + Util::ptr_shared new_content) { if (_in_transaction) { _log_builder.setContent(node, old_content, new_content); @@ -98,8 +98,8 @@ void SimpleSession::notifyContentChanged(Node &node, void SimpleSession::notifyAttributeChanged(Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value) + Util::ptr_shared old_value, + Util::ptr_shared new_value) { if (_in_transaction) { _log_builder.setAttribute(node, name, old_value, new_value); diff --git a/src/xml/simple-session.h b/src/xml/simple-session.h index 9e3693d9a..ecd61ba08 100644 --- a/src/xml/simple-session.h +++ b/src/xml/simple-session.h @@ -52,12 +52,12 @@ public: Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev); void notifyContentChanged(Inkscape::XML::Node &node, - Util::shared_ptr old_content, - Util::shared_ptr new_content); + Util::ptr_shared old_content, + Util::ptr_shared new_content); void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name, - Util::shared_ptr old_value, - Util::shared_ptr new_value); + Util::ptr_shared old_value, + Util::ptr_shared new_value); private: SimpleSession(SimpleSession const &); // no copy diff --git a/src/xml/text-node.h b/src/xml/text-node.h index bcd1c3e4f..bd6095f3b 100644 --- a/src/xml/text-node.h +++ b/src/xml/text-node.h @@ -23,7 +23,7 @@ namespace Inkscape { namespace XML { struct TextNode : public SimpleNode { - TextNode(Util::shared_ptr content) + TextNode(Util::ptr_shared content) : SimpleNode(g_quark_from_static_string("string")) { setContent(content); -- 2.30.2