seed r649 - in trunk: libseed tests
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r649 - in trunk: libseed tests
- Date: Mon, 5 Jan 2009 05:10:34 +0000 (UTC)
Author: racarr
Date: Mon Jan 5 05:10:34 2009
New Revision: 649
URL: http://svn.gnome.org/viewvc/seed?rev=649&view=rev
Log:
Refactor some of the property handling code in order to prepare for
getters/setters.
Modified:
trunk/libseed/seed-engine.c
trunk/libseed/seed-gtype.c
trunk/tests/function-info.js
trunk/tests/gtype-property.js
trunk/tests/object-info.js
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Mon Jan 5 05:10:34 2009
@@ -1418,6 +1418,12 @@
seed_create_function(eng->context, "import_namespace",
&seed_gi_import_namespace, seed_obj_ref);
+
+ g_irepository_require(g_irepository_get_default(), "GObject",
+ NULL, 0, 0);
+ g_irepository_require(g_irepository_get_default(), "GIRepository",
+ NULL, 0, 0);
+
seed_init_builtins(eng, argc, argv);
seed_closures_init();
seed_structs_init();
@@ -1426,7 +1432,7 @@
defaults_script =
JSStringCreateWithUTF8CString("Seed.import_namespace(\""
- "GIRepository\");"
+ "GObject\");"
"try{Seed.include(\"/usr/share/"
"seed/Seed.js\");} catch(e){}"
"Seed.include(\"/usr/local/share"
Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c (original)
+++ trunk/libseed/seed-gtype.c Mon Jan 5 05:10:34 2009
@@ -21,6 +21,7 @@
#include <sys/mman.h>
JSClassRef seed_gtype_class;
+GIBaseInfo * objectclass_info = NULL;
/* From pygobject */
static ffi_type *g_value_to_ffi_type(const GValue * gvalue, gpointer * value)
@@ -406,7 +407,7 @@
klass->set_property = seed_gtype_set_property;
type = (GType) JSObjectGetPrivate(*(JSObjectRef *) args[1]);
- jsargs[0] = seed_make_pointer(ctx, *(gpointer *) args[0]);
+ jsargs[0] = seed_make_struct(ctx, *(gpointer *) args[0], objectclass_info);
jsargs[1] = seed_gobject_get_prototype_for_gtype(type);
SEED_NOTE(GTYPE, "Marshalling class init closure for type: %s",
@@ -415,14 +416,9 @@
// TODO:
// Should probably have a custom type for class, and have it auto convert.
seed_object_set_property(ctx, (JSObjectRef) jsargs[0],
- "type", seed_value_from_int(ctx, type, 0));
+ "type", seed_value_from_int(ctx, type, 0));
seed_object_set_property(ctx, (JSObjectRef) jsargs[0],
"property_count", seed_value_from_int(ctx, 1, 0));
- seed_create_function(ctx, "install_signal",
- &seed_gsignal_method_invoked, (JSObjectRef) jsargs[0]);
- seed_create_function(ctx, "install_property",
- &seed_property_method_invoked,
- (JSObjectRef) jsargs[0]);
JSObjectCallAsFunction(ctx, function, 0, 2, jsargs, &exception);
if (exception)
@@ -615,6 +611,23 @@
return JSObjectMake(ctx, gobject_constructor_class, (gpointer) new_type);
}
+void seed_define_gtype_functions(JSContextRef ctx)
+{
+ JSObjectRef proto;
+
+ objectclass_info = g_irepository_find_by_name(NULL,
+ "GObject",
+ "ObjectClass");
+
+ proto = seed_struct_prototype(ctx, objectclass_info);
+
+ seed_create_function(ctx, "c_install_property",
+ &seed_property_method_invoked,
+ proto);
+ seed_create_function(ctx, "install_signal",
+ &seed_gsignal_method_invoked, proto);
+}
+
void seed_gtype_init(SeedEngine * local_eng)
{
JSClassDefinition gtype_def = kJSClassDefinitionEmpty;
@@ -627,5 +640,9 @@
gtype_constructor = JSObjectMake(local_eng->context, seed_gtype_class, 0);
seed_object_set_property(local_eng->context,
- local_eng->global, "GType", gtype_constructor);
+ local_eng->global,
+ "GType",
+ gtype_constructor);
+
+ seed_define_gtype_functions(local_eng->context);
}
Modified: trunk/tests/function-info.js
==============================================================================
--- trunk/tests/function-info.js (original)
+++ trunk/tests/function-info.js Mon Jan 5 05:10:34 2009
@@ -4,6 +4,7 @@
// STDOUT:resize
// STDERR:
Seed.import_namespace("Gtk");
+Seed.import_namespace("GIRepository");
f = Gtk.Window.prototype.resize.info
Modified: trunk/tests/gtype-property.js
==============================================================================
--- trunk/tests/gtype-property.js (original)
+++ trunk/tests/gtype-property.js Mon Jan 5 05:10:34 2009
@@ -17,7 +17,7 @@
name: "HelloWindow",
class_init: function(klass, prototype)
{
- klass.install_property(GObject.param_spec_boolean("test",
+ klass.c_install_property(GObject.param_spec_boolean("test",
"test property",
"A test property!",
false,
Modified: trunk/tests/object-info.js
==============================================================================
--- trunk/tests/object-info.js (original)
+++ trunk/tests/object-info.js Mon Jan 5 05:10:34 2009
@@ -4,6 +4,7 @@
// STDOUT:Window implements interfaces\nInterface: Buildable\nInterface: ImplementorIface
// STDERR:
Seed.import_namespace("Gtk");
+Seed.import_namespace("GIRepository");
info = GIRepository.irepository_find_by_gtype(null, Gtk.Window.type);
Seed.print(GIRepository.base_info_get_name(info) + " implements interfaces");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]