[gjs: 2/7] object: Move some methods out of the class body
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/7] object: Move some methods out of the class body
- Date: Sun, 1 Jul 2018 17:09:05 +0000 (UTC)
commit 70123645e83ac5ff5bf1b6b62171325913e68110
Author: Philip Chimento <philip chimento gmail com>
Date: Wed Jun 13 22:20:10 2018 -0700
object: Move some methods out of the class body
We are going to move this class to a separate header. Methods defined in
the class body are inlined by default, and these methods are too large
for that.
gi/object.cpp | 68 ++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 39 insertions(+), 29 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 1e7a6995..28e3faad 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -195,13 +195,7 @@ class ObjectInstance {
/* Helper methods for both prototypes and instances */
private:
- bool check_is_instance(JSContext *cx, const char *for_what) const {
- if (!is_prototype())
- return true;
- gjs_throw(cx, "Can't %s on %s.%s.prototype; only on instances",
- for_what, ns(), name());
- return false;
- }
+ bool check_is_instance(JSContext* cx, const char* for_what) const;
void debug_lifecycle(const char *message) const {
gjs_debug_lifecycle(GJS_DEBUG_GOBJECT,
"[%p: GObject %p JS wrapper %p %s.%s (%s)] %s",
@@ -238,18 +232,7 @@ class ObjectInstance {
public:
void ensure_uses_toggle_ref(JSContext *cx);
- bool check_gobject_disposed(const char *for_what) const {
- if (!m_gobj_disposed)
- return true;
-
- g_critical("Object %s.%s (%p), has been already deallocated — "
- "impossible to %s it. This might be caused by the object "
- "having been destroyed from C code using something such as "
- "destroy(), dispose(), or remove() vfuncs.",
- ns(), name(), m_gobj, for_what);
- gjs_dumpstack();
- return false;
- }
+ bool check_gobject_disposed(const char* for_what) const;
/* Prototype-only helper methods */
@@ -271,16 +254,8 @@ class ObjectInstance {
private:
static ObjectInstance *wrapped_gobject_list;
ObjectInstance *next(void) const { return m_instance_link.next(); }
- void unlink(void) {
- if (wrapped_gobject_list == this)
- wrapped_gobject_list = m_instance_link.next();
- m_instance_link.unlink();
- }
- void link(void) {
- if (wrapped_gobject_list)
- m_instance_link.prepend(this, wrapped_gobject_list);
- wrapped_gobject_list = this;
- }
+ void link(void);
+ void unlink(void);
public:
GjsListLink *get_link(void) { return &m_instance_link; }
@@ -457,6 +432,18 @@ GjsListLink::size(void) const
return count;
}
+void ObjectInstance::link(void) {
+ if (wrapped_gobject_list)
+ m_instance_link.prepend(this, wrapped_gobject_list);
+ wrapped_gobject_list = this;
+}
+
+void ObjectInstance::unlink(void) {
+ if (wrapped_gobject_list == this)
+ wrapped_gobject_list = m_instance_link.next();
+ m_instance_link.unlink();
+}
+
static bool
throw_priv_is_null_error(JSContext *context)
{
@@ -467,6 +454,29 @@ throw_priv_is_null_error(JSContext *context)
return false;
}
+bool ObjectInstance::check_is_instance(JSContext* cx,
+ const char* for_what) const {
+ if (!is_prototype())
+ return true;
+ gjs_throw(cx, "Can't %s on %s.%s.prototype; only on instances", for_what,
+ ns(), name());
+ return false;
+}
+
+bool ObjectInstance::check_gobject_disposed(const char* for_what) const {
+ if (!m_gobj_disposed)
+ return true;
+
+ g_critical(
+ "Object %s.%s (%p), has been already deallocated — impossible to %s "
+ "it. This might be caused by the object having been destroyed from C "
+ "code using something such as destroy(), dispose(), or remove() "
+ "vfuncs.",
+ ns(), name(), m_gobj, for_what);
+ gjs_dumpstack();
+ return false;
+}
+
/* Gets the ObjectInstance belonging to a particular JS object wrapper. Checks
* that the wrapper object has the right JSClass (ObjectInstance::klass)
* and returns null if not. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]