Re: libseed-list imports.searchPath
- From: Jonatan Liljedahl <lijon kymatica com>
- To: Seed - Gnome Javascript <libseed-list gnome org>
- Subject: Re: libseed-list imports.searchPath
- Date: Fri, 18 Jun 2010 13:35:56 +0200
Yes, you're absolutely right! Ignore my Seed.js change :)
/J
Alan Knowles wrote:
I'm trying to get my head round that ;)
our "." always points to the currently running script path
eg.
seed a.js
base/a.js
-------
c = imports.b.c; // -> base/b/c.js
base/b/c.js
----
d = imports.d; // could be base/b/d.js or base/d.js
however, unless we add __script_path__ on the initial run, that could never find base/d.js
or did I miss something.
Regards
Alan
--- On 18/Jun/2010, Jonatan Liljedahl wrote:
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
_______________________________________________
libseed-list mailing list
libseed-list gnome org
http://mail.gnome.org/mailman/listinfo/libseed-list
_______________________________________________
libseed-list mailing list
libseed-list gnome org
http://mail.gnome.org/mailman/listinfo/libseed-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]