Skip to content

Low level JavaScript FFI using JavaScriptCore #41

Closed
hamishmack opened this Issue Sep 23, 2012 · 7 comments

3 participants

@hamishmack
ghcjs member

I think the native Haskell first approach to the DOM has worked well and we should do the same for a low level JavaScript interface. WebKitGtk comes with JavaScriptCore so that will probably be easiest.

The header files are in /usr/include/webkitgtk-1.0/JavaScriptCore. It's not GObject based and there's no IDL, so we might as well just wrap each function manually. I think the entry point we will need is webkit_web_frame_get_global_context to get a JavaScript context.

Once we have a working native code example that calls JavaScript we can compile it with GHCJS and write some JavaScript functions to implement the calls to JavaScriptCore.

Hopefully this interface will provide a foundation for a high level FFI as described in #3

@wavewave
ghcjs member
wavewave commented Oct 8, 2012

I started wetkit JavaScriptCore FFI at http://www.github.com/wavewave/webkit-javascriptcore

JSBase, JSContextGroup and JSObjectRef are implemented currently. will complete apis.

@wavewave wavewave was assigned Oct 8, 2012
@wavewave
ghcjs member
wavewave commented Oct 8, 2012

I think I almost implemented JavaScriptCore FFI (except windows-specific BSTR and mac os x-specific CFString thing) I haven't tested anything yet, but codes are compilable. Please feel free to fork it and modify as needed for ghcjs project!

@wavewave
ghcjs member

Now in https://github.com/wavewave/webkit-javascriptcore , webkit_web_frame_get_global_context is now added so that we can access javascript engine from webkit. I started a simple example in ghcjs-hello2 of my fork of ghcjs-examples https://github.com/wavewave/ghcjs-examples for javascriptcore ffi testing. Currently, a very simple javascript expression evaluation has been checked.

@hamishmack
ghcjs member

I have added some RTS support for the trampoline code gen (but in the Gen2 branch right now). I also added a higher level interface in https://github.com/ghcjs/jsc. I have added some sample code to ghcjs-hello.

@wavewave
ghcjs member
wavewave commented Dec 9, 2012

Great! I am going to test it soon. I need to switch to gen2 then, right?

@hamishmack
ghcjs member

I am currently testing with https://github.com/ghcjs/ghc/tree/ghc-7.6 and https://github.com/ghcjs/ghcjs/tree/gen2

But I am not using the Gen2 generator yet.

There is a .travis.yml file in ghc-7.6 that should indicate how to get the source. It uses unpack.sh to get source files needed (including switching ghcjs to the gen2 branch).

Once you have the source files you should be able to use ghcjs-build.sh to build both the integrated and stand alone versions of GHCJS.

@luite
ghcjs member
luite commented May 20, 2014

I think this works now, probably better to open new tickets for specific issues when they arise

@luite luite closed this May 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.