Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Spidermonkey library loading mechanism?

22 views
Skip to first unread message

aum

unread,
Oct 12, 2006, 7:55:51 PM10/12/06
to
Hi,

Are there any plans to add a mechanism into SpiderMonkey to let it
interact with its environment, eg accessing libraries?

I've been looking into the task of implementing a libdl bridge, which
would allow:
- loading any C library dynamically, such as libmysqlclient, libc etc
- passing opaque pointers to and from javascript code
- javascript code to access C data structures, including
dereferencing pointers, pulling out native typed items etc
- javascript code to set up C call frames and invoke C functions
- javascript code to create/populate C data structures

Such a mechanism would allow people to write wrappers in
pure javascript to interact with any C library on the system, and
ultimately allow Spidermonkey to be used to power websites written in
server-side javascript.

This would have the appeal of allowing the same language to be used on
server and client side.

My question - are there any plans to move Spidermonkey in this direction,
or has anyone written anything like this?

For me, it would be quite a learning curve to accomplish all of this, and
I'd rather not re-invent the wheel.

Cheers
aum


sha...@shantirao.com

unread,
Oct 15, 2006, 8:47:26 PM10/15/06
to
Take a look at xpcshell, wxjs, or jsdb.

Shanti

lpsa...@gmail.com

unread,
Oct 16, 2006, 2:04:42 AM10/16/06
to
You ought to also look into JSNI (http://code.google.com/p/jsni/).

Louis

franck.fr

unread,
Oct 16, 2006, 5:05:17 AM10/16/06
to
Because JSNI is a wrapper to libffi, I moved it here: http://code.google.com/p/jslibs/ , and renamed it to jsffi.

It is quite easy to use it, you need to checkout http://jslibs.googlecode.com/svn/trunk/libffi/ and http://jslibs.googlecode.com/svn/trunk/jsffi/

Here is an example of use ( http://jslibs.googlecode.com/svn/trunk/tests/jsni_system.js ) :

function Alert( text, caption ) {

ret = new NativeData()
ret.PU32.Alloc();
new NativeModule('User32', true ).Proc('MessageBoxA')( ret, NULL(), SZ(text), SZ( caption || 'Alert' ), INT( 0 ) ); // using ordinal value of MessageBoxA
return ret[0];
}

(give me feedback)

Franck.

aum

unread,
Oct 16, 2006, 7:41:19 PM10/16/06
to
On Mon, 16 Oct 2006 11:05:17 +0200, franck.fr wrote:

> (give me feedback)

* Write some nice thorough HTML doco, sufficient for
folks to accomplish whatever they need without having
to look at the source code

* Toss in a couple of unix examples:
- using simple libc functions like sprintf
- using socket functions to build a minimal http client

Cheers
aum


0 new messages