[seed] Add gtype-property-construct.js test. Tests installing construction properties
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] Add gtype-property-construct.js test. Tests installing construction properties
- Date: Thu, 23 Apr 2009 17:41:20 -0400 (EDT)
commit d0113b18407552a044d4163bdaf0079575bb0afd
Author: Robert Carr <racarr svn gnome org>
Date: Thu Apr 23 17:39:35 2009 -0400
Add gtype-property-construct.js test. Tests installing construction properties
---
libseed/seed-gtype.c | 35 ++++++++++++++++++++++++++
tests/javascript/Makefile.am | 1 +
tests/javascript/gtype-property-construct.js | 30 ++++++++++++++++++++++
tests/javascript/gtype-property.js | 5 +--
tests/javascript/readline_bind.js | 9 ------
5 files changed, 68 insertions(+), 12 deletions(-)
diff --git a/libseed/seed-gtype.c b/libseed/seed-gtype.c
index 0587d50..5852967 100644
--- a/libseed/seed-gtype.c
+++ b/libseed/seed-gtype.c
@@ -33,6 +33,8 @@ GQuark qcinit;
typedef struct _SeedGClassPrivates {
JSObjectRef constructor;
JSObjectRef func;
+
+ JSObjectRef definition;
} SeedGClassPrivates;
static JSValueRef
@@ -334,6 +336,34 @@ seed_gtype_construct (GType type,
}
static void
+seed_gtype_install_signals (JSContextRef ctx,
+ JSObjectRef definition,
+ GType type)
+{
+ JSObjectRef signals;
+ JSValueRef jslength;
+ guint i, length;
+
+ signals = seed_object_get_property (ctx, definition, "signals");
+ if (JSValueIsNull(ctx, signals) || !JSValueIsObject (ctx, signals))
+ return;
+
+ jslength = seed_object_get_property (ctx, definition, "length");
+ if (JSValueIsNull (ctx, jslength))
+ return;
+
+ length = seed_value_to_uint (ctx, jslength, NULL);
+ for (i = 0; i < length; i++)
+ {
+ JSObjectRef signal = JSObjectGetPropertyAtIndex (ctx,
+ (JSObjectRef) signals,
+ i,
+ NULL);
+ }
+
+}
+
+static void
seed_gtype_class_init (gpointer g_class,
gpointer class_data)
{
@@ -355,6 +385,8 @@ seed_gtype_class_init (gpointer g_class,
ctx = JSGlobalContextCreateInGroup (context_group, 0);
seed_prepare_global_context (ctx);
+
+ seed_gtype_install_signals (ctx, priv->definition, type);
type = (GType) JSObjectGetPrivate (priv->constructor);
class_info = seed_get_class_info_for_type (type);
@@ -476,6 +508,9 @@ seed_gtype_constructor_invoked (JSContextRef ctx,
priv->constructor = constructor_ref;
+ JSValueProtect (ctx, arguments[0]);
+ priv->definition = (JSObjectRef) arguments[0];
+
type_info.class_data = priv;
new_type = g_type_register_static (parent_type, new_name, &type_info, 0);
diff --git a/tests/javascript/Makefile.am b/tests/javascript/Makefile.am
index f92263c..7ec6cd2 100644
--- a/tests/javascript/Makefile.am
+++ b/tests/javascript/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST = \
gtype-class-init-exception.js \
gtype.js \
gtype-property.js \
+ gtype-property-construct.js \
gtype-signal-exception.js \
gtype-signal-args.js \
gtype-signal.js \
diff --git a/tests/javascript/gtype-property-construct.js b/tests/javascript/gtype-property-construct.js
new file mode 100755
index 0000000..f5fb895
--- /dev/null
+++ b/tests/javascript/gtype-property-construct.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env seed
+// Returns: 0
+// STDIN:
+// STDOUT:1\.000000
+// STDERR:
+
+Gtk = imports.gi.Gtk;
+GObject = imports.gi.GObject;
+Gtk.init(null, null);
+
+HelloWindowType = {
+parent: Gtk.Window.type,
+name: "HelloWindow",
+class_init: function(klass, prototype)
+{
+ klass.c_install_property(GObject.param_spec_boolean("test",
+ "test property",
+ "A test property!",
+ false,
+ GObject.ParamFlags.CONSTRUCT | GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE));
+},
+init: function()
+{
+ Seed.print(this.test);
+}};
+
+HelloWindow = new GType(HelloWindowType);
+w = new HelloWindow({test: true});
+
+
diff --git a/tests/javascript/gtype-property.js b/tests/javascript/gtype-property.js
index 97583a2..3a1b2d6 100755
--- a/tests/javascript/gtype-property.js
+++ b/tests/javascript/gtype-property.js
@@ -19,9 +19,8 @@ class_init: function(klass, prototype)
false,
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE));
},
-init: function(klass)
+init: function()
{
-
}};
HelloWindow = new GType(HelloWindowType);
@@ -29,4 +28,4 @@ w = new HelloWindow({test: true});
Seed.print(w.test);
w = new HelloWindow();
Seed.print(w.test);
-
+
diff --git a/tests/javascript/readline_bind.js b/tests/javascript/readline_bind.js
deleted file mode 100755
index 8b47b5d..0000000
--- a/tests/javascript/readline_bind.js
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env seed
-// Returns: 0
-// STDIN:a 2+2
-// STDOUT:Got here!\n4.000000
-// STDERR:
-
-readline = imports.readline;
-readline.bind("a", function () { Seed.print("Got here!"); });
-Seed.print(eval(readline.readline("")));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]