[seed] [libseed] Indentation fix. Sorry, Robb.
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [seed] [libseed] Indentation fix. Sorry, Robb.
- Date: Thu, 30 Jul 2009 00:55:01 +0000 (UTC)
commit b8aa7fd72ea82785122937ab617a5cde6c21d9bf
Author: Tim Horton <hortont424 gmail com>
Date: Wed Jul 29 20:54:45 2009 -0400
[libseed] Indentation fix. Sorry, Robb.
libseed/seed-api.c | 97 +++++++----------
libseed/seed-builtins.c | 23 ++--
libseed/seed-builtins.h | 5 +-
libseed/seed-closure.c | 67 +++++++-----
libseed/seed-closure.h | 22 ++--
libseed/seed-engine.c | 97 +++++++++--------
libseed/seed-engine.h | 11 +-
libseed/seed-exceptions.c | 5 +-
libseed/seed-exceptions.h | 22 ++--
libseed/seed-gtype.c | 119 +++++++++++---------
libseed/seed-importer.c | 275 +++++++++++++++++++++++----------------------
libseed/seed-signals.c | 75 +++++++------
libseed/seed-structs.c | 17 ++--
libseed/seed-types.c | 130 ++++++++++------------
libseed/seed-types.h | 15 +--
15 files changed, 496 insertions(+), 484 deletions(-)
---
diff --git a/libseed/seed-api.c b/libseed/seed-api.c
index 0a43326..f8dc2ba 100644
--- a/libseed/seed-api.c
+++ b/libseed/seed-api.c
@@ -32,8 +32,7 @@
*
*/
void
-seed_value_protect (JSContextRef ctx,
- JSValueRef value)
+seed_value_protect (JSContextRef ctx, JSValueRef value)
{
JSValueProtect (ctx, value);
}
@@ -48,8 +47,7 @@ seed_value_protect (JSContextRef ctx,
*
*/
void
-seed_value_unprotect (JSContextRef ctx,
- JSValueRef value)
+seed_value_unprotect (JSContextRef ctx, JSValueRef value)
{
JSValueUnprotect (ctx, value);
}
@@ -69,8 +67,7 @@ seed_value_unprotect (JSContextRef ctx,
*
*/
JSGlobalContextRef
-seed_context_create (JSContextGroupRef group,
- JSClassRef global_class)
+seed_context_create (JSContextGroupRef group, JSClassRef global_class)
{
return JSGlobalContextCreateInGroup (group, global_class);
}
@@ -114,9 +111,7 @@ seed_context_unref (JSGlobalContextRef ctx)
*
*/
JSObjectRef
-seed_make_object (JSContextRef ctx,
- JSClassRef class,
- gpointer private)
+seed_make_object (JSContextRef ctx, JSClassRef class, gpointer private)
{
return JSObjectMake (ctx, class, private);
}
@@ -145,8 +140,7 @@ seed_object_set_property_at_index (JSContextRef ctx,
JSValueRef
seed_object_get_property_at_index (JSContextRef ctx,
JSObjectRef object,
- gint index,
- JSValueRef * exception)
+ gint index, JSValueRef * exception)
{
return JSObjectGetPropertyAtIndex (ctx, object, index, exception);
}
@@ -199,8 +193,7 @@ seed_object_call (JSContextRef ctx,
SeedScript *
seed_make_script (JSContextRef ctx,
const gchar * js,
- const gchar * source_url,
- gint line_number)
+ const gchar * source_url, gint line_number)
{
SeedScript *ret = g_new0 (SeedScript, 1);
@@ -232,8 +225,7 @@ seed_make_script (JSContextRef ctx,
*
*/
SeedScript *
-seed_script_new_from_file (JSContextRef ctx,
- gchar * file)
+seed_script_new_from_file (JSContextRef ctx, gchar * file)
{
SeedScript *script;
GError *e = NULL;
@@ -262,9 +254,7 @@ seed_script_new_from_file (JSContextRef ctx,
*
*/
JSValueRef
-seed_evaluate (JSContextRef ctx,
- SeedScript * s,
- JSObjectRef this)
+seed_evaluate (JSContextRef ctx, SeedScript * s, JSObjectRef this)
{
JSValueRef ret;
@@ -290,8 +280,7 @@ seed_evaluate (JSContextRef ctx,
*/
JSValueRef
seed_simple_evaluate (JSContextRef ctx,
- const gchar * source,
- JSValueRef *exception)
+ const gchar * source, JSValueRef * exception)
{
JSValueRef ret;
JSStringRef script = JSStringCreateWithUTF8CString (source);
@@ -405,12 +394,12 @@ seed_string_unref (JSStringRef string)
JSStringRelease (string);
}
-void
-seed_script_destroy (SeedScript *s)
+void
+seed_script_destroy (SeedScript * s)
{
seed_string_unref (s->script);
seed_string_unref (s->source_url);
-
+
g_free (s);
}
@@ -539,9 +528,11 @@ seed_value_is_object (JSContextRef ctx, JSValueRef value)
*
*/
gboolean
-seed_value_is_object_of_class (JSContextRef ctx, JSValueRef value, JSClassRef klass)
+seed_value_is_object_of_class (JSContextRef ctx, JSValueRef value,
+ JSClassRef klass)
{
- return !seed_value_is_null (ctx, value) && JSValueIsObjectOfClass (ctx, value, klass);
+ return !seed_value_is_null (ctx, value)
+ && JSValueIsObjectOfClass (ctx, value, klass);
}
/**
@@ -639,12 +630,11 @@ seed_engine_get_search_path (SeedEngine * eng)
*/
void
seed_signal_connect_full (JSContextRef ctx,
- GObject *object,
- const gchar *signal,
- JSObjectRef function,
- JSObjectRef user_data)
+ GObject * object,
+ const gchar * signal,
+ JSObjectRef function, JSObjectRef user_data)
{
- seed_gobject_signal_connect(ctx, signal, object, function,
+ seed_gobject_signal_connect (ctx, signal, object, function,
NULL, user_data);
}
@@ -662,15 +652,13 @@ seed_signal_connect_full (JSContextRef ctx,
*/
void
seed_signal_connect (JSContextRef ctx,
- GObject *object,
- const gchar *signal,
- const gchar *script)
+ GObject * object,
+ const gchar * signal, const gchar * script)
{
JSValueRef func;
- func = seed_simple_evaluate(ctx, script, NULL);
- seed_signal_connect_full(ctx, object, signal, (JSObjectRef)func,
- NULL);
+ func = seed_simple_evaluate (ctx, script, NULL);
+ seed_signal_connect_full (ctx, object, signal, (JSObjectRef) func, NULL);
}
/**
@@ -682,7 +670,7 @@ seed_signal_connect (JSContextRef ctx,
JSObjectRef
seed_context_get_global_object (JSGlobalContextRef ctx)
{
- return JSContextGetGlobalObject(ctx);
+ return JSContextGetGlobalObject (ctx);
}
@@ -703,8 +691,7 @@ seed_context_get_global_object (JSGlobalContextRef ctx)
JSObjectRef
seed_make_array (JSContextRef ctx,
const JSValueRef elements[],
- gsize num_elements,
- JSValueRef *exception)
+ gsize num_elements, JSValueRef * exception)
{
return JSObjectMakeArray (ctx, num_elements, elements, exception);
}
@@ -750,8 +737,7 @@ seed_make_undefined (JSContextRef ctx)
* Return value: The type of @value
*/
JSType
-seed_value_get_type (JSContextRef ctx,
- JSValueRef value)
+seed_value_get_type (JSContextRef ctx, JSValueRef value)
{
return JSValueGetType (ctx, value);
}
@@ -764,8 +750,7 @@ seed_value_get_type (JSContextRef ctx,
* Return value: A %NULL terminated array containing the property names of @object
*/
gchar **
-seed_object_copy_property_names(JSContextRef ctx,
- JSObjectRef object)
+seed_object_copy_property_names (JSContextRef ctx, JSObjectRef object)
{
JSPropertyNameArrayRef names;
JSStringRef name;
@@ -776,12 +761,12 @@ seed_object_copy_property_names(JSContextRef ctx,
names = JSObjectCopyPropertyNames (ctx, object);
length = JSPropertyNameArrayGetCount (names);
- ret = (gchar**) g_malloc((length+1)*sizeof(gchar *));
+ ret = (gchar **) g_malloc ((length + 1) * sizeof (gchar *));
for (i = 0; i < length; i++)
{
name = JSPropertyNameArrayGetNameAtIndex (names, i);
max_length = JSStringGetMaximumUTF8CStringSize (name);
- c_name = (gchar*) g_malloc (max_length * sizeof (gchar));
+ c_name = (gchar *) g_malloc (max_length * sizeof (gchar));
JSStringGetUTF8CString (name, c_name, length);
ret[i] = c_name;
@@ -823,9 +808,7 @@ seed_object_is_of_class (JSContextRef ctx, JSObjectRef obj, JSClassRef class)
* Return value: A #SeedObject representing the function
*/
JSObjectRef
-seed_make_function (JSContextRef ctx,
- gpointer func,
- gchar *name)
+seed_make_function (JSContextRef ctx, gpointer func, gchar * name)
{
JSObjectRef oref;
JSStringRef jsname = NULL;
@@ -864,10 +847,8 @@ seed_make_function (JSContextRef ctx,
*/
gboolean
seed_value_to_format (JSContextRef ctx,
- const gchar *format,
- JSValueRef *values,
- JSValueRef *exception,
- ...)
+ const gchar * format,
+ JSValueRef * values, JSValueRef * exception, ...)
{
va_list argp;
const gchar *c;
@@ -891,32 +872,32 @@ seed_value_to_format (JSContextRef ctx,
{
case 'i':
{
- *((gint *)p) = seed_value_to_int (ctx, val, exception);
+ *((gint *) p) = seed_value_to_int (ctx, val, exception);
break;
}
case 'u':
{
- *((guint *)p) = seed_value_to_uint (ctx, val, exception);
+ *((guint *) p) = seed_value_to_uint (ctx, val, exception);
break;
}
case 's':
{
- *((gchar **)p) = seed_value_to_string (ctx, val, exception);
+ *((gchar **) p) = seed_value_to_string (ctx, val, exception);
break;
}
case 'f':
{
- *((gdouble *)p) = seed_value_to_int (ctx, val, exception);
+ *((gdouble *) p) = seed_value_to_int (ctx, val, exception);
break;
}
case 'o':
{
- *((GObject **)p) = seed_value_to_object (ctx, val, exception);
+ *((GObject **) p) = seed_value_to_object (ctx, val, exception);
break;
}
case 'c':
{
- *((gchar *)c) = seed_value_to_char (ctx, val, exception);
+ *((gchar *) c) = seed_value_to_char (ctx, val, exception);
break;
}
}
diff --git a/libseed/seed-builtins.c b/libseed/seed-builtins.c
index f9eed75..0592d2c 100644
--- a/libseed/seed-builtins.c
+++ b/libseed/seed-builtins.c
@@ -52,7 +52,7 @@ seed_include (JSContextRef ctx,
g_file_get_contents (import_file, &buffer, 0, NULL);
else /* A search path is set and path given is not absolute. */
{
- len = g_strv_length(eng->search_path);
+ len = g_strv_length (eng->search_path);
for (i = 0; i < len; ++i)
{
dir = g_dir_open (eng->search_path[i], 0, NULL);
@@ -66,7 +66,7 @@ seed_include (JSContextRef ctx,
if (g_file_get_contents (abs_path, &buffer, 0, NULL))
{
g_free (abs_path);
- g_dir_close (dir);
+ g_dir_close (dir);
break;
}
@@ -211,7 +211,7 @@ seed_print (JSContextRef ctx,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef * exception)
{
- gchar *buf;
+ gchar *buf;
if (argumentCount != 1)
{
seed_make_exception (ctx, exception, "ArgumentError",
@@ -220,7 +220,7 @@ seed_print (JSContextRef ctx,
return JSValueMakeNull (ctx);
}
- buf = seed_value_to_string (ctx, arguments[0], exception);
+ buf = seed_value_to_string (ctx, arguments[0], exception);
puts (buf);
g_free (buf);
@@ -298,7 +298,7 @@ seed_introspect (JSContextRef ctx,
nargs = g_callable_info_get_n_args (info);
for (i = 0; i < nargs; ++i)
{
- argument = JSObjectMake (ctx, NULL, NULL);
+ argument = JSObjectMake (ctx, NULL, NULL);
const gchar *arg_name =
seed_g_type_name_to_string (g_arg_info_get_type
@@ -321,12 +321,10 @@ seed_check_syntax (JSContextRef ctx,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef * exception)
{
- JSStringRef jsstr;
+ JSStringRef jsstr;
if (argumentCount == 1)
{
- jsstr = JSValueToStringCopy (ctx,
- arguments[0],
- exception);
+ jsstr = JSValueToStringCopy (ctx, arguments[0], exception);
JSCheckScriptSyntax (ctx, jsstr, 0, 0, exception);
if (jsstr)
@@ -373,9 +371,11 @@ seed_spawn (JSContextRef ctx,
ret = JSObjectMake (ctx, NULL, NULL);
seed_object_set_property (ctx, ret, "stdout",
- seed_value_from_string (ctx, stdoutstr, exception));
+ seed_value_from_string (ctx, stdoutstr,
+ exception));
seed_object_set_property (ctx, ret, "stderr",
- seed_value_from_string (ctx, stderrstr, exception));
+ seed_value_from_string (ctx, stderrstr,
+ exception));
g_free (line);
g_free (stdoutstr);
@@ -504,4 +504,3 @@ seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv)
seed_object_set_property (local_eng->context, obj, "argv", arrayObj);
}
-
diff --git a/libseed/seed-builtins.h b/libseed/seed-builtins.h
index d752fa6..cf47a35 100644
--- a/libseed/seed-builtins.h
+++ b/libseed/seed-builtins.h
@@ -29,8 +29,9 @@ extern JSValueRef seed_print_ref;
void seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv);
extern JSClassRef seed_argv_class;
-typedef struct _SeedArgvPrivates {
- gchar ** argv;
+typedef struct _SeedArgvPrivates
+{
+ gchar **argv;
gint argc;
} SeedArgvPrivates;
diff --git a/libseed/seed-closure.c b/libseed/seed-closure.c
index 159e283..9905a61 100644
--- a/libseed/seed-closure.c
+++ b/libseed/seed-closure.c
@@ -174,8 +174,7 @@ seed_handle_closure (ffi_cif * cif, void *result, void **args, void *userdata)
if (exception)
{
- mes = seed_exception_to_string (ctx,
- exception);
+ mes = seed_exception_to_string (ctx, exception);
g_warning ("Exception in closure marshal. %s \n", mes);
g_free (mes);
exception = 0;
@@ -274,8 +273,7 @@ seed_handle_closure (ffi_cif * cif, void *result, void **args, void *userdata)
SeedNativeClosure *
seed_make_native_closure (JSContextRef ctx,
GICallableInfo * info,
- GIArgInfo *arg_info,
- JSValueRef function)
+ GIArgInfo * arg_info, JSValueRef function)
{
ffi_cif *cif;
ffi_closure *closure;
@@ -301,11 +299,14 @@ seed_make_native_closure (JSContextRef ctx,
privates = g_new0 (SeedNativeClosure, 1);
privates->info = (GICallableInfo *) g_base_info_ref ((GIBaseInfo *) info);
- privates->arg_info = (GIArgInfo *) g_base_info_ref ((GIBaseInfo *) arg_info);
+ privates->arg_info =
+ (GIArgInfo *) g_base_info_ref ((GIBaseInfo *) arg_info);
privates->function = function;
privates->cif = cif;
- closure = g_callable_info_prepare_closure (info, cif, seed_handle_closure, privates);
+ closure =
+ g_callable_info_prepare_closure (info, cif, seed_handle_closure,
+ privates);
privates->closure = closure;
JSValueProtect (ctx, function);
@@ -327,8 +328,9 @@ closure_invalidated (gpointer data, GClosure * c)
SeedClosure *closure = (SeedClosure *) c;
SEED_NOTE (FINALIZATION, "Finalizing closure.");
- if (closure->user_data && !JSValueIsUndefined(eng->context, closure->user_data))
- JSValueUnprotect(eng->context, closure->user_data);
+ if (closure->user_data
+ && !JSValueIsUndefined (eng->context, closure->user_data))
+ JSValueUnprotect (eng->context, closure->user_data);
if (!JSValueIsUndefined (eng->context, closure->function))
JSValueUnprotect (eng->context, closure->function);
@@ -337,48 +339,60 @@ closure_invalidated (gpointer data, GClosure * c)
}
JSObjectRef
-seed_closure_get_callable (GClosure *c)
+seed_closure_get_callable (GClosure * c)
{
- return ((SeedClosure *)c)->function;
+ return ((SeedClosure *) c)->function;
}
JSValueRef
-seed_closure_invoke (GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception)
+seed_closure_invoke (GClosure * closure, JSValueRef * args, guint argc,
+ JSValueRef * exception)
{
JSContextRef ctx = JSGlobalContextCreateInGroup (context_group, 0);
- JSValueRef *real_args = g_newa (JSValueRef, argc +1);
+ JSValueRef *real_args = g_newa (JSValueRef, argc + 1);
JSValueRef ret;
guint i;
seed_prepare_global_context (ctx);
for (i = 0; i < argc; i++)
real_args[i] = args[i];
- args[argc] = ((SeedClosure *)closure)->user_data ? ((SeedClosure *)closure)->user_data : JSValueMakeNull (ctx);
+ args[argc] =
+ ((SeedClosure *) closure)->user_data ? ((SeedClosure *) closure)->
+ user_data : JSValueMakeNull (ctx);
- ret = JSObjectCallAsFunction (ctx, ((SeedClosure *)closure)->function, NULL, argc+1, real_args, exception);
+ ret =
+ JSObjectCallAsFunction (ctx, ((SeedClosure *) closure)->function, NULL,
+ argc + 1, real_args, exception);
JSGlobalContextRelease ((JSGlobalContextRef) ctx);
return ret;
}
JSValueRef
-seed_closure_invoke_with_context (JSContextRef ctx, GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception)
+seed_closure_invoke_with_context (JSContextRef ctx, GClosure * closure,
+ JSValueRef * args, guint argc,
+ JSValueRef * exception)
{
- JSValueRef *real_args = g_newa (JSValueRef, argc +1);
+ JSValueRef *real_args = g_newa (JSValueRef, argc + 1);
JSValueRef ret;
guint i;
for (i = 0; i < argc; i++)
real_args[i] = args[i];
- args[argc] = ((SeedClosure *)closure)->user_data ? ((SeedClosure *)closure)->user_data : JSValueMakeNull (ctx);
+ args[argc] =
+ ((SeedClosure *) closure)->user_data ? ((SeedClosure *) closure)->
+ user_data : JSValueMakeNull (ctx);
- ret = JSObjectCallAsFunction (ctx, ((SeedClosure *)closure)->function, NULL, argc+1, real_args, exception);
+ ret =
+ JSObjectCallAsFunction (ctx, ((SeedClosure *) closure)->function, NULL,
+ argc + 1, real_args, exception);
return ret;
}
GClosure *
-seed_closure_new (JSContextRef ctx, JSObjectRef function, JSObjectRef user_data, const gchar *description)
+seed_closure_new (JSContextRef ctx, JSObjectRef function,
+ JSObjectRef user_data, const gchar * description)
{
GClosure *closure;
@@ -391,7 +405,7 @@ seed_closure_new (JSContextRef ctx, JSObjectRef function, JSObjectRef user_data,
if (user_data && !JSValueIsNull (ctx, user_data))
{
((SeedClosure *) closure)->user_data = user_data;
- JSValueProtect(ctx, user_data);
+ JSValueProtect (ctx, user_data);
}
if (description)
@@ -401,17 +415,19 @@ seed_closure_new (JSContextRef ctx, JSObjectRef function, JSObjectRef user_data,
}
void
-seed_closure_warn_exception (GClosure *c,
- JSContextRef ctx,
- JSValueRef exception)
+seed_closure_warn_exception (GClosure * c,
+ JSContextRef ctx, JSValueRef exception)
{
JSObjectRef callable = seed_closure_get_callable (c);
gchar *name = seed_value_to_string (ctx,
- seed_object_get_property (ctx, callable, "name"),
+ seed_object_get_property (ctx, callable,
+ "name"),
NULL);
gchar *mes = seed_exception_to_string (ctx, exception);
- g_warning("Exception in closure (%p) for %s (handler %s). %s", c, ((SeedClosure *)c)->description, *name == '\0' ? "[anonymous]" : name, mes);
+ g_warning ("Exception in closure (%p) for %s (handler %s). %s", c,
+ ((SeedClosure *) c)->description,
+ *name == '\0' ? "[anonymous]" : name, mes);
g_free (name);
g_free (mes);
@@ -443,4 +459,3 @@ seed_closures_init (void)
seed_native_callback_class = JSClassCreate (&seed_native_callback_def);
JSClassRetain (seed_native_callback_class);
}
-
diff --git a/libseed/seed-closure.h b/libseed/seed-closure.h
index 58bac5a..d2504f1 100644
--- a/libseed/seed-closure.h
+++ b/libseed/seed-closure.h
@@ -49,25 +49,25 @@ extern JSClassRef seed_native_callback_class;
SeedNativeClosure *seed_make_native_closure (JSContextRef ctx,
GICallableInfo * info,
- GIArgInfo *arg_info,
+ GIArgInfo * arg_info,
JSValueRef function);
GClosure *seed_closure_new (JSContextRef ctx,
JSObjectRef function,
- JSObjectRef user_data,
- const gchar *description);
+ JSObjectRef user_data, const gchar * description);
-JSObjectRef
-seed_closure_get_callable (GClosure *c);
+JSObjectRef seed_closure_get_callable (GClosure * c);
JSValueRef
-seed_closure_invoke (GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception);
-JSValueRef
-seed_closure_invoke_with_context (JSContextRef ctx, GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception);
+seed_closure_invoke (GClosure * closure, JSValueRef * args, guint argc,
+ JSValueRef * exception);
+JSValueRef seed_closure_invoke_with_context (JSContextRef ctx,
+ GClosure * closure,
+ JSValueRef * args, guint argc,
+ JSValueRef * exception);
void
-seed_closure_warn_exception (GClosure *c,
- JSContextRef ctx,
- JSValueRef exception);
+seed_closure_warn_exception (GClosure * c,
+ JSContextRef ctx, JSValueRef exception);
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 9fac9e5..30f1106 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -70,7 +70,8 @@ static const GDebugKey seed_debug_keys[] = {
* to a fresh #SeedContext.
*
*/
-void seed_prepare_global_context (JSContextRef ctx)
+void
+seed_prepare_global_context (JSContextRef ctx)
{
JSObjectRef global = JSContextGetGlobalObject (ctx);
@@ -201,7 +202,7 @@ seed_gobject_constructor_invoked (JSContextRef ctx,
{
g_free (params);
JSPropertyNameArrayRelease (jsprops);
- seed_next_gobject_wrapper = NULL;
+ seed_next_gobject_wrapper = NULL;
return 0;
}
params[ri].name = prop_name;
@@ -217,11 +218,10 @@ seed_gobject_constructor_invoked (JSContextRef ctx,
gobject = g_object_newv (type, ri, params);
- if (G_IS_INITIALLY_UNOWNED (gobject) &&
- !g_object_is_floating(gobject))
- g_object_ref(gobject);
- else if (g_object_is_floating(gobject))
- g_object_ref_sink(gobject);
+ if (G_IS_INITIALLY_UNOWNED (gobject) && !g_object_is_floating (gobject))
+ g_object_ref (gobject);
+ else if (g_object_is_floating (gobject))
+ g_object_ref_sink (gobject);
if (!gobject)
ret = (JSObjectRef) JSValueMakeNull (ctx);
@@ -293,15 +293,14 @@ seed_gobject_method_finalize (JSObjectRef method)
g_base_info_unref (info);
}
-typedef void (*InitMethodCallback) (gint *argc, gchar ***argv);
+typedef void (*InitMethodCallback) (gint * argc, gchar *** argv);
static gboolean
seed_gobject_init_build_argv (JSContextRef ctx,
JSObjectRef array,
- SeedArgvPrivates *priv,
- JSValueRef *exception)
+ SeedArgvPrivates * priv, JSValueRef * exception)
{
- guint i,length;
+ guint i, length;
JSValueRef jsl;
jsl = seed_object_get_property (ctx, array, "length");
@@ -309,13 +308,15 @@ seed_gobject_init_build_argv (JSContextRef ctx,
return FALSE;
length = seed_value_to_uint (ctx, jsl, exception);
- priv->argv = g_new(gchar *, length);
+ priv->argv = g_new (gchar *, length);
priv->argc = length;
for (i = 0; i < length; i++)
{
priv->argv[i] = seed_value_to_string (ctx,
- JSObjectGetPropertyAtIndex (ctx, array, i,
+ JSObjectGetPropertyAtIndex (ctx,
+ array,
+ i,
exception),
exception);
}
@@ -340,31 +341,33 @@ seed_gobject_init_method_invoked (JSContextRef ctx,
if (argumentCount != 1 && argumentCount != 2)
{
seed_make_exception (ctx, exception,
- "ArgumentError", "init method expects 1 argument, got %zd",
+ "ArgumentError",
+ "init method expects 1 argument, got %zd",
argumentCount);
return JSValueMakeUndefined (ctx);
}
- if (argumentCount ==1)
+ if (argumentCount == 1)
{
- if (JSValueIsNull (ctx, arguments[0]) || !JSValueIsObject (ctx, arguments[0]))
+ if (JSValueIsNull (ctx, arguments[0])
+ || !JSValueIsObject (ctx, arguments[0]))
{
seed_make_exception (ctx, exception,
- "ArgumentError", "init method expects an array object as argument");
+ "ArgumentError",
+ "init method expects an array object as argument");
return JSValueMakeUndefined (ctx);
}
- if(JSValueIsObjectOfClass (ctx, arguments[0], seed_argv_class))
+ if (JSValueIsObjectOfClass (ctx, arguments[0], seed_argv_class))
{
- priv = JSObjectGetPrivate ((JSObjectRef)arguments[0]);
+ priv = JSObjectGetPrivate ((JSObjectRef) arguments[0]);
}
else
{
- priv = g_newa (SeedArgvPrivates,1);
+ priv = g_newa (SeedArgvPrivates, 1);
if (!seed_gobject_init_build_argv (ctx,
- (JSObjectRef)arguments[0],
- priv,
- exception))
+ (JSObjectRef) arguments[0],
+ priv, exception))
{
seed_make_exception (ctx, exception, "ArgumentError",
"Init method expects an array as argument");
@@ -377,15 +380,17 @@ seed_gobject_init_method_invoked (JSContextRef ctx,
info = JSObjectGetPrivate (function);
typelib = g_base_info_get_typelib (info);
- g_typelib_symbol (typelib, g_function_info_get_symbol ((GIFunctionInfo *)info), (gpointer *)&c);
+ g_typelib_symbol (typelib,
+ g_function_info_get_symbol ((GIFunctionInfo *) info),
+ (gpointer *) & c);
// Backwards compatibility
if (!priv)
{
- c(NULL, NULL);
+ c (NULL, NULL);
return JSValueMakeUndefined (ctx);
}
- c(&priv->argc, &priv->argv);
+ c (&priv->argc, &priv->argv);
if (allocated)
g_free (priv->argv);
@@ -436,7 +441,9 @@ seed_gobject_method_invoked (JSContextRef ctx,
for (i = 0; (i < (n_args)); i++)
{
- SEED_NOTE (INVOCATION, "Converting arg: %d of function %s, exception is %p", i, g_base_info_get_name (info), exception);
+ SEED_NOTE (INVOCATION,
+ "Converting arg: %d of function %s, exception is %p", i,
+ g_base_info_get_name (info), exception);
arg_info = g_callable_info_get_arg ((GICallableInfo *) info, i);
dir = g_arg_info_get_direction (arg_info);
type_info = g_arg_info_get_type (arg_info);
@@ -456,7 +463,8 @@ seed_gobject_method_invoked (JSContextRef ctx,
"Unable to make argument %d for"
" function: %s. \n",
i + 1,
- g_base_info_get_name ((GIBaseInfo *) info));
+ g_base_info_get_name ((GIBaseInfo *)
+ info));
g_base_info_unref ((GIBaseInfo *) type_info);
g_base_info_unref ((GIBaseInfo *) arg_info);
@@ -558,8 +566,9 @@ seed_gobject_method_invoked (JSContextRef ctx,
{
seed_gi_release_in_arg (g_arg_info_get_ownership_transfer
(arg_info), type_info,
- &in_args[in_args_pos + (instance_method ? 1 : 0)]);
- in_args_pos++;
+ &in_args[in_args_pos +
+ (instance_method ? 1 : 0)]);
+ in_args_pos++;
g_base_info_unref ((GIBaseInfo *) type_info);
g_base_info_unref ((GIBaseInfo *) arg_info);
@@ -620,7 +629,7 @@ seed_gobject_define_property_from_function_info (JSContextRef ctx,
method_ref = JSObjectMake (ctx, gobject_method_class,
g_base_info_ref ((GIBaseInfo *) info));
-
+
JSObjectSetPrototype (ctx, method_ref, function_proto);
name = g_base_info_get_name ((GIBaseInfo *) info);
@@ -967,8 +976,7 @@ seed_gobject_set_property (JSContextRef context,
static JSValueRef
seed_gobject_constructor_convert_to_type (JSContextRef ctx,
JSObjectRef object,
- JSType type,
- JSValueRef *exception)
+ JSType type, JSValueRef * exception)
{
GType gtype;
gchar *as_string;
@@ -978,7 +986,8 @@ seed_gobject_constructor_convert_to_type (JSContextRef ctx,
JSValueRef ret;
gtype = (GType) JSObjectGetPrivate (object);
- as_string = g_strdup_printf("[gobject_constructor %s]", g_type_name (gtype));
+ as_string =
+ g_strdup_printf ("[gobject_constructor %s]", g_type_name (gtype));
ret = seed_value_from_string (ctx, as_string, exception);
g_free (as_string);
@@ -988,8 +997,10 @@ seed_gobject_constructor_convert_to_type (JSContextRef ctx,
}
JSStaticFunction gobject_static_funcs[] = {
- {"__debug_ref_count", seed_gobject_ref_count, 0},
- {"__property_type", seed_gobject_property_type, 0},
+ {"__debug_ref_count", seed_gobject_ref_count, 0}
+ ,
+ {"__property_type", seed_gobject_property_type, 0}
+ ,
{0, 0, 0}
};
@@ -1147,9 +1158,7 @@ JSClassDefinition struct_constructor_def = {
*/
void
seed_create_function (JSContextRef ctx,
- gchar * name,
- gpointer func,
- JSObjectRef obj)
+ gchar * name, gpointer func, JSObjectRef obj)
{
JSObjectRef oref;
@@ -1301,8 +1310,7 @@ seed_parse_args (int *argc, char ***argv)
*/
SeedEngine *
seed_init_with_context_group (gint * argc,
- gchar *** argv,
- JSContextGroupRef group)
+ gchar *** argv, JSContextGroupRef group)
{
g_type_init ();
@@ -1329,7 +1337,7 @@ seed_init_with_context_group (gint * argc,
eng->search_path = NULL;
function_proto = (JSObjectRef)
- seed_simple_evaluate (eng->context, "Function.prototype", NULL);
+ seed_simple_evaluate (eng->context, "Function.prototype", NULL);
gobject_class = JSClassCreate (&gobject_def);
JSClassRetain (gobject_class);
@@ -1369,7 +1377,8 @@ seed_init_with_context_group (gint * argc,
defaults_script =
- JSStringCreateWithUTF8CString ("Seed.include(\""SEED_PREFIX_PATH"extensions/Seed.js\");");
+ JSStringCreateWithUTF8CString ("Seed.include(\"" SEED_PREFIX_PATH
+ "extensions/Seed.js\");");
JSEvaluateScript (eng->context, defaults_script, NULL, NULL, 0, NULL);
@@ -1400,5 +1409,3 @@ seed_init (gint * argc, gchar *** argv)
return seed_init_with_context_group (argc, argv, context_group);
}
-
-
diff --git a/libseed/seed-engine.h b/libseed/seed-engine.h
index 89b0203..e1149af 100644
--- a/libseed/seed-engine.h
+++ b/libseed/seed-engine.h
@@ -70,15 +70,16 @@ void seed_prepare_global_context (JSContextRef ctx);
SeedScript *seed_make_script (JSContextRef ctx,
const gchar * js,
- const gchar * source_url,
- gint line_number);
+ const gchar * source_url, gint line_number);
SeedScript *seed_script_new_from_file (JSContextRef ctx, gchar * file);
JSValueRef seed_script_exception (SeedScript * s);
-JSValueRef seed_evaluate (JSContextRef ctx, SeedScript *script, JSObjectRef this);
+JSValueRef seed_evaluate (JSContextRef ctx, SeedScript * script,
+ JSObjectRef this);
-void seed_script_destroy (SeedScript *s);
+void seed_script_destroy (SeedScript * s);
-JSValueRef seed_simple_evaluate (JSContextRef ctx, const gchar *script, JSValueRef *exception);
+JSValueRef seed_simple_evaluate (JSContextRef ctx, const gchar * script,
+ JSValueRef * exception);
#endif
diff --git a/libseed/seed-exceptions.c b/libseed/seed-exceptions.c
index 182d180..1e808bc 100644
--- a/libseed/seed-exceptions.c
+++ b/libseed/seed-exceptions.c
@@ -35,9 +35,7 @@
void
seed_make_exception (JSContextRef ctx,
JSValueRef * exception,
- const gchar * name,
- const gchar * message,
- ...)
+ const gchar * name, const gchar * message, ...)
{
JSStringRef js_name = 0;
JSStringRef js_message = 0;
@@ -238,4 +236,3 @@ seed_exception_to_string (JSContextRef ctx, JSValueRef e)
return ret;
}
-
diff --git a/libseed/seed-exceptions.h b/libseed/seed-exceptions.h
index c415090..32a5dea 100644
--- a/libseed/seed-exceptions.h
+++ b/libseed/seed-exceptions.h
@@ -24,17 +24,19 @@
#include "seed-private.h"
-void seed_make_exception (JSContextRef ctx, JSValueRef * exception,
- const gchar * name, const gchar * message, ...) G_GNUC_PRINTF(4,5);
+void
+seed_make_exception (JSContextRef ctx, JSValueRef * exception,
+ const gchar * name, const gchar * message, ...)
+G_GNUC_PRINTF (4, 5);
-void seed_make_exception_from_gerror (JSContextRef ctx,
- JSValueRef * exception,
- GError * e);
+ void seed_make_exception_from_gerror (JSContextRef ctx,
+ JSValueRef * exception,
+ GError * 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);
+ 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
diff --git a/libseed/seed-gtype.c b/libseed/seed-gtype.c
index 41b956d..850629f 100644
--- a/libseed/seed-gtype.c
+++ b/libseed/seed-gtype.c
@@ -18,7 +18,8 @@
#include "seed-private.h"
#include <sys/mman.h>
-typedef GObject * (*GObjectConstructCallback) (GType, guint, GObjectConstructParam *);
+typedef GObject *(*GObjectConstructCallback) (GType, guint,
+ GObjectConstructParam *);
GHashTable *gtype_iinits;
@@ -28,7 +29,8 @@ GIBaseInfo *paramspec_info = NULL;
JSObjectRef seed_gtype_constructor;
-typedef struct _SeedGClassPrivates {
+typedef struct _SeedGClassPrivates
+{
JSObjectRef constructor;
JSObjectRef func;
@@ -164,16 +166,14 @@ seed_gsignal_method_invoked (JSContextRef ctx,
if (n_params > 0)
{
guint i;
- JSValueRef ptype;
+ JSValueRef ptype;
param_types = g_new0 (GType, n_params);
for (i = 0; i < n_params; i++)
{
- ptype = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef)
- jsparams,
- i,
- exception);
+ ptype = JSObjectGetPropertyAtIndex (ctx,
+ (JSObjectRef)
+ jsparams, i, exception);
param_types[i] = seed_value_to_int (ctx, ptype, exception);
}
@@ -202,8 +202,8 @@ seed_get_class_info_for_type (GType type)
if (object_info)
{
return
- (GIBaseInfo *)g_object_info_get_class_struct
- ((GIObjectInfo *)object_info);
+ (GIBaseInfo *) g_object_info_get_class_struct
+ ((GIObjectInfo *) object_info);
}
g_base_info_unref (object_info);
}
@@ -213,7 +213,7 @@ seed_get_class_info_for_type (GType type)
static void
seed_attach_methods_to_class_object (JSContextRef ctx,
JSObjectRef object,
- JSValueRef *exception)
+ JSValueRef * exception)
{
seed_create_function (ctx, "c_install_property",
&seed_property_method_invoked, object);
@@ -222,12 +222,12 @@ seed_attach_methods_to_class_object (JSContextRef ctx,
}
static void
-seed_gtype_call_construct (GType type, GObject *object)
+seed_gtype_call_construct (GType type, GObject * object)
{
JSContextRef ctx;
JSObjectRef func, this_object;
JSValueRef exception = NULL, args[1];
- gchar * mes;
+ gchar *mes;
func = g_hash_table_lookup (gtype_iinits, GINT_TO_POINTER (type));
if (func)
@@ -256,7 +256,7 @@ seed_gtype_call_construct (GType type, GObject *object)
static GObject *
seed_gtype_construct (GType type,
guint n_construct_params,
- GObjectConstructParam *construct_params)
+ GObjectConstructParam * construct_params)
{
GObject *object;
GType parent;
@@ -264,7 +264,7 @@ seed_gtype_construct (GType type,
parent = g_type_parent (type);
parent_class = g_type_class_ref (parent);
-
+
if (parent_class->constructor == seed_gtype_construct)
{
parent = g_type_parent (parent);
@@ -272,15 +272,18 @@ seed_gtype_construct (GType type,
g_type_class_unref (parent_class);
parent_class = g_type_class_ref (parent);
- object = parent_class->constructor (type, n_construct_params, construct_params);
+ object =
+ parent_class->constructor (type, n_construct_params,
+ construct_params);
g_type_class_unref (parent_class);
}
else
- object = parent_class->constructor (type, n_construct_params, construct_params);
-
+ object =
+ parent_class->constructor (type, n_construct_params, construct_params);
+
seed_gtype_call_construct (type, object);
-
+
g_type_class_unref (parent_class);
return object;
@@ -288,8 +291,7 @@ seed_gtype_construct (GType type,
static void
seed_gtype_install_signals (JSContextRef ctx,
- JSObjectRef definition,
- GType type)
+ JSObjectRef definition, GType type)
{
JSObjectRef signals, signal_def;
JSValueRef jslength;
@@ -301,8 +303,9 @@ seed_gtype_install_signals (JSContextRef ctx,
JSValueRef jsname, jsflags, jsreturn_type, jsparams;
gchar *name;
- signals = (JSObjectRef) seed_object_get_property (ctx, definition, "signals");
- if (JSValueIsNull(ctx, signals) || !JSValueIsObject (ctx, signals))
+ signals =
+ (JSObjectRef) seed_object_get_property (ctx, definition, "signals");
+ if (JSValueIsNull (ctx, signals) || !JSValueIsObject (ctx, signals))
return;
jslength = seed_object_get_property (ctx, signals, "length");
@@ -312,29 +315,33 @@ seed_gtype_install_signals (JSContextRef ctx,
length = seed_value_to_uint (ctx, jslength, NULL);
for (i = 0; i < length; i++)
{
- signal_def = (JSObjectRef)JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) signals,
- i,
- NULL);
+ signal_def = (JSObjectRef) JSObjectGetPropertyAtIndex (ctx,
+ (JSObjectRef)
+ signals, i,
+ NULL);
- if (JSValueIsNull (ctx, signal_def) || !JSValueIsObject(ctx, signal_def))
+ if (JSValueIsNull (ctx, signal_def)
+ || !JSValueIsObject (ctx, signal_def))
continue;
// TODO: Error checking
jsname = seed_object_get_property (ctx, signal_def, "name");
name = seed_value_to_string (ctx, jsname, NULL);
- SEED_NOTE(GTYPE, "Installing signal with name: %s on type: %s",
- name, g_type_name (type));
+ SEED_NOTE (GTYPE, "Installing signal with name: %s on type: %s",
+ name, g_type_name (type));
- jsflags = seed_object_get_property (ctx, (JSObjectRef) signal_def, "flags");
+ jsflags =
+ seed_object_get_property (ctx, (JSObjectRef) signal_def, "flags");
if (JSValueIsNull (ctx, jsflags) || !JSValueIsNumber (ctx, jsflags))
- flags = G_SIGNAL_RUN_LAST;
+ flags = G_SIGNAL_RUN_LAST;
else
- flags = seed_value_to_long (ctx, jsflags, NULL);
+ flags = seed_value_to_long (ctx, jsflags, NULL);
- jsreturn_type = seed_object_get_property (ctx, signal_def, "return_type");
- if (JSValueIsNull (ctx, jsreturn_type) || !JSValueIsNumber (ctx, jsreturn_type))
+ jsreturn_type =
+ seed_object_get_property (ctx, signal_def, "return_type");
+ if (JSValueIsNull (ctx, jsreturn_type)
+ || !JSValueIsNumber (ctx, jsreturn_type))
return_type = G_TYPE_NONE;
else
return_type = seed_value_to_long (ctx, jsreturn_type, NULL);
@@ -343,10 +350,15 @@ seed_gtype_install_signals (JSContextRef ctx,
if (!JSValueIsNull (ctx, jsparams) && JSValueIsObject (ctx, jsparams))
{
- n_params = seed_value_to_int (ctx, seed_object_get_property (ctx, (JSObjectRef) jsparams, "length"), NULL);
+ n_params =
+ seed_value_to_int (ctx,
+ seed_object_get_property (ctx,
+ (JSObjectRef)
+ jsparams, "length"),
+ NULL);
if (n_params > 0)
{
- param_types = g_alloca (sizeof (GType)*n_params);
+ param_types = g_alloca (sizeof (GType) * n_params);
for (j = 0; j < n_params; j++)
{
JSValueRef ptype = JSObjectGetPropertyAtIndex (ctx,
@@ -354,7 +366,8 @@ seed_gtype_install_signals (JSContextRef ctx,
jsparams,
j,
NULL);
- param_types[j] = (GType) seed_value_to_long (ctx, ptype, NULL);
+ param_types[j] =
+ (GType) seed_value_to_long (ctx, ptype, NULL);
}
}
}
@@ -369,8 +382,7 @@ seed_gtype_install_signals (JSContextRef ctx,
}
static void
-seed_gtype_class_init (gpointer g_class,
- gpointer class_data)
+seed_gtype_class_init (gpointer g_class, gpointer class_data)
{
SeedGClassPrivates *priv;
GIBaseInfo *class_info;
@@ -380,9 +392,9 @@ seed_gtype_class_init (gpointer g_class,
gchar *mes;
JSValueRef exception = NULL;
- priv = (SeedGClassPrivates *)class_data;
+ priv = (SeedGClassPrivates *) class_data;
- ((GObjectClass *)g_class)->constructor = seed_gtype_construct;
+ ((GObjectClass *) g_class)->constructor = seed_gtype_construct;
ctx = JSGlobalContextCreateInGroup (context_group, 0);
@@ -402,7 +414,8 @@ seed_gtype_class_init (gpointer g_class,
jsargs[0] = seed_make_struct (ctx, g_class, class_info);
jsargs[1] = seed_gobject_get_prototype_for_gtype (type);
- seed_attach_methods_to_class_object (ctx, (JSObjectRef) jsargs[0], &exception);
+ seed_attach_methods_to_class_object (ctx, (JSObjectRef) jsargs[0],
+ &exception);
g_base_info_unref ((GIBaseInfo *) class_info);
@@ -428,10 +441,10 @@ seed_gtype_class_init (gpointer g_class,
static JSObjectRef
seed_gtype_constructor_invoked (JSContextRef ctx,
- JSObjectRef constructor,
- gsize argumentCount,
- const JSValueRef arguments[],
- JSValueRef * exception)
+ JSObjectRef constructor,
+ gsize argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
{
JSValueRef class_init, instance_init, name, parent_ref;
GType parent_type, new_type;
@@ -529,7 +542,8 @@ seed_gtype_constructor_invoked (JSContextRef ctx,
JSValueIsObject (ctx, instance_init) &&
JSObjectIsFunction (ctx, (JSObjectRef) instance_init))
{
- g_hash_table_insert (gtype_iinits, GINT_TO_POINTER (new_type), (gpointer) instance_init);
+ g_hash_table_insert (gtype_iinits, GINT_TO_POINTER (new_type),
+ (gpointer) instance_init);
JSValueProtect (ctx, instance_init);
}
@@ -557,13 +571,14 @@ seed_gtype_init (SeedEngine * local_eng)
seed_gtype_class = JSClassCreate (>ype_def);
JSClassRetain (seed_gtype_class);
- seed_gtype_constructor = JSObjectMake (local_eng->context, seed_gtype_class, 0);
+ seed_gtype_constructor =
+ JSObjectMake (local_eng->context, seed_gtype_class, 0);
seed_object_set_property (local_eng->context,
- local_eng->global, "GType", seed_gtype_constructor);
+ local_eng->global, "GType",
+ seed_gtype_constructor);
seed_define_gtype_functions (local_eng->context);
-
+
gtype_iinits = g_hash_table_new (g_int_hash, g_str_equal);
}
-
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index 1de329c..808ff3a 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -60,13 +60,13 @@ GHashTable *file_imports;
*/
static gboolean
-seed_gi_importer_is_init (GIFunctionInfo *info)
+seed_gi_importer_is_init (GIFunctionInfo * info)
{
if (g_strcmp0 (g_base_info_get_name ((GIBaseInfo *) info), "init"))
{
return FALSE;
}
- if (g_callable_info_get_n_args ((GICallableInfo *)info) != 2)
+ if (g_callable_info_get_n_args ((GICallableInfo *) info) != 2)
return FALSE;
return TRUE;
@@ -75,8 +75,8 @@ seed_gi_importer_is_init (GIFunctionInfo *info)
static void
seed_gi_importer_handle_function (JSContextRef ctx,
JSObjectRef namespace_ref,
- GIFunctionInfo *info,
- JSValueRef *exception)
+ GIFunctionInfo * info,
+ JSValueRef * exception)
{
if (!seed_gi_importer_is_init (info))
seed_gobject_define_property_from_function_info (ctx,
@@ -86,8 +86,8 @@ seed_gi_importer_handle_function (JSContextRef ctx,
{
JSObjectRef init_method;
- init_method = JSObjectMake(ctx, gobject_init_method_class,
- g_base_info_ref ((GIBaseInfo *)info));
+ init_method = JSObjectMake (ctx, gobject_init_method_class,
+ g_base_info_ref ((GIBaseInfo *) info));
seed_object_set_property (ctx, namespace_ref, "init", init_method);
}
}
@@ -101,8 +101,7 @@ seed_gi_importer_handle_function (JSContextRef ctx,
static void
seed_gi_importer_handle_enum (JSContextRef ctx,
JSObjectRef namespace_ref,
- GIEnumInfo *info,
- JSValueRef *exception)
+ GIEnumInfo * info, JSValueRef * exception)
{
JSObjectRef enum_class;
guint num_vals, i, j;
@@ -114,7 +113,7 @@ seed_gi_importer_handle_enum (JSContextRef ctx,
enum_class = JSObjectMake (ctx, 0, 0);
num_vals = g_enum_info_get_n_values (info);
seed_object_set_property (ctx, namespace_ref,
- g_base_info_get_name ((GIBaseInfo *)info),
+ g_base_info_get_name ((GIBaseInfo *) info),
enum_class);
for (i = 0; i < num_vals; i++)
@@ -151,14 +150,12 @@ seed_gi_importer_handle_enum (JSContextRef ctx,
static void
seed_gi_importer_handle_object (JSContextRef ctx,
JSObjectRef namespace_ref,
- GIObjectInfo *info,
- JSValueRef *exception)
+ GIObjectInfo * info, JSValueRef * exception)
{
GType type;
JSClassRef class_ref;
- type =
- g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) info);
+ type = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *) info);
if (type != 0)
{
@@ -170,9 +167,7 @@ seed_gi_importer_handle_object (JSContextRef ctx,
class_ref = seed_gobject_get_class_for_gtype (ctx, type);
constructor_ref =
- JSObjectMake (ctx,
- gobject_constructor_class,
- (gpointer) type);
+ JSObjectMake (ctx, gobject_constructor_class, (gpointer) type);
seed_object_set_property (ctx, constructor_ref,
"type",
@@ -195,8 +190,7 @@ seed_gi_importer_handle_object (JSContextRef ctx,
fname = "c_new";
seed_object_set_property (ctx,
- constructor_ref,
- fname, constructor);
+ constructor_ref, fname, constructor);
}
else if (!(flags & GI_FUNCTION_IS_METHOD))
{
@@ -225,16 +219,14 @@ seed_gi_importer_handle_object (JSContextRef ctx,
static void
seed_gi_importer_handle_struct (JSContextRef ctx,
JSObjectRef namespace_ref,
- GIStructInfo *info,
- JSValueRef *exception)
+ GIStructInfo * info, JSValueRef * exception)
{
JSObjectRef struct_ref;
JSObjectRef proto;
gint i, n_methods;
GIFunctionInfo *finfo;
- struct_ref =
- JSObjectMake (ctx, seed_struct_constructor_class, info);
+ struct_ref = JSObjectMake (ctx, seed_struct_constructor_class, info);
n_methods = g_struct_info_get_n_methods (info);
@@ -250,8 +242,7 @@ seed_gi_importer_handle_struct (JSContextRef ctx,
JSObjectRef constructor = JSObjectMake (ctx,
gobject_named_constructor_class,
finfo);
- const gchar *fname =
- g_base_info_get_name ((GIBaseInfo *) finfo);
+ const gchar *fname = g_base_info_get_name ((GIBaseInfo *) finfo);
if (g_str_has_prefix (fname, "new_"))
fname += 4;
else if (!g_strcmp0 (fname, "new"))
@@ -266,25 +257,25 @@ seed_gi_importer_handle_struct (JSContextRef ctx,
(ctx, finfo, struct_ref, FALSE);
}
- proto = seed_struct_prototype (ctx, (GIBaseInfo *)info);
+ proto = seed_struct_prototype (ctx, (GIBaseInfo *) info);
seed_object_set_property (ctx, struct_ref, "prototype", proto);
- seed_object_set_property (ctx, namespace_ref, g_base_info_get_name ((GIBaseInfo *)info), struct_ref);
+ seed_object_set_property (ctx, namespace_ref,
+ g_base_info_get_name ((GIBaseInfo *) info),
+ struct_ref);
}
static void
seed_gi_importer_handle_union (JSContextRef ctx,
JSObjectRef namespace_ref,
- GIUnionInfo *info,
- JSValueRef *exception)
+ GIUnionInfo * info, JSValueRef * exception)
{
JSObjectRef union_ref;
JSObjectRef proto;
guint i, n_methods;
GIFunctionInfo *finfo;
- union_ref =
- JSObjectMake (ctx, seed_struct_constructor_class, info);
+ union_ref = JSObjectMake (ctx, seed_struct_constructor_class, info);
n_methods = g_union_info_get_n_methods (info);
@@ -302,17 +293,19 @@ seed_gi_importer_handle_union (JSContextRef ctx,
(ctx, finfo, union_ref, FALSE);
}
- proto = seed_union_prototype (ctx, (GIBaseInfo *)info);
+ proto = seed_union_prototype (ctx, (GIBaseInfo *) info);
seed_object_set_property (ctx, union_ref, "prototype", proto);
- seed_object_set_property (ctx, namespace_ref, g_base_info_get_name ((GIBaseInfo *)info), union_ref);
+ seed_object_set_property (ctx, namespace_ref,
+ g_base_info_get_name ((GIBaseInfo *) info),
+ union_ref);
}
static void
seed_gi_importer_handle_callback (JSContextRef ctx,
JSObjectRef namespace_ref,
- GICallbackInfo *info,
- JSValueRef *exception)
+ GICallbackInfo * info,
+ JSValueRef * exception)
{
JSObjectRef callback_ref = JSObjectMake (ctx,
seed_callback_class,
@@ -328,18 +321,16 @@ seed_gi_importer_handle_callback (JSContextRef ctx,
static void
seed_gi_importer_handle_constant (JSContextRef ctx,
JSObjectRef namespace_ref,
- GIConstantInfo *info,
- JSValueRef *exception)
+ GIConstantInfo * info,
+ JSValueRef * exception)
{
GArgument argument;
- GITypeInfo *constant_type =
- g_constant_info_get_type (info);
+ GITypeInfo *constant_type = g_constant_info_get_type (info);
JSValueRef constant_value;
g_constant_info_get_value (info, &argument);
constant_value =
- seed_gi_argument_make_js (ctx, &argument,
- constant_type, exception);
+ seed_gi_argument_make_js (ctx, &argument, constant_type, exception);
seed_object_set_property (ctx, namespace_ref,
g_base_info_get_name ((GIBaseInfo *) info),
constant_value);
@@ -349,14 +340,14 @@ seed_gi_importer_handle_constant (JSContextRef ctx,
static gchar *
seed_gi_importer_get_version (JSContextRef ctx,
- gchar *namespace,
- JSValueRef *exception)
+ gchar * namespace, JSValueRef * exception)
{
JSValueRef version_ref;
gchar *version = NULL;
- version_ref = seed_object_get_property (ctx, gi_importer_versions, namespace);
- if (!JSValueIsUndefined(ctx, version_ref))
+ version_ref =
+ seed_object_get_property (ctx, gi_importer_versions, namespace);
+ if (!JSValueIsUndefined (ctx, version_ref))
version = seed_value_to_string (ctx, version_ref, exception);
return version;
@@ -364,8 +355,7 @@ seed_gi_importer_get_version (JSContextRef ctx,
static JSObjectRef
seed_gi_importer_do_namespace (JSContextRef ctx,
- gchar *namespace,
- JSValueRef *exception)
+ gchar * namespace, JSValueRef * exception)
{
GIBaseInfo *info;
JSObjectRef namespace_ref;
@@ -383,12 +373,11 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
}
version = seed_gi_importer_get_version (ctx, namespace, exception);
- if (!g_irepository_require (NULL, namespace,
- version, 0, &e))
+ if (!g_irepository_require (NULL, namespace, version, 0, &e))
{
seed_make_exception_from_gerror (ctx, exception, e);
g_error_free (e);
- g_free (version);
+ g_free (version);
return NULL;
}
g_free (version);
@@ -411,26 +400,36 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
switch (info_type)
{
case GI_INFO_TYPE_FUNCTION:
- seed_gi_importer_handle_function (ctx, namespace_ref, (GIFunctionInfo *) info, exception);
+ seed_gi_importer_handle_function (ctx, namespace_ref,
+ (GIFunctionInfo *) info,
+ exception);
break;
case GI_INFO_TYPE_ENUM:
case GI_INFO_TYPE_FLAGS:
- seed_gi_importer_handle_enum (ctx, namespace_ref, (GIEnumInfo *) info, exception);
+ seed_gi_importer_handle_enum (ctx, namespace_ref,
+ (GIEnumInfo *) info, exception);
break;
case GI_INFO_TYPE_OBJECT:
- seed_gi_importer_handle_object (ctx, namespace_ref, (GIObjectInfo *) info, exception);
+ seed_gi_importer_handle_object (ctx, namespace_ref,
+ (GIObjectInfo *) info, exception);
break;
case GI_INFO_TYPE_STRUCT:
- seed_gi_importer_handle_struct (ctx, namespace_ref, (GIStructInfo *) info, exception);
+ seed_gi_importer_handle_struct (ctx, namespace_ref,
+ (GIStructInfo *) info, exception);
break;
case GI_INFO_TYPE_UNION:
- seed_gi_importer_handle_union (ctx, namespace_ref, (GIUnionInfo *) info, exception);
+ seed_gi_importer_handle_union (ctx, namespace_ref,
+ (GIUnionInfo *) info, exception);
break;
case GI_INFO_TYPE_CALLBACK:
- seed_gi_importer_handle_callback (ctx, namespace_ref, (GICallbackInfo *) info, exception);
+ seed_gi_importer_handle_callback (ctx, namespace_ref,
+ (GICallbackInfo *) info,
+ exception);
break;
case GI_INFO_TYPE_CONSTANT:
- seed_gi_importer_handle_constant (ctx, namespace_ref, (GIConstantInfo *) info, exception);
+ seed_gi_importer_handle_constant (ctx, namespace_ref,
+ (GIConstantInfo *) info,
+ exception);
break;
default:
break;
@@ -438,10 +437,9 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
g_base_info_unref (info);
}
- g_hash_table_insert (gi_imports, g_strdup(namespace), namespace_ref);
+ g_hash_table_insert (gi_imports, g_strdup (namespace), namespace_ref);
- jsextension = g_strdup_printf ("imports.extensions.%s",
- namespace);
+ jsextension = g_strdup_printf ("imports.extensions.%s", namespace);
extension_script = JSStringCreateWithUTF8CString (jsextension);
JSEvaluateScript (ctx, extension_script, NULL, NULL, 0, NULL);
JSStringRelease (extension_script);
@@ -456,7 +454,7 @@ static JSValueRef
seed_gi_importer_get_property (JSContextRef ctx,
JSObjectRef object,
JSStringRef property_name,
- JSValueRef *exception)
+ JSValueRef * exception)
{
JSObjectRef ret;
guint len;
@@ -468,12 +466,12 @@ seed_gi_importer_get_property (JSContextRef ctx,
SEED_NOTE (IMPORTER, "seed_gi_importer_get_property with %s", prop);
- if (!g_strcmp0(prop, "versions"))
+ if (!g_strcmp0 (prop, "versions"))
return gi_importer_versions;
// Nasty hack
- else if (!g_strcmp0(prop, "toString"))
+ else if (!g_strcmp0 (prop, "toString"))
return 0;
- if (!g_strcmp0 (prop, "valueOf")) // HACK
+ if (!g_strcmp0 (prop, "valueOf")) // HACK
return NULL;
@@ -485,7 +483,7 @@ seed_gi_importer_get_property (JSContextRef ctx,
}
static JSObjectRef
-seed_make_importer_dir (JSContextRef ctx, gchar *path)
+seed_make_importer_dir (JSContextRef ctx, gchar * path)
{
gchar *init;
JSObjectRef dir;
@@ -497,7 +495,7 @@ seed_make_importer_dir (JSContextRef ctx, gchar *path)
{
SeedScript *s;
SEED_NOTE (IMPORTER, "Found __init__.js (%s)", path);
-
+
s = seed_script_new_from_file (ctx, init);
seed_evaluate (ctx, s, dir);
seed_script_destroy (s);
@@ -508,7 +506,7 @@ seed_make_importer_dir (JSContextRef ctx, gchar *path)
}
static void
-seed_importer_free_search_path (GSList *path)
+seed_importer_free_search_path (GSList * path)
{
GSList *walk = path;
@@ -523,8 +521,7 @@ seed_importer_free_search_path (GSList *path)
GSList *
-seed_importer_get_search_path (JSContextRef ctx,
- JSValueRef *exception)
+seed_importer_get_search_path (JSContextRef ctx, JSValueRef * exception)
{
GSList *path = NULL;
gchar *entry;
@@ -532,20 +529,24 @@ seed_importer_get_search_path (JSContextRef ctx,
guint length, i;
search_path_ref = seed_object_get_property (ctx, importer, "searchPath");
- if (!JSValueIsObject(ctx, search_path_ref))
+ if (!JSValueIsObject (ctx, search_path_ref))
{
- seed_make_exception (ctx, exception, "ArgumentError", "Importer searchPath object is not an array");
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "Importer searchPath object is not an array");
return NULL;
}
- length_ref = seed_object_get_property (ctx, (JSObjectRef) search_path_ref, "length");
+ length_ref =
+ seed_object_get_property (ctx, (JSObjectRef) search_path_ref, "length");
length = seed_value_to_uint (ctx, length_ref, exception);
for (i = 0; i < length; i++)
{
JSValueRef entry_ref;
- entry_ref = JSObjectGetPropertyAtIndex (ctx, (JSObjectRef) search_path_ref, i, exception);
+ entry_ref =
+ JSObjectGetPropertyAtIndex (ctx, (JSObjectRef) search_path_ref, i,
+ exception);
entry = seed_value_to_string (ctx, entry_ref, exception);
path = g_slist_append (path, entry);
@@ -556,10 +557,9 @@ seed_importer_get_search_path (JSContextRef ctx,
static JSObjectRef
seed_importer_handle_native_module (JSContextRef ctx,
- const gchar *dir,
- const gchar *file,
- JSValueRef *exception)
-
+ const gchar * dir,
+ const gchar * file,
+ JSValueRef * exception)
{
GModule *module;
JSObjectRef module_obj;
@@ -581,13 +581,12 @@ seed_importer_handle_native_module (JSContextRef ctx,
// Could be a better exception
seed_make_exception (ctx, exception, "ModuleError",
"Error loading native module at %s: %s",
- file_path,
- g_module_error());
+ file_path, g_module_error ());
g_free (file_path);
return NULL;
}
- g_module_symbol (module, "seed_module_init", (gpointer *) &init);
+ g_module_symbol (module, "seed_module_init", (gpointer *) & init);
module_obj = (*init) (eng);
g_hash_table_insert (file_imports, file_path, module_obj);
SEED_NOTE (IMPORTER, "Loaded native module");
@@ -598,7 +597,7 @@ seed_importer_handle_native_module (JSContextRef ctx,
}
static gchar *
-seed_importer_canonicalize_path (gchar *path)
+seed_importer_canonicalize_path (gchar * path)
{
GFile *file;
gchar *absolute_path;
@@ -612,9 +611,8 @@ seed_importer_canonicalize_path (gchar *path)
static JSObjectRef
seed_importer_handle_file (JSContextRef ctx,
- const gchar *dir,
- const gchar *file,
- JSValueRef *exception)
+ const gchar * dir,
+ const gchar * file, JSValueRef * exception)
{
JSContextRef nctx;
JSValueRef js_file_dirname;
@@ -623,7 +621,7 @@ seed_importer_handle_file (JSContextRef ctx,
gchar *contents, *walk, *file_path, *canonical, *absolute_path;
gchar *normalized_path;
- file_path = g_build_filename(dir, file, NULL);
+ file_path = g_build_filename (dir, file, NULL);
canonical = seed_importer_canonicalize_path (file_path);
SEED_NOTE (IMPORTER, "Trying to import file: %s", file_path);
@@ -666,20 +664,20 @@ seed_importer_handle_file (JSContextRef ctx,
global = JSContextGetGlobalObject (nctx);
c_global = JSContextGetGlobalObject (ctx);
JSValueProtect (eng->context, global);
-
- absolute_path = g_path_get_dirname(file_path);
- if(!g_path_is_absolute(absolute_path))
+
+ absolute_path = g_path_get_dirname (file_path);
+ if (!g_path_is_absolute (absolute_path))
{
- g_free(absolute_path);
- absolute_path = g_build_filename(g_get_current_dir(),
- g_path_get_dirname(file_path), NULL);
+ g_free (absolute_path);
+ absolute_path = g_build_filename (g_get_current_dir (),
+ g_path_get_dirname (file_path), NULL);
}
- normalized_path = canonicalize_file_name(absolute_path);
+ normalized_path = canonicalize_file_name (absolute_path);
+
+ js_file_dirname = seed_value_from_string (ctx, normalized_path, NULL);
- js_file_dirname = seed_value_from_string(ctx, normalized_path, NULL);
-
- seed_object_set_property(nctx, global, "__script_path__", js_file_dirname);
+ seed_object_set_property (nctx, global, "__script_path__", js_file_dirname);
g_hash_table_insert (file_imports, canonical, global);
g_free (file_path);
@@ -689,7 +687,8 @@ seed_importer_handle_file (JSContextRef ctx,
// Does leak...but it's a debug statement.
SEED_NOTE (IMPORTER, "Evaluated file, exception: %s",
- *exception ? seed_exception_to_string (ctx, *exception) : "(null)");
+ *exception ? seed_exception_to_string (ctx,
+ *exception) : "(null)");
JSGlobalContextRelease ((JSGlobalContextRef) nctx);
@@ -701,9 +700,7 @@ seed_importer_handle_file (JSContextRef ctx,
}
static JSObjectRef
-seed_importer_search (JSContextRef ctx,
- gchar *prop,
- JSValueRef *exception)
+seed_importer_search (JSContextRef ctx, gchar * prop, JSValueRef * exception)
{
GDir *dir;
@@ -711,7 +708,8 @@ seed_importer_search (JSContextRef ctx,
gchar *mentry;
GSList *path, *walk;
JSObjectRef ret;
- gchar *prop_as_lib = g_strconcat ("libseed_", prop, ".", G_MODULE_SUFFIX, NULL);
+ gchar *prop_as_lib =
+ g_strconcat ("libseed_", prop, ".", G_MODULE_SUFFIX, NULL);
gsize i, mentrylen;
path = seed_importer_get_search_path (ctx, exception);
@@ -722,7 +720,7 @@ seed_importer_search (JSContextRef ctx,
e = NULL;
const gchar *entry;
- dir = g_dir_open ((gchar *)walk->data, 0, &e);
+ dir = g_dir_open ((gchar *) walk->data, 0, &e);
if (e)
{
g_error_free (e);
@@ -730,11 +728,11 @@ seed_importer_search (JSContextRef ctx,
walk = walk->next;
continue;
}
- while ((entry = g_dir_read_name(dir)))
+ while ((entry = g_dir_read_name (dir)))
{
mentry = g_strdup (entry);
- mentrylen = strlen(mentry);
+ mentrylen = strlen (mentry);
for (i = 0; i < mentrylen; i++)
{
if (mentry[i] == '.')
@@ -742,7 +740,8 @@ seed_importer_search (JSContextRef ctx,
}
if (!g_strcmp0 (mentry, prop))
{
- ret = seed_importer_handle_file (ctx, walk->data, entry, exception);
+ ret =
+ seed_importer_handle_file (ctx, walk->data, entry, exception);
g_dir_close (dir);
g_free (mentry);
@@ -751,9 +750,11 @@ seed_importer_search (JSContextRef ctx,
return ret;
}
- else if (!g_strcmp0(entry, prop_as_lib))
+ else if (!g_strcmp0 (entry, prop_as_lib))
{
- ret = seed_importer_handle_native_module (ctx, walk->data, entry, exception);
+ ret =
+ seed_importer_handle_native_module (ctx, walk->data, entry,
+ exception);
g_dir_close (dir);
g_free (mentry);
g_free (prop_as_lib);
@@ -777,8 +778,7 @@ seed_importer_search (JSContextRef ctx,
static JSValueRef
seed_importer_get_property (JSContextRef ctx,
JSObjectRef object,
- JSStringRef property_name,
- JSValueRef *exception)
+ JSStringRef property_name, JSValueRef * exception)
{
JSValueRef ret;
guint len;
@@ -792,7 +792,7 @@ seed_importer_get_property (JSContextRef ctx,
return gi_importer;
if (!g_strcmp0 (prop, "searchPath"))
return NULL;
- if (!g_strcmp0 (prop, "toString")) // HACK
+ if (!g_strcmp0 (prop, "toString")) // HACK
return NULL;
ret = seed_importer_search (ctx, prop, exception);
@@ -804,7 +804,7 @@ static JSValueRef
seed_importer_dir_get_property (JSContextRef ctx,
JSObjectRef object,
JSStringRef property_name,
- JSValueRef *exception)
+ JSValueRef * exception)
{
GError *e = NULL;
GDir *dir;
@@ -832,7 +832,7 @@ seed_importer_dir_get_property (JSContextRef ctx,
while ((entry = g_dir_read_name (dir)))
{
mentry = g_strdup (entry);
- mentrylen = strlen(mentry);
+ mentrylen = strlen (mentry);
for (i = 0; i < mentrylen; i++)
{
@@ -864,17 +864,18 @@ seed_importer_dir_finalize (JSObjectRef dir)
}
void
-seed_importer_add_global(JSObjectRef global,
- gchar *name)
+seed_importer_add_global (JSObjectRef global, gchar * name)
{
JSValueProtect (eng->context, global);
- g_hash_table_insert (file_imports, seed_importer_canonicalize_path (name), global);
+ g_hash_table_insert (file_imports, seed_importer_canonicalize_path (name),
+ global);
}
static void
seed_importer_dir_enumerate_properties (JSContextRef ctx,
JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames)
+ JSPropertyNameAccumulatorRef
+ propertyNames)
{
const gchar *entry;
GDir *dir;
@@ -885,7 +886,9 @@ seed_importer_dir_enumerate_properties (JSContextRef ctx,
dir = g_dir_open (path, 0, &e);
if (e)
{
- SEED_NOTE(IMPORTER, "Error in g_dir_open in seed_importer_enumerate_dir_properties: %s", e->message);
+ SEED_NOTE (IMPORTER,
+ "Error in g_dir_open in seed_importer_enumerate_dir_properties: %s",
+ e->message);
g_error_free (e);
// Not much we can do here.
return;
@@ -907,14 +910,14 @@ seed_importer_construct_dir (JSContextRef ctx,
JSObjectRef constructor,
gsize argumentCount,
const JSValueRef arguments[],
- JSValueRef *exception)
+ JSValueRef * exception)
{
gchar *path;
if (argumentCount != 1)
{
seed_make_exception (ctx, exception, "ArgumentError",
"Directory constructor expects 1 argument");
- return (JSObjectRef)JSValueMakeUndefined (ctx);
+ return (JSObjectRef) JSValueMakeUndefined (ctx);
}
path = seed_value_to_string (ctx, arguments[0], exception);
@@ -923,22 +926,24 @@ seed_importer_construct_dir (JSContextRef ctx,
seed_make_exception (ctx, exception, "ArgumentError",
"Path (%s) is not a directory", path);
g_free (path);
- return (JSObjectRef)JSValueMakeUndefined (ctx);
+ return (JSObjectRef) JSValueMakeUndefined (ctx);
}
return seed_make_importer_dir (ctx, path);
}
void
-seed_importer_set_search_path(JSContextRef ctx,
- gchar **search_path)
+seed_importer_set_search_path (JSContextRef ctx, gchar ** search_path)
{
JSObjectRef imports, array;
JSValueRef *array_elem;
guint length = g_strv_length (search_path), i;
array_elem = g_alloca (length * sizeof (array_elem));
- imports = (JSObjectRef) seed_object_get_property (ctx, JSContextGetGlobalObject (ctx), "imports");
+ imports =
+ (JSObjectRef) seed_object_get_property (ctx,
+ JSContextGetGlobalObject (ctx),
+ "imports");
for (i = 0; i < length; i++)
{
@@ -953,19 +958,19 @@ seed_importer_set_search_path(JSContextRef ctx,
JSClassDefinition importer_class_def = {
0, /* Version, always 0 */
0,
- "importer", /* Class Name */
+ "importer", /* Class Name */
NULL, /* Parent Class */
NULL, /* Static Values */
NULL, /* Static Functions */
- NULL, /* Initialize */
+ NULL, /* Initialize */
NULL, /* Finalize */
NULL, /* Has Property */
seed_importer_get_property, /* Get Property */
- NULL, /* Set Property */
+ NULL, /* Set Property */
NULL, /* Delete Property */
NULL, /* Get Property Names */
NULL, /* Call As Function */
- NULL, /* Call As Constructor */
+ NULL, /* Call As Constructor */
NULL, /* Has Instance */
NULL /* Convert To Type */
};
@@ -977,15 +982,15 @@ JSClassDefinition gi_importer_class_def = {
NULL, /* Parent Class */
NULL, /* Static Values */
NULL, /* Static Functions */
- NULL, /* Initialize */
+ NULL, /* Initialize */
NULL, /* Finalize */
NULL, /* Has Property */
- seed_gi_importer_get_property,/* Get Property */
+ seed_gi_importer_get_property, /* Get Property */
NULL, /* Set Property */
NULL, /* Delete Property */
NULL, /* Get Property Names */
NULL, /* Call As Function */
- NULL, /* Call As Constructor */
+ NULL, /* Call As Constructor */
NULL, /* Has Instance */
NULL /* Convert To Type */
};
@@ -997,21 +1002,21 @@ JSClassDefinition importer_dir_class_def = {
NULL, /* Parent Class */
NULL, /* Static Values */
NULL, /* Static Functions */
- NULL, /* Initialize */
+ NULL, /* Initialize */
seed_importer_dir_finalize, /* Finalize */
NULL, /* Has Property */
seed_importer_dir_get_property, /* Get Property */
NULL, /* Set Property */
NULL, /* Delete Property */
- seed_importer_dir_enumerate_properties, /* Get Property Names */
+ seed_importer_dir_enumerate_properties, /* Get Property Names */
NULL, /* Call As Function */
- NULL, /* Call As Constructor */
+ NULL, /* Call As Constructor */
NULL, /* Has Instance */
NULL /* Convert To Type */
};
-void seed_initialize_importer(JSContextRef ctx,
- JSObjectRef global)
+void
+seed_initialize_importer (JSContextRef ctx, JSObjectRef global)
{
JSObjectRef dir_constructor;
@@ -1032,9 +1037,9 @@ void seed_initialize_importer(JSContextRef ctx,
/* Passing nonnull for class requires a webkit fix that most people wont have yet. It also has minimal benefit */
// dir_constructor = JSObjectMakeConstructor (ctx, importer_dir_class, seed_importer_construct_dir);
- dir_constructor = JSObjectMakeConstructor (ctx, NULL, seed_importer_construct_dir);
+ dir_constructor =
+ JSObjectMakeConstructor (ctx, NULL, seed_importer_construct_dir);
seed_object_set_property (ctx, importer, "Directory", dir_constructor);
seed_object_set_property (ctx, global, "imports", importer);
}
-
diff --git a/libseed/seed-signals.c b/libseed/seed-signals.c
index 1fbe5a5..360cb92 100644
--- a/libseed/seed-signals.c
+++ b/libseed/seed-signals.c
@@ -40,8 +40,7 @@ seed_gobject_signal_connect (JSContextRef ctx,
const gchar * signal_name,
GObject * on_obj,
JSObjectRef func,
- JSObjectRef this_obj,
- JSObjectRef user_data)
+ JSObjectRef this_obj, JSObjectRef user_data)
{
GSignalQuery query;
GClosure *closure;
@@ -50,15 +49,18 @@ seed_gobject_signal_connect (JSContextRef ctx,
&query);
#ifdef SEED_ENABLE_DEBUG
{
- guint function_arity =
- seed_value_to_uint (ctx,
- seed_object_get_property(ctx, func, "length"),
- NULL);
+ guint function_arity = seed_value_to_uint (ctx,
+ seed_object_get_property (ctx,
+ func,
+ "length"),
+ NULL);
if (function_arity != query.n_params)
{
- SEED_MARK();
- SEED_NOTE(SIGNAL, "Connecting signal: %s. Function has arity %d, signal expects %d", query.signal_name, function_arity, query.n_params);
- SEED_MARK();
+ SEED_MARK ();
+ SEED_NOTE (SIGNAL,
+ "Connecting signal: %s. Function has arity %d, signal expects %d",
+ query.signal_name, function_arity, query.n_params);
+ SEED_MARK ();
}
}
#endif
@@ -87,8 +89,7 @@ seed_gobject_signal_connect_by_name (JSContextRef ctx,
{
seed_make_exception (ctx, exception, "ArgumentError",
"Signal connection expected"
- " 2 or 3 arguments. Got " "%zd",
- argumentCount);
+ " 2 or 3 arguments. Got " "%zd", argumentCount);
return JSValueMakeNull (ctx);
}
@@ -99,8 +100,7 @@ seed_gobject_signal_connect_by_name (JSContextRef ctx,
{
seed_make_exception (ctx, exception, "ArgumentError",
"Signal connection by name "
- "requires a function"
- " as second argument");
+ "requires a function" " as second argument");
return JSValueMakeNull (ctx);
}
@@ -114,7 +114,8 @@ seed_gobject_signal_connect_by_name (JSContextRef ctx,
obj_type = G_OBJECT_TYPE (obj);
id = seed_gobject_signal_connect (ctx, signal_name, obj,
- (JSObjectRef) arguments[1], NULL, user_data);
+ (JSObjectRef) arguments[1], NULL,
+ user_data);
g_free (signal_name);
@@ -142,8 +143,7 @@ seed_signal_marshal_func (GClosure * closure,
GValue * return_value,
guint n_param_values,
const GValue * param_values,
- gpointer invocation_hint,
- gpointer marshall_data)
+ gpointer invocation_hint, gpointer marshall_data)
{
SeedClosure *seed_closure = (SeedClosure *) closure;
JSValueRef *args, exception = 0;
@@ -175,8 +175,7 @@ seed_signal_marshal_func (GClosure * closure,
args[i] = JSValueMakeNull (ctx);
ret = JSObjectCallAsFunction (ctx, seed_closure->function,
- NULL,
- n_param_values + 1, args, &exception);
+ NULL, n_param_values + 1, args, &exception);
if (exception)
{
@@ -232,8 +231,7 @@ seed_gobject_signal_emit (JSContextRef ctx,
"arguments, got %zd",
query.signal_name,
g_type_name (query.itype),
- query.n_params,
- argumentCount);
+ query.n_params, argumentCount);
return JSValueMakeNull (ctx);
}
@@ -283,7 +281,7 @@ seed_gobject_signal_disconnect (JSContextRef ctx,
id = seed_value_to_ulong (ctx, arguments[0], exception);
g_signal_handler_disconnect (JSObjectGetPrivate (thisObject), id);
- return JSValueMakeUndefined(ctx);
+ return JSValueMakeUndefined (ctx);
}
static JSValueRef
@@ -310,8 +308,7 @@ seed_gobject_signal_connect_on_property (JSContextRef ctx,
{
seed_make_exception (ctx, exception, "ArgumentError",
"Signal connection expected"
- " 1, or 2 arguments. Got "
- "%zd", argumentCount);
+ " 1, or 2 arguments. Got " "%zd", argumentCount);
return JSValueMakeNull (ctx);
}
@@ -327,12 +324,13 @@ seed_gobject_signal_connect_on_property (JSContextRef ctx,
}
if (argumentCount == 1)
- {
- id = seed_gobject_signal_connect (ctx, privates->signal_name,
- privates->object,
- (JSObjectRef) arguments[0], this_obj, NULL);
+ {
+ id = seed_gobject_signal_connect (ctx, privates->signal_name,
+ privates->object,
+ (JSObjectRef) arguments[0], this_obj,
+ NULL);
- }
+ }
else if (argumentCount == 2)
{
id = seed_gobject_signal_connect (ctx, privates->signal_name,
@@ -345,14 +343,18 @@ seed_gobject_signal_connect_on_property (JSContextRef ctx,
}
JSStaticFunction signal_static_functions[] = {
- {"connect", seed_gobject_signal_connect_on_property, 0},
- {"emit", seed_gobject_signal_emit, 0},
+ {"connect", seed_gobject_signal_connect_on_property, 0}
+ ,
+ {"emit", seed_gobject_signal_emit, 0}
+ ,
{0, 0, 0}
};
-JSStaticFunction signal_holder_static_functions [] = {
- {"connect", seed_gobject_signal_connect_by_name, 0},
- {"disconnect", seed_gobject_signal_disconnect, 0},
+JSStaticFunction signal_holder_static_functions[] = {
+ {"connect", seed_gobject_signal_connect_by_name, 0}
+ ,
+ {"disconnect", seed_gobject_signal_disconnect, 0}
+ ,
{0, 0, 0}
};
@@ -380,7 +382,7 @@ static JSValueRef
seed_signal_holder_get_property (JSContextRef ctx,
JSObjectRef object,
JSStringRef property_name,
- JSValueRef *exception)
+ JSValueRef * exception)
{
GObject *gobj = JSObjectGetPrivate (object);
signal_privates *priv;
@@ -390,7 +392,9 @@ seed_signal_holder_get_property (JSContextRef ctx,
JSStringGetUTF8CString (property_name, signal_name, length);
- if (!(g_strcmp0 (signal_name, "connect") && g_strcmp0 (signal_name, "disconnect")) )
+ if (!
+ (g_strcmp0 (signal_name, "connect")
+ && g_strcmp0 (signal_name, "disconnect")))
{
g_free (signal_name);
return NULL;
@@ -425,4 +429,3 @@ seed_get_signal_class (void)
return &gobject_signal_def;
}
-
diff --git a/libseed/seed-structs.c b/libseed/seed-structs.c
index 83d67f7..b6a132e 100644
--- a/libseed/seed-structs.c
+++ b/libseed/seed-structs.c
@@ -102,7 +102,7 @@ seed_union_find_field (GIUnionInfo * info, gchar * field_name)
}
GIFieldInfo *
-seed_struct_find_field (GIStructInfo *info, gchar *field_name)
+seed_struct_find_field (GIStructInfo * info, gchar * field_name)
{
gint n, i;
const gchar *name;
@@ -239,7 +239,8 @@ seed_union_set_property (JSContextRef context,
field_type = g_field_info_get_type (field);
- seed_gi_make_argument (context, value, field_type, NULL, &field_value, exception);
+ seed_gi_make_argument (context, value, field_type, NULL, &field_value,
+ exception);
ret = g_field_info_set_field (field, priv->pointer, &field_value);
g_base_info_unref ((GIBaseInfo *) field_type);
@@ -281,7 +282,8 @@ seed_struct_set_property (JSContextRef context,
field_type = g_field_info_get_type (field);
- seed_gi_make_argument (context, value, field_type, NULL, &field_value, exception);
+ seed_gi_make_argument (context, value, field_type, NULL, &field_value,
+ exception);
ret = g_field_info_set_field (field, priv->pointer, &field_value);
g_base_info_unref ((GIBaseInfo *) field_type);
@@ -624,8 +626,8 @@ seed_struct_prototype (JSContextRef ctx, GIBaseInfo * info)
JSObjectRef
seed_make_struct (JSContextRef ctx, gpointer strukt, GIBaseInfo * info)
{
- JSObjectRef object, proto;
- seed_struct_privates *priv = g_slice_alloc (sizeof (seed_struct_privates));
+ JSObjectRef object, proto;
+ seed_struct_privates *priv = g_slice_alloc (sizeof (seed_struct_privates));
priv->info = info ? g_base_info_ref (info) : 0;
priv->pointer = strukt;
@@ -634,10 +636,10 @@ seed_make_struct (JSContextRef ctx, gpointer strukt, GIBaseInfo * info)
object = JSObjectMake (ctx, seed_struct_class, priv);
// Examine cases where struct is being used without info.
if (info)
- {
+ {
proto = seed_struct_prototype (ctx, info);
if (proto)
- JSObjectSetPrototype (ctx, object, proto);
+ JSObjectSetPrototype (ctx, object, proto);
else
g_assert_not_reached ();
}
@@ -749,4 +751,3 @@ seed_construct_struct_type_with_parameters (JSContextRef ctx,
return ret;
}
-
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 285f57d..b2953aa 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -75,7 +75,7 @@ seed_make_wrapper_for_type (JSContextRef ctx, GType type)
if (prototype)
JSObjectSetPrototype (ctx, ret, prototype);
else
- g_assert_not_reached();
+ g_assert_not_reached ();
return ret;
}
@@ -102,7 +102,7 @@ seed_wrap_object (JSContextRef ctx, GObject * object)
JSObjectSetPrivate (js_ref, object);
g_object_set_qdata_full (object, js_ref_quark, (gpointer) js_ref,
- seed_gobject_destroyed);
+ seed_gobject_destroyed);
JSValueProtect (eng->context, js_ref);
g_object_add_toggle_ref (object, seed_toggle_ref, (gpointer) js_ref);
@@ -218,8 +218,7 @@ seed_gi_release_arg (GITransfer transfer,
gboolean
seed_gi_release_in_arg (GITransfer transfer,
- GITypeInfo * type_info,
- GArgument * arg)
+ GITypeInfo * type_info, GArgument * arg)
{
GITypeTag type_tag;
@@ -256,7 +255,7 @@ seed_gi_make_jsarray (JSContextRef ctx,
GITypeTag element_type;
JSValueRef *elements;
guint length, i;
- gchar **str_array = (gchar**) array;
+ gchar **str_array = (gchar **) array;
JSValueRef ret = JSValueMakeNull (ctx);
element_type = g_type_info_get_tag (param_type);
@@ -297,14 +296,13 @@ seed_gi_make_array (JSContextRef ctx,
{
case GI_TYPE_TAG_UTF8:
{
- gchar** strresult = g_new0 (gchar *, length + 1);
+ gchar **strresult = g_new0 (gchar *, length + 1);
for (i = 0; i < length; i++)
{
- elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ elem = JSObjectGetPropertyAtIndex (ctx,
+ (JSObjectRef) array,
+ i, exception);
strresult[i] = seed_value_to_string (ctx, elem, exception);
}
@@ -320,9 +318,8 @@ seed_gi_make_array (JSContextRef ctx,
for (i = 0; i < length; i++)
{
elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ (JSObjectRef) array,
+ i, exception);
typeresult[i] = seed_value_to_int (ctx, elem, exception);
}
@@ -338,9 +335,8 @@ seed_gi_make_array (JSContextRef ctx,
for (i = 0; i < length; i++)
{
elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ (JSObjectRef) array,
+ i, exception);
floatresult[i] = seed_value_to_float (ctx, elem, exception);
}
@@ -356,9 +352,8 @@ seed_gi_make_array (JSContextRef ctx,
for (i = 0; i < length; i++)
{
elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ (JSObjectRef) array,
+ i, exception);
dblresult[i] = seed_value_to_double (ctx, elem, exception);
}
@@ -374,9 +369,8 @@ seed_gi_make_array (JSContextRef ctx,
for (i = 0; i < length; i++)
{
elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ (JSObjectRef) array,
+ i, exception);
intresult[i] = seed_value_to_int (ctx, elem, exception);
}
@@ -392,9 +386,8 @@ seed_gi_make_array (JSContextRef ctx,
for (i = 0; i < length; i++)
{
elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ (JSObjectRef) array,
+ i, exception);
guint8result[i] = seed_value_to_uchar (ctx, elem, exception);
}
@@ -422,10 +415,9 @@ seed_gi_make_array (JSContextRef ctx,
for (i = 0; i < length; i++)
{
- elem = JSObjectGetPropertyAtIndex (ctx,
- (JSObjectRef) array,
- i,
- exception);
+ elem = JSObjectGetPropertyAtIndex (ctx,
+ (JSObjectRef) array,
+ i, exception);
seed_gvalue_from_seed_value (ctx, elem,
(GType) 0,
&gvalresult[i], exception);
@@ -452,9 +444,8 @@ gboolean
seed_gi_make_argument (JSContextRef ctx,
JSValueRef value,
GITypeInfo * type_info,
- GIArgInfo *arg_info,
- GArgument * arg,
- JSValueRef * exception)
+ GIArgInfo * arg_info,
+ GArgument * arg, JSValueRef * exception)
{
GITypeTag gi_tag = g_type_info_get_tag (type_info);
@@ -566,7 +557,9 @@ seed_gi_make_argument (JSContextRef ctx,
interface_type == GI_INFO_TYPE_FLAGS)
{
arg->v_long = seed_value_to_long (ctx, value, exception);
- if (!(interface_type == GI_INFO_TYPE_FLAGS) && !seed_validate_enum ((GIEnumInfo *)interface, arg->v_long))
+ if (!(interface_type == GI_INFO_TYPE_FLAGS)
+ && !seed_validate_enum ((GIEnumInfo *) interface,
+ arg->v_long))
{
seed_make_exception (ctx, exception, "EnumRange",
"Enum value: %ld is out of range",
@@ -612,7 +605,8 @@ seed_gi_make_argument (JSContextRef ctx,
if (JSObjectIsFunction (ctx, (JSObjectRef) value))
{
arg->v_pointer =
- seed_closure_new (ctx, (JSObjectRef) value, NULL, NULL);
+ seed_closure_new (ctx, (JSObjectRef) value, NULL,
+ NULL);
}
}
else
@@ -872,7 +866,7 @@ seed_gi_argument_make_js (JSContextRef ctx,
{
GITypeInfo *list_type;
JSObjectRef ret;
- JSValueRef ival;
+ JSValueRef ival;
GArgument larg;
guint i = 0;
GSList *list = arg->v_pointer;
@@ -1082,12 +1076,11 @@ seed_gvalue_from_seed_value (JSContextRef ctx,
if (type == 0 && JSValueIsObject (ctx, val))
{
// TODO: FIXME: Better array test like the cool one on reddit.
- guint length =
- seed_value_to_int (ctx,
- seed_object_get_property (ctx,
- (JSObjectRef) val,
- "length"),
- exception);
+ guint length = seed_value_to_int (ctx,
+ seed_object_get_property (ctx,
+ (JSObjectRef) val,
+ "length"),
+ exception);
if (length)
{
@@ -1251,7 +1244,8 @@ seed_object_set_property (JSContextRef ctx, JSObjectRef object,
if (value)
{
- JSObjectSetProperty (ctx, (JSObjectRef) object, jname, value, 0, &exception);
+ JSObjectSetProperty (ctx, (JSObjectRef) object, jname, value, 0,
+ &exception);
}
JSStringRelease (jname);
@@ -1584,7 +1578,8 @@ seed_value_from_short (JSContextRef ctx, gshort val, JSValueRef * exception)
*
*/
gushort
-seed_value_to_ushort (JSContextRef ctx, JSValueRef val, JSValueRef * exception)
+seed_value_to_ushort (JSContextRef ctx, JSValueRef val,
+ JSValueRef * exception)
{
if (!JSValueIsNumber (ctx, val) && !JSValueIsBoolean (ctx, val))
{
@@ -2012,13 +2007,12 @@ seed_value_from_string (JSContextRef ctx,
*/
JSValueRef
seed_value_from_binary_string (JSContextRef ctx,
- const gchar *bytes,
- gint n_bytes,
- JSValueRef *exception)
+ const gchar * bytes,
+ gint n_bytes, JSValueRef * exception)
{
JSValueRef ret;
- gchar *nstr = g_alloca ((n_bytes +1)*sizeof(gchar));
+ gchar *nstr = g_alloca ((n_bytes + 1) * sizeof (gchar));
g_strlcpy (nstr, bytes, n_bytes);
nstr[n_bytes] = '\0';
@@ -2137,7 +2131,7 @@ seed_value_to_object (JSContextRef ctx,
}
gobject = (GObject *) JSObjectGetPrivate ((JSObjectRef) val);
- g_assert(G_IS_OBJECT(gobject));
+ g_assert (G_IS_OBJECT (gobject));
return gobject;
}
@@ -2166,8 +2160,7 @@ seed_value_from_object (JSContextRef ctx,
}
gboolean
-seed_validate_enum (GIEnumInfo *info,
- long val)
+seed_validate_enum (GIEnumInfo * info, long val)
{
gint n, i;
GIValueInfo *value_info;
@@ -2179,7 +2172,7 @@ seed_validate_enum (GIEnumInfo *info,
value_info = g_enum_info_get_value (info, i);
value = g_value_info_get_value (value_info);
- g_base_info_unref ((GIBaseInfo *)value_info);
+ g_base_info_unref ((GIBaseInfo *) value_info);
if (value == val)
return TRUE;
}
@@ -2188,24 +2181,21 @@ seed_validate_enum (GIEnumInfo *info,
}
JSValueRef
-seed_value_from_time_t (JSContextRef ctx,
- time_t time,
- JSValueRef *exception)
+seed_value_from_time_t (JSContextRef ctx, time_t time, JSValueRef * exception)
{
JSValueRef args[1];
- args[0] = seed_value_from_double (ctx, ((gdouble)time)*1000, exception);
- return JSObjectMakeDate(ctx, 1, args, exception);
+ args[0] = seed_value_from_double (ctx, ((gdouble) time) * 1000, exception);
+ return JSObjectMakeDate (ctx, 1, args, exception);
}
time_t
seed_value_to_time_t (JSContextRef ctx,
- JSValueRef value,
- JSValueRef *exception)
+ JSValueRef value, JSValueRef * exception)
{
- JSValueRef get_time_method;
- JSValueRef jstime;
- gdouble time;
+ JSValueRef get_time_method;
+ JSValueRef jstime;
+ gdouble time;
if (JSValueIsNumber (ctx, value))
@@ -2214,26 +2204,24 @@ seed_value_to_time_t (JSContextRef ctx,
}
else if (JSValueIsObject (ctx, value))
{
- get_time_method = seed_object_get_property (ctx, (JSObjectRef)value,
+ get_time_method = seed_object_get_property (ctx, (JSObjectRef) value,
"getTime");
- if (JSValueIsNull(ctx, get_time_method) ||
- !JSValueIsObject(ctx, get_time_method))
+ if (JSValueIsNull (ctx, get_time_method) ||
+ !JSValueIsObject (ctx, get_time_method))
{
goto out;
}
jstime = JSObjectCallAsFunction (ctx,
- (JSObjectRef)get_time_method,
- (JSObjectRef)value,
- 0, NULL,
- exception);
+ (JSObjectRef) get_time_method,
+ (JSObjectRef) value,
+ 0, NULL, exception);
time = seed_value_to_double (ctx, jstime, exception);
- return (unsigned long)(time/1000);
+ return (unsigned long) (time / 1000);
}
- out:
+out:
seed_make_exception (ctx, exception,
"TypeError",
"Unable to convert JavaScript value to time_t");
return 0;
}
-
diff --git a/libseed/seed-types.h b/libseed/seed-types.h
index d3d0bb7..b44ff2e 100644
--- a/libseed/seed-types.h
+++ b/libseed/seed-types.h
@@ -41,7 +41,7 @@ gboolean seed_gvalue_from_seed_value (JSContextRef ctx,
gboolean seed_gi_make_argument (JSContextRef ctx,
JSValueRef value,
GITypeInfo * type_info,
- GIArgInfo *arg_info,
+ GIArgInfo * arg_info,
GArgument * arg, JSValueRef * exception);
JSValueRef seed_gi_argument_make_js (JSContextRef ctx,
GArgument * arg,
@@ -125,12 +125,10 @@ JSValueRef seed_value_from_string (JSContextRef ctx,
const gchar * val, JSValueRef * exception);
time_t seed_value_to_time_t (JSContextRef ctx,
- JSValueRef val,
- JSValueRef *exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_time_t (JSContextRef ctx,
- time_t time,
- JSValueRef *exception);
+ time_t time, JSValueRef * exception);
GObject *seed_value_to_object (JSContextRef ctx,
JSValueRef val, JSValueRef * exception);
@@ -139,13 +137,12 @@ JSValueRef seed_value_from_object (JSContextRef ctx,
void seed_toggle_ref (gpointer data, GObject * object, gboolean is_last_ref);
-gboolean seed_validate_enum (GIEnumInfo *info, long val);
+gboolean seed_validate_enum (GIEnumInfo * info, long val);
JSValueRef
seed_value_from_binary_string (JSContextRef ctx,
- const gchar *bytes,
- gint n_bytes,
- JSValueRef *exception);
+ const gchar * bytes,
+ gint n_bytes, JSValueRef * exception);
JSObjectRef seed_make_wrapper_for_type (JSContextRef ctx, GType type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]