Re: libseed-list imports.searchPath



I forgot I also made some changes to Seed.js:

if(!imports.searchPath || (imports.searchPath.length == 0))
{
	imports.searchPath = [
		"/usr/share/gnome-js",
		"/usr/lib/seed",
		"/usr/share/seed",
		"/usr/local/lib/seed",
		"/usr/local/share/seed",
		"/usr/lib/seed",
		"/usr/share/seed"];

__script_path__ = GLib.path_get_dirname(Seed.argv.length > 1 ? Seed.argv[1] : ".");
		
		try
		{
			if(!GLib.path_is_absolute(__script_path__))
			{
				__script_path__ = GLib.build_filenamev([GLib.get_current_dir(),
				                                      __script_path__]);
			}
		
			__script_path__ = imports.os.realpath(__script_path__);
		
		}
		catch(e)
		{
			print(imports.JSON.stringify(e));
		}

	imports.searchPath.unshift(".");
}
//////////////////////////

(always try to set __script_path__ but don't add it to searchPath since
we now replaces '.' with this instead)

/J

Jonatan Liljedahl wrote:
Here's the patch. It does the below, including replacing '.' with current script_path if set. It also shrank the source by 55 lines.

I've tested it, and everything works as expected. Please apply!

PS: something that didn't work before but now does, is that a dir_importer object will now allow importing of any existing libseed_xxx.so modules in that dir.

Regards
/Jonatan

Jonatan Liljedahl wrote:
Looking at the importer, I see a lot of things I'd like to do:

seed_importer_search() and seed_importer_dir_get_property() actually does the same thing, except seed_importer_search() does it once for each searchpath. I'll do a seed_importer_search_in_dir(dirpath, prop) that is called by both.

In this seed_importer_search_in_dir() I will instead of walking through all directory entries simply:

- is dirpath/prop a file or dir? pass it to seed_importer_handle_file()
- is dirpath/prop.js a file? pass it to seed_importer_handle_file()
- is dirpath/libseed_prop.so a file? pass it to seed_importer_handle_native_module()
- else return NULL

Note the check for .js extension. I really think this is the way to do it, you don't want it to load an old foo.js~ backup file or foo.data or whatever.

Patch coming soon!

/Jonatan

Jonatan Liljedahl wrote:
...
for the importer you could try changing the
seed-importer.c:seed_importer_search

from dir = g_dir_open ((gchar *) walk->data, 0, &e);


to something like this. gchar* sp = seed_value_to_string (ctx, seed_object_get_property (nctx, global, "__script_path__"); exception);

gchar* test_path = (gchar *) walk->data; if (strcmp(test_path, ".")
== 0) { test_path = sp; }

And see how it behaves. Regards Alan

Ok, will try something out.
/Jonatan






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]