seed r724 - in trunk: libseed modules/Multiprocessing modules/canvas modules/readline modules/sqlite
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r724 - in trunk: libseed modules/Multiprocessing modules/canvas modules/readline modules/sqlite
- Date: Wed, 14 Jan 2009 05:10:40 +0000 (UTC)
Author: hortont
Date: Wed Jan 14 05:10:40 2009
New Revision: 724
URL: http://svn.gnome.org/viewvc/seed?rev=724&view=rev
Log:
Indentation update.
Modified:
trunk/libseed/indent.sh
trunk/libseed/seed-api.c
trunk/libseed/seed-builtins.c
trunk/libseed/seed-closure.c
trunk/libseed/seed-engine.c
trunk/libseed/seed-gtype.c
trunk/libseed/seed-signals.c
trunk/libseed/seed-structs.c
trunk/libseed/seed-structs.h
trunk/libseed/seed-types.c
trunk/libseed/seed-types.h
trunk/libseed/seed.h
trunk/modules/Multiprocessing/multi.c
trunk/modules/canvas/seed-canvas.c
trunk/modules/readline/seed-readline.c
trunk/modules/sqlite/seed-sqlite.c
Modified: trunk/libseed/indent.sh
==============================================================================
--- trunk/libseed/indent.sh (original)
+++ trunk/libseed/indent.sh Wed Jan 14 05:10:40 2009
@@ -1,5 +1,3 @@
-indent -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -nce -ci4 \
- -cli0 -d0 -di1 -nfc1 -i4 -ip0 -l80 -lp -npcs -nprs -npsl -sai \
- -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts4 -il1 -bl -bli0 *.c *.h
-
-
+indent -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -nce -ci4 \
+ -cli0 -d0 -di1 -nfc1 -i4 -ip0 -l80 -lp -npcs -nprs -npsl -sai \
+ -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts4 -il1 -bl -bli0 *.c *.h
Modified: trunk/libseed/seed-api.c
==============================================================================
--- trunk/libseed/seed-api.c (original)
+++ trunk/libseed/seed-api.c Wed Jan 14 05:10:40 2009
@@ -54,10 +54,9 @@
}
void seed_object_set_property_at_index(JSContextRef ctx,
- JSObjectRef object,
- gint index,
- JSValueRef value,
- JSValueRef * exception)
+ JSObjectRef object,
+ gint index,
+ JSValueRef value, JSValueRef * exception)
{
JSObjectSetPropertyAtIndex(ctx, object, index, value, exception);
}
@@ -109,7 +108,7 @@
{
JSValueRef ret;
JSStringRef script = JSStringCreateWithUTF8CString(source);
-
+
ret = JSEvaluateScript(ctx, script, NULL, NULL, 0, NULL);
JSStringRelease(script);
Modified: trunk/libseed/seed-builtins.c
==============================================================================
--- trunk/libseed/seed-builtins.c (original)
+++ trunk/libseed/seed-builtins.c Wed Jan 14 05:10:40 2009
@@ -40,7 +40,7 @@
{
gchar *mes =
g_strdup_printf("Seed.include expected 1 argument, "
- "got %d", (unsigned int) argumentCount);
+ "got %d", (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
return JSValueMakeNull(ctx);
@@ -53,7 +53,7 @@
{
gchar *mes = g_strdup_printf("File not found: %s.\n", import_file);
seed_make_exception(ctx, exception, "FileNotFound", mes);
-
+
g_free(import_file);
g_free(buffer);
g_free(mes);
@@ -96,7 +96,7 @@
{
gchar *mes =
g_strdup_printf("Seed.print expected 1 argument," " got %d",
- (unsigned int) argumentCount);
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
return JSValueMakeNull(ctx);
@@ -146,7 +146,7 @@
{
gchar *mes =
g_strdup_printf("Seed.introspect expected 1 argument, "
- "got %d", (unsigned int) argumentCount);
+ "got %d", (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
return JSValueMakeNull(ctx);
@@ -213,7 +213,7 @@
{
gchar *mes = g_strdup_printf("Seed.check_syntax expected "
"1 argument, got %d",
- (unsigned int) argumentCount);
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
}
@@ -289,7 +289,7 @@
else if (argumentCount > 1)
{
gchar *mes = g_strdup_printf("Seed.quit expected " "1 argument, got %d",
- (unsigned int) argumentCount);
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
}
@@ -318,15 +318,17 @@
arrayObj = JSObjectMake(local_eng->context, NULL, NULL);
- if(argc)
+ if (argc)
{
for (i = 0; i < *argc; ++i)
{
// TODO: exceptions!
JSObjectSetPropertyAtIndex(local_eng->context, arrayObj, i,
- seed_value_from_string(local_eng->context,
- (*argv)[i], 0), NULL);
+ seed_value_from_string(local_eng->
+ context,
+ (*argv)[i], 0),
+ NULL);
}
argcref = seed_value_from_int(local_eng->context, *argc, 0);
@@ -335,7 +337,7 @@
{
argcref = seed_value_from_int(local_eng->context, 0, 0);
}
-
+
seed_object_set_property(local_eng->context, arrayObj, "length", argcref);
seed_object_set_property(local_eng->context, obj, "argv", arrayObj);
}
Modified: trunk/libseed/seed-closure.c
==============================================================================
--- trunk/libseed/seed-closure.c (original)
+++ trunk/libseed/seed-closure.c Wed Jan 14 05:10:40 2009
@@ -374,19 +374,19 @@
cif = g_new0(ffi_cif, 1);
privates = g_new0(SeedNativeClosure, 1);
- privates->info = (GICallableInfo *)g_base_info_ref((GIBaseInfo *)info);
+ privates->info = (GICallableInfo *) g_base_info_ref((GIBaseInfo *) info);
privates->function = function;
privates->cif = cif;
for (i = 0; i < num_args; i++)
{
- GITypeInfo * type;
-
+ GITypeInfo *type;
+
arg_info = g_callable_info_get_arg(info, i);
type = g_arg_info_get_type(arg_info);
arg_types[i] = get_ffi_type(type);
- g_base_info_unref((GIBaseInfo *)arg_info);
- g_base_info_unref((GIBaseInfo *)type);
+ g_base_info_unref((GIBaseInfo *) arg_info);
+ g_base_info_unref((GIBaseInfo *) type);
}
arg_types[num_args] = 0;
@@ -403,8 +403,8 @@
(JSValueRef) JSObjectMake(ctx,
seed_native_callback_class,
privates));
-
- g_base_info_unref((GIBaseInfo *)return_type);
+
+ g_base_info_unref((GIBaseInfo *) return_type);
return privates;
}
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Wed Jan 14 05:10:40 2009
@@ -74,7 +74,7 @@
}
ret = seed_construct_struct_type_with_parameters(ctx, info,
parameters, exception);
-
+
return (JSObjectRef) ret;
}
@@ -107,7 +107,8 @@
if (argumentCount > 1)
{
gchar *mes = g_strdup_printf("Constructor expects"
- " 1 argument, got %d", (unsigned int) argumentCount);
+ " 1 argument, got %d",
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
@@ -220,7 +221,8 @@
if (argumentCount != 1)
{
gchar *mes = g_strdup_printf("GObject equals comparison expected"
- " 1 argument, got %d", (unsigned int) argumentCount);
+ " 1 argument, got %d",
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
@@ -377,7 +379,8 @@
{
if (G_IS_OBJECT(retval.v_pointer))
{
- sunk = G_IS_INITIALLY_UNOWNED(G_OBJECT(retval.v_pointer));
+ sunk =
+ G_IS_INITIALLY_UNOWNED(G_OBJECT(retval.v_pointer));
if (sunk)
g_object_ref_sink(G_OBJECT(retval.v_pointer));
}
@@ -445,15 +448,14 @@
static JSObjectRef
seed_gobject_named_constructor_invoked(JSContextRef ctx,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef * exception)
-{
- return (JSObjectRef)seed_gobject_method_invoked(ctx, constructor,
- NULL, argumentCount,
- arguments,
- exception);
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ return (JSObjectRef) seed_gobject_method_invoked(ctx, constructor,
+ NULL, argumentCount,
+ arguments, exception);
}
void
@@ -964,7 +966,7 @@
seed_object_set_property(ctx, enum_class, name, value_ref);
g_free(name);
- g_base_info_unref((GIBaseInfo*)val);
+ g_base_info_unref((GIBaseInfo *) val);
}
}
@@ -1002,22 +1004,19 @@
flags = g_function_info_get_flags(finfo);
if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
{
- JSObjectRef constructor =
- JSObjectMake(ctx,
- gobject_named_constructor_class,
- finfo);
- const gchar * fname =
- g_base_info_get_name((GIBaseInfo *)
- finfo);
+ JSObjectRef constructor = JSObjectMake(ctx,
+ gobject_named_constructor_class,
+ finfo);
+ const gchar *fname =
+ g_base_info_get_name((GIBaseInfo *) finfo);
if (strstr(fname, "new_") == fname)
fname += 4;
else if (!strcmp(fname, "new"))
- fname ="c_new";
-
+ fname = "c_new";
+
seed_object_set_property(ctx,
constructor_ref,
- fname,
- constructor);
+ fname, constructor);
}
else if (!(flags & GI_FUNCTION_IS_METHOD))
{
@@ -1057,19 +1056,17 @@
finfo = g_struct_info_get_method((GIStructInfo *) info, i);
flags = g_function_info_get_flags(finfo);
-
+
if (flags & GI_FUNCTION_IS_METHOD)
- g_base_info_unref((GIBaseInfo *)finfo);
+ g_base_info_unref((GIBaseInfo *) finfo);
else
seed_gobject_define_property_from_function_info
(ctx, finfo, struct_ref, FALSE);
}
-
- proto = seed_struct_prototype(ctx,
- info);
- seed_object_set_property(ctx, struct_ref,
- "prototype", proto);
+
+ proto = seed_struct_prototype(ctx, info);
+ seed_object_set_property(ctx, struct_ref, "prototype", proto);
seed_object_set_property(ctx, namespace_ref,
g_base_info_get_name(info), struct_ref);
@@ -1093,19 +1090,17 @@
finfo = g_union_info_get_method((GIUnionInfo *) info, i);
flags = g_function_info_get_flags(finfo);
-
+
if (flags & GI_FUNCTION_IS_METHOD)
- g_base_info_unref((GIBaseInfo *)finfo);
+ g_base_info_unref((GIBaseInfo *) finfo);
else
seed_gobject_define_property_from_function_info
(ctx, finfo, struct_ref, FALSE);
}
- proto = seed_union_prototype(ctx,
- info);
- seed_object_set_property(ctx, struct_ref,
- "prototype", proto);
+ proto = seed_union_prototype(ctx, info);
+ seed_object_set_property(ctx, struct_ref, "prototype", proto);
seed_object_set_property(ctx, namespace_ref,
g_base_info_get_name(info), struct_ref);
@@ -1124,7 +1119,7 @@
else if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_CONSTANT))
{
GArgument argument;
- GITypeInfo * constant_type =
+ GITypeInfo *constant_type =
g_constant_info_get_type((GIConstantInfo *) info);
JSValueRef constant_value;
@@ -1135,8 +1130,8 @@
seed_object_set_property(ctx, namespace_ref,
g_base_info_get_name(info),
constant_value);
-
- g_base_info_unref((GIBaseInfo *)constant_type);
+
+ g_base_info_unref((GIBaseInfo *) constant_type);
}
g_base_info_unref(info);
@@ -1248,7 +1243,7 @@
JSClassDefinition gobject_named_constructor_def = {
0, /* Version, always 0 */
0,
- "gobject_named_constructor", /* Class Name */
+ "gobject_named_constructor", /* Class Name */
NULL, /* Parent Class */
NULL, /* Static Values */
NULL, /* Static Functions */
@@ -1327,7 +1322,8 @@
static GOptionEntry seed_args[] = {
#ifdef SEED_ENABLE_DEBUG
{"seed-debug", 0, 0, G_OPTION_ARG_CALLBACK, seed_arg_debug_cb,
- "Seed debugging messages to show. Comma separated list of: all, misc, finalization, initialization, construction, invocation, signal, structs, gtype.", "FLAGS"},
+ "Seed debugging messages to show. Comma separated list of: all, misc, finalization, initialization, construction, invocation, signal, structs, gtype.",
+ "FLAGS"},
{"seed-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, seed_arg_no_debug_cb,
"Disable Seed debugging", "FLAGS"},
#endif /* SEED_ENABLE_DEBUG */
@@ -1410,7 +1406,8 @@
JSClassRetain(gobject_method_class);
gobject_constructor_class = JSClassCreate(&gobject_constructor_def);
JSClassRetain(gobject_constructor_class);
- gobject_named_constructor_class = JSClassCreate(&gobject_named_constructor_def);
+ gobject_named_constructor_class =
+ JSClassCreate(&gobject_named_constructor_def);
JSClassRetain(gobject_named_constructor_class);
gobject_signal_class = JSClassCreate(seed_get_signal_class());
JSClassRetain(gobject_signal_class);
@@ -1428,8 +1425,7 @@
seed_create_function(eng->context, "import_namespace",
&seed_gi_import_namespace, seed_obj_ref);
- g_irepository_require(g_irepository_get_default(), "GObject",
- NULL, 0, 0);
+ g_irepository_require(g_irepository_get_default(), "GObject", NULL, 0, 0);
g_irepository_require(g_irepository_get_default(), "GIRepository",
NULL, 0, 0);
Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c (original)
+++ trunk/libseed/seed-gtype.c Wed Jan 14 05:10:40 2009
@@ -21,8 +21,8 @@
#include <sys/mman.h>
JSClassRef seed_gtype_class;
-GIBaseInfo * objectclass_info = NULL;
-GIBaseInfo * paramspec_info = NULL;
+GIBaseInfo *objectclass_info = NULL;
+GIBaseInfo *paramspec_info = NULL;
GQuark qgetter;
GQuark qsetter;
@@ -216,7 +216,7 @@
{
gchar *mes =
g_strdup_printf("Property installation expected 1 argument"
- " got %d \n", (unsigned int) argumentCount);
+ " got %d \n", (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
@@ -268,7 +268,7 @@
if (argumentCount != 1)
{
gchar *mes = g_strdup_printf("Signal constructor expected 1 argument"
- " got %d \n", (unsigned int) argumentCount);
+ " got %d \n", (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
return (JSObjectRef) JSValueMakeNull(ctx);
@@ -357,48 +357,43 @@
}
static void seed_gtype_builtin_set_property(GObject * object,
- guint property_id,
- const GValue *value,
- GParamSpec *spec)
+ guint property_id,
+ const GValue * value,
+ GParamSpec * spec)
{
JSContextRef ctx = JSGlobalContextCreateInGroup(context_group, 0);
- gchar * name = g_strjoin(NULL, "_", spec->name, NULL);
- JSObjectRef jsobj = (JSObjectRef)seed_value_from_object(ctx, object, 0);
-
- seed_object_set_property(ctx,
- jsobj,
- name,
- seed_value_from_gvalue(ctx,
- (GValue *)value,
- 0));
-
+ gchar *name = g_strjoin(NULL, "_", spec->name, NULL);
+ JSObjectRef jsobj = (JSObjectRef) seed_value_from_object(ctx, object, 0);
+
+ seed_object_set_property(ctx,
+ jsobj,
+ name,
+ seed_value_from_gvalue(ctx, (GValue *) value, 0));
+
g_free(name);
JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
static void seed_gtype_builtin_get_property(GObject * object,
- guint property_id,
- GValue *value,
- GParamSpec *spec)
+ guint property_id,
+ GValue * value, GParamSpec * spec)
{
// TODO: Exceptions
JSContextRef ctx = JSGlobalContextCreateInGroup(context_group, 0);
- gchar * name = g_strjoin(NULL, "_", spec->name, NULL);
+ gchar *name = g_strjoin(NULL, "_", spec->name, NULL);
JSObjectRef jsobj = (JSObjectRef) seed_value_from_object(ctx, object, 0);
JSValueRef jsval = seed_object_get_property(ctx, jsobj,
name);
-
- seed_gvalue_from_seed_value(ctx, jsval, spec->value_type,
- value, 0);
-
+
+ seed_gvalue_from_seed_value(ctx, jsval, spec->value_type, value, 0);
+
g_free(name);
JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
static void seed_gtype_set_property(GObject * object,
guint property_id,
- const GValue *value,
- GParamSpec *spec)
+ const GValue * value, GParamSpec * spec)
{
gpointer data = g_param_spec_get_qdata(spec, qsetter);
@@ -411,8 +406,7 @@
static void seed_gtype_get_property(GObject * object,
guint property_id,
- GValue *value,
- GParamSpec *spec)
+ GValue * value, GParamSpec * spec)
{
gpointer data = g_param_spec_get_qdata(spec, qgetter);
@@ -433,8 +427,8 @@
JSValueRef exception = 0;
JSContextRef ctx = JSGlobalContextCreateInGroup(context_group,
0);
- GObjectClass * klass = *(GObjectClass **) args[0];
-
+ GObjectClass *klass = *(GObjectClass **) args[0];
+
klass->get_property = seed_gtype_get_property;
klass->set_property = seed_gtype_set_property;
@@ -448,7 +442,7 @@
// TODO:
// Should probably have a custom type for class, and have it auto convert.
seed_object_set_property(ctx, (JSObjectRef) jsargs[0],
- "type", seed_value_from_int(ctx, type, 0));
+ "type", seed_value_from_int(ctx, type, 0));
seed_object_set_property(ctx, (JSObjectRef) jsargs[0],
"property_count", seed_value_from_int(ctx, 1, 0));
@@ -572,7 +566,7 @@
gchar *mes =
g_strdup_printf("GType constructor expected 1 "
"argument, got %d \n",
- (unsigned int) argumentCount);
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
return (JSObjectRef) JSValueMakeNull(ctx);
@@ -638,9 +632,10 @@
new_type = g_type_register_static(parent_type, new_name, &type_info, 0);
seed_gobject_get_class_for_gtype(ctx, new_type);
JSObjectSetPrivate(constructor_ref, (gpointer) new_type);
-
- seed_object_set_property(ctx, constructor_ref,
- "type", seed_value_from_int(ctx, new_type, exception));
+
+ seed_object_set_property(ctx, constructor_ref,
+ "type", seed_value_from_int(ctx, new_type,
+ exception));
g_free(new_name);
return constructor_ref;
@@ -648,71 +643,69 @@
static JSValueRef
seed_param_getter_invoked(JSContextRef ctx,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef * exception)
+ JSObjectRef function,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[], JSValueRef * exception)
{
GParamSpec *pspec = seed_pointer_get_pointer(ctx, thisObject);
if (argumentCount != 1)
{
- gchar * mes = g_strdup_printf("ParamSpec.get expected "
- "1 argument, got %d",
- (unsigned int) argumentCount);
+ gchar *mes = g_strdup_printf("ParamSpec.get expected "
+ "1 argument, got %d",
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
-
+
return JSValueMakeNull(ctx);
}
else if (JSValueIsNull(ctx, arguments[0]) ||
!JSValueIsObject(ctx, arguments[0]) ||
- !JSObjectIsFunction(ctx, (JSObjectRef)arguments[0]))
+ !JSObjectIsFunction(ctx, (JSObjectRef) arguments[0]))
{
// Maybe should accept C functions
seed_make_exception(ctx, exception, "ArgumentError",
"ParamSpec.get expected a function");
return JSValueMakeNull(ctx);
}
-
- g_param_spec_set_qdata(pspec, qgetter, (gpointer)arguments[0]);
-
+
+ g_param_spec_set_qdata(pspec, qgetter, (gpointer) arguments[0]);
+
return seed_value_from_boolean(ctx, TRUE, exception);
}
static JSValueRef
seed_param_setter_invoked(JSContextRef ctx,
- JSObjectRef function,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef * exception)
+ JSObjectRef function,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[], JSValueRef * exception)
{
GParamSpec *pspec = seed_pointer_get_pointer(ctx, thisObject);
if (argumentCount != 1)
{
- gchar * mes = g_strdup_printf("ParamSpec.set expected "
- "1 argument, got %d",
- (unsigned int) argumentCount);
+ gchar *mes = g_strdup_printf("ParamSpec.set expected "
+ "1 argument, got %d",
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
-
+
return JSValueMakeNull(ctx);
}
else if (JSValueIsNull(ctx, arguments[0]) ||
!JSValueIsObject(ctx, arguments[0]) ||
- !JSObjectIsFunction(ctx, (JSObjectRef)arguments[0]))
+ !JSObjectIsFunction(ctx, (JSObjectRef) arguments[0]))
{
// Maybe should accept C functions
seed_make_exception(ctx, exception, "ArgumentError",
"ParamSpec.set expected a function");
return JSValueMakeNull(ctx);
}
-
- g_param_spec_set_qdata(pspec, qsetter, (gpointer)arguments[0]);
-
+
+ g_param_spec_set_qdata(pspec, qsetter, (gpointer) arguments[0]);
+
return seed_value_from_boolean(ctx, TRUE, exception);
}
@@ -721,28 +714,20 @@
JSObjectRef proto;
objectclass_info = g_irepository_find_by_name(NULL,
- "GObject",
- "ObjectClass");
+ "GObject", "ObjectClass");
proto = seed_struct_prototype(ctx, objectclass_info);
seed_create_function(ctx, "c_install_property",
- &seed_property_method_invoked,
- proto);
+ &seed_property_method_invoked, proto);
seed_create_function(ctx, "install_signal",
&seed_gsignal_method_invoked, proto);
- paramspec_info = g_irepository_find_by_name(NULL,
- "GObject",
- "ParamSpec");
+ paramspec_info = g_irepository_find_by_name(NULL, "GObject", "ParamSpec");
proto = seed_struct_prototype(ctx, paramspec_info);
- seed_create_function(ctx, "get",
- &seed_param_getter_invoked,
- proto);
- seed_create_function(ctx, "set",
- &seed_param_setter_invoked,
- proto);
+ seed_create_function(ctx, "get", &seed_param_getter_invoked, proto);
+ seed_create_function(ctx, "set", &seed_param_setter_invoked, proto);
}
void seed_gtype_init(SeedEngine * local_eng)
@@ -757,12 +742,10 @@
gtype_constructor = JSObjectMake(local_eng->context, seed_gtype_class, 0);
seed_object_set_property(local_eng->context,
- local_eng->global,
- "GType",
- gtype_constructor);
+ local_eng->global, "GType", gtype_constructor);
qgetter = g_quark_from_static_string("js-getter");
qsetter = g_quark_from_static_string("js-setter");
-
+
seed_define_gtype_functions(local_eng->context);
}
Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c (original)
+++ trunk/libseed/seed-signals.c Wed Jan 14 05:10:40 2009
@@ -85,8 +85,8 @@
{
JSContextRef ctx = JSGlobalContextCreateInGroup(context_group,
0);
- SeedClosure * closure = (SeedClosure *) c;
-
+ SeedClosure *closure = (SeedClosure *) c;
+
SEED_NOTE(FINALIZATION, "Finalizing closure.");
/*
WebKit bug?
@@ -97,7 +97,7 @@
if (!JSValueIsUndefined(ctx, closure->function))
JSValueUnprotect(ctx, closure->function);
- JSGlobalContextRelease((JSGlobalContextRef)ctx);
+ JSGlobalContextRelease((JSGlobalContextRef) ctx);
}
static void seed_gobject_signal_connect(JSContextRef ctx,
@@ -125,7 +125,7 @@
if (this_obj && !JSValueIsNull(ctx, this_obj))
{
JSValueProtect(ctx, this_obj);
-// ((SeedClosure *) closure)->this = this_obj;
+// ((SeedClosure *) closure)->this = this_obj;
}
else
{
@@ -135,7 +135,7 @@
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);
@@ -160,7 +160,7 @@
{
gchar *mes = g_strdup_printf("Signal connection expected"
" 2 or 3 arguments. Got "
- "%d", (unsigned int) argumentCount);
+ "%d", (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
@@ -171,7 +171,7 @@
{
user_data = (JSObjectRef) arguments[2];
}
-
+
signal_name = seed_value_to_string(ctx, arguments[0], exception);
obj = (GObject *) JSObjectGetPrivate(thisObject);
obj_type = G_OBJECT_TYPE(obj);
@@ -310,8 +310,8 @@
"arguments, got %d",
query.signal_name,
g_type_name(query.itype),
- (unsigned int) query.n_params,
- (unsigned int) argumentCount);
+ (unsigned int)query.n_params,
+ (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
return JSValueMakeNull(ctx);
@@ -360,7 +360,7 @@
{
gchar *mes = g_strdup_printf("Signal connection expected"
" 1, or 2 arguments. Got "
- "%d", (unsigned int) argumentCount);
+ "%d", (unsigned int)argumentCount);
seed_make_exception(ctx, exception, "ArgumentError", mes);
g_free(mes);
Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c (original)
+++ trunk/libseed/seed-structs.c Wed Jan 14 05:10:40 2009
@@ -33,8 +33,8 @@
gsize size;
} seed_struct_privates;
-GHashTable * struct_prototype_hash = NULL;
-GHashTable * union_prototype_hash = NULL;
+GHashTable *struct_prototype_hash = NULL;
+GHashTable *union_prototype_hash = NULL;
static void seed_pointer_finalize(JSObjectRef object)
{
@@ -46,7 +46,7 @@
priv->pointer,
priv->free_pointer,
priv->info ? g_base_info_get_name(priv->info) : "[generic]",
- priv->size);
+ priv->size);
if (priv->free_pointer)
{
@@ -143,7 +143,7 @@
interface = g_type_info_get_interface(field_type);
gint offset = g_field_info_get_offset(field);
- g_base_info_unref((GIBaseInfo *)field_type);
+ g_base_info_unref((GIBaseInfo *) field_type);
switch (g_base_info_get_type(interface))
{
case GI_INFO_TYPE_STRUCT:
@@ -160,7 +160,7 @@
break;
}
g_base_info_unref(interface);
-
+
return ret;
}
@@ -215,7 +215,7 @@
gint length;
GArgument field_value;
GIFieldInfo *field;
- gchar * cproperty_name;
+ gchar *cproperty_name;
GITypeInfo *field_type;
seed_struct_privates *priv =
(seed_struct_privates *) JSObjectGetPrivate(object);
@@ -243,7 +243,7 @@
g_base_info_unref((GIBaseInfo *) field_type);
g_base_info_unref((GIBaseInfo *) field);
-
+
return TRUE;
}
@@ -426,9 +426,8 @@
}
static void seed_pointer_set_slice(JSContextRef ctx,
- JSValueRef pointer,
- gboolean free_pointer,
- gsize size)
+ JSValueRef pointer,
+ gboolean free_pointer, gsize size)
{
seed_struct_privates *priv = JSObjectGetPrivate((JSObjectRef) pointer);
priv->slice_alloc = free_pointer;
@@ -445,21 +444,19 @@
return JSObjectMake(ctx, seed_pointer_class, priv);
}
-JSObjectRef seed_union_prototype(JSContextRef ctx,
- GIBaseInfo *info)
+JSObjectRef seed_union_prototype(JSContextRef ctx, GIBaseInfo * info)
{
JSObjectRef proto;
const gchar *namespace, *name;
gchar *key;
gint n_methods, i;
-
+
name = g_base_info_get_name(info);
namespace = g_base_info_get_namespace(info);
key = g_strjoin(NULL, namespace, name, NULL);
-
- proto = (JSObjectRef) g_hash_table_lookup(union_prototype_hash,
- key);
-
+
+ proto = (JSObjectRef) g_hash_table_lookup(union_prototype_hash, key);
+
if (!proto)
{
proto = JSObjectMake(ctx, 0, 0);
@@ -473,15 +470,12 @@
seed_gobject_define_property_from_function_info(ctx,
(GIFunctionInfo *)
- finfo, proto,
- TRUE);
+ finfo, proto, TRUE);
g_base_info_unref((GIBaseInfo *) finfo);
}
- g_hash_table_insert(union_prototype_hash,
- key,
- proto);
+ g_hash_table_insert(union_prototype_hash, key, proto);
}
else
{
@@ -532,21 +526,19 @@
return object;
}
-JSObjectRef seed_struct_prototype(JSContextRef ctx,
- GIBaseInfo *info)
+JSObjectRef seed_struct_prototype(JSContextRef ctx, GIBaseInfo * info)
{
JSObjectRef proto;
const gchar *namespace, *name;
gchar *key;
gint n_methods, i;
-
+
name = g_base_info_get_name(info);
namespace = g_base_info_get_namespace(info);
key = g_strjoin(NULL, namespace, name, NULL);
-
- proto = (JSObjectRef) g_hash_table_lookup(struct_prototype_hash,
- key);
-
+
+ proto = (JSObjectRef) g_hash_table_lookup(struct_prototype_hash, key);
+
if (!proto)
{
proto = JSObjectMake(ctx, 0, 0);
@@ -560,15 +552,12 @@
seed_gobject_define_property_from_function_info(ctx,
(GIFunctionInfo *)
- finfo, proto,
- TRUE);
+ finfo, proto, TRUE);
g_base_info_unref((GIBaseInfo *) finfo);
}
- g_hash_table_insert(struct_prototype_hash,
- key,
- proto);
+ g_hash_table_insert(struct_prototype_hash, key, proto);
}
else
{
@@ -612,11 +601,9 @@
seed_union_class = JSClassCreate(&seed_union_def);
seed_boxed_def.parentClass = seed_struct_class;
seed_boxed_class = JSClassCreate(&seed_boxed_def);
-
- struct_prototype_hash = g_hash_table_new(g_str_hash,
- g_str_equal);
- union_prototype_hash = g_hash_table_new(g_str_hash,
- g_str_equal);
+
+ struct_prototype_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ union_prototype_hash = g_hash_table_new(g_str_hash, g_str_equal);
}
JSObjectRef
@@ -648,10 +635,10 @@
g_assert(size);
object = g_slice_alloc0(size);
- SEED_NOTE(CONSTRUCTION, "Constructing struct/union of type: %s. Size: %zu \n",
+ SEED_NOTE(CONSTRUCTION,
+ "Constructing struct/union of type: %s. Size: %zu \n",
g_base_info_get_name(info), size);
-
if (type == GI_INFO_TYPE_STRUCT)
ret = seed_make_struct(ctx, object, info);
else
Modified: trunk/libseed/seed-structs.h
==============================================================================
--- trunk/libseed/seed-structs.h (original)
+++ trunk/libseed/seed-structs.h Wed Jan 14 05:10:40 2009
@@ -50,10 +50,8 @@
JSObjectRef parameters,
JSValueRef * exception);
-JSObjectRef seed_union_prototype(JSContextRef ctx,
- GIBaseInfo *info);
-JSObjectRef seed_struct_prototype(JSContextRef ctx,
- GIBaseInfo *info);
+JSObjectRef seed_union_prototype(JSContextRef ctx, GIBaseInfo * info);
+JSObjectRef seed_struct_prototype(JSContextRef ctx, GIBaseInfo * info);
void seed_structs_init();
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Wed Jan 14 05:10:40 2009
@@ -153,7 +153,7 @@
}
else if (g_type_is_a(gtype, G_TYPE_VALUE))
{
- GValue * gval = (GValue *)arg->v_pointer;
+ GValue *gval = (GValue *) arg->v_pointer;
// Free/unref the GValue's contents.
g_value_unset(gval);
// Free the GValue.
@@ -203,10 +203,10 @@
{
// TODO: FIXME: Leaaaks?
case GI_TYPE_TAG_INTERFACE:
- {
- // TODO: FIXME: Need some safe way to look for GClosure.
- break;
- }
+ {
+ // TODO: FIXME: Need some safe way to look for GClosure.
+ break;
+ }
case GI_TYPE_TAG_UTF8:
case GI_TYPE_TAG_FILENAME:
case GI_TYPE_TAG_ARRAY:
@@ -221,20 +221,19 @@
static JSValueRef
seed_gi_make_jsarray(JSContextRef ctx,
- void * array,
- GITypeInfo * param_type,
- JSValueRef * exception)
+ void *array,
+ GITypeInfo * param_type, JSValueRef * exception)
{
GITypeTag element_type;
JSValueRef ret = JSValueMakeNull(ctx);
element_type = g_type_info_get_tag(param_type);
-
+
if (element_type == GI_TYPE_TAG_UTF8)
{
- JSValueRef * elements;
+ JSValueRef *elements;
guint length, i;
- gchar ** str_array = (gchar **) array;
+ gchar **str_array = (gchar **) array;
length = g_strv_length(str_array);
if (!length)
@@ -243,15 +242,12 @@
elements = g_alloca(sizeof(JSValueRef) * length);
for (i = 0; i < length; ++i)
{
- elements[i] = seed_value_from_string(ctx,
- str_array[i],
- exception);
+ elements[i] = seed_value_from_string(ctx, str_array[i], exception);
}
-
- ret = (JSValueRef) JSObjectMakeArray(ctx, length,
- elements, exception);
+
+ ret = (JSValueRef) JSObjectMakeArray(ctx, length, elements, exception);
}
-
+
return ret;
}
@@ -444,14 +440,13 @@
}
else if (type == G_TYPE_VALUE)
{
- GValue * gval = g_slice_alloc0(sizeof(GValue));
+ GValue *gval = g_slice_alloc0(sizeof(GValue));
seed_gvalue_from_seed_value(ctx,
value,
- (GType)NULL,
- gval,
- exception);
+ (GType) NULL,
+ gval, exception);
arg->v_pointer = gval;
-
+
g_base_info_unref(interface);
break;
}
@@ -470,8 +465,7 @@
JSObjectRef strukt =
seed_construct_struct_type_with_parameters(ctx,
interface,
- (JSObjectRef)
- value,
+ (JSObjectRef) value,
exception);
arg->v_pointer = seed_pointer_get_pointer(ctx, strukt);
}
@@ -635,23 +629,23 @@
case GI_TYPE_TAG_GTYPE:
return seed_value_from_int(ctx, arg->v_int, exception);
case GI_TYPE_TAG_ARRAY:
- {
- GITypeInfo *param_type;
- JSValueRef ret;
- if (!g_type_info_is_zero_terminated(type_info))
- break;
-
- param_type = g_type_info_get_param_type(type_info, 0);
-
- ret = seed_gi_make_jsarray(ctx, arg->v_pointer, param_type,
- exception);
-
- g_base_info_unref((GIBaseInfo *) param_type);
-
- return ret;
- }
+ {
+ GITypeInfo *param_type;
+ JSValueRef ret;
+ if (!g_type_info_is_zero_terminated(type_info))
+ break;
+
+ param_type = g_type_info_get_param_type(type_info, 0);
+
+ ret = seed_gi_make_jsarray(ctx, arg->v_pointer, param_type,
+ exception);
+
+ g_base_info_unref((GIBaseInfo *) param_type);
+
+ return ret;
+ }
case GI_TYPE_TAG_INTERFACE:
- {
+ {
GIBaseInfo *interface;
GIInfoType interface_type;
@@ -913,45 +907,45 @@
return TRUE;
}
default:
- {
- // TODO: FIXME: This whole undefined type area
- // needs some heaaavy improvement.
+ {
+ // TODO: FIXME: This whole undefined type area
+ // needs some heaaavy improvement.
- // Support [GObject.TYPE_INT, 3]
- // TODO: FIXME: Might crash.
- if (type == 0 && JSValueIsObject(ctx, val))
- {
- // TODO: FIXME: Better array test like the cool one on reddit.
- guint length =
- seed_value_to_int(ctx,
- seed_object_get_property(ctx,
- (JSObjectRef) val,
- "length"),
- exception);
-
- if (length)
+ // Support [GObject.TYPE_INT, 3]
+ // TODO: FIXME: Might crash.
+ if (type == 0 && JSValueIsObject(ctx, val))
{
- type = seed_value_to_int(ctx,
- JSObjectGetPropertyAtIndex(ctx,
- (JSObjectRef) val,
- 0, exception),
- exception);
- val = JSObjectGetPropertyAtIndex(ctx,
- (JSObjectRef) val,
- 1, exception);
- if (type) // Prevents recursion.
- {
- return seed_gvalue_from_seed_value(ctx, val,
- type, ret,
- exception);
+ // TODO: FIXME: Better array test like the cool one on reddit.
+ guint length = seed_value_to_int(ctx,
+ seed_object_get_property(ctx,
+ (JSObjectRef) val,
+ "length"),
+ exception);
+
+ if (length)
+ {
+ type = seed_value_to_int(ctx,
+ JSObjectGetPropertyAtIndex(ctx,
+ (JSObjectRef)
+ val, 0,
+ exception),
+ exception);
+ val =
+ JSObjectGetPropertyAtIndex(ctx, (JSObjectRef) val, 1,
+ exception);
+ if (type) // Prevents recursion.
+ {
+ return seed_gvalue_from_seed_value(ctx, val,
+ type, ret,
+ exception);
+ }
+ // TODO: FIXME: Handle better?
+ else
+ g_assert_not_reached();
}
- // TODO: FIXME: Handle better?
- else
- g_assert_not_reached();
}
- }
- switch (JSValueGetType(ctx, val))
- {
+ switch (JSValueGetType(ctx, val))
+ {
case kJSTypeBoolean:
{
g_value_init(ret, G_TYPE_BOOLEAN);
@@ -1398,10 +1392,9 @@
JSValueRef * exception)
{
GError *e = NULL;
- gchar * utf8;
-
- utf8 = g_filename_to_utf8(filename, -1, NULL,
- NULL, &e);
+ gchar *utf8;
+
+ utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, &e);
if (e)
{
seed_make_exception_from_gerror(ctx, exception, e);
@@ -1409,21 +1402,18 @@
// TODO: FIXMEShould be JS Null maybe?
return NULL;
}
-
+
return seed_value_from_string(ctx, utf8, exception);
}
-gchar * seed_value_to_filename(JSContextRef ctx,
- JSValueRef val,
- JSValueRef *exception)
-{
- GError * e = NULL;
- gchar * utf8 = seed_value_to_string(ctx, val, exception);
- gchar * filename;
-
- filename = g_filename_from_utf8(utf8, -1,
- NULL, NULL,
- &e);
+gchar *seed_value_to_filename(JSContextRef ctx,
+ JSValueRef val, JSValueRef * exception)
+{
+ GError *e = NULL;
+ gchar *utf8 = seed_value_to_string(ctx, val, exception);
+ gchar *filename;
+
+ filename = g_filename_from_utf8(utf8, -1, NULL, NULL, &e);
g_free(utf8);
if (e)
{
Modified: trunk/libseed/seed-types.h
==============================================================================
--- trunk/libseed/seed-types.h (original)
+++ trunk/libseed/seed-types.h Wed Jan 14 05:10:40 2009
@@ -109,9 +109,8 @@
JSValueRef seed_value_from_double(JSContextRef ctx,
gdouble val, JSValueRef * exception);
-gchar * seed_value_to_filename(JSContextRef ctx,
- JSValueRef val,
- JSValueRef *exception);
+gchar *seed_value_to_filename(JSContextRef ctx,
+ JSValueRef val, JSValueRef * exception);
JSValueRef seed_value_from_filename(JSContextRef ctx,
const gchar * filename,
JSValueRef * exception);
Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h (original)
+++ trunk/libseed/seed.h Wed Jan 14 05:10:40 2009
@@ -197,13 +197,11 @@
SeedValue seed_value_from_string(SeedContext ctx,
gchar * val, SeedException * exception);
-gchar * seed_value_to_filename(SeedContext ctx,
- SeedValue val,
- SeedValue *exception);
+gchar *seed_value_to_filename(SeedContext ctx,
+ SeedValue val, SeedValue * exception);
SeedValue seed_value_from_filename(SeedContext ctx,
- const gchar * filename,
- SeedValue * exception);
-
+ const gchar * filename,
+ SeedValue * exception);
GObject *seed_value_to_object(SeedContext ctx,
SeedValue val, SeedException * exception);
Modified: trunk/modules/Multiprocessing/multi.c
==============================================================================
--- trunk/modules/Multiprocessing/multi.c (original)
+++ trunk/modules/Multiprocessing/multi.c Wed Jan 14 05:10:40 2009
@@ -2,19 +2,18 @@
#include <unistd.h>
#include <stdio.h>
-SeedEngine * eng;
+SeedEngine *eng;
SeedObject namespace_ref;
SeedClass pipe_class;
-typedef struct _pipe_priv
-{
- GIOChannel * read;
- GIOChannel * write;
+typedef struct _pipe_priv {
+ GIOChannel *read;
+ GIOChannel *write;
} pipe_priv;
void pipe_finalize(SeedObject pipeobj)
{
- pipe_priv * priv = seed_object_get_private(pipeobj);
+ pipe_priv *priv = seed_object_get_private(pipeobj);
g_io_channel_unref(priv->read);
g_io_channel_unref(priv->write);
g_free(priv);
@@ -29,8 +28,8 @@
GIOChannel *oner, *onew, twor, twow;
SeedObject jsone, jstwo, jsret;
int fd1[2], fd2[2];
- pipe_priv * priv_one, * priv_two;
-
+ pipe_priv *priv_one, *priv_two;
+
if (pipe(fd1) < 0)
{
perror("Pipe failed. Make me a javascript exception");
@@ -41,97 +40,92 @@
perror("Pipe failed. Make me a javascript exception");
return seed_make_null(ctx);
}
-
+
priv_one = g_new0(pipe_priv, 1);
priv_two = g_new0(pipe_priv, 1);
-
+
priv_one->read = g_io_channel_unix_new(fd1[0]);
priv_one->write = g_io_channel_unix_new(fd2[1]);
priv_two->read = g_io_channel_unix_new(fd2[0]);
priv_two->write = g_io_channel_unix_new(fd1[1]);
-
+
g_io_channel_set_close_on_unref(priv_one->read, TRUE);
g_io_channel_set_close_on_unref(priv_one->write, TRUE);
g_io_channel_set_close_on_unref(priv_two->read, TRUE);
g_io_channel_set_close_on_unref(priv_two->write, TRUE);
-
+
jsret = seed_make_object(ctx, 0, 0);
jsone = seed_make_object(ctx, pipe_class, priv_one);
jstwo = seed_make_object(ctx, pipe_class, priv_two);
-
+
seed_object_set_property_at_index(ctx, jsret, 0, jsone, exception);
seed_object_set_property_at_index(ctx, jsret, 1, jstwo, exception);
-
+
return jsret;
}
#define GET_CHANNEL pipe_priv * priv = \
seed_object_get_private(this_object)
-
-SeedValue seed_pipe_read (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_pipe_read(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[], SeedException * exception)
{
SeedValue ret;
- gchar * read;
+ gchar *read;
GET_CHANNEL;
g_io_channel_read_line(priv->read, &read, 0, 0, 0);
ret = seed_value_from_string(ctx, read, exception);
g_free(read);
-
+
return ret;
}
-typedef struct _marshal_privates
-{
+typedef struct _marshal_privates {
SeedObject function;
SeedObject source;
SeedValue user_data;
} marshal_privates;
static gboolean gio_marshal_func(GIOChannel * source,
- GIOCondition condition,
- gpointer data)
+ GIOCondition condition, gpointer data)
{
SeedGlobalContext ctx = seed_context_create(eng->group, 0);
- SeedValue jscondition = seed_value_from_long(ctx, (glong)condition, 0);
+ SeedValue jscondition = seed_value_from_long(ctx, (glong) condition, 0);
SeedValue args[3], ret;
- marshal_privates * priv = (marshal_privates *) data;
+ marshal_privates *priv = (marshal_privates *) data;
gboolean bret;
-
+
args[0] = priv->source;
args[1] = jscondition;
args[2] = priv->user_data;
-
- ret = seed_object_call(ctx, priv->function, 0,
- 3, args, 0);
-
+
+ ret = seed_object_call(ctx, priv->function, 0, 3, args, 0);
+
bret = seed_value_to_boolean(ctx, ret, 0);
seed_context_unref(ctx);
-
+
if (!bret)
g_free(priv);
return bret;
}
-SeedValue seed_pipe_write (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_pipe_write(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
- gchar * data;
+ gchar *data;
gsize written;
gchar eol = '\n';
GET_CHANNEL;
-
+
data = seed_value_to_string(ctx, arguments[0], exception);
g_io_channel_write_chars(priv->write, data, -1, &written, 0);
g_io_channel_write_chars(priv->write, &eol, 1, 0, 0);
@@ -140,29 +134,31 @@
return seed_value_from_int(ctx, written, exception);
}
-SeedValue seed_pipe_add_watch (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_pipe_add_watch(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CHANNEL;
- marshal_privates * mpriv = g_malloc0(sizeof(marshal_privates));
+ marshal_privates *mpriv = g_malloc0(sizeof(marshal_privates));
glong condition = seed_value_to_long(ctx, arguments[0], exception);
-
+
mpriv->function = arguments[1];
mpriv->source = this_object;
mpriv->user_data = argument_count == 3 ? arguments[2] : seed_make_null(ctx);
-
+
g_io_add_watch(priv->read, condition, gio_marshal_func, mpriv);
-
+
return seed_value_from_boolean(ctx, TRUE, exception);
}
seed_static_function pipe_funcs[] = {
- {"read", seed_pipe_read, 0},
- {"write", seed_pipe_write, 0},
+ {"read", seed_pipe_read, 0}
+ ,
+ {"write", seed_pipe_write, 0}
+ ,
{"add_watch", seed_pipe_add_watch, 0}
};
@@ -171,28 +167,22 @@
SeedObject pipe_constructor;
seed_class_definition pipe_class_def = seed_empty_class;
eng = local_eng;
-
+
namespace_ref = seed_make_object(eng->context, 0, 0);
-
+
pipe_class_def.class_name = "Pipe";
pipe_class_def.static_functions = pipe_funcs;
pipe_class_def.finalize = pipe_finalize;
pipe_class = seed_create_class(&pipe_class_def);
-
- seed_object_set_property(eng->context,
- eng->global,
- "Multiprocessing",
- namespace_ref);
+ seed_object_set_property(eng->context,
+ eng->global, "Multiprocessing", namespace_ref);
pipe_constructor = seed_make_constructor(eng->context,
- 0,
- seed_construct_pipe);
-
+ 0, seed_construct_pipe);
+
seed_object_set_property(eng->context,
- namespace_ref,
- "Pipe",
- pipe_constructor);
-
+ namespace_ref, "Pipe", pipe_constructor);
+
}
Modified: trunk/modules/canvas/seed-canvas.c
==============================================================================
--- trunk/modules/canvas/seed-canvas.c (original)
+++ trunk/modules/canvas/seed-canvas.c Wed Jan 14 05:10:40 2009
@@ -8,7 +8,7 @@
SeedObject namespace_ref;
SeedClass canvas_class;
-SeedEngine * eng;
+SeedEngine *eng;
#define GET_CR cairo_t * cr = seed_object_get_private(this_object)
@@ -19,7 +19,7 @@
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_miter_limit(cr, 10);
-
+
obj = seed_make_object(ctx, canvas_class, cr);
seed_object_set_property(ctx, obj, "globalAlpha",
@@ -33,109 +33,108 @@
seed_object_set_property(ctx, obj, "lineJoin",
seed_value_from_string(ctx, "miter", exception));
seed_object_set_property(ctx, obj, "cairo",
- (SeedValue)seed_make_pointer(ctx, cr));
-
+ (SeedValue) seed_make_pointer(ctx, cr));
+
return obj;
}
SeedObject seed_construct_image_canvas(SeedContext ctx,
- SeedObject constructor,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+ SeedObject constructor,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
SeedObject obj;
- cairo_surface_t * surface;
- cairo_t * cr;
- gchar * filename;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gchar *filename;
gdouble width, height;
-
+
if (argument_count != 3)
{
seed_make_exception(ctx, exception, "ArgumentError",
"Canvas.PDFCanvas constructor expected"
"3 arguments");
- return (SeedObject)seed_make_null(ctx);
+ return (SeedObject) seed_make_null(ctx);
}
-
+
filename = seed_value_to_string(ctx, arguments[0], exception);
width = seed_value_to_double(ctx, arguments[1], exception);
height = seed_value_to_double(ctx, arguments[2], exception);
-
- surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
- width, height);
+
+ surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cr = cairo_create(surface);
cairo_surface_destroy(surface);
-
+
obj = canvas_construct_canvas_from_cairo(ctx, cr, exception);
return obj;
}
SeedObject canvas_construct_pdf_canvas(SeedContext ctx,
- SeedObject constructor,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+ SeedObject constructor,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
SeedObject obj;
- cairo_surface_t * surface;
- cairo_t * cr;
- gchar * filename;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gchar *filename;
gdouble width, height;
-
+
if (argument_count != 3)
{
seed_make_exception(ctx, exception, "ArgumentError",
"Canvas.PDFCanvas constructor expected"
"3 arguments");
- return (SeedObject)seed_make_null(ctx);
+ return (SeedObject) seed_make_null(ctx);
}
-
+
filename = seed_value_to_string(ctx, arguments[0], exception);
width = seed_value_to_double(ctx, arguments[1], exception);
height = seed_value_to_double(ctx, arguments[2], exception);
-
+
surface = cairo_pdf_surface_create(filename, width, height);
cr = cairo_create(surface);
cairo_surface_destroy(surface);
-
+
obj = canvas_construct_canvas_from_cairo(ctx, cr, exception);
return obj;
}
SeedObject canvas_construct_svg_canvas(SeedContext ctx,
- SeedObject constructor,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+ SeedObject constructor,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
SeedObject obj;
- cairo_surface_t * surface;
- cairo_t * cr;
- gchar * filename;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gchar *filename;
gdouble width, height;
-
+
if (argument_count != 3)
{
seed_make_exception(ctx, exception, "ArgumentError",
"Canvas.PDFCanvas constructor expected"
"3 arguments");
- return (SeedObject)seed_make_null(ctx);
+ return (SeedObject) seed_make_null(ctx);
}
-
+
filename = seed_value_to_string(ctx, arguments[0], exception);
width = seed_value_to_double(ctx, arguments[1], exception);
height = seed_value_to_double(ctx, arguments[2], exception);
-
+
surface = cairo_svg_surface_create(filename, width, height);
cr = cairo_create(surface);
cairo_surface_destroy(surface);
-
+
obj = canvas_construct_canvas_from_cairo(ctx, cr, exception);
return obj;
@@ -148,19 +147,19 @@
SeedException * exception)
{
SeedObject obj;
- cairo_t * cr;
+ cairo_t *cr;
if (argument_count != 1)
{
seed_make_exception(ctx, exception, "ArgumentError",
"Canvas.CairoCanvas constructor"
"expected 1 argument");
- return (SeedObject)seed_make_null(ctx);
+ return (SeedObject) seed_make_null(ctx);
}
cr = seed_pointer_get_pointer(ctx, arguments[0]);
-
+
obj = canvas_construct_canvas_from_cairo(ctx, cr, exception);
-
+
return obj;
}
@@ -168,42 +167,46 @@
{
if (*spec == '#')
{
- guint r=0,g=0,b=0,a=0, found;
+ guint r = 0, g = 0, b = 0, a = 0, found;
// Might be libc dependent (the alpha behaviour);
if (strlen(spec) > 4)
found = sscanf(spec, "#%2x%2x%2x%2x", &r, &g, &b, &a);
else
{
found = sscanf(spec, "#%1x%1x%1x%1x", &r, &g, &b, &a);
- r *= 17; g *= 17; b *= 17; a *= 17;
+ r *= 17;
+ g *= 17;
+ b *= 17;
+ a *= 17;
}
if (found < 4)
- a = global_alpha*255;
+ a = global_alpha * 255;
- cairo_set_source_rgba(cr, r/255.0, g/255.0, b/255.0, a/255.0);
+ cairo_set_source_rgba(cr, r / 255.0, g / 255.0, b / 255.0, a / 255.0);
return;
}
else if (*spec == 'r')
{
- switch(*(spec+3))
+ switch (*(spec + 3))
{
case 'a':
- {
- gint r, g, b;
- gfloat a;
-
- sscanf(spec, "rgba(%d,%d,%d,%f)", &r, &g, &b, &a);
- cairo_set_source_rgba(cr, r/255.0, g/255.0, b/255.0, a);
- return;
- }
+ {
+ gint r, g, b;
+ gfloat a;
+
+ sscanf(spec, "rgba(%d,%d,%d,%f)", &r, &g, &b, &a);
+ cairo_set_source_rgba(cr, r / 255.0, g / 255.0, b / 255.0, a);
+ return;
+ }
case '(':
- {
- gint r, g, b;
+ {
+ gint r, g, b;
- sscanf(spec, "rgb(%d,%d,%d)", &r, &g, &b);
- cairo_set_source_rgba(cr, r/255.0, g/255.0, b/255.0, global_alpha);
- return;
- }
+ sscanf(spec, "rgb(%d,%d,%d)", &r, &g, &b);
+ cairo_set_source_rgba(cr, r / 255.0, g / 255.0, b / 255.0,
+ global_alpha);
+ return;
+ }
}
}
else if (*spec == '[')
@@ -212,113 +215,101 @@
}
}
-gboolean seed_canvas_set_linewidth (SeedContext ctx,
- SeedObject this_object,
- SeedString property_name,
- SeedValue value,
- SeedException * e)
+gboolean seed_canvas_set_linewidth(SeedContext ctx,
+ SeedObject this_object,
+ SeedString property_name,
+ SeedValue value, SeedException * e)
{
GET_CR;
- gdouble line_width =
- seed_value_to_double(ctx, value, e);
-
+ gdouble line_width = seed_value_to_double(ctx, value, e);
+
cairo_set_line_width(cr, line_width);
return TRUE;
}
-gboolean seed_canvas_set_miterlimit (SeedContext ctx,
+gboolean seed_canvas_set_miterlimit(SeedContext ctx,
SeedObject this_object,
SeedString property_name,
- SeedValue value,
- SeedException * e)
+ SeedValue value, SeedException * e)
{
GET_CR;
-
+
cairo_set_miter_limit(cr, seed_value_to_double(ctx, value, e));
}
-gboolean seed_canvas_set_linecap (SeedContext ctx,
- SeedObject this_object,
- SeedString property_name,
- SeedValue value,
- SeedException * e)
+gboolean seed_canvas_set_linecap(SeedContext ctx,
+ SeedObject this_object,
+ SeedString property_name,
+ SeedValue value, SeedException * e)
{
GET_CR;
cairo_line_cap_t cap = CAIRO_LINE_CAP_BUTT;
- gchar * line_cap =
- seed_value_to_string(ctx, value, e);
-
+ gchar *line_cap = seed_value_to_string(ctx, value, e);
+
if (!strcmp(line_cap, "round"))
cap = CAIRO_LINE_CAP_ROUND;
else if (!strcmp(line_cap, "square"))
cap = CAIRO_LINE_CAP_SQUARE;
-
+
g_free(line_cap);
-
+
cairo_set_line_cap(cr, cap);
}
-gboolean seed_canvas_set_linejoin (SeedContext ctx,
- SeedObject this_object,
- SeedString property_name,
- SeedValue value,
- SeedException * e)
+gboolean seed_canvas_set_linejoin(SeedContext ctx,
+ SeedObject this_object,
+ SeedString property_name,
+ SeedValue value, SeedException * e)
{
GET_CR;
cairo_line_join_t join = CAIRO_LINE_JOIN_MITER;
- gchar * line_join =
- seed_value_to_string(ctx, value, e);
-
+ gchar *line_join = seed_value_to_string(ctx, value, e);
+
if (!strcmp(line_join, "round"))
join = CAIRO_LINE_JOIN_ROUND;
else if (!strcmp(line_join, "bevel"))
join = CAIRO_LINE_JOIN_BEVEL;
-
+
g_free(line_join);
-
- cairo_set_line_join (cr, join);
-}
+ cairo_set_line_join(cr, join);
+}
void seed_canvas_stroke_setup(SeedContext ctx,
SeedObject this_object,
- cairo_t * cr,
- SeedException * exception)
+ cairo_t * cr, SeedException * exception)
{
- gchar * stroke_color =
- seed_value_to_string(ctx,
- seed_object_get_property(ctx, this_object,
- "strokeStyle"),
- exception);
- gdouble global_alpha =
- seed_value_to_double(ctx,
- seed_object_get_property(ctx, this_object,
- "globalAlpha"),
- exception);
-
+ gchar *stroke_color = seed_value_to_string(ctx,
+ seed_object_get_property(ctx,
+ this_object,
+ "strokeStyle"),
+ exception);
+ gdouble global_alpha = seed_value_to_double(ctx,
+ seed_object_get_property(ctx,
+ this_object,
+ "globalAlpha"),
+ exception);
seed_canvas_parse_color(cr, stroke_color, global_alpha);
g_free(stroke_color);
}
-
-
-SeedValue seed_canvas_save (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_save(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
cairo_save(cr);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_restore (SeedContext ctx,
+SeedValue seed_canvas_restore(SeedContext ctx,
SeedObject function,
SeedObject this_object,
size_t argument_count,
@@ -327,68 +318,68 @@
{
GET_CR;
cairo_restore(cr);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_scale (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_scale(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x = seed_value_to_double(ctx, arguments[0], exception);
gdouble y = seed_value_to_double(ctx, arguments[1], exception);
-
+
cairo_scale(cr, x, y);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_translate (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_translate(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x = seed_value_to_double(ctx, arguments[0], exception);
gdouble y = seed_value_to_double(ctx, arguments[1], exception);
-
+
cairo_translate(cr, x, y);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_rotate (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_rotate(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x = seed_value_to_double(ctx, arguments[0], exception);
-
+
cairo_rotate(cr, x);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_transform (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_transform(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
cairo_matrix_t matrix;
- gdouble xx, yx, xy, yy, x0, y0;
-
+ gdouble xx, yx, xy, yy, x0, y0;
+
xx = seed_value_to_double(ctx, arguments[0], exception);
yx = seed_value_to_double(ctx, arguments[1], exception);
xy = seed_value_to_double(ctx, arguments[2], exception);
@@ -402,17 +393,17 @@
return seed_make_null(ctx);
}
-SeedValue seed_canvas_set_transform (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_set_transform(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
cairo_matrix_t matrix;
- gdouble xx, yx, xy, yy, x0, y0;
-
+ gdouble xx, yx, xy, yy, x0, y0;
+
cairo_identity_matrix(cr);
xx = seed_value_to_double(ctx, arguments[0], exception);
@@ -421,106 +412,103 @@
yy = seed_value_to_double(ctx, arguments[3], exception);
x0 = seed_value_to_double(ctx, arguments[4], exception);
y0 = seed_value_to_double(ctx, arguments[5], exception);
-
+
cairo_matrix_init(&matrix, xx, yx, xy, yy, x0, y0);
cairo_transform(cr, &matrix);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_clear_rect (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_clear_rect(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x, y, width, height;
-
+
x = seed_value_to_double(ctx, arguments[0], exception);
y = seed_value_to_double(ctx, arguments[1], exception);
- width = seed_value_to_double(ctx, arguments[2], exception);
+ width = seed_value_to_double(ctx, arguments[2], exception);
height = seed_value_to_double(ctx, arguments[3], exception);
-
+
cairo_save(cr);
-
+
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_rectangle(cr, x, y, width, height);
-
cairo_fill(cr);
-
+
cairo_restore(cr);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_stroke_rect (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_stroke_rect(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x, y, width, height;
seed_canvas_stroke_setup(ctx, this_object, cr, exception);
-
+
x = seed_value_to_double(ctx, arguments[0], exception);
y = seed_value_to_double(ctx, arguments[1], exception);
- width = seed_value_to_double(ctx, arguments[2], exception);
+ width = seed_value_to_double(ctx, arguments[2], exception);
height = seed_value_to_double(ctx, arguments[3], exception);
cairo_rectangle(cr, x, y, width, height);
cairo_stroke(cr);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_fill_rect (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+
+SeedValue seed_canvas_fill_rect(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x, y, width, height;
- gchar * stroke_color =
- seed_value_to_string(ctx,
- seed_object_get_property(ctx, this_object,
- "fillStyle"),
- exception);
- gdouble global_alpha =
- seed_value_to_double(ctx,
- seed_object_get_property(ctx, this_object,
- "globalAlpha"),
- exception);
-
+ gchar *stroke_color = seed_value_to_string(ctx,
+ seed_object_get_property(ctx,
+ this_object,
+ "fillStyle"),
+ exception);
+ gdouble global_alpha = seed_value_to_double(ctx,
+ seed_object_get_property(ctx,
+ this_object,
+ "globalAlpha"),
+ exception);
-
seed_canvas_parse_color(cr, stroke_color, global_alpha);
g_free(stroke_color);
-
+
x = seed_value_to_double(ctx, arguments[0], exception);
y = seed_value_to_double(ctx, arguments[1], exception);
- width = seed_value_to_double(ctx, arguments[2], exception);
+ width = seed_value_to_double(ctx, arguments[2], exception);
height = seed_value_to_double(ctx, arguments[3], exception);
-
+
cairo_rectangle(cr, x, y, width, height);
cairo_fill(cr);
-
return seed_make_null(ctx);
}
-SeedValue seed_canvas_end_path (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_end_path(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
@@ -529,21 +517,21 @@
return seed_make_null(ctx);
}
-SeedValue seed_canvas_begin_path (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_begin_path(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
-
+
cairo_new_path(cr);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_move_to (SeedContext ctx,
+SeedValue seed_canvas_move_to(SeedContext ctx,
SeedObject function,
SeedObject this_object,
size_t argument_count,
@@ -552,7 +540,7 @@
{
GET_CR;
gdouble x, y;
-
+
x = seed_value_to_double(ctx, arguments[0], exception);
y = seed_value_to_double(ctx, arguments[1], exception);
@@ -561,7 +549,7 @@
return seed_make_null(ctx);
}
-SeedValue seed_canvas_line_to (SeedContext ctx,
+SeedValue seed_canvas_line_to(SeedContext ctx,
SeedObject function,
SeedObject this_object,
size_t argument_count,
@@ -570,22 +558,22 @@
{
GET_CR;
gdouble x, y;
-
+
x = seed_value_to_double(ctx, arguments[0], exception);
y = seed_value_to_double(ctx, arguments[1], exception);
cairo_line_to(cr, x, y);
}
-SeedValue seed_canvas_stroke (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_stroke(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
-
+
seed_canvas_stroke_setup(ctx, this_object, cr, exception);
cairo_stroke(cr);
@@ -593,66 +581,65 @@
return seed_make_null(ctx);
}
-SeedValue seed_canvas_clip (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_clip(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
-
+
cairo_clip(cr);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_fill (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
-{
- GET_CR;
- gchar * stroke_color =
- seed_value_to_string(ctx,
- seed_object_get_property(ctx, this_object,
- "fillStyle"),
- exception);
- gdouble global_alpha =
- seed_value_to_double(ctx,
- seed_object_get_property(ctx, this_object,
- "globalAlpha"),
- exception);
-
+SeedValue seed_canvas_fill(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gchar *stroke_color = seed_value_to_string(ctx,
+ seed_object_get_property(ctx,
+ this_object,
+ "fillStyle"),
+ exception);
+ gdouble global_alpha = seed_value_to_double(ctx,
+ seed_object_get_property(ctx,
+ this_object,
+ "globalAlpha"),
+ exception);
+
seed_canvas_parse_color(cr, stroke_color, global_alpha);
g_free(stroke_color);
-
-
+
cairo_fill(cr);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_arc (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_arc(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble xc, yc, radius, start, end;
gboolean counter_clockwise;
-
+
xc = seed_value_to_double(ctx, arguments[0], exception);
yc = seed_value_to_double(ctx, arguments[1], exception);
radius = seed_value_to_double(ctx, arguments[2], exception);
start = seed_value_to_double(ctx, arguments[3], exception);
end = seed_value_to_double(ctx, arguments[4], exception);
counter_clockwise = seed_value_to_boolean(ctx, arguments[5], exception);
-
+
if (counter_clockwise)
cairo_arc_negative(cr, xc, yc, radius, end, start);
else
@@ -661,67 +648,67 @@
return seed_make_null(ctx);
}
-SeedValue seed_canvas_quadratic (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_quadratic(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
-
+
gdouble p0x, p0y, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y;
gdouble qp1x, qp1y, qp2x, qp2y;
-
+
cairo_get_current_point(cr, &p0x, &p0y);
-
+
qp1x = seed_value_to_double(ctx, arguments[0], exception);
qp1y = seed_value_to_double(ctx, arguments[1], exception);
qp2x = seed_value_to_double(ctx, arguments[2], exception);
qp2y = seed_value_to_double(ctx, arguments[3], exception);
-
+
cp3x = qp2x;
cp3y = qp2y;
-
- cp1x = p0x + 2/3.0 * (qp1x-p0x);
- cp1y = p0y + 2/3.0 * (qp1y-p0y);
-
- cp2x = cp1x + 1/3.0 * (qp2x-p0x);
- cp2y = cp1y + 1/3.0 * (qp2y-p0y);
-
+
+ cp1x = p0x + 2 / 3.0 * (qp1x - p0x);
+ cp1y = p0y + 2 / 3.0 * (qp1y - p0y);
+
+ cp2x = cp1x + 1 / 3.0 * (qp2x - p0x);
+ cp2y = cp1y + 1 / 3.0 * (qp2y - p0y);
+
cairo_curve_to(cr, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y);
-
- return seed_make_null(ctx);
+
+ return seed_make_null(ctx);
}
-SeedValue seed_canvas_bezier (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_bezier(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble cp0x, cp0y, cp1x, cp1y, cp2x, cp2y;
-
+
cp0x = seed_value_to_double(ctx, arguments[0], exception);
cp0y = seed_value_to_double(ctx, arguments[1], exception);
cp1x = seed_value_to_double(ctx, arguments[2], exception);
cp1y = seed_value_to_double(ctx, arguments[3], exception);
cp2x = seed_value_to_double(ctx, arguments[4], exception);
cp2y = seed_value_to_double(ctx, arguments[5], exception);
-
+
cairo_curve_to(cr, cp0x, cp0y, cp1x, cp1y, cp2x, cp2y);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_rect (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_rect(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
gdouble x, y, width, height;
@@ -730,117 +717,146 @@
y = seed_value_to_double(ctx, arguments[1], exception);
width = seed_value_to_double(ctx, arguments[2], exception);
height = seed_value_to_double(ctx, arguments[3], exception);
-
+
cairo_rectangle(cr, x, y, width, height);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_flush (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_flush(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
- cairo_surface_t * surface = cairo_get_target(cr);
-
+ cairo_surface_t *surface = cairo_get_target(cr);
+
cairo_surface_flush(surface);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_finish (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_finish(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
- cairo_surface_t * surface = cairo_get_target(cr);
-
+ cairo_surface_t *surface = cairo_get_target(cr);
+
cairo_surface_finish(surface);
return seed_make_null(ctx);
}
-SeedValue seed_canvas_showpage (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_showpage(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
cairo_show_page(cr);
-
+
return seed_make_null(ctx);
}
-SeedValue seed_canvas_destroy (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_canvas_destroy(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
GET_CR;
cairo_destroy(cr);
-
+
return seed_make_null(ctx);
}
static void canvas_finalize(SeedObject object)
{
- cairo_t * cr = seed_object_get_private(object);
+ cairo_t *cr = seed_object_get_private(object);
if (cr)
cairo_destroy(cr);
}
seed_static_function canvas_funcs[] = {
- {"save", seed_canvas_save, 0},
- {"restore", seed_canvas_restore, 0},
- {"scale", seed_canvas_scale, 0},
- {"rotate", seed_canvas_rotate, 0},
- {"translate", seed_canvas_translate, 0},
- {"transform", seed_canvas_transform, 0},
- {"setTransform", seed_canvas_set_transform, 0},
- {"clearRect", seed_canvas_clear_rect, 0},
- {"fillRect", seed_canvas_fill_rect, 0},
- {"strokeRect", seed_canvas_stroke_rect, 0},
- {"beginPath", seed_canvas_begin_path, 0},
- {"closePath", seed_canvas_end_path, 0},
- {"moveTo", seed_canvas_move_to, 0},
- {"lineTo", seed_canvas_line_to, 0},
- {"fill", seed_canvas_fill, 0},
- {"stroke", seed_canvas_stroke, 0},
- {"clip", seed_canvas_clip, 0},
- {"arc", seed_canvas_arc, 0},
- {"quadraticCurveTo", seed_canvas_quadratic, 0},
- {"bezierCurveTo", seed_canvas_bezier, 0},
- {"rect", seed_canvas_rect, 0},
- {"flush", seed_canvas_flush, 0},
- {"finish", seed_canvas_finish, 0},
- {"showPage", seed_canvas_showpage, 0},
- {"destroy", seed_canvas_destroy, 0},
+ {"save", seed_canvas_save, 0}
+ ,
+ {"restore", seed_canvas_restore, 0}
+ ,
+ {"scale", seed_canvas_scale, 0}
+ ,
+ {"rotate", seed_canvas_rotate, 0}
+ ,
+ {"translate", seed_canvas_translate, 0}
+ ,
+ {"transform", seed_canvas_transform, 0}
+ ,
+ {"setTransform", seed_canvas_set_transform, 0}
+ ,
+ {"clearRect", seed_canvas_clear_rect, 0}
+ ,
+ {"fillRect", seed_canvas_fill_rect, 0}
+ ,
+ {"strokeRect", seed_canvas_stroke_rect, 0}
+ ,
+ {"beginPath", seed_canvas_begin_path, 0}
+ ,
+ {"closePath", seed_canvas_end_path, 0}
+ ,
+ {"moveTo", seed_canvas_move_to, 0}
+ ,
+ {"lineTo", seed_canvas_line_to, 0}
+ ,
+ {"fill", seed_canvas_fill, 0}
+ ,
+ {"stroke", seed_canvas_stroke, 0}
+ ,
+ {"clip", seed_canvas_clip, 0}
+ ,
+ {"arc", seed_canvas_arc, 0}
+ ,
+ {"quadraticCurveTo", seed_canvas_quadratic, 0}
+ ,
+ {"bezierCurveTo", seed_canvas_bezier, 0}
+ ,
+ {"rect", seed_canvas_rect, 0}
+ ,
+ {"flush", seed_canvas_flush, 0}
+ ,
+ {"finish", seed_canvas_finish, 0}
+ ,
+ {"showPage", seed_canvas_showpage, 0}
+ ,
+ {"destroy", seed_canvas_destroy, 0}
+ ,
{0, 0, 0}
};
//TODO: Implement getters that use cairo for consistency...
seed_static_value canvas_properties[] = {
- {"lineWidth", 0, seed_canvas_set_linewidth, 0},
- {"lineCap", 0, seed_canvas_set_linecap, 0},
- {"lineJoin", 0, seed_canvas_set_linejoin, 0},
- {"miterLimit", 0, seed_canvas_set_miterlimit, 0},
+ {"lineWidth", 0, seed_canvas_set_linewidth, 0}
+ ,
+ {"lineCap", 0, seed_canvas_set_linecap, 0}
+ ,
+ {"lineJoin", 0, seed_canvas_set_linejoin, 0}
+ ,
+ {"miterLimit", 0, seed_canvas_set_miterlimit, 0}
+ ,
{0, 0, 0, 0}
};
void seed_module_init(SeedEngine * local_eng)
{
SeedObject canvas_constructor, pdf_constructor,
- svg_constructor, image_constructor;
+ svg_constructor, image_constructor;
seed_class_definition canvas_class_def = seed_empty_class;
eng = local_eng;
@@ -849,37 +865,37 @@
seed_object_set_property(eng->context, eng->global, "Canvas",
namespace_ref);
-
+
canvas_class_def.class_name = "CairoCanvas";
canvas_class_def.static_functions = canvas_funcs;
canvas_class_def.finalize = canvas_finalize;
canvas_class_def.static_values = canvas_properties;
-
+
canvas_class = seed_create_class(&canvas_class_def);
-
+
canvas_constructor = seed_make_constructor(eng->context,
canvas_class,
canvas_construct_canvas);
pdf_constructor = seed_make_constructor(eng->context,
- canvas_class,
- canvas_construct_pdf_canvas);
+ canvas_class,
+ canvas_construct_pdf_canvas);
svg_constructor = seed_make_constructor(eng->context,
- canvas_class,
- canvas_construct_svg_canvas);
-
+ canvas_class,
+ canvas_construct_svg_canvas);
+
image_constructor = seed_make_constructor(eng->context,
canvas_class,
seed_construct_image_canvas);
-
+
seed_object_set_property(eng->context, namespace_ref, "CairoCanvas",
- canvas_constructor);
+ canvas_constructor);
seed_object_set_property(eng->context, namespace_ref, "PDFCanvas",
- pdf_constructor);
+ pdf_constructor);
seed_object_set_property(eng->context, namespace_ref, "SVGCanvas",
- svg_constructor);
+ svg_constructor);
seed_object_set_property(eng->context, namespace_ref, "ImageCanvas",
- svg_constructor);
-
+ svg_constructor);
+
}
Modified: trunk/modules/readline/seed-readline.c
==============================================================================
--- trunk/modules/readline/seed-readline.c (original)
+++ trunk/modules/readline/seed-readline.c Wed Jan 14 05:10:40 2009
@@ -6,13 +6,10 @@
#include <sys/mman.h>
SeedObject namespace_ref;
-SeedEngine * eng;
+SeedEngine *eng;
static void
-seed_handle_rl_closure(ffi_cif * cif,
- void * result,
- void ** args,
- void * userdata)
+seed_handle_rl_closure(ffi_cif * cif, void *result, void **args, void *userdata)
{
SeedContext ctx = seed_context_create(eng->group, NULL);
SeedValue exception = 0;
@@ -21,28 +18,28 @@
seed_object_call(ctx, function, 0, 0, 0, &exception);
if (exception)
{
- gchar *mes = seed_exception_to_string(ctx,
+ gchar *mes = seed_exception_to_string(ctx,
exception);
g_warning("Exception in readline bind key closure. %s \n", mes, 0);
}
- seed_context_unref((SeedContext)ctx);
+ seed_context_unref((SeedContext) ctx);
}
// "Leaky" in that it exists for lifetime of program,
// kind of unavoidable though.
-static ffi_closure * seed_make_rl_closure(SeedObject function)
+static ffi_closure *seed_make_rl_closure(SeedObject function)
{
- ffi_cif * cif;
+ ffi_cif *cif;
ffi_closure *closure;
ffi_arg result;
ffi_status status;
-
+
cif = g_new0(ffi_cif, 1);
closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
ffi_prep_cif(cif, FFI_DEFAULT_ABI, 0, &ffi_type_sint, 0);
ffi_prep_closure(closure, cif, seed_handle_rl_closure, function);
-
+
return closure;
}
@@ -51,11 +48,10 @@
SeedObject function,
SeedObject this_object,
size_t argumentCount,
- const SeedValue arguments[],
- SeedValue * exception)
+ const SeedValue arguments[], SeedValue * exception)
{
- gchar * key;
- ffi_closure * c;
+ gchar *key;
+ ffi_closure *c;
if (argumentCount != 2)
{
@@ -68,12 +64,12 @@
}
key = seed_value_to_string(ctx, arguments[0], exception);
- c = seed_make_rl_closure((SeedObject)arguments[1]);
-
- rl_bind_key(*key, (Function*)c);
-
+ c = seed_make_rl_closure((SeedObject) arguments[1]);
+
+ rl_bind_key(*key, (Function *) c);
+
g_free(key);
-
+
return seed_make_null(ctx);
}
@@ -82,8 +78,7 @@
SeedObject function,
SeedObject this_object,
size_t argumentCount,
- const SeedValue arguments[],
- SeedValue * exception)
+ const SeedValue arguments[], SeedValue * exception)
{
SeedValue valstr = 0;
gchar *str = 0;
@@ -120,21 +115,21 @@
void seed_module_init(SeedEngine * local_eng)
{
seed_class_definition readline_class_def = seed_empty_class;
-
+
eng = local_eng;
namespace_ref = seed_make_object(eng->context, 0, 0);
seed_create_function(eng->context,
"readline",
- (SeedFunctionCallback)seed_readline,
- (SeedObject)namespace_ref);
+ (SeedFunctionCallback) seed_readline,
+ (SeedObject) namespace_ref);
seed_create_function(eng->context,
"bind",
- (SeedFunctionCallback)seed_readline_bind,
- (SeedObject)namespace_ref);
-
- seed_object_set_property(eng->context,
+ (SeedFunctionCallback) seed_readline_bind,
+ (SeedObject) namespace_ref);
+
+ seed_object_set_property(eng->context,
eng->global, "readline", namespace_ref);
}
Modified: trunk/modules/sqlite/seed-sqlite.c
==============================================================================
--- trunk/modules/sqlite/seed-sqlite.c (original)
+++ trunk/modules/sqlite/seed-sqlite.c Wed Jan 14 05:10:40 2009
@@ -3,7 +3,7 @@
SeedObject namespace_ref;
SeedClass sqlite_class;
-SeedEngine * eng;
+SeedEngine *eng;
#define MAKE_ERROR_ENUM(name) \
seed_object_set_property(eng->context, namespace_ref, #name, \
@@ -43,34 +43,34 @@
void sqlite_database_finalize(SeedObject object)
{
- sqlite3 * db = seed_object_get_private(object);
+ sqlite3 *db = seed_object_get_private(object);
if (db)
sqlite3_close(db);
}
SeedObject sqlite_construct_database(SeedContext ctx,
- SeedObject constructor,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+ SeedObject constructor,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
SeedObject ret;
- gchar * file;
- sqlite3 * db;
+ gchar *file;
+ sqlite3 *db;
int rc;
if (argument_count != 1)
{
seed_make_exception(ctx, exception, "ArgumentError",
"sqlite.Database constructor expected 1 argument");
- return (SeedObject)seed_make_null(ctx);
+ return (SeedObject) seed_make_null(ctx);
}
file = seed_value_to_string(ctx, arguments[0], exception);
rc = sqlite3_open(file, &db);
-
+
g_free(file);
-
+
ret = seed_make_object(ctx, sqlite_class, db);
seed_object_set_property(ctx, ret, "status",
seed_value_from_int(ctx, rc, exception));
@@ -80,13 +80,12 @@
static int seed_sqlite_exec_callback(SeedObject function,
int argc,
- gchar ** argv,
- gchar ** azColName)
+ gchar ** argv, gchar ** azColName)
{
SeedGlobalContext ctx;
SeedObject hash;
int i;
-
+
if (!function)
return 0;
@@ -96,78 +95,77 @@
for (i = 0; i < argc; i++)
{
seed_object_set_property(ctx, hash,
- azColName[i],
- seed_value_from_string(ctx, argv[i], 0));
+ azColName[i],
+ seed_value_from_string(ctx, argv[i], 0));
}
-
+
seed_object_call(ctx, function, 0, 1, &hash, 0);
-
+
seed_context_unref(ctx);
-
+
return 0;
}
-SeedValue seed_sqlite_exec (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
-{
- gchar * statement;
- gchar * sqlite_error = 0;
- sqlite3 * db;
+SeedValue seed_sqlite_exec(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ gchar *statement;
+ gchar *sqlite_error = 0;
+ sqlite3 *db;
int rc;
-
+
if (argument_count < 1)
{
seed_make_exception(ctx, exception, "ArgumentError",
"sqlite.Database.exec expected 1 or 2 arguments");
return seed_make_null(ctx);
}
-
+
statement = seed_value_to_string(ctx, arguments[0], exception);
db = seed_object_get_private(this_object);
g_assert(db);
- rc = sqlite3_exec(db, statement,
- seed_sqlite_exec_callback,
+ rc = sqlite3_exec(db, statement,
+ seed_sqlite_exec_callback,
argument_count == 2 ? arguments[1] : 0, &sqlite_error);
g_free(statement);
-
+
if (rc != SQLITE_OK)
{
if (sqlite_error)
{
- seed_make_exception(ctx,
- exception,
- "SqliteError",
- sqlite_error);
+ seed_make_exception(ctx, exception, "SqliteError", sqlite_error);
sqlite3_free(sqlite_error);
}
return seed_make_null(ctx);
}
return seed_value_from_int(ctx, rc, exception);
-
+
}
-SeedValue seed_sqlite_close (SeedContext ctx,
- SeedObject function,
- SeedObject this_object,
- size_t argument_count,
- const SeedValue arguments[],
- SeedException * exception)
+SeedValue seed_sqlite_close(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
- sqlite3 * db = seed_object_get_private(this_object);
+ sqlite3 *db = seed_object_get_private(this_object);
sqlite3_close(db);
return seed_value_from_boolean(ctx, TRUE, exception);
}
seed_static_function database_funcs[] = {
- {"close", seed_sqlite_close, 0},
- {"exec", seed_sqlite_exec, 0 },
+ {"close", seed_sqlite_close, 0}
+ ,
+ {"exec", seed_sqlite_exec, 0}
+ ,
{0, 0, 0}
};
@@ -175,23 +173,23 @@
{
SeedObject db_constructor;
seed_class_definition sqlite_class_def = seed_empty_class;
-
+
eng = local_eng;
namespace_ref = seed_make_object(eng->context, 0, 0);
-
- seed_object_set_property(eng->context,
+
+ seed_object_set_property(eng->context,
eng->global, "sqlite", namespace_ref);
-
+
define_errors(eng);
-
+
sqlite_class_def.class_name = "Database";
sqlite_class_def.finalize = sqlite_database_finalize;
sqlite_class_def.static_functions = database_funcs;
sqlite_class = seed_create_class(&sqlite_class_def);
-
- db_constructor = seed_make_constructor(eng->context,
+
+ db_constructor = seed_make_constructor(eng->context,
sqlite_class,
sqlite_construct_database);
seed_object_set_property(eng->context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]