seed r694 - trunk/libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r694 - trunk/libseed
- Date: Fri, 9 Jan 2009 06:37:33 +0000 (UTC)
Author: racarr
Date: Fri Jan 9 06:37:33 2009
New Revision: 694
URL: http://svn.gnome.org/viewvc/seed?rev=694&view=rev
Log:
Add support for GI_TYPE_TAG_FILENAME.
Modified:
trunk/libseed/seed-types.c
trunk/libseed/seed-types.h
trunk/libseed/seed.h
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Fri Jan 9 06:37:33 2009
@@ -108,6 +108,7 @@
switch (type_tag)
{
case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
g_free(arg->v_string);
break;
case GI_TYPE_TAG_ARRAY:
@@ -197,6 +198,7 @@
{
// TODO: FIXME: Leaaaks?
case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
return seed_release_arg(GI_TRANSFER_EVERYTHING,
type_info, type_tag, arg);
default:
@@ -367,6 +369,9 @@
case GI_TYPE_TAG_UTF8:
arg->v_string = seed_value_to_string(ctx, value, exception);
break;
+ case GI_TYPE_TAG_FILENAME:
+ arg->v_string = seed_value_to_filename(ctx, value, exception);
+ break;
case GI_TYPE_TAG_GTYPE:
arg->v_int = seed_value_to_int(ctx, value, exception);
break;
@@ -614,6 +619,8 @@
return seed_value_from_double(ctx, arg->v_double, exception);
case GI_TYPE_TAG_UTF8:
return seed_value_from_string(ctx, arg->v_string, exception);
+ case GI_TYPE_TAG_FILENAME:
+ return seed_value_from_filename(ctx, arg->v_string, exception);
case GI_TYPE_TAG_GTYPE:
return seed_value_from_int(ctx, arg->v_int, exception);
case GI_TYPE_TAG_ARRAY:
@@ -1375,6 +1382,48 @@
return valstr;
}
+JSValueRef seed_value_from_filename(JSContextRef ctx,
+ const gchar * filename,
+ JSValueRef * exception)
+{
+ GError *e = NULL;
+ gchar * utf8;
+
+ utf8 = g_filename_to_utf8(filename, -1, NULL,
+ NULL, &e);
+ if (e)
+ {
+ seed_make_exception_from_gerror(ctx, exception, e);
+ g_error_free(e);
+ // 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);
+ g_free(utf8);
+ if (e)
+ {
+ seed_make_exception_from_gerror(ctx, exception, e);
+ g_error_free(e);
+ return NULL;
+ }
+
+ return filename;
+}
+
GObject *seed_value_to_object(JSContextRef ctx,
JSValueRef val, JSValueRef * exception)
{
Modified: trunk/libseed/seed-types.h
==============================================================================
--- trunk/libseed/seed-types.h (original)
+++ trunk/libseed/seed-types.h Fri Jan 9 06:37:33 2009
@@ -109,8 +109,16 @@
JSValueRef seed_value_from_double(JSContextRef ctx,
gdouble 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);
+
gchar *seed_value_to_string(JSContextRef ctx,
JSValueRef val, JSValueRef * exception);
+
JSValueRef seed_value_from_string(JSContextRef ctx,
const gchar * val, JSValueRef * exception);
Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h (original)
+++ trunk/libseed/seed.h Fri Jan 9 06:37:33 2009
@@ -197,6 +197,14 @@
SeedValue seed_value_from_string(SeedContext ctx,
gchar * val, SeedException * exception);
+gchar * seed_value_to_filename(SeedContext ctx,
+ SeedValue val,
+ SeedValue *exception);
+SeedValue seed_value_from_filename(SeedContext ctx,
+ const gchar * filename,
+ SeedValue * exception);
+
+
GObject *seed_value_to_object(SeedContext ctx,
SeedValue val, SeedException * exception);
SeedValue seed_value_from_object(SeedContext ctx,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]