SeedObject seed_module_init(SeedEngine *local_eng) { SeedGlobalContext ctx = local_eng->context; seed_class_definition gettext_ns_class_def = seed_empty_class; gettext_ns_class_def.static_functions = gettext_funcs; SeedClass gettext_ns_class = seed_create_class(&gettext_ns_class_def); ns_ref = seed_make_object (ctx, gettext_ns_class, NULL); seed_value_protect (ctx, ns_ref); /* define enums for setlocale. Where to put them? */ DEFINE_ENUM_MEMBER(ns_ref, LC_CTYPE); DEFINE_ENUM_MEMBER(ns_ref, LC_NUMERIC); DEFINE_ENUM_MEMBER(ns_ref, LC_TIME); DEFINE_ENUM_MEMBER(ns_ref, LC_COLLATE); DEFINE_ENUM_MEMBER(ns_ref, LC_MONETARY); DEFINE_ENUM_MEMBER(ns_ref, LC_MESSAGES); DEFINE_ENUM_MEMBER(ns_ref, LC_ALL); DEFINE_ENUM_MEMBER(ns_ref, LC_PAPER); DEFINE_ENUM_MEMBER(ns_ref, LC_NAME); DEFINE_ENUM_MEMBER(ns_ref, LC_ADDRESS); DEFINE_ENUM_MEMBER(ns_ref, LC_TELEPHONE); DEFINE_ENUM_MEMBER(ns_ref, LC_MEASUREMENT); DEFINE_ENUM_MEMBER(ns_ref, LC_IDENTIFICATION); DEFINE_ENUM_MEMBER(ns_ref, LC_CTYPE); return ns_ref; }
static void seed_xml_node_init (SeedContext ctx, SeedObject object) { xmlNodePtr node = XML_NODE_PRIV (object); if (node && node->doc->_private) seed_value_protect (ctx, node->doc->_private); }
SeedObject seed_module_init(SeedEngine *local_eng) { eng = local_eng; namespace_ref = seed_make_object (eng->context, NULL, NULL); seed_value_protect (eng->context, namespace_ref); seed_libxml_define_stuff(); return namespace_ref; }
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; }
static SeedObject seed_ffi_make_function (SeedContext ctx, SeedObject module_obj, gpointer symbol, const gchar *name, GHashTable *symbols) { SeedValue ret; seed_ffi_function_priv *priv = g_slice_alloc0 (sizeof (seed_ffi_function_priv)); priv->symbol = symbol; priv->module_obj = module_obj; priv->name = g_strdup (name); ret = seed_make_object (ctx, ffi_function_class, priv); seed_value_protect (ctx, ret); g_hash_table_insert (symbols, g_strdup (name), ret); return ret; }
static SeedValue seed_xml_construct_xpath_context (SeedContext ctx, SeedObject function, SeedObject this_object, gsize argument_count, const SeedValue arguments[], SeedException * exception) { xmlXPathContextPtr xpath; xmlDocPtr doc; doc = XML_DOC_PRIV (this_object); xpath = xmlXPathNewContext (doc); seed_value_protect (ctx, this_object); return seed_make_object (ctx, xml_xpath_class, xpath); }
static gboolean seed_ffi_build_signature (SeedContext ctx, seed_ffi_function_priv *priv, SeedObject sig, SeedException *exception) { SeedObject arguments; SeedValue ret_type_ref, length_ref; guint length, i; arguments = seed_object_get_property (ctx, sig, "arguments"); ret_type_ref = seed_object_get_property (ctx, sig, "returns"); if (!seed_value_is_object (ctx, arguments)) { seed_make_exception (ctx, exception, "FFIError", "Signature arguments member must be an array describing argument types"); return FALSE; } length_ref = seed_object_get_property (ctx, arguments, "length"); length = seed_value_to_uint (ctx, length_ref, exception); priv->n_args = length; priv->args = g_slice_alloc (length * sizeof (GType)); for (i = 0; i < length; i++) { SeedValue type = seed_object_get_property_at_index (ctx, arguments, i, exception); priv->args[i] = seed_value_to_int (ctx, type, exception); } priv->ret_val = seed_value_to_int (ctx, ret_type_ref, exception); priv->signature_obj = sig; seed_value_protect (ctx, sig); return TRUE; }
GObject * peas_extension_seed_new (GType exten_type, SeedContext js_context, SeedObject js_object) { PeasExtensionSeed *sexten; GType real_type; g_return_val_if_fail (js_context != NULL, NULL); g_return_val_if_fail (js_object != NULL, NULL); real_type = peas_extension_register_subclass (PEAS_TYPE_EXTENSION_SEED, exten_type); sexten = PEAS_EXTENSION_SEED (g_object_new (real_type, NULL)); sexten->js_context = js_context; sexten->js_object = js_object; PEAS_EXTENSION_WRAPPER (sexten)->exten_type = exten_type; seed_context_ref (sexten->js_context); seed_value_protect (sexten->js_context, sexten->js_object); return G_OBJECT (sexten); }
static gboolean peas_plugin_loader_seed_load (PeasPluginLoader *loader, PeasPluginInfo *info) { PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader); gchar *filename; gchar *content; GError *error = NULL; SeedContext context; SeedScript *script; SeedException exc = NULL; SeedObject global, extensions; SeedInfo *sinfo; filename = get_script_filename_for_plugin_info (info); g_debug ("Seed script filename is '%s'", filename); if (!g_file_get_contents (filename, &content, NULL, &error)) { g_warning ("Error: %s", error->message); g_error_free (error); g_free (filename); return FALSE; } context = seed_context_create (seed->group, NULL); seed_prepare_global_context (context); script = seed_make_script (context, content, filename, 0); seed_evaluate (context, script, NULL); exc = seed_script_exception (script); seed_script_destroy (script); g_free (content); g_free (filename); 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_value_protect (context, extensions); g_hash_table_insert (sloader->loaded_plugins, info, sinfo); return TRUE; } else { g_warning ("extensions is not an object in plugin '%s'", peas_plugin_info_get_module_name (info)); seed_context_unref (context); return FALSE; } }