static void seed_libxml_define_stuff () { SeedObject node_proto; seed_class_definition xml_doc_class_def = seed_empty_class; seed_class_definition xml_node_class_def = seed_empty_class; seed_class_definition xml_attr_class_def = seed_empty_class; seed_class_definition xml_xpath_class_def = seed_empty_class; seed_class_definition xml_xpathobj_class_def = seed_empty_class; xml_doc_class_def.class_name="XMLDocument"; xml_doc_class_def.static_functions = doc_funcs; xml_doc_class_def.static_values = doc_values; xml_doc_class_def.finalize = seed_xml_doc_finalize; xml_doc_class = seed_create_class (&xml_doc_class_def); xml_node_class_def.class_name="XMLNode"; xml_node_class_def.static_functions = node_funcs; xml_node_class_def.static_values = node_values; xml_node_class_def.finalize = seed_xml_node_finalize; xml_node_class_def.initialize = seed_xml_node_init; xml_node_class = seed_create_class (&xml_node_class_def); xml_attr_class_def.class_name="XMLAttribute"; xml_attr_class_def.static_functions = attr_funcs; xml_attr_class_def.static_values = attr_values; xml_attr_class_def.finalize = seed_xml_node_finalize; xml_attr_class_def.initialize = seed_xml_node_init; xml_attr_class = seed_create_class (&xml_attr_class_def); xml_xpath_class_def.class_name = "XMLXPathContext"; xml_xpath_class_def.finalize = seed_xml_xpath_finalize; xml_xpath_class_def.static_functions = xpath_funcs; xml_xpath_class = seed_create_class (&xml_xpath_class_def); xml_xpathobj_class_def.class_name = "XMLXPathObj"; xml_xpathobj_class_def.finalize = seed_xml_xpathobj_finalize; xml_xpathobj_class_def.static_values = xpathobj_values; xml_xpathobj_class = seed_create_class (&xml_xpathobj_class_def); seed_create_function (eng->context, "parseFile", (SeedFunctionCallback) seed_xml_parse_file, namespace_ref); seed_create_function (eng->context, "parseString", (SeedFunctionCallback) seed_xml_parse_string, namespace_ref); node_proto = seed_object_get_prototype (eng->context, seed_make_object (eng->context, xml_node_class, NULL)); seed_make_object (eng->context, xml_node_class, NULL); seed_object_set_property (eng->context, namespace_ref, "_nodeProto", node_proto); seed_simple_evaluate (eng->context, "imports.extensions.xml", NULL); }
void js_signal_from_c(TestSimpleFixture* fixture, gconstpointer _data) { TestSharedState* state = (TestSharedState*) _data; SeedValue* val = seed_simple_evaluate( state->eng->context, "Gtk = imports.gi.Gtk;" "GObject = imports.gi.GObject;" "Gtk.init(null, null);" "HelloWindowType = {" " parent: Gtk.Window.type," " name: \"HelloWindow\"," " class_init: function(klass, prototype)" " {" " var HelloSignalDefinition = {name: \"hello\"," " " "parameters: [GObject.TYPE_INT," " " " GObject.TYPE_STRING]," " " "return_type: GObject.TYPE_DOUBLE};" " hello_signal_id = klass.install_signal(HelloSignalDefinition);" " }," " init: function(instance)" " {" " }};" "HelloWindow = new GType(HelloWindowType);" "w = new HelloWindow();", NULL); GObject* obj = seed_value_to_object(state->eng->context, val, NULL); g_signal_connect(obj, "hello", G_CALLBACK(hello_cb), NULL); val = seed_simple_evaluate(state->eng->context, "g = w.signal.hello.emit(2,'Test')", NULL); g_assert(seed_value_to_double(state->eng->context, val, NULL) == 5.12); }
SeedObject seed_module_init(SeedEngine *eng) { SeedObject gtkbuilder_proto; gtkbuilder_proto = seed_simple_evaluate (eng->context, "imports.gi.Gtk.Builder.prototype", NULL); seed_create_function (eng->context, "connect_signals", seed_gtk_builder_connect_signals, gtkbuilder_proto); return seed_make_object (eng->context, NULL, NULL); }
static gboolean peas_plugin_loader_seed_load (PeasPluginLoader *loader, PeasPluginInfo *info) { PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader); SeedContext context; gchar *script; SeedException exc = NULL; SeedObject global, extensions; SeedInfo *sinfo; context = seed_context_create (seed->group, NULL); seed_prepare_global_context (context); script = get_script_for_plugin_info (info, context); seed_simple_evaluate (context, script, &exc); g_free (script); if (exc) { gchar *exc_string = seed_exception_to_string (context, exc); g_warning ("Seed Exception: %s", exc_string); g_free (exc_string); seed_context_unref (context); return FALSE; } global = seed_context_get_global_object (context); extensions = seed_object_get_property (context, global, "extensions"); if (seed_value_is_object (context, extensions)) { sinfo = (SeedInfo *) g_slice_new (SeedInfo); sinfo->context = context; sinfo->extensions = extensions; seed_context_ref (context); seed_value_protect (context, extensions); g_hash_table_insert (sloader->loaded_plugins, info, sinfo); } seed_context_unref (context); return TRUE; }