seed r347 - in trunk: libseed src
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r347 - in trunk: libseed src
- Date: Tue, 25 Nov 2008 06:40:15 +0000 (UTC)
Author: racarr
Date: Tue Nov 25 06:40:15 2008
New Revision: 347
URL: http://svn.gnome.org/viewvc/seed?rev=347&view=rev
Log:
Exception code is global context free. seed_init returns the default Engine now.
Modified:
trunk/libseed/seed-engine.c
trunk/libseed/seed-exceptions.c
trunk/libseed/seed-exceptions.h
trunk/libseed/seed-gtype.c
trunk/libseed/seed-signals.c
trunk/libseed/seed.h
trunk/src/main.c
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Tue Nov 25 06:40:15 2008
@@ -1261,7 +1261,7 @@
return ret;
}
-gboolean seed_init(gint * argc, gchar *** argv)
+SeedEngine * seed_init(gint * argc, gchar *** argv)
{
JSObjectRef seed_obj_ref;
JSStringRef defaults_script;
@@ -1317,6 +1317,6 @@
JSEvaluateScript(eng->context, defaults_script, NULL, NULL, 0, NULL);
JSStringRelease(defaults_script);
- return TRUE;
+ return eng;
}
Modified: trunk/libseed/seed-exceptions.c
==============================================================================
--- trunk/libseed/seed-exceptions.c (original)
+++ trunk/libseed/seed-exceptions.c Tue Nov 25 06:40:15 2008
@@ -84,57 +84,57 @@
g_string_free(string, TRUE);
}
-gchar *seed_exception_get_name(JSValueRef e)
+gchar *seed_exception_get_name(JSContextRef ctx, JSValueRef e)
{
JSValueRef name;
g_assert((e));
- if (!JSValueIsObject(eng->context, e))
+ if (!JSValueIsObject(ctx, e))
return 0;
name = seed_object_get_property((JSObjectRef) e, "name");
return seed_value_to_string(name, 0);
}
-gchar *seed_exception_get_message(JSValueRef e)
+gchar *seed_exception_get_message(JSContextRef ctx, JSValueRef e)
{
JSValueRef name;
g_assert((e));
- if (!JSValueIsObject(eng->context, e))
+ if (!JSValueIsObject(ctx, e))
return 0;
name = seed_object_get_property((JSObjectRef) e, "message");
return seed_value_to_string(name, 0);
}
-guint seed_exception_get_line(JSValueRef e)
+guint seed_exception_get_line(JSContextRef ctx, JSValueRef e)
{
JSValueRef line;
g_assert((e));
- if (!JSValueIsObject(eng->context, e))
+ if (!JSValueIsObject(ctx, e))
return 0;
line = seed_object_get_property((JSObjectRef) e, "line");
return seed_value_to_uint(line, 0);
}
-gchar *seed_exception_get_file(JSValueRef e)
+gchar *seed_exception_get_file(JSContextRef ctx, JSValueRef e)
{
JSValueRef line;
g_assert((e));
- if (!JSValueIsObject(eng->context, e))
+ if (!JSValueIsObject(ctx, e))
return 0;
line = seed_object_get_property((JSObjectRef) e, "sourceURL");
return seed_value_to_string(line, 0);
}
-gchar *seed_exception_to_string(JSValueRef e)
+gchar *seed_exception_to_string(JSContextRef ctx, JSValueRef e)
{
guint line;
gchar *mes, *name, *file, *ret;
- line = seed_exception_get_line(e);
- mes = seed_exception_get_message(e);
- file = seed_exception_get_file(e);
- name = seed_exception_get_name(e);
+ line = seed_exception_get_line(ctx,e);
+ mes = seed_exception_get_message(ctx,e);
+ file = seed_exception_get_file(ctx,e);
+ name = seed_exception_get_name(ctx,e);
ret = g_strdup_printf("Line %d in %s: %s %s", line, file, name, mes);
Modified: trunk/libseed/seed-exceptions.h
==============================================================================
--- trunk/libseed/seed-exceptions.h (original)
+++ trunk/libseed/seed-exceptions.h Tue Nov 25 06:40:15 2008
@@ -29,10 +29,10 @@
void seed_make_exception_from_gerror(JSContextRef ctx,
JSValueRef * exception, GError * e);
-gchar *seed_exception_get_name(JSValueRef e);
-gchar *seed_exception_get_message(JSValueRef e);
-guint seed_exception_get_line(JSValueRef e);
-gchar *seed_exception_get_file(JSValueRef e);
-gchar *seed_exception_to_string(JSValueRef e);
+gchar *seed_exception_get_name(JSContextRef ctx, JSValueRef e);
+gchar *seed_exception_get_message(JSContextRef ctx, JSValueRef e);
+guint seed_exception_get_line(JSContextRef ctx, JSValueRef e);
+gchar *seed_exception_get_file(JSContextRef ctx, JSValueRef e);
+gchar *seed_exception_to_string(JSContextRef ctx, JSValueRef e);
#endif
Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c (original)
+++ trunk/libseed/seed-gtype.c Tue Nov 25 06:40:15 2008
@@ -380,7 +380,8 @@
JSObjectCallAsFunction(eng->context, function, 0, 2, jsargs, 0);
if (exception)
{
- gchar *mes = seed_exception_to_string(exception);
+ gchar *mes = seed_exception_to_string(eng->context,
+ exception);
g_warning("Exception in class init closure. %s \n", mes, 0);
}
}
@@ -402,39 +403,13 @@
&exception);
if (exception)
{
- gchar *mes = seed_exception_to_string(exception);
+ gchar *mes = seed_exception_to_string(eng->context,
+ exception);
g_warning("Exception in instance init closure. %s \n", mes, 0);
}
}
-static void
-seed_handle_set_property_closure(ffi_cif * cif,
- void *result, void **args, void *userdata)
-{
- JSObjectRef function = (JSObjectRef) userdata;
- JSValueRef jsargs[2];
- JSValueRef exception = 0;
- JSObjectRef this_object;
- GParamSpec *spec;
-
- this_object =
- (JSObjectRef) seed_value_from_object(*(GObject **) args[0], &exception);
- spec = *(GParamSpec **) args[3];
-
- jsargs[0] = seed_value_from_string(spec->name, &exception);
- jsargs[1] = seed_value_from_gvalue(*(GValue **) args[2], &exception);
-
- JSObjectCallAsFunction(eng->context, function, this_object, 2, jsargs,
- &exception);
- if (exception)
- {
- gchar *mes = seed_exception_to_string(exception);
- g_warning("Exception in set property closure. %s \n", mes, 0);
- }
-
-}
-
static ffi_closure *seed_make_class_init_closure(JSObjectRef function)
{
ffi_cif *cif;
@@ -485,33 +460,6 @@
return closure;
}
-static ffi_closure *seed_make_set_property_closure(JSObjectRef function)
-{
- ffi_cif *cif;
- ffi_closure *closure;
- ffi_type **arg_types;;
- ffi_arg result;
- ffi_status status;
-
- JSValueProtect(eng->context, function);
-
- cif = g_new0(ffi_cif, 1);
- arg_types = g_new0(ffi_type *, 5);
-
- arg_types[0] = &ffi_type_pointer;
- arg_types[1] = &ffi_type_uint;
- arg_types[2] = &ffi_type_pointer;
- arg_types[3] = &ffi_type_pointer;
- arg_types[4] = 0;
-
- closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
- PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-
- ffi_prep_cif(cif, FFI_DEFAULT_ABI, 4, &ffi_type_void, arg_types);
- ffi_prep_closure(closure, cif, seed_handle_set_property_closure, function);
- return closure;
-}
-
static JSObjectRef
seed_gtype_constructor_invoked(JSContextRef ctx,
JSObjectRef constructor,
Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c (original)
+++ trunk/libseed/seed-signals.c Tue Nov 25 06:40:15 2008
@@ -238,7 +238,8 @@
if (exception)
{
- gchar *mes = seed_exception_to_string(exception);
+ gchar *mes = seed_exception_to_string(eng->context,
+ exception);
g_warning("Exception in signal handler. %s \n", mes, 0);
g_free(mes);
exception = 0;
@@ -253,7 +254,7 @@
if (exception)
{
- gchar *mes = seed_exception_to_string(exception);
+ gchar *mes = seed_exception_to_string(eng->context, exception);
g_warning("Exception in signal handler return value. %s \n", mes, 0);
g_free(mes);
}
Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h (original)
+++ trunk/libseed/seed.h Tue Nov 25 06:40:15 2008
@@ -50,18 +50,18 @@
/*
* seed-engine.c
*/
-gboolean seed_init(gint * argc, gchar *** argv);
+SeedEngine * seed_init(gint * argc, gchar *** argv);
SeedScript *seed_make_script(const gchar * s, const gchar * source_url,
gint line_number);
SeedException seed_script_exception(SeedScript * s);
void seed_make_exception(SeedContext ctx, SeedException e,
gchar * name, gchar * message);
-gchar *seed_exception_get_name(SeedException e);
-gchar *seed_exception_get_message(SeedException e);
-guint seed_exception_get_line(SeedException e);
-gchar *seed_exception_get_file(SeedException e);
-gchar *seed_exception_to_string(SeedException e);
+gchar *seed_exception_get_name(SeedContext ctx, SeedException e);
+gchar *seed_exception_get_message(SeedContext ctx, SeedException e);
+guint seed_exception_get_line(SeedContext ctx, SeedException e);
+gchar *seed_exception_get_file(SeedContext ctx, SeedException e);
+gchar *seed_exception_to_string(SeedContext ctx, SeedException e);
SeedValue seed_evaluate(SeedScript * s, SeedObject this);
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Tue Nov 25 06:40:15 2008
@@ -27,6 +27,8 @@
#include <stdlib.h>
#include <girepository.h>
+SeedEngine * eng;
+
void seed_repl(int argc, char ** argv)
{
SeedScript * script;
@@ -64,19 +66,19 @@
if (e = seed_script_exception(script))
{
g_critical("%s. %s in %s at line %d",
- seed_exception_get_name(e),
- seed_exception_get_message(e),
- seed_exception_get_file(e),
- seed_exception_get_line(e));
+ seed_exception_get_name(eng->context, e),
+ seed_exception_get_message(eng->context, e),
+ seed_exception_get_file(eng->context, e),
+ seed_exception_get_line(eng->context, e));
exit(1);
}
seed_evaluate(script, 0);
if (e = seed_script_exception(script))
g_critical("%s. %s in %s at line %d",
- seed_exception_get_name(e),
- seed_exception_get_message(e),
- seed_exception_get_file(e),
- seed_exception_get_line(e));
+ seed_exception_get_name(eng->context, e),
+ seed_exception_get_message(eng->context, e),
+ seed_exception_get_file(eng->context, e),
+ seed_exception_get_line(eng->context, e));
g_free(script);
}
@@ -85,7 +87,7 @@
{
g_set_prgname("seed");
g_thread_init(0);
- seed_init(&argc, &argv);
+ eng = seed_init(&argc, &argv);
if (!g_irepository_require(g_irepository_get_default(),
"GObject", 0, 0, 0))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]