[glibmm/refptr_as_sharedptr_v3: 1/6] Add and use make_refptr_for_instance().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/refptr_as_sharedptr_v3: 1/6] Add and use make_refptr_for_instance().
- Date: Sun, 11 Dec 2016 20:51:44 +0000 (UTC)
commit ac50f9c7fc7624d578a0656ae535ba05cd4c7bc4
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Apr 10 11:25:29 2016 +0200
Add and use make_refptr_for_instance().
gio/giomm/socketsource.cc | 2 +-
gio/src/asyncresult.ccg | 2 +-
gio/src/bufferedinputstream.ccg | 2 +-
gio/src/bufferedoutputstream.ccg | 2 +-
gio/src/dbusconnection.ccg | 16 ++++++++--------
gio/src/dbusproxy.ccg | 8 ++++----
gio/src/dbusserver.ccg | 8 ++++----
gio/src/liststore.hg | 2 +-
gio/src/socket.ccg | 4 ++--
gio/src/tlscertificate.ccg | 2 +-
glib/glibmm/containerhandle_shared.h | 4 ++--
glib/glibmm/interface.cc | 2 +-
glib/glibmm/main.cc | 18 +++++++++---------
glib/glibmm/object.h | 4 ++--
glib/glibmm/refptr.h | 7 +++++++
glib/glibmm/streamiochannel.cc | 6 +++---
glib/glibmm/value.cc | 2 +-
glib/glibmm/wrap.cc | 2 +-
glib/src/balancedtree.hg | 4 ++--
glib/src/binding.ccg | 2 +-
glib/src/bytearray.hg | 2 +-
glib/src/iochannel.ccg | 2 +-
tests/giomm_listmodel/main.cc | 2 +-
tests/giomm_stream_vfuncs/main.cc | 2 +-
tests/glibmm_refptr/main.cc | 2 +-
tools/m4/class_gobject.m4 | 4 ++--
tools/m4/class_interface.m4 | 2 +-
tools/m4/class_opaque_refcounted.m4 | 4 ++--
28 files changed, 63 insertions(+), 56 deletions(-)
---
diff --git a/gio/giomm/socketsource.cc b/gio/giomm/socketsource.cc
index 4284261..2dc275f 100644
--- a/gio/giomm/socketsource.cc
+++ b/gio/giomm/socketsource.cc
@@ -89,7 +89,7 @@ Glib::RefPtr<SocketSource>
SocketSource::create(const Glib::RefPtr<Socket>& socket, Glib::IOCondition condition,
const Glib::RefPtr<Cancellable>& cancellable)
{
- return Glib::RefPtr<SocketSource>(new SocketSource(socket, condition, cancellable));
+ return Glib::make_refptr_for_instance<SocketSource>(new SocketSource(socket, condition, cancellable));
}
SocketSource::SocketSource(const Glib::RefPtr<Socket>& socket, Glib::IOCondition condition,
diff --git a/gio/src/asyncresult.ccg b/gio/src/asyncresult.ccg
index 252fb87..bebc7ab 100644
--- a/gio/src/asyncresult.ccg
+++ b/gio/src/asyncresult.ccg
@@ -35,7 +35,7 @@ AsyncResult::get_source_object_base()
{
auto cobj = g_async_result_get_source_object(gobj());
auto cppobj = Glib::wrap_auto(cobj); // ObjectBase::_get_current_wrapper(cobj);
- return Glib::RefPtr<Glib::ObjectBase>(
+ return Glib::make_refptr_for_instance<Glib::ObjectBase>(
cppobj); // g_async_result_get_source_object() gives us a ref, unusually.
// TODO: For some reason this fails: Glib::wrap(cobj);
}
diff --git a/gio/src/bufferedinputstream.ccg b/gio/src/bufferedinputstream.ccg
index 862db1c..888b7af 100644
--- a/gio/src/bufferedinputstream.ccg
+++ b/gio/src/bufferedinputstream.ccg
@@ -26,7 +26,7 @@ namespace Gio
Glib::RefPtr<BufferedInputStream>
BufferedInputStream::create_sized(const Glib::RefPtr<InputStream>& base_stream, gsize buffer_size)
{
- return Glib::RefPtr<Gio::BufferedInputStream>(new BufferedInputStream(base_stream, buffer_size));
+ return Glib::make_refptr_for_instance<Gio::BufferedInputStream>(new BufferedInputStream(base_stream,
buffer_size));
}
void
diff --git a/gio/src/bufferedoutputstream.ccg b/gio/src/bufferedoutputstream.ccg
index 3985649..c549775 100644
--- a/gio/src/bufferedoutputstream.ccg
+++ b/gio/src/bufferedoutputstream.ccg
@@ -26,7 +26,7 @@ namespace Gio
Glib::RefPtr<BufferedOutputStream>
BufferedOutputStream::create_sized(const Glib::RefPtr<OutputStream>& base_stream, gsize size)
{
- return Glib::RefPtr<Gio::BufferedOutputStream>(new BufferedOutputStream(base_stream, size));
+ return Glib::make_refptr_for_instance<Gio::BufferedOutputStream>(new BufferedOutputStream(base_stream,
size));
}
} // namespace Gio
diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg
index 557d695..5fe37d9 100644
--- a/gio/src/dbusconnection.ccg
+++ b/gio/src/dbusconnection.ccg
@@ -279,7 +279,7 @@ Connection::create_sync(const Glib::RefPtr<IOStream>& stream, const std::string&
const Glib::RefPtr<AuthObserver>& observer, const Glib::RefPtr<Cancellable>& cancellable,
ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(stream, guid, observer, cancellable, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(stream, guid, observer, cancellable,
flags));
}
// static
@@ -287,7 +287,7 @@ Glib::RefPtr<Connection>
Connection::create_sync(const Glib::RefPtr<IOStream>& stream, const std::string& guid,
const Glib::RefPtr<Cancellable>& cancellable, ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(stream, guid, cancellable, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(stream, guid, cancellable, flags));
}
// static
@@ -295,7 +295,7 @@ Glib::RefPtr<Connection>
Connection::create_sync(const Glib::RefPtr<IOStream>& stream, const std::string& guid,
const Glib::RefPtr<AuthObserver>& observer, ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(stream, guid, observer, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(stream, guid, observer, flags));
}
// static
@@ -303,7 +303,7 @@ Glib::RefPtr<Connection>
Connection::create_sync(
const Glib::RefPtr<IOStream>& stream, const std::string& guid, ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(stream, guid, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(stream, guid, flags));
}
// static
@@ -353,7 +353,7 @@ Connection::create_for_address_sync(const std::string& address,
const Glib::RefPtr<AuthObserver>& observer, const Glib::RefPtr<Cancellable>& cancellable,
ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(address, observer, cancellable, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(address, observer, cancellable, flags));
}
// static
@@ -361,7 +361,7 @@ Glib::RefPtr<Connection>
Connection::create_for_address_sync(
const std::string& address, const Glib::RefPtr<Cancellable>& cancellable, ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(address, cancellable, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(address, cancellable, flags));
}
// static
@@ -369,14 +369,14 @@ Glib::RefPtr<Connection>
Connection::create_for_address_sync(
const std::string& address, const Glib::RefPtr<AuthObserver>& observer, ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(address, observer, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(address, observer, flags));
}
// static
Glib::RefPtr<Connection>
Connection::create_for_address_sync(const std::string& address, ConnectionFlags flags)
{
- return Glib::RefPtr<Connection>(new Connection(address, flags));
+ return Glib::make_refptr_for_instance<Connection>(new Connection(address, flags));
}
// static
diff --git a/gio/src/dbusproxy.ccg b/gio/src/dbusproxy.ccg
index b13f92f..4bc9ecd 100644
--- a/gio/src/dbusproxy.ccg
+++ b/gio/src/dbusproxy.ccg
@@ -146,7 +146,7 @@ Proxy::create_sync(const Glib::RefPtr<Connection>& connection, const Glib::ustri
const Glib::RefPtr<Cancellable>& cancellable, const Glib::RefPtr<InterfaceInfo>& info,
ProxyFlags flags)
{
- return Glib::RefPtr<Proxy>(
+ return Glib::make_refptr_for_instance<Proxy>(
new Proxy(connection, name, object_path, interface_name, cancellable, info, flags));
}
@@ -155,7 +155,7 @@ Proxy::create_sync(const Glib::RefPtr<Connection>& connection, const Glib::ustri
const Glib::ustring& object_path, const Glib::ustring& interface_name,
const Glib::RefPtr<InterfaceInfo>& info, ProxyFlags flags)
{
- return Glib::RefPtr<Proxy>(new Proxy(connection, name, object_path, interface_name, info, flags));
+ return Glib::make_refptr_for_instance<Proxy>(new Proxy(connection, name, object_path, interface_name,
info, flags));
}
void
@@ -181,7 +181,7 @@ Proxy::create_for_bus_sync(BusType bus_type, const Glib::ustring& name,
const Glib::RefPtr<Cancellable>& cancellable, const Glib::RefPtr<InterfaceInfo>& info,
ProxyFlags flags)
{
- return Glib::RefPtr<Proxy>(
+ return Glib::make_refptr_for_instance<Proxy>(
new Proxy(bus_type, name, object_path, interface_name, cancellable, info, flags));
}
@@ -190,7 +190,7 @@ Proxy::create_for_bus_sync(BusType bus_type, const Glib::ustring& name,
const Glib::ustring& object_path, const Glib::ustring& interface_name,
const Glib::RefPtr<InterfaceInfo>& info, ProxyFlags flags)
{
- return Glib::RefPtr<Proxy>(new Proxy(bus_type, name, object_path, interface_name, info, flags));
+ return Glib::make_refptr_for_instance<Proxy>(new Proxy(bus_type, name, object_path, interface_name, info,
flags));
}
void
diff --git a/gio/src/dbusserver.ccg b/gio/src/dbusserver.ccg
index 2d6aea8..7134737 100644
--- a/gio/src/dbusserver.ccg
+++ b/gio/src/dbusserver.ccg
@@ -68,27 +68,27 @@ Server::create_sync(const std::string& address, const std::string& guid,
const Glib::RefPtr<AuthObserver>& observer, const Glib::RefPtr<Cancellable>& cancellable,
ServerFlags flags)
{
- return Glib::RefPtr<Server>(new Server(address, guid, observer, cancellable, flags));
+ return Glib::make_refptr_for_instance<Server>(new Server(address, guid, observer, cancellable, flags));
}
Glib::RefPtr<Server>
Server::create_sync(const std::string& address, const std::string& guid,
const Glib::RefPtr<Cancellable>& cancellable, ServerFlags flags)
{
- return Glib::RefPtr<Server>(new Server(address, guid, cancellable, flags));
+ return Glib::make_refptr_for_instance<Server>(new Server(address, guid, cancellable, flags));
}
Glib::RefPtr<Server>
Server::create_sync(const std::string& address, const std::string& guid,
const Glib::RefPtr<AuthObserver>& observer, ServerFlags flags)
{
- return Glib::RefPtr<Server>(new Server(address, guid, observer, flags));
+ return Glib::make_refptr_for_instance<Server>(new Server(address, guid, observer, flags));
}
Glib::RefPtr<Server>
Server::create_sync(const std::string& address, const std::string& guid, ServerFlags flags)
{
- return Glib::RefPtr<Server>(new Server(address, guid, flags));
+ return Glib::make_refptr_for_instance<Server>(new Server(address, guid, flags));
}
} // namespace DBus
diff --git a/gio/src/liststore.hg b/gio/src/liststore.hg
index 2b3af6c..77e2375 100644
--- a/gio/src/liststore.hg
+++ b/gio/src/liststore.hg
@@ -244,7 +244,7 @@ ListStore<T_item>::ListStore()
template <typename T_item>
Glib::RefPtr<ListStore<T_item>> ListStore<T_item>::create()
{
- return Glib::RefPtr<ListStore<T_item>>(new ListStore<T_item>());
+ return Glib::make_refptr_for_instance<ListStore<T_item>>(new ListStore<T_item>());
}
template <typename T_item>
diff --git a/gio/src/socket.ccg b/gio/src/socket.ccg
index 6dfd71e..21f5473 100644
--- a/gio/src/socket.ccg
+++ b/gio/src/socket.ccg
@@ -43,14 +43,14 @@ Glib::RefPtr<Socket>
Socket::create(SocketFamily family, SocketType type, SocketProtocol protocol,
const Glib::RefPtr<Cancellable>& cancellable)
{
- return Glib::RefPtr<Socket>(new Socket(family, type, protocol, cancellable));
+ return Glib::make_refptr_for_instance<Socket>(new Socket(family, type, protocol, cancellable));
}
// static
Glib::RefPtr<Socket>
Socket::create_from_fd(int fd, const Glib::RefPtr<Cancellable>& cancellable)
{
- return Glib::RefPtr<Socket>(new Socket(fd, cancellable));
+ return Glib::make_refptr_for_instance<Socket>(new Socket(fd, cancellable));
}
gssize
diff --git a/gio/src/tlscertificate.ccg b/gio/src/tlscertificate.ccg
index 448757f..2df281e 100644
--- a/gio/src/tlscertificate.ccg
+++ b/gio/src/tlscertificate.ccg
@@ -25,7 +25,7 @@ namespace Gio
Glib::RefPtr<TlsCertificate>
TlsCertificate::create_from_pem(const std::string& data, gssize length)
{
- return Glib::RefPtr<TlsCertificate>(new TlsCertificate(data, length));
+ return Glib::make_refptr_for_instance<TlsCertificate>(new TlsCertificate(data, length));
}
} // namesapce Gio
diff --git a/glib/glibmm/containerhandle_shared.h b/glib/glibmm/containerhandle_shared.h
index dffce99..c7543e6 100644
--- a/glib/glibmm/containerhandle_shared.h
+++ b/glib/glibmm/containerhandle_shared.h
@@ -206,7 +206,7 @@ struct TypeTraits<Glib::RefPtr<T>>
// because that would be "dependent", and g++ 3.4 does not allow that.
// The specific Glib::wrap() overloads don't do anything special anyway.
GObject* cobj = (GObject*)(ptr);
- return Glib::RefPtr<T>(dynamic_cast<T*>(Glib::wrap_auto(cobj, true /* take_copy */)));
+ return Glib::make_refptr_for_instance<T>(dynamic_cast<T*>(Glib::wrap_auto(cobj, true /* take_copy */)));
// We use dynamic_cast<> in case of multiple inheritance.
}
@@ -242,7 +242,7 @@ struct TypeTraits<Glib::RefPtr<const T>>
// because that would be "dependent", and g++ 3.4 does not allow that.
// The specific Glib::wrap() overloads don't do anything special anyway.
GObject* cobj = (GObject*)const_cast<CTypeNonConst>(ptr);
- return Glib::RefPtr<const T>(
+ return Glib::make_refptr_for_instance<const T>(
dynamic_cast<const T*>(Glib::wrap_auto(cobj, true /* take_copy */)));
// We use dynamic_cast<> in case of multiple inheritance.
}
diff --git a/glib/glibmm/interface.cc b/glib/glibmm/interface.cc
index 0429840..e554fb0 100644
--- a/glib/glibmm/interface.cc
+++ b/glib/glibmm/interface.cc
@@ -157,7 +157,7 @@ Interface::get_base_type()
RefPtr<ObjectBase>
wrap_interface(GObject* object, bool take_copy)
{
- return Glib::RefPtr<ObjectBase>(wrap_auto(object, take_copy));
+ return Glib::make_refptr_for_instance<ObjectBase>(wrap_auto(object, take_copy));
}
} // namespace Glib
diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc
index 1f19f46..419dd72 100644
--- a/glib/glibmm/main.cc
+++ b/glib/glibmm/main.cc
@@ -536,7 +536,7 @@ signal_child_watch()
Glib::RefPtr<MainContext>
MainContext::create()
{
- return Glib::RefPtr<MainContext>(reinterpret_cast<MainContext*>(g_main_context_new()));
+ return Glib::make_refptr_for_instance<MainContext>(reinterpret_cast<MainContext*>(g_main_context_new()));
}
// static
@@ -718,7 +718,7 @@ wrap(GMainContext* gobject, bool take_copy)
if (take_copy && gobject)
g_main_context_ref(gobject);
- return Glib::RefPtr<MainContext>(reinterpret_cast<MainContext*>(gobject));
+ return Glib::make_refptr_for_instance<MainContext>(reinterpret_cast<MainContext*>(gobject));
}
/**** Glib::MainLoop *******************************************************/
@@ -726,13 +726,13 @@ wrap(GMainContext* gobject, bool take_copy)
Glib::RefPtr<MainLoop>
MainLoop::create(bool is_running)
{
- return Glib::RefPtr<MainLoop>(reinterpret_cast<MainLoop*>(g_main_loop_new(nullptr, is_running)));
+ return Glib::make_refptr_for_instance<MainLoop>(reinterpret_cast<MainLoop*>(g_main_loop_new(nullptr,
is_running)));
}
Glib::RefPtr<MainLoop>
MainLoop::create(const Glib::RefPtr<MainContext>& context, bool is_running)
{
- return Glib::RefPtr<MainLoop>(
+ return Glib::make_refptr_for_instance<MainLoop>(
reinterpret_cast<MainLoop*>(g_main_loop_new(Glib::unwrap(context), is_running)));
}
@@ -804,7 +804,7 @@ wrap(GMainLoop* gobject, bool take_copy)
if (take_copy && gobject)
g_main_loop_ref(gobject);
- return Glib::RefPtr<MainLoop>(reinterpret_cast<MainLoop*>(gobject));
+ return Glib::make_refptr_for_instance<MainLoop>(reinterpret_cast<MainLoop*>(gobject));
}
/**** Glib::Source *********************************************************/
@@ -1094,7 +1094,7 @@ Source::get_slot_from_callback_data(void* data)
Glib::RefPtr<TimeoutSource>
TimeoutSource::create(unsigned int interval)
{
- return Glib::RefPtr<TimeoutSource>(new TimeoutSource(interval));
+ return Glib::make_refptr_for_instance<TimeoutSource>(new TimeoutSource(interval));
}
sigc::connection
@@ -1179,7 +1179,7 @@ TimeoutSource::dispatch(sigc::slot_base* slot)
Glib::RefPtr<IdleSource>
IdleSource::create()
{
- return Glib::RefPtr<IdleSource>(new IdleSource());
+ return Glib::make_refptr_for_instance<IdleSource>(new IdleSource());
}
sigc::connection
@@ -1222,13 +1222,13 @@ IdleSource::dispatch(sigc::slot_base* slot)
Glib::RefPtr<IOSource>
IOSource::create(PollFD::fd_t fd, IOCondition condition)
{
- return Glib::RefPtr<IOSource>(new IOSource(fd, condition));
+ return Glib::make_refptr_for_instance<IOSource>(new IOSource(fd, condition));
}
Glib::RefPtr<IOSource>
IOSource::create(const Glib::RefPtr<IOChannel>& channel, IOCondition condition)
{
- return Glib::RefPtr<IOSource>(new IOSource(channel, condition));
+ return Glib::make_refptr_for_instance<IOSource>(new IOSource(channel, condition));
}
sigc::connection
diff --git a/glib/glibmm/object.h b/glib/glibmm/object.h
index 3ff39b0..9b4dda2 100644
--- a/glib/glibmm/object.h
+++ b/glib/glibmm/object.h
@@ -186,7 +186,7 @@ struct TypeTraits<Glib::RefPtr<T>>
// because that would be "dependent", and g++ 3.4 does not allow that.
// The specific Glib::wrap() overloads don't do anything special anyway.
GObject* cobj = (GObject*)const_cast<CTypeNonConst>(ptr);
- return Glib::RefPtr<T>(dynamic_cast<T*>(Glib::wrap_auto(cobj, true /* take_copy */)));
+ return Glib::make_refptr_for_instance<T>(dynamic_cast<T*>(Glib::wrap_auto(cobj, true /* take_copy */)));
// We use dynamic_cast<> in case of multiple inheritance.
}
@@ -222,7 +222,7 @@ struct TypeTraits<Glib::RefPtr<const T>>
// because that would be "dependent", and g++ 3.4 does not allow that.
// The specific Glib::wrap() overloads don't do anything special anyway.
GObject* cobj = (GObject*)(ptr);
- return Glib::RefPtr<const T>(
+ return Glib::make_refptr_for_instance<const T>(
dynamic_cast<const T*>(Glib::wrap_auto(cobj, true /* take_copy */)));
// We use dynamic_cast<> in case of multiple inheritance.
}
diff --git a/glib/glibmm/refptr.h b/glib/glibmm/refptr.h
index 892b6a6..4ded0b7 100644
--- a/glib/glibmm/refptr.h
+++ b/glib/glibmm/refptr.h
@@ -505,6 +505,13 @@ swap(RefPtr<T_CppObject>& lhs, RefPtr<T_CppObject>& rhs) noexcept
lhs.swap(rhs);
}
+template <class T_CppObject>
+RefPtr<T_CppObject>
+make_refptr_for_instance(T_CppObject* object)
+{
+ return RefPtr<T_CppObject>(object);
+}
+
} // namespace Glib
#endif /* _GLIBMM_REFPTR_H */
diff --git a/glib/glibmm/streamiochannel.cc b/glib/glibmm/streamiochannel.cc
index 9444216..28d1372 100644
--- a/glib/glibmm/streamiochannel.cc
+++ b/glib/glibmm/streamiochannel.cc
@@ -32,21 +32,21 @@ namespace Glib
Glib::RefPtr<StreamIOChannel>
StreamIOChannel::create(std::istream& stream)
{
- return Glib::RefPtr<StreamIOChannel>(new StreamIOChannel(&stream, nullptr));
+ return Glib::make_refptr_for_instance<StreamIOChannel>(new StreamIOChannel(&stream, nullptr));
}
// static
Glib::RefPtr<StreamIOChannel>
StreamIOChannel::create(std::ostream& stream)
{
- return Glib::RefPtr<StreamIOChannel>(new StreamIOChannel(nullptr, &stream));
+ return Glib::make_refptr_for_instance<StreamIOChannel>(new StreamIOChannel(nullptr, &stream));
}
// static
Glib::RefPtr<StreamIOChannel>
StreamIOChannel::create(std::iostream& stream)
{
- return Glib::RefPtr<StreamIOChannel>(new StreamIOChannel(&stream, &stream));
+ return Glib::make_refptr_for_instance<StreamIOChannel>(new StreamIOChannel(&stream, &stream));
}
StreamIOChannel::StreamIOChannel(std::istream* stream_in, std::ostream* stream_out)
diff --git a/glib/glibmm/value.cc b/glib/glibmm/value.cc
index ef68fce..893bb85 100644
--- a/glib/glibmm/value.cc
+++ b/glib/glibmm/value.cc
@@ -138,7 +138,7 @@ Glib::RefPtr<Glib::ObjectBase>
ValueBase_Object::get_object_copy() const
{
GObject* const data = static_cast<GObject*>(g_value_get_object(&gobject_));
- return Glib::RefPtr<Glib::ObjectBase>(Glib::wrap_auto(data, true));
+ return Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(data, true));
}
GParamSpec*
diff --git a/glib/glibmm/wrap.cc b/glib/glibmm/wrap.cc
index f30fea9..ee9ca79 100644
--- a/glib/glibmm/wrap.cc
+++ b/glib/glibmm/wrap.cc
@@ -216,7 +216,7 @@ wrap_auto(GObject* object, bool take_copy)
Glib::RefPtr<Object>
wrap(GObject* object, bool take_copy /* = false */)
{
- return Glib::RefPtr<Object>(dynamic_cast<Object*>(wrap_auto(object, take_copy)));
+ return Glib::make_refptr_for_instance<Object>(dynamic_cast<Object*>(wrap_auto(object, take_copy)));
}
} /* namespace Glib */
diff --git a/glib/src/balancedtree.hg b/glib/src/balancedtree.hg
index 5444046..13158ef 100644
--- a/glib/src/balancedtree.hg
+++ b/glib/src/balancedtree.hg
@@ -78,12 +78,12 @@ protected:
public:
static Glib::RefPtr< BalancedTree<K, V> > create()
{
- return Glib::RefPtr< BalancedTree<K, V> >(new BalancedTree());
+ return Glib::make_refptr_for_instance< BalancedTree<K, V> >(new BalancedTree());
}
static Glib::RefPtr< BalancedTree<K, V> > create(const CompareFunc &key_compare_slot)
{
- return Glib::RefPtr< BalancedTree<K, V> >(new BalancedTree(key_compare_slot));
+ return Glib::make_refptr_for_instance< BalancedTree<K, V> >(new BalancedTree(key_compare_slot));
}
~BalancedTree()
diff --git a/glib/src/binding.ccg b/glib/src/binding.ccg
index 576b64f..7d66029 100644
--- a/glib/src/binding.ccg
+++ b/glib/src/binding.ccg
@@ -112,7 +112,7 @@ Binding::bind_property_value(const PropertyProxy_Base& source_property,
// either the source object or the target object is finalized.
// The GBinding object must not be destroyed while there are RefPtrs around.
g_object_ref(binding);
- return Glib::RefPtr<Binding>(new Binding(binding));
+ return Glib::make_refptr_for_instance<Binding>(new Binding(binding));
}
void
diff --git a/glib/src/bytearray.hg b/glib/src/bytearray.hg
index 1e657b5..3ed2d69 100644
--- a/glib/src/bytearray.hg
+++ b/glib/src/bytearray.hg
@@ -104,7 +104,7 @@ class Value< Glib::RefPtr<Glib::ByteArray> > : public ValueBase_Boxed
public:
static GType value_type() { return Glib::ByteArray::get_type(); }
void set(const Glib::RefPtr<Glib::ByteArray>& array) { set_boxed(Glib::unwrap(array)); }
- Glib::RefPtr<Glib::ByteArray> get() { return
Glib::RefPtr<Glib::ByteArray>(reinterpret_cast<Glib::ByteArray*>(get_boxed())); }
+ Glib::RefPtr<Glib::ByteArray> get() { return
make_refptr_for_instance<Glib::ByteArray>(reinterpret_cast<Glib::ByteArray*>(get_boxed())); }
};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
diff --git a/glib/src/iochannel.ccg b/glib/src/iochannel.ccg
index 7577a84..a071ba3 100644
--- a/glib/src/iochannel.ccg
+++ b/glib/src/iochannel.ccg
@@ -421,7 +421,7 @@ wrap(GIOChannel* gobject, bool take_copy)
}
}
- return Glib::RefPtr<IOChannel>(cpp_object);
+ return Glib::make_refptr_for_instance<IOChannel>(cpp_object);
}
/**** Glib::GlibmmIOChannel ************************************************/
diff --git a/tests/giomm_listmodel/main.cc b/tests/giomm_listmodel/main.cc
index f40a943..dbd36d2 100644
--- a/tests/giomm_listmodel/main.cc
+++ b/tests/giomm_listmodel/main.cc
@@ -260,7 +260,7 @@ protected:
public:
static Glib::RefPtr<MyObject> create(int id)
{
- return Glib::RefPtr<MyObject>(new MyObject(id));
+ return Glib::make_refptr_for_instance<MyObject>(new MyObject(id));
}
int get_id() const { return m_id; }
diff --git a/tests/giomm_stream_vfuncs/main.cc b/tests/giomm_stream_vfuncs/main.cc
index f70a1fa..1ab34b5 100644
--- a/tests/giomm_stream_vfuncs/main.cc
+++ b/tests/giomm_stream_vfuncs/main.cc
@@ -28,7 +28,7 @@ public:
void set_column_width(unsigned cw) { column_width = cw; }
static Glib::RefPtr<Base64OutputStream> create(const Glib::RefPtr<OutputStream>& base_stream)
{
- return Glib::RefPtr<Base64OutputStream>(new Base64OutputStream(base_stream));
+ return Glib::make_refptr_for_instance<Base64OutputStream>(new Base64OutputStream(base_stream));
}
protected:
diff --git a/tests/glibmm_refptr/main.cc b/tests/glibmm_refptr/main.cc
index 53a7449..793f8af 100644
--- a/tests/glibmm_refptr/main.cc
+++ b/tests/glibmm_refptr/main.cc
@@ -139,7 +139,7 @@ get_something()
static Glib::RefPtr<Something> something_to_get;
// Reinitialize it each time:
- something_to_get = Glib::RefPtr<Something>(new Something());
+ something_to_get = Glib::make_refptr_for_instance<Something>(new Something());
return something_to_get;
}
diff --git a/tools/m4/class_gobject.m4 b/tools/m4/class_gobject.m4
index 0e0e4f6..ff07505 100644
--- a/tools/m4/class_gobject.m4
+++ b/tools/m4/class_gobject.m4
@@ -105,7 +105,7 @@ define(`_CREATE_METHOD',`
_PUSH(SECTION_CC)
Glib::RefPtr<`'__CPPNAME__`'> __CPPNAME__`'::create(`'$2`')
{
- return Glib::RefPtr<`'__CPPNAME__`'>( new __CPPNAME__`'(`'$3`') );
+ return Glib::make_refptr_for_instance<`'__CPPNAME__`'>( new __CPPNAME__`'(`'$3`') );
}
_POP()
@@ -169,7 +169,7 @@ namespace Glib
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__REAL_CNAME__`'* object, bool take_copy)
{
- return Glib::RefPtr<__NAMESPACE__::__CPPNAME__>( dynamic_cast<__NAMESPACE__::__CPPNAME__*>
(Glib::wrap_auto ((GObject*)(object), take_copy)) );
+ return Glib::make_refptr_for_instance<__NAMESPACE__::__CPPNAME__>(
dynamic_cast<__NAMESPACE__::__CPPNAME__*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
//We use dynamic_cast<> in case of multiple inheritance.
}
diff --git a/tools/m4/class_interface.m4 b/tools/m4/class_interface.m4
index 3c0b93e..bce51ff 100644
--- a/tools/m4/class_interface.m4
+++ b/tools/m4/class_interface.m4
@@ -161,7 +161,7 @@ namespace Glib
Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__CNAME__`'* object, bool take_copy)
{
- return Glib::RefPtr<__NAMESPACE__::__CPPNAME__>( dynamic_cast<__NAMESPACE__::__CPPNAME__*>
(Glib::wrap_auto_interface<__NAMESPACE__::__CPPNAME__> ((GObject*)(object), take_copy)) );
+ return Glib::make_refptr_for_instance<__NAMESPACE__::__CPPNAME__>(
dynamic_cast<__NAMESPACE__::__CPPNAME__*> (Glib::wrap_auto_interface<__NAMESPACE__::__CPPNAME__>
((GObject*)(object), take_copy)) );
//We use dynamic_cast<> in case of multiple inheritance.
}
diff --git a/tools/m4/class_opaque_refcounted.m4 b/tools/m4/class_opaque_refcounted.m4
index e90a1c0..41fbc5a 100644
--- a/tools/m4/class_opaque_refcounted.m4
+++ b/tools/m4/class_opaque_refcounted.m4
@@ -66,7 +66,7 @@ Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__CNAME__* object, bool take_copy)
__OPAQUE_FUNC_REF`'(object);
// See the comment at the top of this file, if you want to know why the cast works.
- return Glib::RefPtr<__NAMESPACE__::__CPPNAME__>(reinterpret_cast<__NAMESPACE__::__CPPNAME__*>(object));
+ return
Glib::make_refptr_for_instance<__NAMESPACE__::__CPPNAME__>(reinterpret_cast<__NAMESPACE__::__CPPNAME__*>(object));
}
} // namespace Glib
@@ -84,7 +84,7 @@ ifelse(__OPAQUE_FUNC_NEW,NONE,`dnl
Glib::RefPtr<__CPPNAME__> __CPPNAME__::create()
{
// See the comment at the top of this file, if you want to know why the cast works.
- return Glib::RefPtr<__CPPNAME__>(reinterpret_cast<__CPPNAME__*>(__OPAQUE_FUNC_NEW`'()));
+ return Glib::make_refptr_for_instance<__CPPNAME__>(reinterpret_cast<__CPPNAME__*>(__OPAQUE_FUNC_NEW`'()));
}
')dnl endif __OPAQUE_FUNC_NEW
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]