Subj : Re: Executing a line of C code in javascript To : netscape.public.mozilla.jseng From : Heath Raftery Date : Tue Aug 26 2003 01:18 am In article , Heath Raftery wrote: > In article , > David Bradley wrote: > > > Heath Raftery wrote: > > > 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! > > > > Do you have control over the code you're embedding SpiderMonkey in? What > > you need to do is to use JS_DefineFunction to link the C function to an > > object, possibly the global object. js.c has an example of what I'm > > talking about http://lxr.mozilla.org/seamonkey/source/js/src/js.c#2218. > > That defines multiple functions, JS_DefineFunction can be used to define > > a single function. > > Ah! That looks perfect! Very interesting indeed. Give me a couple of > days to find some time to read up and give it a shot, but it looks like > that should get me home :) > > Thanks very much, I'll report on any progress soon. Woohoo! As of a minute ago, I am successfully parsing PAC files in my application. I started looking at the leads you all provided about 3 or 4 hours ago, and just managed to get it all working! Thanks so much for your help. I will give a summary of my methods soon, and will also follow up with some tips on coding style in SpiderMonkey. I'm afraid my handling of contexts and objects might be a little sub par! Going to bed a happy man :) -- Heath ________________________________________________________ | *Nothing is foolproof to a sufficiently talented fool* | | _\|/_ | |________________________________________m(. .)m_________| .