seed r580 - trunk/libseed
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r580 - trunk/libseed
- Date: Tue, 30 Dec 2008 08:36:02 +0000 (UTC)
Author: hortont
Date: Tue Dec 30 08:36:02 2008
New Revision: 580
URL: http://svn.gnome.org/viewvc/seed?rev=580&view=rev
Log:
Update indentation.
Modified:
trunk/libseed/seed-api.c
trunk/libseed/seed-builtins.c
trunk/libseed/seed-closure.c
trunk/libseed/seed-closure.h
trunk/libseed/seed-engine.c
trunk/libseed/seed-engine.h
trunk/libseed/seed-exceptions.c
trunk/libseed/seed-gtype.c
trunk/libseed/seed-private.h
trunk/libseed/seed-signals.c
trunk/libseed/seed-signals.h
trunk/libseed/seed-structs.c
trunk/libseed/seed-structs.h
trunk/libseed/seed-types.c
trunk/libseed/seed-types.h
trunk/libseed/seed.h
Modified: trunk/libseed/seed-api.c
==============================================================================
--- trunk/libseed/seed-api.c (original)
+++ trunk/libseed/seed-api.c Tue Dec 30 08:36:02 2008
@@ -14,7 +14,6 @@
* Copyright (C) Robert Carr 2008 <carrr rpi edu>
*/
-
#include "seed-private.h"
void seed_value_protect(JSContextRef ctx, JSValueRef value)
@@ -35,12 +34,12 @@
JSGlobalContextRef seed_context_ref(JSGlobalContextRef ctx)
{
- return JSGlobalContextRetain(ctx);
+ return JSGlobalContextRetain(ctx);
}
void seed_context_unref(JSGlobalContextRef ctx)
{
- JSGlobalContextRelease(ctx);
+ JSGlobalContextRelease(ctx);
}
JSValueRef seed_make_null(JSContextRef ctx)
@@ -48,9 +47,8 @@
return JSValueMakeNull(ctx);
}
-JSObjectRef seed_make_object(JSContextRef ctx,
- JSClassRef class,
- gpointer private)
+JSObjectRef seed_make_object(JSContextRef ctx,
+ JSClassRef class, gpointer private)
{
return JSObjectMake(ctx, class, private);
}
@@ -65,21 +63,19 @@
}
JSValueRef seed_object_call(JSContextRef ctx,
- JSObjectRef object,
- JSObjectRef this,
- size_t argument_count,
- const JSValueRef arguments[],
- JSValueRef * exception)
+ JSObjectRef object,
+ JSObjectRef this,
+ size_t argument_count,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
{
return JSObjectCallAsFunction(ctx, object, this,
- argument_count, arguments,
- exception);
+ argument_count, arguments, exception);
}
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);
@@ -97,9 +93,7 @@
return ret;
}
-JSValueRef seed_evaluate(JSContextRef ctx,
- SeedScript * js,
- JSObjectRef this)
+JSValueRef seed_evaluate(JSContextRef ctx, SeedScript * js, JSObjectRef this)
{
JSValueRef ret;
@@ -122,7 +116,7 @@
}
gsize seed_string_to_utf8_buffer(JSStringRef string, gchar * buffer,
- size_t buffer_size)
+ size_t buffer_size)
{
return JSStringGetUTF8CString(string, buffer, buffer_size);
}
@@ -153,19 +147,18 @@
}
JSObjectRef seed_make_constructor(JSContextRef ctx,
- JSClassRef class,
- JSObjectCallAsConstructorCallback constructor)
+ JSClassRef class,
+ JSObjectCallAsConstructorCallback constructor)
{
return JSObjectMakeConstructor(ctx, class, constructor);
}
gpointer seed_object_get_private(JSObjectRef object)
{
- return (gpointer)JSObjectGetPrivate(object);
+ return (gpointer) JSObjectGetPrivate(object);
}
void seed_object_set_private(JSObjectRef object, gpointer value)
{
JSObjectSetPrivate(object, value);
}
-
Modified: trunk/libseed/seed-builtins.c
==============================================================================
--- trunk/libseed/seed-builtins.c (original)
+++ trunk/libseed/seed-builtins.c Tue Dec 30 08:36:02 2008
@@ -19,7 +19,6 @@
* Copyright (C) Matthew Arsenault 2008 <arsenm2 rpi edu>
*/
-
#include <stdio.h>
#include "seed-private.h"
#include <string.h>
@@ -71,7 +70,7 @@
file_contents = JSStringCreateWithUTF8CString(walk);
file_name = JSStringCreateWithUTF8CString(import_file);
-
+
JSEvaluateScript(ctx, file_contents, NULL, file_name, 0, exception);
JSStringRelease(file_contents);
@@ -179,7 +178,7 @@
(g_callable_info_get_arg(info, i)));
seed_object_set_property(ctx, argument, "type",
- seed_value_from_string(ctx,
+ seed_value_from_string(ctx,
arg_name, exception));
JSObjectSetPropertyAtIndex(ctx, args_obj, i, argument, NULL);
@@ -230,10 +229,10 @@
static JSValueRef
seed_spawn(JSContextRef ctx,
- JSObjectRef function,
- JSObjectRef this_object,
- size_t argumentCount,
- const JSValueRef arguments[], JSValueRef * exception)
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[], JSValueRef * exception)
{
gchar *line, *stdout, *stderr;
JSObjectRef ret;
@@ -242,7 +241,7 @@
if (argumentCount != 1)
{
// I am so lazy
- seed_make_exception(ctx, exception, "ArgumentError",
+ seed_make_exception(ctx, exception, "ArgumentError",
"Seed.spawn expected 1 argument");
return JSValueMakeNull(ctx);
}
@@ -257,7 +256,7 @@
g_error_free(error);
return JSValueMakeNull(ctx);
}
-
+
ret = JSObjectMake(ctx, NULL, NULL);
seed_object_set_property(ctx, ret, "stdout",
seed_value_from_string(ctx, stdout, exception));
@@ -267,7 +266,7 @@
g_free(stdout);
g_free(stderr);
- return ret;
+ return ret;
}
static JSValueRef
@@ -281,10 +280,9 @@
{
exit(seed_value_to_int(ctx, arguments[0], NULL));
}
- else if(argumentCount > 1)
+ else if (argumentCount > 1)
{
- gchar *mes = g_strdup_printf("Seed.quit expected "
- "1 argument, got %d",
+ gchar *mes = g_strdup_printf("Seed.quit expected " "1 argument, got %d",
argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
@@ -298,24 +296,19 @@
guint i;
JSObjectRef arrayObj;
JSValueRef argcref;
- JSObjectRef obj =
- (JSObjectRef) seed_object_get_property(local_eng->context,
- local_eng->global, "Seed");
-
- seed_create_function(local_eng->context,
- "include", &seed_include, obj);
- seed_create_function(local_eng->context,
- "print", &seed_print, obj);
- seed_create_function(local_eng->context,
+ JSObjectRef obj = (JSObjectRef) seed_object_get_property(local_eng->context,
+ local_eng->global,
+ "Seed");
+
+ seed_create_function(local_eng->context, "include", &seed_include, obj);
+ seed_create_function(local_eng->context, "print", &seed_print, obj);
+ seed_create_function(local_eng->context,
"check_syntax", &seed_check_syntax, obj);
- seed_create_function(local_eng->context,
+ seed_create_function(local_eng->context,
"introspect", &seed_introspect, obj);
- seed_create_function(local_eng->context,
- "fork", &seed_fork, obj);
- seed_create_function(local_eng->context,
- "spawn", &seed_spawn, obj);
- seed_create_function(local_eng->context,
- "quit", &seed_quit, obj);
+ seed_create_function(local_eng->context, "fork", &seed_fork, obj);
+ seed_create_function(local_eng->context, "spawn", &seed_spawn, obj);
+ seed_create_function(local_eng->context, "quit", &seed_quit, obj);
arrayObj = JSObjectMake(local_eng->context, NULL, NULL);
@@ -324,7 +317,7 @@
// TODO: exceptions!
JSObjectSetPropertyAtIndex(local_eng->context, arrayObj, i,
- seed_value_from_string(local_eng->context,
+ seed_value_from_string(local_eng->context,
(*argv)[i], 0), NULL);
}
Modified: trunk/libseed/seed-closure.c
==============================================================================
--- trunk/libseed/seed-closure.c (original)
+++ trunk/libseed/seed-closure.c Tue Dec 30 08:36:02 2008
@@ -2,7 +2,6 @@
* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
*/
-
/* This file is part of Seed.
* Seed is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -19,7 +18,6 @@
* Copyright (C) Robert Carr 2008 <carrr rpi edu>
*/
-
#include "seed-private.h"
#include <sys/mman.h>
@@ -104,14 +102,14 @@
{
SeedNativeClosure *privates =
(SeedNativeClosure *) JSObjectGetPrivate(object);
-
+
SEED_NOTE(FINALIZATION, "Finalizing closure object %p with "
"GIBaseInfo: %s \n", object,
- g_base_info_get_name((GIBaseInfo *)privates->info));
+ g_base_info_get_name((GIBaseInfo *) privates->info));
g_free(privates->cif->arg_types);
g_free(privates->cif);
- g_base_info_unref((GIBaseInfo *)privates->info);
+ g_base_info_unref((GIBaseInfo *) privates->info);
munmap(privates->closure, sizeof(ffi_closure));
}
@@ -128,9 +126,7 @@
GITypeInfo *return_type;
GArgument rarg;
GArgument return_arg;
- JSContextRef ctx =
- JSGlobalContextCreateInGroup(context_group, 0);
-
+ JSContextRef ctx = JSGlobalContextCreateInGroup(context_group, 0);
SEED_NOTE(INVOCATION, "Invoking closure of type: %s \n",
g_base_info_get_name((GIBaseInfo *) privates->info));
@@ -246,10 +242,10 @@
JSObjectCallAsFunction(ctx,
(JSObjectRef) privates->function, 0,
num_args, jsargs, &exception);
-
+
if (exception)
{
- gchar *mes = seed_exception_to_string(ctx,
+ gchar *mes = seed_exception_to_string(ctx,
exception);
g_warning("Exception in closure marshal. %s \n", mes, 0);
g_free(mes);
@@ -343,7 +339,7 @@
}
g_base_info_unref((GIBaseInfo *) return_type);
- JSGlobalContextRelease((JSGlobalContextRef)ctx);
+ JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
SeedNativeClosure *seed_make_native_closure(JSContextRef ctx,
@@ -365,8 +361,7 @@
(JSObjectRef) seed_object_get_property(ctx, (JSObjectRef) function,
"__seed_native_closure");
if (cached
- && JSValueIsObjectOfClass(ctx, cached,
- seed_native_callback_class))
+ && JSValueIsObjectOfClass(ctx, cached, seed_native_callback_class))
{
return (SeedNativeClosure *) JSObjectGetPrivate(cached);
}
@@ -399,15 +394,14 @@
seed_object_set_property(ctx, (JSObjectRef) function,
"__seed_native_closure",
(JSValueRef) JSObjectMake(ctx,
- seed_native_callback_class,
- privates));
+ seed_native_callback_class,
+ privates));
return privates;
}
SeedClosure *seed_make_gclosure(JSContextRef ctx,
- JSObjectRef function,
- JSObjectRef this)
+ JSObjectRef function, JSObjectRef this)
{
GClosure *closure;
Modified: trunk/libseed/seed-closure.h
==============================================================================
--- trunk/libseed/seed-closure.h (original)
+++ trunk/libseed/seed-closure.h Tue Dec 30 08:36:02 2008
@@ -25,7 +25,7 @@
typedef struct _SeedClosure {
GClosure closure;
-
+
JSObjectRef function;
JSObjectRef object;
JSObjectRef this;
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Tue Dec 30 08:36:02 2008
@@ -17,7 +17,6 @@
* Copyright (C) Robert Carr 2008 <carrr rpi edu>
*/
-
#include "seed-private.h"
#include <sys/types.h>
@@ -34,7 +33,7 @@
gchar *glib_message = 0;
-GIBaseInfo * base_info_info = 0;
+GIBaseInfo *base_info_info = 0;
guint seed_debug_flags = 0; /* global seed debug flag */
@@ -51,16 +50,15 @@
};
#endif /* SEED_ENABLE_DEBUG */
-
// TODO: JSON field initialization.
static JSObjectRef
seed_struct_constructor_invoked(JSContextRef ctx,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef * exception)
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
{
- GIBaseInfo * info = JSObjectGetPrivate(constructor);
+ GIBaseInfo *info = JSObjectGetPrivate(constructor);
JSValueRef ret;
JSObjectRef parameters = 0;
@@ -70,14 +68,13 @@
{
seed_make_exception(ctx, exception, "ArgmuentError",
"Constructor expects object as argument");
- return (JSObjectRef) JSValueMakeNull(ctx);
+ return (JSObjectRef) JSValueMakeNull(ctx);
}
- parameters = (JSObjectRef)arguments[0];
+ parameters = (JSObjectRef) arguments[0];
}
ret = seed_construct_struct_type_with_parameters(ctx, info,
- parameters,
- exception);
-
+ parameters, exception);
+
}
static JSObjectRef
@@ -100,7 +97,7 @@
JSStringRef jsprop_name;
JSValueRef jsprop_value;
gboolean sunk = TRUE;
-
+
type = (GType) JSObjectGetPrivate(constructor);
if (!type)
return 0;
@@ -127,8 +124,7 @@
return (JSObjectRef) JSValueMakeNull(ctx);
}
- jsprops = JSObjectCopyPropertyNames(ctx,
- (JSObjectRef) arguments[0]);
+ jsprops = JSObjectCopyPropertyNames(ctx, (JSObjectRef) arguments[0]);
nparams = JSPropertyNameArrayGetCount(jsprops);
}
i = 0;
@@ -156,7 +152,7 @@
g_free(mes);
g_free(params);
-
+
JSPropertyNameArrayRelease(jsprops);
return (JSObjectRef) JSValueMakeNull(ctx);
}
@@ -198,11 +194,11 @@
ret = (JSObjectRef) JSValueMakeNull(ctx);
else
ret = (JSObjectRef) seed_value_from_object(ctx, gobject, exception);
-
+
for (i = 0; i < nparams; i++)
{
g_value_unset(¶ms[i].value);
- g_free((gchar *)params[i].name);
+ g_free((gchar *) params[i].name);
}
if (G_IS_INITIALLY_UNOWNED(gobject))
@@ -229,7 +225,7 @@
gchar *mes = g_strdup_printf("GObject equals comparison expected"
" 1 argument, got %d", argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
- g_free(mes);
+ g_free(mes);
return JSValueMakeNull(ctx);
}
@@ -256,10 +252,9 @@
return seed_value_from_int(ctx, this->ref_count, exception);
}
-static void
-seed_gobject_method_finalize(JSObjectRef method)
+static void seed_gobject_method_finalize(JSObjectRef method)
{
- GIBaseInfo * info = (GIBaseInfo *)JSObjectGetPrivate(method);
+ GIBaseInfo *info = (GIBaseInfo *) JSObjectGetPrivate(method);
if (info)
g_base_info_unref(info);
}
@@ -285,7 +280,7 @@
GIDirection dir;
JSValueRef retval_ref;
GError *error = 0;
-
+
info = JSObjectGetPrivate(function);
// We just want to check if there IS an object, not actually throw an
// exception if we don't
@@ -379,32 +374,30 @@
GIBaseInfo *interface;
GIInfoType interface_type;
-
+
interface = g_type_info_get_interface(type_info);
interface_type = g_base_info_get_type(interface);
g_base_info_unref(interface);
-
+
if (interface_type == GI_INFO_TYPE_OBJECT ||
interface_type == GI_INFO_TYPE_INTERFACE)
{
if (G_IS_OBJECT(retval.v_pointer))
{
- sunk =
- g_object_is_floating(G_OBJECT(retval.v_pointer));
+ sunk = g_object_is_floating(G_OBJECT(retval.v_pointer));
g_object_ref_sink(G_OBJECT(retval.v_pointer));
}
}
-
+
}
retval_ref =
seed_gi_argument_make_js(ctx, &retval, type_info, exception);
if (!sunk)
g_object_unref(G_OBJECT(retval.v_pointer));
-
- seed_gi_release_arg(
- g_callable_info_get_caller_owns((GICallableInfo*) info),
- type_info, &retval);
+
+ seed_gi_release_arg(g_callable_info_get_caller_owns
+ ((GICallableInfo *) info), type_info, &retval);
}
g_base_info_unref((GIBaseInfo *) type_info);
}
@@ -467,7 +460,6 @@
//if (g_base_info_is_deprecated ((GIBaseInfo *) info))
//g_printf("Not defining deprecated symbol: %s \n",
//g_base_info_get_name((GIBaseInfo *)info));
-
flags = g_function_info_get_flags(info);
@@ -476,16 +468,17 @@
return;
}
- method_ref = JSObjectMake(ctx, gobject_method_class,
- g_base_info_ref((GIBaseInfo *)info));
+ method_ref = JSObjectMake(ctx, gobject_method_class,
+ g_base_info_ref((GIBaseInfo *) info));
name = g_base_info_get_name((GIBaseInfo *) info);
if (!strcmp(name, "new"))
name = "_new";
seed_object_set_property(ctx, object, name, method_ref);
- seed_object_set_property(ctx, method_ref, "info",
- seed_make_struct(ctx,
- g_base_info_ref((GIBaseInfo *)info),
+ seed_object_set_property(ctx, method_ref, "info",
+ seed_make_struct(ctx,
+ g_base_info_ref((GIBaseInfo *)
+ info),
base_info_info));
}
@@ -518,7 +511,7 @@
}
static void
-seed_gobject_add_methods_for_type(JSContextRef ctx,
+seed_gobject_add_methods_for_type(JSContextRef ctx,
GIObjectInfo * oinfo, JSObjectRef object)
{
gint n_methods;
@@ -530,7 +523,7 @@
for (i = 0; i < n_methods; i++)
{
info = g_object_info_get_method(oinfo, i);
- seed_gobject_define_property_from_function_info(ctx,
+ seed_gobject_define_property_from_function_info(ctx,
info, object, TRUE);
}
}
@@ -578,7 +571,7 @@
if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
{
- seed_gobject_add_methods_for_type(ctx,
+ seed_gobject_add_methods_for_type(ctx,
(GIObjectInfo *) info, prototype_obj);
seed_gobject_add_methods_for_interfaces(ctx, (GIObjectInfo *) info,
prototype_obj);
@@ -628,7 +621,7 @@
{
GObject *gobject;
- gobject = (GObject *)JSObjectGetPrivate((JSObjectRef)object);
+ gobject = (GObject *) JSObjectGetPrivate((JSObjectRef) object);
if (!gobject)
{
SEED_NOTE(FINALIZATION,
@@ -740,11 +733,10 @@
found_field:
if (field)
{
- ret = seed_field_get_value(context, b,
- field, exception);
+ ret = seed_field_get_value(context, b, field, exception);
g_base_info_unref((GIBaseInfo *) info);
g_free(cproperty_name);
- return ret;
+ return ret;
}
g_base_info_unref((GIBaseInfo *) info);
}
@@ -836,28 +828,28 @@
return TRUE;
}
-static GModule * seed_try_load_extension(gchar * name)
+static GModule *seed_try_load_extension(gchar * name)
{
- GModule * module;
- gchar * path;
- gchar * lowername;
+ GModule *module;
+ gchar *path;
+ gchar *lowername;
lowername = g_utf8_strdown(name, -1);
path = g_module_build_path("/usr/local/lib/seed", lowername);
-
+
module = g_module_open(path, G_MODULE_BIND_LAZY);
if (!module)
{
g_free(path);
path = g_module_build_path("/usr/lib/seed", lowername);
-
+
module = g_module_open(path, G_MODULE_BIND_LAZY);
}
g_free(path);
g_free(lowername);
- return module;
+ return module;
}
static JSValueRef
@@ -871,11 +863,11 @@
GError *e = 0;
gchar *namespace;
const gchar *version = 0;
- gchar * jsextension;
+ gchar *jsextension;
JSObjectRef namespace_ref;
JSStringRef extension_script;
gint n, i;
- GModule * extension;
+ GModule *extension;
if (argumentCount == 0)
{
@@ -891,18 +883,16 @@
{
version = seed_value_to_string(ctx, arguments[1], exception);
}
-
+
extension = seed_try_load_extension(namespace);
if (extension)
{
SeedModuleInitCallback init;
-
- g_module_symbol(extension,
- "seed_module_init",
- (gpointer *)&init);
- (*init)(eng);
-
+ g_module_symbol(extension, "seed_module_init", (gpointer *) & init);
+
+ (*init) (eng);
+
g_free(namespace);
return JSValueMakeNull(ctx);
}
@@ -926,7 +916,7 @@
namespace, i);
if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_FUNCTION))
{
- seed_gobject_define_property_from_function_info(ctx,
+ seed_gobject_define_property_from_function_info(ctx,
(GIFunctionInfo *)
info, namespace_ref,
FALSE);
@@ -962,7 +952,7 @@
if (name[j] == '-')
name[j] = '_';
}
-
+
// Non ascii enums? :P
*name = g_ascii_toupper(*name);
@@ -988,8 +978,7 @@
GIFunctionInfo *finfo;
GIFunctionInfoFlags flags;
- class_ref = seed_gobject_get_class_for_gtype(ctx,
- type);
+ class_ref = seed_gobject_get_class_for_gtype(ctx, type);
constructor_ref =
JSObjectMake(ctx,
@@ -997,7 +986,7 @@
seed_object_set_property(ctx, constructor_ref,
"type",
- seed_value_from_int(ctx, type,
+ seed_value_from_int(ctx, type,
exception));
n_methods = g_object_info_get_n_methods((GIObjectInfo *) info);
@@ -1021,7 +1010,8 @@
(info), constructor_ref);
seed_object_set_property(ctx, constructor_ref,
"prototype",
- seed_gobject_get_prototype_for_gtype(type));
+ seed_gobject_get_prototype_for_gtype
+ (type));
JSValueProtect(ctx, (JSValueRef) constructor_ref);
}
}
@@ -1031,9 +1021,7 @@
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((GIStructInfo *) info);
@@ -1056,9 +1044,7 @@
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_union_info_get_n_methods((GIUnionInfo *) info);
@@ -1092,7 +1078,7 @@
g_constant_info_get_value((GIConstantInfo *) info, &argument);
constant_value =
seed_gi_argument_make_js(ctx, &argument,
- g_constant_info_get_type((GIConstantInfo *) info), exception);
+ g_constant_info_get_type((GIConstantInfo *) info), exception);
seed_object_set_property(ctx, namespace_ref,
g_base_info_get_name(info),
constant_value);
@@ -1152,7 +1138,7 @@
NULL, /* Static Values */
NULL, /* Static Functions */
NULL,
- seed_gobject_method_finalize, /* Finalize */
+ seed_gobject_method_finalize, /* Finalize */
NULL, /* Has Property */
NULL, /* Get Property */
NULL, /* Set Property */
@@ -1225,8 +1211,7 @@
};
void seed_create_function(JSContextRef ctx,
- gchar * name,
- gpointer func, JSObjectRef obj)
+ gchar * name, gpointer func, JSObjectRef obj)
{
JSObjectRef oref;
@@ -1316,11 +1301,11 @@
return ret;
}
-SeedEngine * seed_init(gint * argc, gchar *** argv)
+SeedEngine *seed_init(gint * argc, gchar *** argv)
{
JSObjectRef seed_obj_ref;
JSStringRef defaults_script;
-
+
signal(SIGCHLD, SIG_IGN);
g_type_init();
@@ -1336,13 +1321,13 @@
qprototype = g_quark_from_static_string("js-prototype");
eng = (SeedEngine *) g_malloc(sizeof(SeedEngine));
-
+
context_group = JSContextGroupCreate();
eng->context = JSGlobalContextCreateInGroup(context_group, NULL);
eng->global = JSContextGetGlobalObject(eng->context);
eng->group = context_group;
-
+
gobject_class = JSClassCreate(&gobject_def);
JSClassRetain(gobject_class);
gobject_method_class = JSClassCreate(&gobject_method_def);
@@ -1362,8 +1347,8 @@
seed_object_set_property(eng->context, eng->global, "Seed", seed_obj_ref);
JSValueProtect(eng->context, seed_obj_ref);
- seed_create_function(eng->context, "import_namespace", &seed_gi_import_namespace,
- seed_obj_ref);
+ seed_create_function(eng->context, "import_namespace",
+ &seed_gi_import_namespace, seed_obj_ref);
seed_init_builtins(eng, argc, argv);
seed_closures_init();
seed_structs_init();
@@ -1373,16 +1358,14 @@
defaults_script =
JSStringCreateWithUTF8CString("Seed.import_namespace(\""
"GIRepository\");"
- "try{Seed.include(\"/usr/share/"
+ "try{Seed.include(\"/usr/share/"
"seed/Seed.js\");} catch(e){}"
"Seed.include(\"/usr/local/share"
"/seed/Seed.js\");");
JSEvaluateScript(eng->context, defaults_script, NULL, NULL, 0, NULL);
JSStringRelease(defaults_script);
-
- base_info_info = g_irepository_find_by_name(0, "GIRepository",
- "IBaseInfo");
+
+ base_info_info = g_irepository_find_by_name(0, "GIRepository", "IBaseInfo");
return eng;
}
-
Modified: trunk/libseed/seed-engine.h
==============================================================================
--- trunk/libseed/seed-engine.h (original)
+++ trunk/libseed/seed-engine.h Tue Dec 30 08:36:02 2008
@@ -48,7 +48,7 @@
GIFunctionInfo * info,
JSObjectRef object,
gboolean instance);
-void seed_create_function(JSContextRef ctx, gchar * name,
+void seed_create_function(JSContextRef ctx, gchar * name,
gpointer func, JSObjectRef obj);
typedef void (*SeedModuleInitCallback) (SeedEngine * eng);
Modified: trunk/libseed/seed-exceptions.c
==============================================================================
--- trunk/libseed/seed-exceptions.c (original)
+++ trunk/libseed/seed-exceptions.c Tue Dec 30 08:36:02 2008
@@ -24,8 +24,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;
@@ -56,9 +55,8 @@
JSStringRelease(js_message);
}
-void seed_make_exception_from_gerror(JSContextRef ctx,
- JSValueRef * exception,
- GError * error)
+void seed_make_exception_from_gerror(JSContextRef ctx,
+ JSValueRef * exception, GError * error)
{
const gchar *domain = g_quark_to_string(error->domain);
GString *string = g_string_new(domain);
@@ -76,10 +74,7 @@
g_string_truncate(string, i - 1);
}
- seed_make_exception(ctx,
- exception,
- string->str,
- error->message);
+ seed_make_exception(ctx, exception, string->str, error->message);
g_string_free(string, TRUE);
}
@@ -131,10 +126,10 @@
guint line;
gchar *mes, *name, *file, *ret;
- line = seed_exception_get_line(ctx,e);
- mes = seed_exception_get_message(ctx,e);
- file = seed_exception_get_file(ctx,e);
- name = seed_exception_get_name(ctx,e);
+ line = seed_exception_get_line(ctx, e);
+ mes = seed_exception_get_message(ctx, e);
+ file = seed_exception_get_file(ctx, e);
+ name = seed_exception_get_name(ctx, e);
ret = g_strdup_printf("Line %d in %s: %s %s", line, file, name, mes);
Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c (original)
+++ trunk/libseed/seed-gtype.c Tue Dec 30 08:36:02 2008
@@ -17,7 +17,6 @@
* Copyright (C) Robert Carr 2008 <carrr rpi edu>
*/
-
#include "seed-private.h"
#include <sys/mman.h>
@@ -269,22 +268,20 @@
g_free(mes);
return (JSObjectRef) JSValueMakeNull(ctx);
}
- if (JSValueIsNull(ctx, arguments[0]) ||
- !JSValueIsObject(ctx, arguments[0]))
+ if (JSValueIsNull(ctx, arguments[0]) || !JSValueIsObject(ctx, arguments[0]))
{
seed_make_exception(ctx, exception, "ArgumentError",
"Signal constructor expected object"
" as first argument");
return (JSObjectRef) JSValueMakeNull(ctx);
}
-
+
/* Signal name */
jsname = seed_object_get_property(ctx, (JSObjectRef) arguments[0], "name");
/* seed_value_to_string can handle non strings, however the kind
* of strings we want as a signal name are rather small, so make sure
* we have an actual string */
- if (JSValueIsNull(ctx, jsname) ||
- !JSValueIsString(ctx, jsname))
+ if (JSValueIsNull(ctx, jsname) || !JSValueIsString(ctx, jsname))
{
seed_make_exception(ctx, exception, "ArgumentError",
"Signal definition needs name property");
@@ -295,16 +292,14 @@
/* Type to install on. Comes from class. */
jstype = seed_object_get_property(ctx, thisObject, "type");
itype = seed_value_to_int(ctx, jstype, exception);
-
+
SEED_NOTE(GTYPE, "Installing signal with name: %s on type: %s",
- name,
- g_type_name(itype));
+ name, g_type_name(itype));
/* Signal flags */
- jsflags = seed_object_get_property(ctx,
+ jsflags = seed_object_get_property(ctx,
(JSObjectRef) arguments[0], "flags");
- if (JSValueIsNull(ctx, jsflags) ||
- !JSValueIsNumber(ctx, jsflags))
+ if (JSValueIsNull(ctx, jsflags) || !JSValueIsNumber(ctx, jsflags))
flags = G_SIGNAL_RUN_LAST;
else
flags = seed_value_to_long(ctx, jsflags, exception);
@@ -321,11 +316,10 @@
/* Number of params and types */
jsparams = seed_object_get_property(ctx, (JSObjectRef) arguments[0],
"parameters");
- if (!JSValueIsNull(ctx, jsparams) &&
- JSValueIsObject(ctx, jsparams))
+ if (!JSValueIsNull(ctx, jsparams) && JSValueIsObject(ctx, jsparams))
{
n_params = seed_value_to_int
- (ctx,
+ (ctx,
seed_object_get_property(ctx, (JSObjectRef) jsparams, "length"),
exception);
if (n_params > 0)
@@ -371,7 +365,7 @@
type = (GType) JSObjectGetPrivate(*(JSObjectRef *) args[1]);
jsargs[0] = seed_make_pointer(ctx, *(gpointer *) args[0]);
jsargs[1] = seed_gobject_get_prototype_for_gtype(type);
-
+
SEED_NOTE(GTYPE, "Marshalling class init closure for type: %s",
g_type_name(type));
@@ -390,12 +384,12 @@
JSObjectCallAsFunction(ctx, function, 0, 2, jsargs, &exception);
if (exception)
{
- gchar *mes = seed_exception_to_string(ctx,
+ gchar *mes = seed_exception_to_string(ctx,
exception);
g_warning("Exception in class init closure. %s \n", mes, 0);
}
-
- JSGlobalContextRelease((JSGlobalContextRef)ctx);
+
+ JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
static void
@@ -410,25 +404,23 @@
JSContextRef ctx = JSGlobalContextCreateInGroup(context_group,
0);
-
jsargs = seed_make_pointer(ctx, *(gpointer *) args[1]);
this_object =
(JSObjectRef) seed_value_from_object(ctx, *(GObject **) args[0], 0);
-
+
SEED_NOTE(GTYPE, "Handling instance init closure for: %p with type: %s",
- *(GObject **)args[0],
- g_type_name(G_OBJECT_TYPE(*(GObject **)args[0])));
+ *(GObject **) args[0],
+ g_type_name(G_OBJECT_TYPE(*(GObject **) args[0])));
- JSObjectCallAsFunction(ctx, function, this_object, 1, &jsargs,
- &exception);
+ JSObjectCallAsFunction(ctx, function, this_object, 1, &jsargs, &exception);
if (exception)
{
- gchar *mes = seed_exception_to_string(ctx,
+ gchar *mes = seed_exception_to_string(ctx,
exception);
g_warning("Exception in instance init closure. %s \n", mes, 0);
}
- JSGlobalContextRelease((JSGlobalContextRef)ctx);
+ JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
@@ -526,7 +518,7 @@
return (JSObjectRef) JSValueMakeNull(ctx);
}
- parent_ref = seed_object_get_property(ctx,
+ parent_ref = seed_object_get_property(ctx,
(JSObjectRef) arguments[0], "parent");
class_init = seed_object_get_property(ctx,
(JSObjectRef) arguments[0],
@@ -560,7 +552,7 @@
}
parent_type = (GType) seed_value_to_int(ctx, parent_ref, exception);
-
+
SEED_NOTE(GTYPE, "Registering new GType with name: %s as child of %s.",
new_name, g_type_name(parent_type));
@@ -581,8 +573,7 @@
JSObjectSetPrivate(constructor_ref, (gpointer) new_type);
g_free(new_name);
- return JSObjectMake(ctx, gobject_constructor_class,
- (gpointer) new_type);
+ return JSObjectMake(ctx, gobject_constructor_class, (gpointer) new_type);
}
void seed_gtype_init(SeedEngine * local_eng)
@@ -596,6 +587,6 @@
gtype_constructor = JSObjectMake(local_eng->context, seed_gtype_class, 0);
- seed_object_set_property(local_eng->context,
+ seed_object_set_property(local_eng->context,
local_eng->global, "GType", gtype_constructor);
}
Modified: trunk/libseed/seed-private.h
==============================================================================
--- trunk/libseed/seed-private.h (original)
+++ trunk/libseed/seed-private.h Tue Dec 30 08:36:02 2008
@@ -36,7 +36,7 @@
struct _SeedEngine {
JSGlobalContextRef context;
JSObjectRef global;
-
+
JSContextGroupRef group;
};
Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c (original)
+++ trunk/libseed/seed-signals.c Tue Dec 30 08:36:02 2008
@@ -17,7 +17,6 @@
* Copyright (C) Robert Carr 2008 <carrr rpi edu>
*/
-
#include <string.h>
#include "seed-private.h"
@@ -25,7 +24,7 @@
typedef struct _signal_privates {
guint signal_id;
GObject *object;
- const gchar * signal_name;
+ const gchar *signal_name;
} signal_privates;
JSClassRef signal_holder_class;
@@ -64,9 +63,8 @@
}
static void
-seed_add_signals_for_type(JSContextRef ctx,
- JSObjectRef object_ref,
- GObject * obj, GType type)
+seed_add_signals_for_type(JSContextRef ctx,
+ JSObjectRef object_ref, GObject * obj, GType type)
{
guint n, i;
guint *signal_ids;
@@ -91,8 +89,8 @@
JSObjectRef user_data)
{
GSignalQuery query;
- GClosure * closure;
-
+ GClosure *closure;
+
g_signal_query(g_signal_lookup(signal_name, G_OBJECT_TYPE(on_obj)), &query);
closure = g_closure_new_simple(sizeof(SeedClosure), 0);
@@ -101,25 +99,25 @@
((SeedClosure *) closure)->function = func;
//((SeedClosure *) closure)->object = on_obj;
((SeedClosure *) closure)->return_type = query.return_type;
-
+
if (this_obj && !JSValueIsNull(ctx, this_obj))
{
-// JSValueProtect(ctx, this_obj);
+// JSValueProtect(ctx, this_obj);
((SeedClosure *) closure)->this = this_obj;
}
else
{
((SeedClosure *) closure)->this = 0;
}
-
+
if (user_data && !JSValueIsNull(ctx, user_data))
{
((SeedClosure *) closure)->user_data = user_data;
-// JSValueProtect(ctx, user_data);
+// JSValueProtect(ctx, user_data);
}
JSValueProtect(ctx, (JSObjectRef) func);
-
+
g_signal_connect_closure(on_obj, signal_name, closure, FALSE);
}
@@ -133,10 +131,10 @@
{
GType obj_type;
JSObjectRef user_data = NULL;
- gchar * signal_name;
- GObject * obj;
-
- if(argumentCount < 2 || argumentCount > 3)
+ gchar *signal_name;
+ GObject *obj;
+
+ if (argumentCount < 2 || argumentCount > 3)
{
gchar *mes = g_strdup_printf("Signal connection expected"
" 2 or 3 arguments. Got "
@@ -146,26 +144,24 @@
g_free(mes);
return JSValueMakeNull(ctx);
}
-
- if(argumentCount == 3)
+
+ if (argumentCount == 3)
{
- user_data = (JSObjectRef)arguments[2];
+ user_data = (JSObjectRef) arguments[2];
}
-
+
signal_name = seed_value_to_string(ctx, arguments[0], NULL);
- obj = (GObject *)JSObjectGetPrivate(thisObject);
+ obj = (GObject *) JSObjectGetPrivate(thisObject);
obj_type = G_OBJECT_TYPE(obj);
-
- seed_gobject_signal_connect(ctx, signal_name, obj,
- (JSObjectRef) arguments[1],
- NULL, user_data);
-
+
+ seed_gobject_signal_connect(ctx, signal_name, obj,
+ (JSObjectRef) arguments[1], NULL, user_data);
+
g_free(signal_name);
}
-void seed_add_signals_to_object(JSContextRef ctx,
- JSObjectRef object_ref,
- GObject * obj)
+void seed_add_signals_to_object(JSContextRef ctx,
+ JSObjectRef object_ref, GObject * obj)
{
GType type;
GType *interfaces;
@@ -196,7 +192,7 @@
connect_func =
JSObjectMakeFunctionWithCallback(ctx, NULL,
&seed_gobject_signal_connect_by_name);
- JSValueProtect(ctx, connect_func);
+ JSValueProtect(ctx, connect_func);
seed_object_set_property(ctx, signals_ref, "connect", connect_func);
}
@@ -212,7 +208,7 @@
JSValueRef *args, exception = 0;
JSValueRef ret = 0;
gint i;
-
+
JSContextRef ctx = JSGlobalContextCreateInGroup(context_group,
0);
@@ -220,9 +216,7 @@
for (i = 0; i < n_param_values; i++)
{
- args[i] = seed_value_from_gvalue(ctx,
- (GValue *) & param_values[i],
- 0);
+ args[i] = seed_value_from_gvalue(ctx, (GValue *) & param_values[i], 0);
if (!args[i])
g_error("Error in signal marshal. "
@@ -242,7 +236,7 @@
if (exception)
{
- gchar *mes = seed_exception_to_string(ctx,
+ gchar *mes = seed_exception_to_string(ctx,
exception);
g_warning("Exception in signal handler. %s \n", mes, 0);
g_free(mes);
@@ -262,8 +256,8 @@
g_warning("Exception in signal handler return value. %s \n", mes, 0);
g_free(mes);
}
-
- JSGlobalContextRelease((JSGlobalContextRef)ctx);
+
+ JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
@@ -330,13 +324,13 @@
JSObjectRef this_obj;
signal_privates *privates;
GClosure *closure;
-
+
privates = (signal_privates *) JSObjectGetPrivate(thisObject);
if (!privates)
g_error("Signal constructed with invalid parameters"
"in namespace import \n");
-
- this_obj =
+
+ this_obj =
(JSObjectRef) seed_value_from_object(ctx, privates->object, exception);
if ((argumentCount > 2) || (argumentCount == 0))
@@ -349,29 +343,30 @@
g_free(mes);
return JSValueMakeNull(ctx);
}
-
+
if (argumentCount == 1)
seed_gobject_signal_connect(ctx, privates->signal_name,
privates->object,
- (JSObjectRef) arguments[0], this_obj,
- NULL);
-
+ (JSObjectRef) arguments[0], this_obj, NULL);
+
if (argumentCount == 2)
{
seed_gobject_signal_connect(ctx, privates->signal_name,
privates->object,
(JSObjectRef) arguments[0],
- this_obj,
- (JSObjectRef) arguments[1]);
+ this_obj, (JSObjectRef) arguments[1]);
}
return JSValueMakeNull(ctx);
}
JSStaticFunction signal_static_functions[] =
- { {"connect", seed_gobject_signal_connect_on_property, 0},
- {"emit", seed_gobject_signal_emit, 0},
- {0, 0, 0} };
+ { {"connect", seed_gobject_signal_connect_on_property, 0}
+,
+{"emit", seed_gobject_signal_emit, 0}
+,
+{0, 0, 0}
+};
JSClassDefinition gobject_signal_def = {
0, /* Version, always 0 */
Modified: trunk/libseed/seed-signals.h
==============================================================================
--- trunk/libseed/seed-signals.h (original)
+++ trunk/libseed/seed-signals.h Tue Dec 30 08:36:02 2008
@@ -30,7 +30,7 @@
const GValue * param_values,
gpointer invocation_hint, gpointer marshall_data);
-void seed_add_signals_to_object(JSContextRef ctx,
+void seed_add_signals_to_object(JSContextRef ctx,
JSObjectRef object_ref, GObject * obj);
JSClassDefinition *seed_get_signal_class(void);
extern JSClassRef gobject_signal_class;
Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c (original)
+++ trunk/libseed/seed-structs.c Tue Dec 30 08:36:02 2008
@@ -17,7 +17,6 @@
* Copyright (C) Robert Carr 2008 <carrr rpi edu>
*/
-
#include "seed-private.h"
#include <string.h>
JSClassRef seed_struct_class = 0;
@@ -28,7 +27,7 @@
typedef struct _seed_struct_privates {
gpointer pointer;
GIBaseInfo *info;
-
+
gboolean free_pointer;
} seed_struct_privates;
@@ -36,9 +35,9 @@
{
seed_struct_privates *priv =
(seed_struct_privates *) JSObjectGetPrivate(object);
-
+
SEED_NOTE(STRUCTS, "Finalizing seed_pointer object %p. with "
- "priv->free_pointer = %d with type: %s",
+ "priv->free_pointer = %d with type: %s",
priv->pointer,
priv->free_pointer,
priv->info ? g_base_info_get_name(priv->info) : "[generic]");
@@ -58,10 +57,9 @@
GType type;
GIRegisteredTypeInfo *info =
(GIRegisteredTypeInfo *) g_base_info_get_type(priv->info);
-
+
SEED_NOTE(STRUCTS, "Finalizing boxed object of type %s \n",
g_base_info_get_name(priv->info));
-
type = g_registered_type_info_get_g_type(info);
g_base_info_unref((GIBaseInfo *) info);
@@ -70,8 +68,7 @@
}
-GIFieldInfo *seed_union_find_field(GIUnionInfo * info,
- gchar * field_name)
+GIFieldInfo *seed_union_find_field(GIUnionInfo * info, gchar * field_name)
{
int n, i;
GIFieldInfo *field;
@@ -92,8 +89,7 @@
return 0;
}
-GIFieldInfo *seed_struct_find_field(GIStructInfo * info,
- gchar * field_name)
+GIFieldInfo *seed_struct_find_field(GIStructInfo * info, gchar * field_name)
{
int n, i;
GIFieldInfo *field;
@@ -117,8 +113,7 @@
JSValueRef
seed_field_get_value(JSContextRef ctx,
gpointer object,
- GIFieldInfo * field,
- JSValueRef * exception)
+ GIFieldInfo * field, JSValueRef * exception)
{
GITypeInfo *field_type;
GArgument field_value;
@@ -162,7 +157,6 @@
return ret;
}
-
static JSValueRef
seed_union_get_property(JSContextRef context,
JSObjectRef object,
@@ -184,9 +178,8 @@
SEED_NOTE(STRUCTS, "Getting property on union of type: %s "
"with name %s \n",
- g_base_info_get_name(priv->info),
- cproperty_name);
-
+ g_base_info_get_name(priv->info), cproperty_name);
+
field = seed_union_find_field((GIUnionInfo *) priv->info, cproperty_name);
if (!field)
{
@@ -194,8 +187,7 @@
return 0;
}
- ret = seed_field_get_value(context,
- priv->pointer, field, exception);
+ ret = seed_field_get_value(context, priv->pointer, field, exception);
g_base_info_unref((GIBaseInfo *) field);
@@ -206,17 +198,17 @@
static bool
seed_struct_set_property(JSContextRef context,
- JSObjectRef object,
- JSStringRef property_name,
- JSValueRef value, JSValueRef * exception)
+ JSObjectRef object,
+ JSStringRef property_name,
+ JSValueRef value, JSValueRef * exception)
{
gint length, i, n;
GArgument field_value;
- GIFieldInfo * field;
- GITypeInfo * field_type;
- gchar * cproperty_name;
- seed_struct_privates *priv =
- (seed_struct_privates *)JSObjectGetPrivate(object);
+ GIFieldInfo *field;
+ GITypeInfo *field_type;
+ gchar *cproperty_name;
+ seed_struct_privates *priv =
+ (seed_struct_privates *) JSObjectGetPrivate(object);
gboolean ret;
length = JSStringGetMaximumUTF8CStringSize(property_name);
@@ -225,8 +217,7 @@
SEED_NOTE(STRUCTS, "Setting property on struct of type: %s "
"with name %s \n",
- g_base_info_get_name(priv->info),
- cproperty_name);
+ g_base_info_get_name(priv->info), cproperty_name);
field = seed_struct_find_field((GIStructInfo *) priv->info, cproperty_name);
@@ -235,14 +226,12 @@
g_free(cproperty_name);
return 0;
}
-
+
field_type = g_field_info_get_type(field);
- seed_gi_make_argument(context,
- value,
- field_type, &field_value, exception);
+ seed_gi_make_argument(context, value, field_type, &field_value, exception);
ret = g_field_info_set_field(field, priv->pointer, &field_value);
-
+
g_free(cproperty_name);
g_base_info_unref((GIBaseInfo *) field_type);
g_base_info_unref((GIBaseInfo *) field);
@@ -269,8 +258,7 @@
SEED_NOTE(STRUCTS, "Getting property on struct of type: %s "
"with name %s \n",
- g_base_info_get_name(priv->info),
- cproperty_name);
+ g_base_info_get_name(priv->info), cproperty_name);
field = seed_struct_find_field((GIStructInfo *) priv->info, cproperty_name);
@@ -280,8 +268,7 @@
return 0;
}
- ret = seed_field_get_value(context,
- priv->pointer, field, exception);
+ ret = seed_field_get_value(context, priv->pointer, field, exception);
g_base_info_unref((GIBaseInfo *) field);
g_free(cproperty_name);
@@ -291,15 +278,16 @@
static void seed_enumerate_structlike_properties(JSContextRef ctx,
JSObjectRef object,
- JSPropertyNameAccumulatorRef propertyNames)
+ JSPropertyNameAccumulatorRef
+ propertyNames)
{
- GIFieldInfo * field;
+ GIFieldInfo *field;
gint i, n;
guchar type;
- seed_struct_privates * priv =
- (seed_struct_privates * )JSObjectGetPrivate(object);
- GIBaseInfo * info = priv->info;
-
+ seed_struct_privates *priv =
+ (seed_struct_privates *) JSObjectGetPrivate(object);
+ GIBaseInfo *info = priv->info;
+
if (!info)
return;
@@ -309,27 +297,27 @@
type = 2;
else
g_assert_not_reached();
-
+
(type == 1) ?
- (n = g_struct_info_get_n_fields((GIStructInfo *)info)) :
- (n = g_union_info_get_n_fields((GIUnionInfo *)info));
-
+ (n = g_struct_info_get_n_fields((GIStructInfo *) info)) :
+ (n = g_union_info_get_n_fields((GIUnionInfo *) info));
+
for (i = 0; i < n; i++)
{
- const gchar * cname;
+ const gchar *cname;
JSStringRef jname;
- (type == 1) ?
- (field = g_struct_info_get_field((GIStructInfo *)info, i)) :
- (field = g_union_info_get_field((GIUnionInfo *)info, i));
-
- jname =
- JSStringCreateWithUTF8CString(
- g_base_info_get_name((GIBaseInfo *) field));
+ (type == 1) ?
+ (field = g_struct_info_get_field((GIStructInfo *) info, i)) :
+ (field = g_union_info_get_field((GIUnionInfo *) info, i));
+
+ jname =
+ JSStringCreateWithUTF8CString(g_base_info_get_name
+ ((GIBaseInfo *) field));
g_base_info_unref((GIBaseInfo *) field);
JSPropertyNameAccumulatorAddName(propertyNames, jname);
-
+
JSStringRelease(jname);
}
}
@@ -365,9 +353,9 @@
NULL,
NULL, /* Has Property */
seed_struct_get_property,
- seed_struct_set_property, /* Set Property */
+ seed_struct_set_property, /* Set Property */
NULL, /* Delete Property */
- seed_enumerate_structlike_properties, /* Get Property Names */
+ seed_enumerate_structlike_properties, /* Get Property Names */
NULL, /* Call As Function */
NULL, /* Call As Constructor */
NULL, /* Has Instance */
@@ -387,7 +375,7 @@
seed_union_get_property,
NULL, /* Set Property */
NULL, /* Delete Property */
- seed_enumerate_structlike_properties, /* Get Property Names */
+ seed_enumerate_structlike_properties, /* Get Property Names */
NULL, /* Call As Function */
NULL, /* Call As Constructor */
NULL, /* Has Instance */
@@ -402,7 +390,7 @@
NULL, /* Static Values */
NULL, /* Static Functions */
NULL,
- seed_boxed_finalize,
+ seed_boxed_finalize,
NULL, /* Has Property */
NULL,
NULL, /* Set Property */
@@ -425,8 +413,7 @@
}
void seed_pointer_set_free(JSContextRef ctx,
- JSValueRef pointer,
- gboolean free_pointer)
+ JSValueRef pointer, gboolean free_pointer)
{
if (JSValueIsObjectOfClass(ctx, pointer, seed_pointer_class))
{
@@ -445,7 +432,7 @@
return JSObjectMake(ctx, seed_pointer_class, priv);
}
-JSObjectRef seed_make_union(JSContextRef ctx, gpointer younion,
+JSObjectRef seed_make_union(JSContextRef ctx, gpointer younion,
GIBaseInfo * info)
{
JSObjectRef object;
@@ -467,11 +454,11 @@
finfo = g_union_info_get_method((GIUnionInfo *) info, i);
- seed_gobject_define_property_from_function_info(ctx,
+ seed_gobject_define_property_from_function_info(ctx,
(GIFunctionInfo *)
finfo, object,
TRUE);
-
+
g_base_info_unref((GIBaseInfo *) finfo);
}
}
@@ -479,9 +466,7 @@
return object;
}
-JSObjectRef seed_make_boxed(JSContextRef ctx,
- gpointer boxed,
- GIBaseInfo * info)
+JSObjectRef seed_make_boxed(JSContextRef ctx, gpointer boxed, GIBaseInfo * info)
{
JSObjectRef object;
gint i, n_methods;
@@ -500,8 +485,7 @@
}
JSObjectRef seed_make_struct(JSContextRef ctx,
- gpointer strukt,
- GIBaseInfo * info)
+ gpointer strukt, GIBaseInfo * info)
{
JSObjectRef object;
gint i, n_methods;
@@ -522,11 +506,11 @@
finfo = g_struct_info_get_method((GIStructInfo *) info, i);
- seed_gobject_define_property_from_function_info(ctx,
+ seed_gobject_define_property_from_function_info(ctx,
(GIFunctionInfo *)
finfo, object,
TRUE);
-
+
g_base_info_unref((GIBaseInfo *) finfo);
}
}
@@ -545,7 +529,7 @@
seed_boxed_class = JSClassCreate(&seed_boxed_def);
}
-JSObjectRef
+JSObjectRef
seed_construct_struct_type_with_parameters(JSContextRef ctx,
GIBaseInfo * info,
JSObjectRef parameters,
@@ -556,19 +540,19 @@
GIInfoType type = g_base_info_get_type(info);
JSObjectRef ret;
gint nparams, i, length;
- GIFieldInfo * field = 0;
+ GIFieldInfo *field = 0;
JSPropertyNameArrayRef jsprops;
JSStringRef jsprop_name;
JSValueRef jsprop_value;
GArgument field_value;
- gchar * prop_name;
-
+ gchar *prop_name;
+
SEED_NOTE(CONSTRUCTION, "Constructing struct/union of type: %s \n",
g_base_info_get_name(info));
if (type == GI_INFO_TYPE_STRUCT)
{
- size = g_struct_info_get_size((GIStructInfo *)info);
+ size = g_struct_info_get_size((GIStructInfo *) info);
}
else
{
@@ -576,64 +560,60 @@
}
g_assert(size);
object = g_malloc0(size);
-
+
if (type == GI_INFO_TYPE_STRUCT)
ret = seed_make_struct(ctx, object, info);
else
ret = seed_make_union(ctx, object, info);
-
+
seed_pointer_set_free(ctx, ret, TRUE);
if (!parameters)
return ret;
- jsprops = JSObjectCopyPropertyNames(ctx,
- (JSObjectRef)parameters);
+ jsprops = JSObjectCopyPropertyNames(ctx, (JSObjectRef) parameters);
nparams = JSPropertyNameArrayGetCount(jsprops);
-
+
while (i < nparams)
{
- GITypeInfo * field_type;
+ GITypeInfo *field_type;
jsprop_name = JSPropertyNameArrayGetNameAtIndex(jsprops, i);
-
+
length = JSStringGetMaximumUTF8CStringSize(jsprop_name);
prop_name = g_malloc(length * sizeof(gchar));
JSStringGetUTF8CString(jsprop_name, prop_name, length);
-
+
if (type == GI_INFO_TYPE_STRUCT)
- field = seed_struct_find_field((GIStructInfo *) info,
- prop_name);
+ field = seed_struct_find_field((GIStructInfo *) info, prop_name);
else
- field = seed_union_find_field((GIUnionInfo *) info,
- prop_name);
+ field = seed_union_find_field((GIUnionInfo *) info, prop_name);
if (!field)
{
gchar *mes =
g_strdup_printf("Invalid property for construction: %s",
prop_name);
seed_make_exception(ctx, exception, "PropertyError", mes);
-
+
g_free(mes);
- JSPropertyNameArrayRelease(jsprops);
+ JSPropertyNameArrayRelease(jsprops);
return (JSObjectRef) JSValueMakeNull(ctx);
}
field_type = g_field_info_get_type(field);
-
+
jsprop_value = JSObjectGetProperty(ctx,
- (JSObjectRef)parameters,
+ (JSObjectRef) parameters,
jsprop_name, NULL);
-
+
seed_gi_make_argument(ctx, jsprop_value, field_type,
&field_value, exception);
g_field_info_set_field(field, object, &field_value);
-
+
g_base_info_unref((GIBaseInfo *) field_type);
g_base_info_unref((GIBaseInfo *) field);
-
+
i++;
}
JSPropertyNameArrayRelease(jsprops);
-
return ret;
}
Modified: trunk/libseed/seed-structs.h
==============================================================================
--- trunk/libseed/seed-structs.h (original)
+++ trunk/libseed/seed-structs.h Tue Dec 30 08:36:02 2008
@@ -23,11 +23,11 @@
#define _SEED_STRUCT_H
extern JSClassRef seed_struct_class;
-JSObjectRef seed_make_union(JSContextRef ctx, gpointer younion,
+JSObjectRef seed_make_union(JSContextRef ctx, gpointer younion,
GIBaseInfo * info);
JSObjectRef seed_make_struct(JSContextRef ctx, gpointer strukt,
GIBaseInfo * info);
-JSObjectRef seed_make_boxed(JSContextRef ctx,
+JSObjectRef seed_make_boxed(JSContextRef ctx,
gpointer boxed, GIBaseInfo * info);
JSObjectRef seed_make_pointer(JSContextRef ctx, gpointer pointer);
@@ -35,26 +35,21 @@
JSValueRef
seed_field_get_value(JSContextRef ctx,
gpointer object,
- GIFieldInfo * field,
- JSValueRef * exception);
+ GIFieldInfo * field, JSValueRef * exception);
gpointer seed_pointer_get_pointer(JSContextRef ctx, JSValueRef strukt);
void seed_pointer_set_free(JSContextRef ctx,
- JSValueRef pointer,
- gboolean free_pointer);
+ JSValueRef pointer, gboolean free_pointer);
-GIFieldInfo *seed_struct_find_field(GIStructInfo * info,
- gchar * field_name);
-GIFieldInfo *seed_union_find_field(GIUnionInfo * info,
- gchar * field_name);
+GIFieldInfo *seed_struct_find_field(GIStructInfo * info, gchar * field_name);
+GIFieldInfo *seed_union_find_field(GIUnionInfo * info, gchar * field_name);
-JSObjectRef
+JSObjectRef
seed_construct_struct_type_with_parameters(JSContextRef ctx,
GIBaseInfo * info,
JSObjectRef parameters,
JSValueRef * exception);
-
void seed_structs_init();
#endif
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Tue Dec 30 08:36:02 2008
@@ -19,8 +19,6 @@
* Copyright (C) Tim Horton 2008 <hortont424 gmail com>
*/
-
-
#include "seed-private.h"
#include <string.h>
#include <dlfcn.h>
@@ -31,11 +29,9 @@
JSClassRef seed_callback_class;
SeedEngine *eng;
-static gboolean seed_value_is_gobject(JSContextRef ctx,
- JSValueRef value)
+static gboolean seed_value_is_gobject(JSContextRef ctx, JSValueRef value)
{
- if (!JSValueIsObject(ctx, value) ||
- JSValueIsNull(ctx, value))
+ if (!JSValueIsObject(ctx, value) || JSValueIsNull(ctx, value))
return FALSE;
return JSValueIsObjectOfClass(ctx, value, gobject_class);
@@ -119,15 +115,15 @@
if (arg->v_pointer)
{
GITypeInfo *param_type;
-
+
param_type = g_type_info_get_param_type(type_info, 0);
-
- if (g_type_info_get_tag (param_type) == GI_TYPE_TAG_UTF8)
- g_strfreev (arg->v_pointer);
+
+ if (g_type_info_get_tag(param_type) == GI_TYPE_TAG_UTF8)
+ g_strfreev(arg->v_pointer);
else
g_assert_not_reached();
-
- g_base_info_unref((GIBaseInfo *)param_type);
+
+ g_base_info_unref((GIBaseInfo *) param_type);
}
case GI_TYPE_TAG_INTERFACE:
{
@@ -200,28 +196,27 @@
}
static gboolean
-seed_gi_make_array (JSContextRef ctx,
- JSValueRef array,
- guint length,
- GITypeInfo *param_type,
- void **array_p,
- JSValueRef *exception)
+seed_gi_make_array(JSContextRef ctx,
+ JSValueRef array,
+ guint length,
+ GITypeInfo * param_type,
+ void **array_p, JSValueRef * exception)
{
GITypeTag element_type;
-
+
element_type = g_type_info_get_tag(param_type);
-
+
if (element_type == GI_TYPE_TAG_UTF8)
{
char **result;
guint i;
-
- result = g_new0(char *, length+1);
-
+
+ result = g_new0(char *, length + 1);
+
for (i = 0; i < length; i++)
{
JSValueRef elem = JSObjectGetPropertyAtIndex(ctx,
- (JSObjectRef)array,
+ (JSObjectRef) array,
i,
exception);
result[i] = seed_value_to_string(ctx, elem, exception);
@@ -235,7 +230,7 @@
"Unhandled array element type");
return FALSE;
}
-
+
return TRUE;
}
@@ -354,10 +349,8 @@
}
else if (interface_type == GI_INFO_TYPE_STRUCT)
{
- if (JSValueIsObjectOfClass(ctx,
- value, seed_struct_class))
- arg->v_pointer = seed_pointer_get_pointer(ctx,
- value);
+ if (JSValueIsObjectOfClass(ctx, value, seed_struct_class))
+ arg->v_pointer = seed_pointer_get_pointer(ctx, value);
else
{
GType type =
@@ -372,22 +365,21 @@
// GClosures where expected.
else if (g_type_is_a(type, G_TYPE_CLOSURE))
{
- if (JSObjectIsFunction
- (ctx, (JSObjectRef) value))
+ if (JSObjectIsFunction(ctx, (JSObjectRef) value))
{
arg->v_pointer =
- seed_make_gclosure(ctx,
- (JSObjectRef) value, 0);
+ seed_make_gclosure(ctx, (JSObjectRef) value, 0);
}
}
else
{
- JSObjectRef strukt =
- seed_construct_struct_type_with_parameters(
- ctx,
- interface, (JSObjectRef)value, exception);
- arg->v_pointer = seed_pointer_get_pointer(ctx,
- strukt);
+ JSObjectRef strukt =
+ seed_construct_struct_type_with_parameters(ctx,
+ interface,
+ (JSObjectRef)
+ value,
+ exception);
+ arg->v_pointer = seed_pointer_get_pointer(ctx, strukt);
}
}
g_base_info_unref(interface);
@@ -445,10 +437,9 @@
// callback.
else if (JSObjectIsFunction(ctx, (JSObjectRef) value))
{
- SeedNativeClosure *privates =
- seed_make_native_closure(ctx,
- (GICallableInfo *) interface,
- value);
+ SeedNativeClosure *privates = seed_make_native_closure(ctx,
+ (GICallableInfo *) interface,
+ value);
arg->v_pointer = privates->closure;
break;
}
@@ -456,42 +447,42 @@
}
}
case GI_TYPE_TAG_ARRAY:
- {
- if (JSValueIsNull(ctx, value))
- {
- arg->v_pointer = NULL;
- break;
- }
- else if (!JSValueIsObject(ctx, value))
{
- // Is this right?
- return FALSE;
- }
- else
- {
- GITypeInfo * param_type;
- guint length =
- seed_value_to_int(ctx, seed_object_get_property(ctx,
- (JSObjectRef)value,
- "length"),
- exception);
- if (!length)
+ if (JSValueIsNull(ctx, value))
{
arg->v_pointer = NULL;
break;
}
-
- param_type = g_type_info_get_param_type(type_info, 0);
- if (!seed_gi_make_array(ctx, value, length, param_type,
- &arg->v_pointer, exception))
+ else if (!JSValueIsObject(ctx, value))
{
- g_base_info_unref((GIBaseInfo *) param_type);
+ // Is this right?
return FALSE;
}
- g_base_info_unref((GIBaseInfo *) param_type);
- break;
+ else
+ {
+ GITypeInfo *param_type;
+ guint length =
+ seed_value_to_int(ctx, seed_object_get_property(ctx,
+ (JSObjectRef) value,
+ "length"),
+ exception);
+ if (!length)
+ {
+ arg->v_pointer = NULL;
+ break;
+ }
+
+ param_type = g_type_info_get_param_type(type_info, 0);
+ if (!seed_gi_make_array(ctx, value, length, param_type,
+ &arg->v_pointer, exception))
+ {
+ g_base_info_unref((GIBaseInfo *) param_type);
+ return FALSE;
+ }
+ g_base_info_unref((GIBaseInfo *) param_type);
+ break;
+ }
}
- }
default:
return FALSE;
@@ -574,8 +565,7 @@
{
JSValueRef strukt;
- strukt = seed_make_struct(ctx,
- arg->v_pointer, interface);
+ strukt = seed_make_struct(ctx, arg->v_pointer, interface);
g_base_info_unref(interface);
return strukt;
@@ -639,8 +629,7 @@
}
JSValueRef seed_value_from_gvalue(JSContextRef ctx,
- GValue * gval,
- JSValueRef * exception)
+ GValue * gval, JSValueRef * exception)
{
if (!G_IS_VALUE(gval))
{
@@ -675,12 +664,10 @@
return seed_value_from_string(ctx, (gchar *)
g_value_get_string(gval), exception);
case G_TYPE_POINTER:
- return seed_make_pointer(ctx,
- g_value_get_pointer(gval));
+ return seed_make_pointer(ctx, g_value_get_pointer(gval));
case G_TYPE_PARAM:
// Might need to dup and make a boxed.
- return seed_make_pointer(ctx,
- g_value_get_param(gval));
+ return seed_make_pointer(ctx, g_value_get_param(gval));
}
if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM) ||
@@ -705,18 +692,15 @@
if (type == GI_INFO_TYPE_UNION)
{
- return seed_make_union(ctx,
- g_value_peek_pointer(gval), info);
+ return seed_make_union(ctx, g_value_peek_pointer(gval), info);
}
else if (type == GI_INFO_TYPE_STRUCT)
{
- return seed_make_struct(ctx,
- g_value_peek_pointer(gval), info);
+ return seed_make_struct(ctx, g_value_peek_pointer(gval), info);
}
else if (type == GI_INFO_TYPE_BOXED)
{
- return seed_make_boxed(ctx,
- g_value_dup_boxed(gval), info);
+ return seed_make_boxed(ctx, g_value_dup_boxed(gval), info);
}
}
@@ -726,9 +710,8 @@
gboolean
seed_gvalue_from_seed_value(JSContextRef ctx,
- JSValueRef val,
- GType type, GValue * ret,
- JSValueRef * exception)
+ JSValueRef val,
+ GType type, GValue * ret, JSValueRef * exception)
{
switch (type)
{
@@ -744,25 +727,21 @@
{
g_value_init(ret, type);
if (type == G_TYPE_INT)
- g_value_set_int(ret, seed_value_to_int(ctx,
- val, exception));
+ g_value_set_int(ret, seed_value_to_int(ctx, val, exception));
else
- g_value_set_uint(ret, seed_value_to_uint(ctx,
- val, exception));
+ g_value_set_uint(ret, seed_value_to_uint(ctx, val, exception));
return TRUE;
}
case G_TYPE_CHAR:
{
g_value_init(ret, G_TYPE_CHAR);
- g_value_set_char(ret, seed_value_to_char(ctx,
- val, exception));
+ g_value_set_char(ret, seed_value_to_char(ctx, val, exception));
return TRUE;
}
case G_TYPE_UCHAR:
{
g_value_init(ret, G_TYPE_UCHAR);
- g_value_set_uchar(ret, seed_value_to_uchar(ctx,
- val, exception));
+ g_value_set_uchar(ret, seed_value_to_uchar(ctx, val, exception));
return TRUE;
}
case G_TYPE_LONG:
@@ -776,8 +755,7 @@
{
case G_TYPE_LONG:
g_value_init(ret, G_TYPE_LONG);
- g_value_set_long(ret, seed_value_to_long(ctx,
- val, exception));
+ g_value_set_long(ret, seed_value_to_long(ctx, val, exception));
break;
case G_TYPE_ULONG:
g_value_init(ret, G_TYPE_ULONG);
@@ -855,21 +833,17 @@
if (g_type_is_a(type, G_TYPE_ENUM) && JSValueIsNumber(ctx, val))
{
g_value_init(ret, type);
- ret->data[0].v_long = seed_value_to_long(ctx,
- val, exception);
+ ret->data[0].v_long = seed_value_to_long(ctx, val, exception);
return TRUE;
}
- else if (g_type_is_a(type, G_TYPE_FLAGS)
- && JSValueIsNumber(ctx, val))
+ else if (g_type_is_a(type, G_TYPE_FLAGS) && JSValueIsNumber(ctx, val))
{
g_value_init(ret, type);
- ret->data[0].v_long = seed_value_to_long(ctx,
- val, exception);
+ ret->data[0].v_long = seed_value_to_long(ctx, val, exception);
return TRUE;
}
else if (g_type_is_a(type, G_TYPE_OBJECT)
- && (JSValueIsNull(ctx, val)
- || seed_value_is_gobject(ctx, val)))
+ && (JSValueIsNull(ctx, val) || seed_value_is_gobject(ctx, val)))
{
GObject *o = seed_value_to_object(ctx,
val, exception);
@@ -896,16 +870,16 @@
{
if (JSValueIsObject(ctx, val))
{
- GIBaseInfo * info = g_irepository_find_by_gtype(0, type);
+ GIBaseInfo *info = g_irepository_find_by_gtype(0, type);
JSObjectRef new_struct;
if (!info)
return FALSE;
- new_struct =
- seed_construct_struct_type_with_parameters(ctx,
- info,
- (JSObjectRef)val,
- exception);
+ new_struct =
+ seed_construct_struct_type_with_parameters(ctx,
+ info,
+ (JSObjectRef)
+ val, exception);
p = seed_pointer_get_pointer(ctx, new_struct);
if (p)
{
@@ -944,8 +918,7 @@
if (value)
{
- JSObjectSetProperty(ctx, (JSObjectRef) object,
- jname, value, 0, 0);
+ JSObjectSetProperty(ctx, (JSObjectRef) object, jname, value, 0, 0);
}
JSStringRelease(jname);
@@ -956,8 +929,7 @@
/* TODO: Make some macros or something for making exceptions, code is littered
with annoyingness right now */
gboolean seed_value_to_boolean(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsBoolean(ctx, val))
{
@@ -975,15 +947,13 @@
}
JSValueRef seed_value_from_boolean(JSContextRef ctx,
- gboolean val,
- JSValueRef * exception)
+ gboolean val, JSValueRef * exception)
{
return JSValueMakeBoolean(ctx, val);
}
guint seed_value_to_uint(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1000,15 +970,12 @@
}
JSValueRef seed_value_from_uint(JSContextRef ctx,
- guint val,
- JSValueRef * exception)
+ guint val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
-gint seed_value_to_int(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+gint seed_value_to_int(JSContextRef ctx, JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1022,15 +989,13 @@
}
JSValueRef seed_value_from_int(JSContextRef ctx,
- gint val,
- JSValueRef * exception)
+ gint val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
gchar seed_value_to_char(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
gint cv;
@@ -1055,15 +1020,13 @@
}
JSValueRef seed_value_from_char(JSContextRef ctx,
- gchar val,
- JSValueRef * exception)
+ gchar val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
guchar seed_value_to_uchar(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
guint cv;
@@ -1089,15 +1052,13 @@
}
JSValueRef seed_value_from_uchar(JSContextRef ctx,
- guchar val,
- JSValueRef * exception)
+ guchar val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
glong seed_value_to_long(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1111,15 +1072,13 @@
}
JSValueRef seed_value_from_long(JSContextRef ctx,
- glong val,
- JSValueRef * exception)
+ glong val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
gulong seed_value_to_ulong(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1134,15 +1093,13 @@
}
JSValueRef seed_value_from_ulong(JSContextRef ctx,
- gulong val,
- JSValueRef * exception)
+ gulong val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
gint64 seed_value_to_int64(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1158,15 +1115,13 @@
}
JSValueRef seed_value_from_int64(JSContextRef ctx,
- gint64 val,
- JSValueRef * exception)
+ gint64 val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
guint64 seed_value_to_uint64(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1182,15 +1137,13 @@
}
JSValueRef seed_value_from_uint64(JSContextRef ctx,
- guint64 val,
- JSValueRef * exception)
+ guint64 val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
gfloat seed_value_to_float(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1205,15 +1158,13 @@
}
JSValueRef seed_value_from_float(JSContextRef ctx,
- gfloat val,
- JSValueRef * exception)
+ gfloat val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
gdouble seed_value_to_double(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
if (!JSValueIsNumber(ctx, val))
{
@@ -1228,15 +1179,13 @@
}
JSValueRef seed_value_from_double(JSContextRef ctx,
- gdouble val,
- JSValueRef * exception)
+ gdouble val, JSValueRef * exception)
{
return JSValueMakeNumber(ctx, (gdouble) val);
}
gchar *seed_value_to_string(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
JSStringRef jsstr = 0;
JSValueRef func, str;
@@ -1246,13 +1195,11 @@
if (val == NULL)
return NULL;
- if (JSValueIsBoolean(ctx, val)
- || JSValueIsNumber(ctx, val))
+ if (JSValueIsBoolean(ctx, val) || JSValueIsNumber(ctx, val))
{
buf = g_strdup_printf("%lf", JSValueToNumber(ctx, val, NULL));
}
- else if (JSValueIsNull(ctx, val)
- || JSValueIsUndefined(ctx, val))
+ else if (JSValueIsNull(ctx, val) || JSValueIsUndefined(ctx, val))
{
buf = strdup("[null]");
}
@@ -1261,8 +1208,7 @@
if (!JSValueIsString(ctx, val)) // In this case,
// it's an object
{
- func = seed_object_get_property(ctx,
- (JSObjectRef) val, "toString");
+ func = seed_object_get_property(ctx, (JSObjectRef) val, "toString");
str =
JSObjectCallAsFunction(ctx,
(JSObjectRef) func,
@@ -1283,9 +1229,8 @@
return buf;
}
-JSValueRef seed_value_from_string(JSContextRef ctx,
- const gchar * val,
- JSValueRef * exception)
+JSValueRef seed_value_from_string(JSContextRef ctx,
+ const gchar * val, JSValueRef * exception)
{
JSStringRef jsstr = JSStringCreateWithUTF8CString(val);
JSValueRef valstr = JSValueMakeString(ctx, jsstr);
@@ -1295,8 +1240,7 @@
}
GObject *seed_value_to_object(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception)
+ JSValueRef val, JSValueRef * exception)
{
GObject *gobject;
@@ -1305,7 +1249,7 @@
* the existing code depends on null Objects not throwing an exception
* however, needs testing at higher level if value can be null
* (through GI)
- */
+ */
if (JSValueIsNull(ctx, val))
return 0;
@@ -1323,8 +1267,7 @@
}
JSValueRef seed_value_from_object(JSContextRef ctx,
- GObject * val,
- JSValueRef * exception)
+ GObject * val, JSValueRef * exception)
{
if (val == NULL)
return JSValueMakeNull(ctx);
Modified: trunk/libseed/seed-types.h
==============================================================================
--- trunk/libseed/seed-types.h (original)
+++ trunk/libseed/seed-types.h Tue Dec 30 08:36:02 2008
@@ -25,8 +25,7 @@
#include "seed-private.h"
JSValueRef seed_value_from_gvalue(JSContextRef ctx,
- GValue * gval,
- JSValueRef * exception);
+ GValue * gval, JSValueRef * exception);
JSValueRef seed_object_get_property(JSContextRef ctx,
JSObjectRef val, const gchar * name);
@@ -53,98 +52,72 @@
GITypeInfo * type_info, GArgument * arg);
gboolean seed_value_to_boolean(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_boolean(JSContextRef ctx,
- gboolean val,
- JSValueRef * exception);
+ gboolean val, JSValueRef * exception);
guint seed_value_to_uint(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_uint(JSContextRef ctx,
- guint val,
- JSValueRef * exception);
+ guint val, JSValueRef * exception);
gint seed_value_to_int(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_int(JSContextRef ctx,
- gint val,
- JSValueRef * exception);
+ gint val, JSValueRef * exception);
gchar seed_value_to_char(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_char(JSContextRef ctx,
- gchar val,
- JSValueRef * exception);
+ gchar val, JSValueRef * exception);
guchar seed_value_to_uchar(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_uchar(JSContextRef ctx,
- guchar val,
- JSValueRef * exception);
+ guchar val, JSValueRef * exception);
glong seed_value_to_long(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_long(JSContextRef ctx,
- glong val,
- JSValueRef * exception);
+ glong val, JSValueRef * exception);
gulong seed_value_to_ulong(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_ulong(JSContextRef ctx,
- gulong val,
- JSValueRef * exception);
+ gulong val, JSValueRef * exception);
gint64 seed_value_to_int64(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_int64(JSContextRef ctx,
- gint64 val,
- JSValueRef * exception);
+ gint64 val, JSValueRef * exception);
guint64 seed_value_to_uint64(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_uint64(JSContextRef ctx,
- guint64 val,
- JSValueRef * exception);
+ guint64 val, JSValueRef * exception);
gfloat seed_value_to_float(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_float(JSContextRef ctx,
- gfloat val,
- JSValueRef * exception);
+ gfloat val, JSValueRef * exception);
gdouble seed_value_to_double(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_double(JSContextRef ctx,
- gdouble val,
- JSValueRef * exception);
+ gdouble val, JSValueRef * exception);
-gchar *seed_value_to_string(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
-JSValueRef seed_value_from_string(JSContextRef ctx,
- const gchar * val,
- JSValueRef * exception);
+gchar *seed_value_to_string(JSContextRef ctx,
+ JSValueRef val, JSValueRef * exception);
+JSValueRef seed_value_from_string(JSContextRef ctx,
+ const gchar * val, JSValueRef * exception);
GObject *seed_value_to_object(JSContextRef ctx,
- JSValueRef val,
- JSValueRef * exception);
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_object(JSContextRef ctx,
- GObject * val,
- JSValueRef * exception);
+ GObject * val, JSValueRef * exception);
void seed_toggle_ref(gpointer data, GObject * object, gboolean is_last_ref);
Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h (original)
+++ trunk/libseed/seed.h Tue Dec 30 08:36:02 2008
@@ -60,21 +60,20 @@
typedef struct _SeedEngine {
SeedGlobalContext context;
SeedValue global;
-
+
SeedContextGroup group;
} SeedEngine;
-
/*
* seed-engine.c
*/
-SeedEngine * seed_init(gint * argc, gchar *** argv);
+SeedEngine *seed_init(gint * argc, gchar *** argv);
SeedScript *seed_make_script(SeedContext ctx,
const gchar * s, const gchar * source_url,
gint line_number);
SeedException seed_script_exception(SeedScript * s);
-void seed_make_exception(SeedContext ctx, SeedException e,
+void seed_make_exception(SeedContext ctx, SeedException e,
gchar * name, gchar * message);
gchar *seed_exception_get_name(SeedContext ctx, SeedException e);
gchar *seed_exception_get_message(SeedContext ctx, SeedException e);
@@ -82,38 +81,35 @@
gchar *seed_exception_get_file(SeedContext ctx, SeedException e);
gchar *seed_exception_to_string(SeedContext ctx, SeedException e);
-SeedValue seed_evaluate(SeedContext ctx,
- SeedScript * s, SeedObject this);
+SeedValue seed_evaluate(SeedContext ctx, SeedScript * s, SeedObject this);
/*
* seed-api.c
*/
-SeedGlobalContext seed_context_create(SeedContextGroup group,
- SeedClass global_class);
+SeedGlobalContext seed_context_create(SeedContextGroup group,
+ SeedClass global_class);
SeedGlobalContext seed_context_ref(SeedGlobalContext ctx);
void seed_context_unref(SeedGlobalContext ctx);
SeedValue seed_make_null(SeedContext ctx);
-SeedObject seed_make_object(SeedContext ctx,
- SeedClass class, gpointer private);
+SeedObject seed_make_object(SeedContext ctx, SeedClass class, gpointer private);
gpointer seed_object_get_private(SeedObject object);
void seed_object_set_private(SeedObject object, gpointer value);
-
SeedString seed_string_ref(SeedString string);
void seed_string_unref(SeedString string);
gsize seed_string_get_maximum_size(SeedString string);
gsize seed_string_to_utf8_buffer(SeedString string, gchar * buffer,
- size_t buffer_size);
+ size_t buffer_size);
gboolean seed_string_is_equal(SeedString a, SeedString b);
gboolean seed_string_is_equal_utf8(SeedString a, const gchar * b);
-SeedValue seed_object_call(SeedContext ctx,
+SeedValue seed_object_call(SeedContext ctx,
SeedObject object,
SeedObject this,
gsize argument_count,
@@ -127,114 +123,85 @@
*/
gboolean seed_object_set_property(SeedContext ctx,
SeedObject object,
- const gchar * name,
- SeedValue value);
+ const gchar * name, SeedValue value);
SeedValue seed_object_get_property(SeedContext ctx,
- SeedObject object,
- const gchar * name);
+ SeedObject object, const gchar * name);
void seed_object_set_property_at_index(SeedContext ctx,
- SeedObject object,
- gint index,
- SeedValue value,
- SeedException * exception);
+ SeedObject object,
+ gint index,
+ SeedValue value,
+ SeedException * exception);
gboolean seed_value_to_boolean(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_boolean(SeedContext ctx,
- gboolean val,
- SeedException * exception);
+ gboolean val, SeedException * exception);
guint seed_value_to_uint(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_uint(SeedContext ctx,
- guint val,
- SeedException * exception);
+ guint val, SeedException * exception);
-gint seed_value_to_int(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+gint seed_value_to_int(SeedContext ctx,
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_int(SeedContext ctx,
- gint val,
- SeedException * exception);
+ gint val, SeedException * exception);
gchar seed_value_to_char(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_char(SeedContext ctx,
- gchar val,
- SeedException * exception);
+ gchar val, SeedException * exception);
guchar seed_value_to_uchar(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_uchar(SeedContext ctx,
- guchar val,
- SeedException * exception);
+ guchar val, SeedException * exception);
glong seed_value_to_long(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_long(SeedContext ctx,
- glong val,
- SeedException * exception);
+ glong val, SeedException * exception);
gulong seed_value_to_ulong(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_ulong(SeedContext ctx,
- gulong val,
- SeedException * exception);
+ gulong val, SeedException * exception);
gint64 seed_value_to_int64(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_int64(SeedContext ctx,
- gint64 val,
- SeedException * exception);
+ gint64 val, SeedException * exception);
guint64 seed_value_to_uint64(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_uint64(SeedContext ctx,
- guint64 val,
- SeedException * exception);
+ guint64 val, SeedException * exception);
gfloat seed_value_to_float(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_float(SeedContext ctx,
- gfloat val,
- SeedException * exception);
+ gfloat val, SeedException * exception);
gdouble seed_value_to_double(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_double(SeedContext ctx,
- gdouble val,
- SeedException * exception);
+ gdouble val, SeedException * exception);
gchar *seed_value_to_string(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_string(SeedContext ctx,
- gchar * val,
- SeedException * exception);
+ gchar * val, SeedException * exception);
GObject *seed_value_to_object(SeedContext ctx,
- SeedValue val,
- SeedException * exception);
+ SeedValue val, SeedException * exception);
SeedValue seed_value_from_object(SeedContext ctx,
- GObject * val,
- SeedException * exception);
+ GObject * val, SeedException * exception);
-gpointer seed_pointer_get_pointer(SeedContext ctx,
- SeedValue pointer);
+gpointer seed_pointer_get_pointer(SeedContext ctx, SeedValue pointer);
typedef void (*SeedFunctionCallback) (SeedContext ctx,
SeedObject function,
@@ -247,7 +214,6 @@
gchar * name, SeedFunctionCallback callback,
SeedObject object);
-
typedef void (*SeedModuleInitCallback) (SeedEngine * eng);
typedef void (*SeedObjectInitializeCallback) (SeedContext ctx,
@@ -257,77 +223,76 @@
*this callback has undefined results */
typedef void (*SeedObjectFinalizeCallback) (SeedObject object);
-typedef gboolean (*SeedObjectHasPropertyCallback) (SeedContext ctx,
+typedef gboolean(*SeedObjectHasPropertyCallback) (SeedContext ctx,
+ SeedObject object,
+ SeedString string);
+typedef SeedValue(*SeedObjectGetPropertyCallback) (SeedContext ctx,
SeedObject object,
- SeedString string);
-typedef SeedValue (*SeedObjectGetPropertyCallback) (SeedContext ctx,
+ SeedString property_name,
+ SeedException * e);
+typedef gboolean(*SeedObjectSetPropertyCallback) (SeedContext ctx,
+ SeedObject object,
+ SeedString property_name,
+ SeedValue value,
+ SeedException * e);
+typedef gboolean(*SeedObjectDeletePropertyCallback) (SeedContext ctx,
SeedObject object,
SeedString property_name,
+ SeedValue value,
SeedException * e);
-typedef gboolean (*SeedObjectSetPropertyCallback) (SeedContext ctx,
- SeedObject object,
- SeedString property_name,
- SeedValue value,
- SeedException * e);
-typedef gboolean (*SeedObjectDeletePropertyCallback) (SeedContext ctx,
- SeedObject object,
- SeedString property_name,
- SeedValue value,
- SeedException * e);
/* TODO: Have to decide on accumulator API
//typedef void (*SeedObjectGetPropertyNamesCallback) (SeedContext ctx, */
typedef void (*SeedObjectGetPropertyNamesCallback) (void);
-typedef SeedValue (*SeedObjectCallAsFunctionCallback) (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- gsize argument_count,
- const SeedValue arguments[],
- SeedException * exception);
-typedef SeedValue (*SeedObjectCallAsConstructorCallback)
- (SeedContext ctx,
- SeedObject constructor,
- gsize argument_count,
- const SeedValue arguments[],
- SeedException * exception);
-
-typedef gboolean (*SeedObjectHasInstanceCallback) (SeedContext ctx,
- SeedObject constructor,
- SeedObject instance_p,
- SeedException * exception);
-
-typedef SeedValue (*SeedObjectConvertToTypeCallback) (SeedContext ctx,
- SeedObject object,
- SeedType type,
- SeedException * exception);
-
-typedef struct _seed_static_value
-{
- const gchar * const name;
+typedef SeedValue(*SeedObjectCallAsFunctionCallback) (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue
+ arguments[],
+ SeedException *
+ exception);
+typedef SeedValue(*SeedObjectCallAsConstructorCallback) (SeedContext ctx,
+ SeedObject constructor,
+ gsize argument_count,
+ const SeedValue
+ arguments[],
+ SeedException *
+ exception);
+
+typedef gboolean(*SeedObjectHasInstanceCallback) (SeedContext ctx,
+ SeedObject constructor,
+ SeedObject instance_p,
+ SeedException * exception);
+
+typedef SeedValue(*SeedObjectConvertToTypeCallback) (SeedContext ctx,
+ SeedObject object,
+ SeedType type,
+ SeedException * exception);
+
+typedef struct _seed_static_value {
+ const gchar *const name;
SeedObjectGetPropertyCallback get_property;
SeedObjectSetPropertyCallback set_property;
SeedPropertyAttributes attributes;
} seed_static_value;
-typedef struct _seed_static_function
-{
- const gchar * const name;
+typedef struct _seed_static_function {
+ const gchar *const name;
SeedObjectCallAsFunctionCallback callback;
SeedPropertyAttributes attributes;
} seed_static_function;
-
-typedef struct _seed_class_definition
-{
- int version; /* Always 0 */
+typedef struct _seed_class_definition {
+ int version; /* Always 0 */
SeedClassAttributes attributes;
- const gchar * class_name;
+ const gchar *class_name;
SeedClass parent_class;
- const seed_static_value * static_values;
- const seed_static_function * static_functions;
+ const seed_static_value *static_values;
+ const seed_static_function *static_functions;
SeedObjectInitializeCallback initialize;
SeedObjectFinalizeCallback finalize;
@@ -342,8 +307,7 @@
SeedObjectConvertToTypeCallback convert_to_type;
} seed_class_definition;
-seed_class_definition seed_empty_class =
-{
+seed_class_definition seed_empty_class = {
0,
0,
0,
@@ -367,6 +331,7 @@
SeedObject seed_make_constructor(SeedContext ctx,
SeedClass class,
- SeedObjectCallAsConstructorCallback constructor);
+ SeedObjectCallAsConstructorCallback
+ constructor);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]