[gjs] gi: object: add function to check if a JSObject contains a GObject
- From: Lionel Landwerlin <llandwerlin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] gi: object: add function to check if a JSObject contains a GObject
- Date: Mon, 24 Feb 2014 00:13:52 +0000 (UTC)
commit 2f886b0f40c44a0b244ddd6cebeca1671c94542d
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Mon Dec 9 16:04:02 2013 +0000
gi: object: add function to check if a JSObject contains a GObject
gi/object.cpp | 20 ++++++++++++++++++++
gi/object.h | 3 +++
2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 93a0ad6..20a2afe 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2079,6 +2079,26 @@ gjs_g_object_from_object(JSContext *context,
}
JSBool
+gjs_typecheck_is_object(JSContext *context,
+ JSObject *object,
+ JSBool throw_error)
+{
+
+ if (do_base_typecheck(context, object, throw_error)) {
+ ObjectInstance *priv = priv_from_js(context, object);
+
+ if (priv)
+ return JS_TRUE;
+ }
+
+ if (throw_error)
+ gjs_throw(context,
+ "Object instance or prototype is not a GObject");
+
+ return JS_FALSE;
+}
+
+JSBool
gjs_typecheck_object(JSContext *context,
JSObject *object,
GType expected_type,
diff --git a/gi/object.h b/gi/object.h
index 7b3b9a4..47b6781 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -43,6 +43,9 @@ JSBool gjs_typecheck_object (JSContext *context,
JSObject *obj,
GType expected_type,
JSBool throw_error);
+JSBool gjs_typecheck_is_object (JSContext *context,
+ JSObject *obj,
+ JSBool throw_error);
void gjs_object_prepare_shutdown (JSContext *context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]