[seed: 12/15] Free the search path
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed: 12/15] Free the search path
- Date: Sun, 12 Apr 2009 02:11:44 -0400 (EDT)
commit 7f6e81885e7b9f492ab09d331015026d644c18e8
Author: Robert Carr <racarr mireia (none)>
Date: Sun Apr 12 01:42:11 2009 -0400
Free the search path
---
libseed/seed-importer.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index f05498e..c60fd63 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -11,6 +11,8 @@ JSObjectRef gi_importer_versions;
JSObjectRef importer_search_path;
+JSClassRef importer_dir_class;
+
GHashTable *gi_imports;
GHashTable *file_imports;
@@ -358,6 +360,21 @@ seed_gi_importer_get_property (JSContextRef ctx,
}
+static void
+seed_importer_free_search_path (GSList *path)
+{
+ GSList *walk = path;
+
+ while (walk)
+ {
+ g_free (walk->data);
+ walk = walk->next;
+ }
+
+ g_slist_free (path);
+}
+
+
GSList *
seed_importer_get_search_path (JSContextRef ctx,
JSValueRef *exception)
@@ -410,7 +427,13 @@ seed_importer_handle_file (JSContextRef ctx,
}
if (!g_file_test (file_path, G_FILE_TEST_IS_REGULAR))
- return NULL;
+ {
+ if (g_file_test (file_path, G_FILE_TEST_IS_DIR))
+ {
+ return JSObjectMake (ctx, importer_dir_class, file_path);
+ }
+ return NULL;
+ }
g_file_get_contents (file_path, &contents, 0, NULL);
walk = contents;
@@ -483,6 +506,7 @@ seed_importer_search (JSContextRef ctx,
g_dir_close (dir);
g_free (mentry);
+ seed_importer_free_search_path (path);
return ret;
}
@@ -494,6 +518,7 @@ seed_importer_search (JSContextRef ctx,
walk = walk->next;
}
+ seed_importer_free_search_path (path);
return NULL;
}
@@ -523,6 +548,29 @@ seed_importer_get_property (JSContextRef ctx,
return ret;
}
+static JSValueRef
+seed_importer_dir_get_property (JSContextRef ctx,
+ JSObjectRef object,
+ JSStringRef property_name,
+ JSValueRef *exception)
+{
+ GDir *dir;
+ guint len;
+ gchar *prop, *dir_path, *entry;
+
+
+ dir_path = JSObjectGetPrivate (object);
+
+ len = JSStringGetMaximumUTF8CStringSize (property_name);
+ prop = g_alloca (len * sizeof (gchar));
+ JSStringGetUTF8CString (property_name, prop, len);
+
+ // TODO: GError
+ dir = g_dir_open (dir_path, 0, NULL);
+
+ return NULL;
+}
+
JSClassDefinition importer_class_def = {
0, /* Version, always 0 */
@@ -564,6 +612,26 @@ JSClassDefinition gi_importer_class_def = {
NULL /* Convert To Type */
};
+JSClassDefinition importer_dir_class_def = {
+ 0, /* Version, always 0 */
+ 0,
+ "importer_dir", /* Class Name */
+ NULL, /* Parent Class */
+ NULL, /* Static Values */
+ NULL, /* Static Functions */
+ NULL, /* Initialize */
+ NULL, /* Finalize */
+ NULL, /* Has Property */
+ seed_importer_dir_get_property, /* Get Property */
+ NULL, /* Set Property */
+ NULL, /* Delete Property */
+ NULL, /* Get Property Names */
+ NULL, /* Call As Function */
+ NULL, /* Call As Constructor */
+ NULL, /* Has Instance */
+ NULL /* Convert To Type */
+};
+
void seed_initialize_importer(JSContextRef ctx,
JSObjectRef global)
{
@@ -574,6 +642,8 @@ void seed_initialize_importer(JSContextRef ctx,
gi_importer = JSObjectMake (ctx, gi_importer_class, NULL);
gi_importer_versions = JSObjectMake (ctx, NULL, NULL);
+ importer_dir_class = JSClassCreate (&importer_dir_class_def);
+
gi_imports = g_hash_table_new (g_str_hash, g_str_equal);
file_imports = g_hash_table_new (g_str_hash, g_str_equal);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]