Subj : Re: Executing a line of C code in javascript To : Heath Raftery From : Brendan Eich Date : Thu Aug 21 2003 12:54 pm Heath Raftery wrote: >I noticed that previously in comp.lang.javascript, people have claimed >that C++/C functions are tricky to execute in javascript, possibly >requiring ActiveX interfaces or JNI work. However, Mozilla seems to do >it fine. > Yeah, we don't need no steeking Active X! ;-) >So, how would I achieve this without including most of mozilla in my >application? Is there a simpler way of achieving the same? I just want >to resolve a host name! Or even simpler - I just want to parse a PAC >file! > Did you read the http://www.mozilla.org/js/spidermonkey/ docs, especially the embedding tutorial? Or look at js.c? You can write a native function pretty easily. It's the thing that takes the (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) parameters and returns a JSBool (false means you reported an error or set a pending exception, true means it succeeded). /be .