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

Include native C++ function at runtime in Javascript?

123 views
Skip to first unread message

manne...@gmail.com

unread,
Dec 17, 2012, 10:49:52 AM12/17/12
to
Hey guys,
is it possible to include native C functions at runtime in my Javascript like it works at Node.js?
For example: var express = require('express');

And if it's possible can you give an example?

greez Manner

Nicolas B. Pierron

unread,
Dec 17, 2012, 11:23:58 AM12/17/12
to
As far as I know, this is not possible, may be the self-hosting modification
made recently made that possible.

Till, do you have any idea about that?

--
Nicolas B. Pierron

Wes Garland

unread,
Dec 17, 2012, 12:46:40 PM12/17/12
to manne...@gmail.com, dev-tech-...@lists.mozilla.org
FWIW, this is exactly the type of problem
http://code.google.com/p/gpseewas created to solve.... provided you
are in a JS embedding environment,
not trying to do this from the browser!

Wes

a.c...@weelya.com

unread,
Dec 17, 2012, 1:43:57 PM12/17/12
to dev-tech-...@lists.mozilla.org
Typo in the URL : http://code.google.com/p/gpsee

BTW, what's the problem with that? You just have to bind an object to a
JSNative or a container at runtime (either by dynamically loading a
library or already loaded binary).

gpsee abstract this to make it easier.

Le 2012-12-17 18:46, Wes Garland a écrit :

> On 17 December 2012 10:49, <manne...@gmail.com> wrote:
>
> FWIW, this is exactly the type of problem
> http://code.google.com/p/gpseewas created to solve.... provided you
> are in a JS embedding environment,
> not trying to do this from the browser!
>
> Wes
> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

manne...@gmail.com

unread,
Dec 17, 2012, 2:24:53 PM12/17/12
to
thanks guys i think this will be very helpfull! :)

anan...@gmail.com

unread,
Mar 26, 2013, 8:32:41 PM3/26/13
to
DO you want to look at this ?
http://code.google.com/p/libjspp/

Wes Garland

unread,
Mar 27, 2013, 10:18:07 AM3/27/13
to anan...@gmail.com, dev-tech-...@lists.mozilla.org
On 26 March 2013 20:32, <anan...@gmail.com> wrote:

> On Tuesday, December 18, 2012 1:49:52 AM UTC+10, manne...@gmail.com wrote:
> > Hey guys,
> >
> > is it possible to include native C functions at runtime in my Javascript
> like it works at Node.js?
> >
> > For example: var express = require('express');
>

If you can live with an older version of SpiderMonkey, you can use GPSEE
for this pretty easily. It's GPSEE's primary design goal.


> >
> >
> >
> > And if it's possible can you give an example?
>

There are many ways, depending on need. The simplest case, which addresses
90% of needs IME, is to use the gffi module.

#! /usr/bin/gsr
var GFFI = require("gffi");
var puts = new GFFI.CFunction(GFFI.int, "puts", GFFI.pointer);

puts("Hello, World");

Wes

--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102

Anand Rathi

unread,
Mar 27, 2013, 8:47:32 PM3/27/13
to anan...@gmail.com, dev-tech-...@lists.mozilla.org
Hi Wes ,
Would you like to try this , its c++ template base interface for JS , Additionaly it avoids multiple mallocs when strings are exchanged between C/C++ & JS
http://code.google.com/p/libjspp/

Thanks

Anand Rathi

unread,
Mar 27, 2013, 11:44:00 PM3/27/13
to anan...@gmail.com, dev-tech-...@lists.mozilla.org
Hi Wes,
I recently saw your replies ,
I was wondering if You want to try

http://code.google.com/p/libjspp/

In your products .
I will be very happy & grateful if you could do that

Thanks
Anand
0 new messages