[seed] [libseed] More minor GLib usage and redefinition fixes.
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] [libseed] More minor GLib usage and redefinition fixes.
- Date: Sat, 11 Jul 2009 05:56:28 +0000 (UTC)
commit 78ca796573ea93c37a049ea9b9c815d79de9b0d8
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date: Sat Jul 11 01:41:47 2009 -0400
[libseed] More minor GLib usage and redefinition fixes.
libseed/seed-api.c | 12 ++--
libseed/seed-builtins.c | 59 +++++++++-------------
libseed/seed-closure.c | 16 +++---
libseed/seed-engine.c | 9 ++--
libseed/seed-exceptions.c | 9 ++--
libseed/seed-gtype.c | 66 +++++++++++-------------
libseed/seed-structs.c | 9 ++--
libseed/seed-types.c | 123 +++++++++++++++++++++------------------------
8 files changed, 141 insertions(+), 162 deletions(-)
---
diff --git a/libseed/seed-api.c b/libseed/seed-api.c
index 336314d..37e0723 100644
--- a/libseed/seed-api.c
+++ b/libseed/seed-api.c
@@ -713,20 +713,20 @@ seed_object_copy_property_names(JSContextRef ctx,
JSObjectRef object)
{
JSPropertyNameArrayRef names;
+ JSStringRef name;
guint i, length;
+ gsize max_length;
+ gchar *c_name;
gchar **ret;
names = JSObjectCopyPropertyNames (ctx, object);
length = JSPropertyNameArrayGetCount (names);
- ret = g_malloc((length+1)*sizeof(gchar *));
+ ret = (gchar**) g_malloc((length+1)*sizeof(gchar *));
for (i = 0; i < length; i++)
{
- JSStringRef name = JSPropertyNameArrayGetNameAtIndex (names, i);
- guint max_length;
- gchar *c_name;
-
+ name = JSPropertyNameArrayGetNameAtIndex (names, i);
max_length = JSStringGetMaximumUTF8CStringSize (name);
- c_name = g_malloc (max_length * sizeof (gchar));
+ c_name = (gchar*) g_malloc (max_length * sizeof (gchar));
JSStringGetUTF8CString (name, c_name, length);
ret[i] = c_name;
diff --git a/libseed/seed-builtins.c b/libseed/seed-builtins.c
index d679472..f9eed75 100644
--- a/libseed/seed-builtins.c
+++ b/libseed/seed-builtins.c
@@ -33,12 +33,9 @@ seed_include (JSContextRef ctx,
JSStringRef file_contents, file_name;
GDir *dir;
-
gchar *import_file, *abs_path;
-
gchar *buffer, *walk;
-
- guint i;
+ guint i, len;
if (argumentCount != 1)
{
@@ -55,7 +52,8 @@ 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. */
{
- for (i = 0; i < g_strv_length (eng->search_path); ++i)
+ len = g_strv_length(eng->search_path);
+ for (i = 0; i < len; ++i)
{
dir = g_dir_open (eng->search_path[i], 0, NULL);
@@ -68,6 +66,7 @@ seed_include (JSContextRef ctx,
if (g_file_get_contents (abs_path, &buffer, 0, NULL))
{
g_free (abs_path);
+ g_dir_close (dir);
break;
}
@@ -119,17 +118,11 @@ seed_scoped_include (JSContextRef ctx,
const JSValueRef arguments[], JSValueRef * exception)
{
JSContextRef nctx;
-
JSObjectRef global;
-
JSStringRef file_contents, file_name;
-
GDir *dir;
-
gchar *import_file, *abs_path;
-
gchar *buffer, *walk;
-
guint i;
if (argumentCount != 1)
@@ -218,6 +211,7 @@ seed_print (JSContextRef ctx,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef * exception)
{
+ gchar *buf;
if (argumentCount != 1)
{
seed_make_exception (ctx, exception, "ArgumentError",
@@ -226,7 +220,7 @@ seed_print (JSContextRef ctx,
return JSValueMakeNull (ctx);
}
- gchar *buf = seed_value_to_string (ctx, arguments[0], exception);
+ buf = seed_value_to_string (ctx, arguments[0], exception);
puts (buf);
g_free (buf);
@@ -240,10 +234,11 @@ seed_g_type_name_to_string (GITypeInfo * type)
GITypeTag type_tag = g_type_info_get_tag (type);
const gchar *type_name;
+ GIBaseInfo *interface;
if (type_tag == GI_TYPE_TAG_INTERFACE)
{
- GIBaseInfo *interface = g_type_info_get_interface (type);
+ interface = g_type_info_get_interface (type);
type_name = g_base_info_get_name (interface);
g_base_info_unref (interface);
@@ -266,10 +261,8 @@ seed_introspect (JSContextRef ctx,
// TODO: LEAKY!
GICallableInfo *info;
-
- JSObjectRef data_obj, args_obj;
-
- guint i;
+ JSObjectRef data_obj, args_obj, argument;
+ guint i, nargs;
if (argumentCount != 1)
{
@@ -302,9 +295,10 @@ seed_introspect (JSContextRef ctx,
seed_object_set_property (ctx, data_obj, "args", args_obj);
- for (i = 0; i < g_callable_info_get_n_args (info); ++i)
+ nargs = g_callable_info_get_n_args (info);
+ for (i = 0; i < nargs; ++i)
{
- JSObjectRef 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
@@ -327,9 +321,10 @@ seed_check_syntax (JSContextRef ctx,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef * exception)
{
+ JSStringRef jsstr;
if (argumentCount == 1)
{
- JSStringRef jsstr = JSValueToStringCopy (ctx,
+ jsstr = JSValueToStringCopy (ctx,
arguments[0],
exception);
@@ -353,10 +348,8 @@ seed_spawn (JSContextRef ctx,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef * exception)
{
- gchar *line, *stdout, *stderr;
-
+ gchar *line, *stdoutstr, *stderrstr;
JSObjectRef ret;
-
GError *error = NULL;
if (argumentCount != 1)
@@ -368,7 +361,7 @@ seed_spawn (JSContextRef ctx,
}
line = seed_value_to_string (ctx, arguments[0], exception);
- g_spawn_command_line_sync (line, &stdout, &stderr, NULL, &error);
+ g_spawn_command_line_sync (line, &stdoutstr, &stderrstr, NULL, &error);
if (error)
{
seed_make_exception_from_gerror (ctx, exception, error);
@@ -380,13 +373,13 @@ seed_spawn (JSContextRef ctx,
ret = JSObjectMake (ctx, NULL, NULL);
seed_object_set_property (ctx, ret, "stdout",
- seed_value_from_string (ctx, stdout, exception));
+ seed_value_from_string (ctx, stdoutstr, exception));
seed_object_set_property (ctx, ret, "stderr",
- seed_value_from_string (ctx, stderr, exception));
+ seed_value_from_string (ctx, stderrstr, exception));
g_free (line);
- g_free (stdout);
- g_free (stderr);
+ g_free (stdoutstr);
+ g_free (stderrstr);
return ret;
}
@@ -430,12 +423,9 @@ seed_argv_get_property (JSContextRef ctx,
JSStringRef property_name, JSValueRef * exception)
{
SeedArgvPrivates *priv;
-
gchar *cproperty_name;
-
- gint length;
-
- gint index;
+ gsize length;
+ guint index;
priv = JSObjectGetPrivate (object);
if (!priv->argc)
@@ -478,9 +468,7 @@ void
seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv)
{
SeedArgvPrivates *priv;
-
JSObjectRef arrayObj;
-
JSObjectRef obj =
(JSObjectRef) seed_object_get_property (local_eng->context,
local_eng->global,
@@ -516,3 +504,4 @@ 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-closure.c b/libseed/seed-closure.c
index 66313b0..159e283 100644
--- a/libseed/seed-closure.c
+++ b/libseed/seed-closure.c
@@ -45,14 +45,16 @@ seed_handle_closure (ffi_cif * cif, void *result, void **args, void *userdata)
SeedNativeClosure *privates = userdata;
gint num_args, i;
JSValueRef *jsargs;
- JSValueRef return_value;
- JSValueRef exception = 0;
+ JSValueRef return_value, exception = 0;
GITypeTag return_tag;
GIArgInfo *arg_info;
GITypeInfo *return_type;
- GArgument rarg;
- GArgument return_arg;
+ GITypeInfo *arg_type;
+ GITypeTag tag;
+ GArgument rarg, return_arg;
JSContextRef ctx = JSGlobalContextCreateInGroup (context_group, 0);
+ GArgument *arg = &rarg;
+ gchar *mes;
seed_prepare_global_context (ctx);
@@ -66,9 +68,6 @@ seed_handle_closure (ffi_cif * cif, void *result, void **args, void *userdata)
for (i = 0; i < num_args; i++)
{
- GITypeInfo *arg_type;
- GITypeTag tag;
- GArgument *arg = &rarg;
arg_info = g_callable_info_get_arg (privates->info, i);
arg_type = g_arg_info_get_type (arg_info);
@@ -175,7 +174,7 @@ seed_handle_closure (ffi_cif * cif, void *result, void **args, void *userdata)
if (exception)
{
- gchar *mes = seed_exception_to_string (ctx,
+ mes = seed_exception_to_string (ctx,
exception);
g_warning ("Exception in closure marshal. %s \n", mes);
g_free (mes);
@@ -444,3 +443,4 @@ seed_closures_init (void)
seed_native_callback_class = JSClassCreate (&seed_native_callback_def);
JSClassRetain (seed_native_callback_class);
}
+
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 04b8ca4..7ff7013 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -1142,7 +1142,7 @@ seed_repl_expose (JSContextRef ctx, ...)
va_list argp;
void *expose;
JSObjectRef arrayObj;
- int i = 0;
+ guint i = 0;
JSStringRef script;
JSObjectRef seed = (JSObjectRef) seed_object_get_property (ctx,
JSContextGetGlobalObject
@@ -1156,7 +1156,7 @@ seed_repl_expose (JSContextRef ctx, ...)
while ((expose = va_arg (argp, void *)))
{
- g_print (" Seed.debug_argv[%d] = %p\n", i, expose);
+ g_print (" Seed.debug_argv[%u] = %p\n", i, expose);
JSObjectSetPropertyAtIndex (ctx, arrayObj, i++, expose, NULL);
}
@@ -1234,6 +1234,7 @@ seed_parse_args (int *argc, char ***argv)
{
GOptionContext *option_context;
GOptionGroup *seed_group;
+
GError *error = NULL;
gboolean ret = TRUE;
@@ -1268,7 +1269,7 @@ seed_parse_args (int *argc, char ***argv)
* @argv: A reference to an array of string arguments remaining to parse.
*
* Initializes a new #SeedEngine. This involves initializing GLib, creating
- * an initial context with all of the default globals, and initializing
+ * an initial context with all of the default globals, and initializing
* various internal parts of Seed.
*
* This function should only be called once within a single Seed application.
@@ -1286,7 +1287,7 @@ seed_init (gint * argc, gchar *** argv)
if ((argc != 0) && seed_parse_args (argc, argv) == FALSE)
{
SEED_NOTE (MISC, "failed to parse arguments.");
- return false;
+ return FALSE;
}
qname = g_quark_from_static_string ("js-type");
diff --git a/libseed/seed-exceptions.c b/libseed/seed-exceptions.c
index 7a0c4ad..182d180 100644
--- a/libseed/seed-exceptions.c
+++ b/libseed/seed-exceptions.c
@@ -129,10 +129,10 @@ seed_exception_get_name (JSContextRef ctx, JSValueRef e)
JSValueRef name;
g_assert ((e));
if (!JSValueIsObject (ctx, e))
- return 0;
+ return NULL;
name = seed_object_get_property (ctx, (JSObjectRef) e, "name");
- return seed_value_to_string (ctx, name, 0);
+ return seed_value_to_string (ctx, name, NULL);
}
/**
@@ -157,7 +157,7 @@ seed_exception_get_message (JSContextRef ctx, JSValueRef e)
return 0;
name = seed_object_get_property (ctx, (JSObjectRef) e, "message");
- return seed_value_to_string (ctx, name, 0);
+ return seed_value_to_string (ctx, name, NULL);
}
/**
@@ -180,7 +180,7 @@ seed_exception_get_line (JSContextRef ctx, JSValueRef e)
if (!JSValueIsObject (ctx, e))
return 0;
line = seed_object_get_property (ctx, (JSObjectRef) e, "line");
- return seed_value_to_uint (ctx, line, 0);
+ return seed_value_to_uint (ctx, line, NULL);
}
/**
@@ -238,3 +238,4 @@ seed_exception_to_string (JSContextRef ctx, JSValueRef e)
return ret;
}
+
diff --git a/libseed/seed-gtype.c b/libseed/seed-gtype.c
index 6cb37e6..4a20a73 100644
--- a/libseed/seed-gtype.c
+++ b/libseed/seed-gtype.c
@@ -41,13 +41,13 @@ static JSValueRef
seed_property_method_invoked (JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
- size_t argumentCount,
+ gsize argumentCount,
const JSValueRef arguments[],
JSValueRef * exception)
{
GParamSpec *spec;
GObjectClass *class;
- int property_count;
+ guint property_count;
JSValueRef newcount, oldcount;
if (argumentCount != 1)
@@ -87,7 +87,7 @@ static JSValueRef
seed_gsignal_method_invoked (JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
- size_t argumentCount,
+ gsize argumentCount,
const JSValueRef arguments[],
JSValueRef * exception)
{
@@ -166,11 +166,12 @@ seed_gsignal_method_invoked (JSContextRef ctx,
if (n_params > 0)
{
guint i;
+ JSValueRef ptype;
param_types = g_new0 (GType, n_params);
for (i = 0; i < n_params; i++)
{
- JSValueRef ptype = JSObjectGetPropertyAtIndex (ctx,
+ ptype = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef)
jsparams,
i,
@@ -301,6 +302,7 @@ seed_gtype_construct (GType type,
GObject *object;
GType parent;
GObjectClass *parent_class;
+ gchar *mes;
parent = g_type_parent (type);
parent_class = g_type_class_ref (parent);
@@ -323,7 +325,7 @@ seed_gtype_construct (GType type,
JSObjectCallAsFunction (ctx, func, this_object, 1, args, &exception);
if (exception)
{
- gchar *mes = seed_exception_to_string (ctx, exception);
+ mes = seed_exception_to_string (ctx, exception);
g_warning ("Exception in instance construction. %s \n", mes);
g_free (mes);
}
@@ -338,9 +340,15 @@ seed_gtype_install_signals (JSContextRef ctx,
JSObjectRef definition,
GType type)
{
- JSObjectRef signals;
+ JSObjectRef signals, signal_def;
JSValueRef jslength;
- guint i, length;
+ guint i, j, length;
+ GType return_type;
+ GType *param_types = NULL;
+ guint n_params = 0;
+ GSignalFlags flags;
+ JSValueRef jsname, jsflags, jsreturn_type, jsparams;
+ gchar *name;
signals = (JSObjectRef) seed_object_get_property (ctx, definition, "signals");
if (JSValueIsNull(ctx, signals) || !JSValueIsObject (ctx, signals))
@@ -353,13 +361,7 @@ seed_gtype_install_signals (JSContextRef ctx,
length = seed_value_to_uint (ctx, jslength, NULL);
for (i = 0; i < length; i++)
{
- GType return_type;
- GType *param_types = NULL;
- guint n_params = 0;
- GSignalFlags flags;
- JSValueRef jsname, jsflags, jsreturn_type, jsparams;
- gchar *name;
- JSObjectRef signal_def = (JSObjectRef)JSObjectGetPropertyAtIndex (ctx,
+ signal_def = (JSObjectRef)JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) signals,
i,
NULL);
@@ -376,9 +378,9 @@ seed_gtype_install_signals (JSContextRef ctx,
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))
@@ -393,17 +395,15 @@ seed_gtype_install_signals (JSContextRef ctx,
n_params = seed_value_to_int (ctx, seed_object_get_property (ctx, (JSObjectRef) jsparams, "length"), NULL);
if (n_params > 0)
{
- guint i;
-
param_types = g_alloca (sizeof (GType)*n_params);
- for (i = 0; i < n_params; i++)
+ for (j = 0; j < n_params; j++)
{
JSValueRef ptype = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef)
jsparams,
- i,
+ j,
NULL);
- param_types[i] = (GType) seed_value_to_long (ctx, ptype, NULL);
+ param_types[j] = (GType) seed_value_to_long (ctx, ptype, NULL);
}
}
}
@@ -415,7 +415,6 @@ seed_gtype_install_signals (JSContextRef ctx,
g_free (name);
}
-
}
static void
@@ -427,7 +426,8 @@ seed_gtype_class_init (gpointer g_class,
JSContextRef ctx;
JSValueRef jsargs[2];
GType type;
- JSValueRef exception = 0;
+ gchar *mes;
+ JSValueRef exception = NULL;
priv = (SeedGClassPrivates *)class_data;
@@ -446,10 +446,8 @@ seed_gtype_class_init (gpointer g_class,
return;
}
-
seed_prepare_global_context (ctx);
-
class_info = seed_get_class_info_for_type (type);
jsargs[0] = seed_make_struct (ctx, g_class, class_info);
@@ -471,7 +469,7 @@ seed_gtype_class_init (gpointer g_class,
JSObjectCallAsFunction (ctx, priv->func, 0, 2, jsargs, &exception);
if (exception)
{
- gchar *mes = seed_exception_to_string (ctx, exception);
+ mes = seed_exception_to_string (ctx, exception);
g_warning ("Exception in class init closure. %s \n", mes);
g_free (mes);
}
@@ -479,14 +477,12 @@ seed_gtype_class_init (gpointer g_class,
JSGlobalContextRelease ((JSGlobalContextRef) ctx);
}
-
-
static JSObjectRef
seed_gtype_constructor_invoked (JSContextRef ctx,
- JSObjectRef constructor,
- size_t 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;
@@ -596,7 +592,7 @@ static JSValueRef
seed_param_getter_invoked (JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
- size_t argumentCount,
+ gsize argumentCount,
const JSValueRef arguments[],
JSValueRef * exception)
{
@@ -629,7 +625,7 @@ static JSValueRef
seed_param_setter_invoked (JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
- size_t argumentCount,
+ gsize argumentCount,
const JSValueRef arguments[],
JSValueRef * exception)
{
@@ -680,7 +676,6 @@ seed_gtype_init (SeedEngine * local_eng)
{
JSClassDefinition gtype_def = kJSClassDefinitionEmpty;
-
gtype_def.callAsConstructor = seed_gtype_constructor_invoked;
seed_gtype_class = JSClassCreate (>ype_def);
JSClassRetain (seed_gtype_class);
@@ -697,3 +692,4 @@ seed_gtype_init (SeedEngine * local_eng)
seed_define_gtype_functions (local_eng->context);
}
+
diff --git a/libseed/seed-structs.c b/libseed/seed-structs.c
index 41a074c..83d67f7 100644
--- a/libseed/seed-structs.c
+++ b/libseed/seed-structs.c
@@ -624,9 +624,8 @@ seed_struct_prototype (JSContextRef ctx, GIBaseInfo * info)
JSObjectRef
seed_make_struct (JSContextRef ctx, gpointer strukt, GIBaseInfo * info)
{
- JSObjectRef object;
- JSObjectRef 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;
@@ -635,10 +634,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 ();
}
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 47379a6..2fe67c5 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -119,6 +119,9 @@ seed_release_arg (GITransfer transfer,
GITypeInfo * type_info, GITypeTag type_tag, GArgument * arg)
{
GType gtype;
+ GITypeInfo *param_type;
+ GIBaseInfo *interface_info;
+ GValue *gval;
switch (type_tag)
{
@@ -129,8 +132,6 @@ seed_release_arg (GITransfer transfer,
case GI_TYPE_TAG_ARRAY:
if (arg->v_pointer)
{
- GITypeInfo *param_type;
-
param_type = g_type_info_get_param_type (type_info, 0);
switch (g_type_info_get_tag (param_type))
@@ -159,8 +160,6 @@ seed_release_arg (GITransfer transfer,
{
if (arg->v_pointer)
{
- GIBaseInfo *interface_info;
-
interface_info = g_type_info_get_interface (type_info);
gtype =
@@ -180,7 +179,7 @@ seed_release_arg (GITransfer transfer,
}
else if (g_type_is_a (gtype, G_TYPE_VALUE))
{
- GValue *gval = (GValue *) arg->v_pointer;
+ gval = (GValue *) arg->v_pointer;
// Free/unref the GValue's contents.
g_value_unset (gval);
// Free the GValue.
@@ -255,15 +254,15 @@ seed_gi_make_jsarray (JSContextRef ctx,
GITypeInfo * param_type, JSValueRef * exception)
{
GITypeTag element_type;
+ JSValueRef *elements;
+ guint length, i;
+ gchar **str_array = (gchar**) array;
JSValueRef ret = JSValueMakeNull (ctx);
element_type = g_type_info_get_tag (param_type);
if (element_type == GI_TYPE_TAG_UTF8)
{
- JSValueRef *elements;
- guint length, i;
- gchar **str_array = (gchar **) array;
length = g_strv_length (str_array);
if (!length)
@@ -289,6 +288,8 @@ seed_gi_make_array (JSContextRef ctx,
void **array_p, JSValueRef * exception)
{
GITypeTag element_type;
+ JSValueRef elem;
+ guint i;
element_type = g_type_info_get_tag (param_type);
@@ -296,116 +297,108 @@ seed_gi_make_array (JSContextRef ctx,
{
case GI_TYPE_TAG_UTF8:
{
- char **result;
- guint i;
-
- result = g_new0 (char *, length + 1);
+ gchar** strresult = g_new0 (gchar *, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
- result[i] = seed_value_to_string (ctx, elem, exception);
+ strresult[i] = seed_value_to_string (ctx, elem, exception);
}
- *array_p = result;
+ *array_p = strresult;
}
break;
case GI_TYPE_TAG_GTYPE:
{
- GType *result;
- guint i;
+ GType *typeresult;
- result = g_new0 (GType, length + 1);
+ typeresult = g_new0 (GType, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
- result[i] = seed_value_to_int (ctx, elem, exception);
+ typeresult[i] = seed_value_to_int (ctx, elem, exception);
}
- *array_p = result;
+ *array_p = typeresult;
}
break;
case GI_TYPE_TAG_FLOAT:
{
- gfloat *result;
- guint i;
+ gfloat *floatresult;
- result = g_new0 (gfloat, length + 1);
+ floatresult = g_new0 (gfloat, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
- result[i] = seed_value_to_float (ctx, elem, exception);
+ floatresult[i] = seed_value_to_float (ctx, elem, exception);
}
- *array_p = result;
+ *array_p = floatresult;
}
break;
case GI_TYPE_TAG_DOUBLE:
{
- gdouble *result;
- guint i;
+ gdouble *dblresult;
- result = g_new0 (gdouble, length + 1);
+ dblresult = g_new0 (gdouble, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
- result[i] = seed_value_to_double (ctx, elem, exception);
+ dblresult[i] = seed_value_to_double (ctx, elem, exception);
}
- *array_p = result;
+ *array_p = dblresult;
}
break;
case GI_TYPE_TAG_INT:
{
- gint *result;
- guint i;
+ gint *intresult;
- result = g_new0 (gint, length + 1);
+ intresult = g_new0 (gint, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
- result[i] = seed_value_to_int (ctx, elem, exception);
+ intresult[i] = seed_value_to_int (ctx, elem, exception);
}
- *array_p = result;
+ *array_p = intresult;
}
break;
case GI_TYPE_TAG_UINT8:
{
- guint8 *result;
- guint i;
+ guint8 *guint8result;
- result = g_new0 (guint8, length + 1);
+ guint8result = g_new0 (guint8, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
- result[i] = seed_value_to_uchar (ctx, elem, exception);
+ guint8result[i] = seed_value_to_uchar (ctx, elem, exception);
}
- *array_p = result;
+ *array_p = guint8result;
}
break;
case GI_TYPE_TAG_INTERFACE:
@@ -421,24 +414,23 @@ seed_gi_make_array (JSContextRef ctx,
interface);
if (g_type_is_a (type, G_TYPE_VALUE))
{
- GValue *result;
- guint i;
+ GValue *gvalresult;
// TODO:FIXME: Robb. Valgrind thinks there's a leak here,
// at least while running Same Seed.
- result = g_new0 (GValue, length + 1);
+ gvalresult = g_new0 (GValue, length + 1);
for (i = 0; i < length; i++)
{
- JSValueRef elem = JSObjectGetPropertyAtIndex (ctx,
+ elem = JSObjectGetPropertyAtIndex (ctx,
(JSObjectRef) array,
i,
exception);
seed_gvalue_from_seed_value (ctx, elem,
(GType) 0,
- &result[i], exception);
+ &gvalresult[i], exception);
}
- *array_p = result;
+ *array_p = gvalresult;
g_base_info_unref (interface);
break;
@@ -880,8 +872,9 @@ seed_gi_argument_make_js (JSContextRef ctx,
{
GITypeInfo *list_type;
JSObjectRef ret;
+ JSValueRef ival;
GArgument larg;
- gint i = 0;
+ guint i = 0;
GSList *list = arg->v_pointer;
ret = JSObjectMakeArray (ctx, 0, NULL, exception);
@@ -889,8 +882,6 @@ seed_gi_argument_make_js (JSContextRef ctx,
for (; list != NULL; list = list->next)
{
- JSValueRef ival;
-
larg.v_pointer = list->data;
ival =
(JSValueRef) seed_gi_argument_make_js (ctx, &larg,
@@ -1292,10 +1283,10 @@ seed_value_to_boolean (JSContextRef ctx,
{
seed_make_exception (eng->context, exception, "ConversionError",
"Can not convert Javascript value to boolean");
- return 0;
+ return FALSE;
}
- return 0;
+ return FALSE;
}
return JSValueToBoolean (ctx, val);
@@ -1439,7 +1430,7 @@ seed_value_to_char (JSContextRef ctx, JSValueRef val, JSValueRef * exception)
return 0;
}
- return (char) cv;
+ return (gchar) cv;
}
/**
@@ -1998,7 +1989,6 @@ seed_value_from_filename (JSContextRef ctx,
}
-
GObject *
seed_value_to_object (JSContextRef ctx,
JSValueRef val, JSValueRef * exception)
@@ -2013,7 +2003,7 @@ seed_value_to_object (JSContextRef ctx,
*/
if (JSValueIsNull (ctx, val))
- return 0;
+ return NULL;
if (!seed_value_is_gobject (ctx, val))
{
seed_make_exception (ctx, exception, "ConversionError",
@@ -2043,12 +2033,14 @@ seed_validate_enum (GIEnumInfo *info,
long val)
{
gint n, i;
+ GIValueInfo *value_info;
+ glong value;
n = g_enum_info_get_n_values (info);
for (i = 0; i < n; i++)
{
- GIValueInfo *value_info = g_enum_info_get_value (info, i);
- glong value = g_value_info_get_value (value_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);
if (value == val)
@@ -2074,16 +2066,17 @@ seed_value_to_time_t (JSContextRef ctx,
JSValueRef value,
JSValueRef *exception)
{
+ JSValueRef get_time_method;
+ JSValueRef jstime;
+ gdouble time;
+
+
if (JSValueIsNumber (ctx, value))
{
return (unsigned long) seed_value_to_long (ctx, value, exception);
}
else if (JSValueIsObject (ctx, value))
{
- JSValueRef get_time_method;
- JSValueRef jstime;
- gdouble time;
-
get_time_method = seed_object_get_property (ctx, (JSObjectRef)value,
"getTime");
if (JSValueIsNull(ctx, get_time_method) ||
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]