
How to roll out your own Javascript API with V8 - olalonde
http://syskall.com/how-to-roll-out-your-own-javascript-api-with
======
vr
Tip: to make V8 startup and context creation significantly faster add
'snapshot=on' to your scons command line. This serializes the default heap
during compilation and quickly deserializes it on startup later.

------
palish
This is epic. Thank you!

Offtopic: I have always wanted a tutorial for "Here is how to embed WebKit
into your C++ application" (to make your own toy web browser). I realize
rendering a webpage is only one very tiny component of a browser, but it's
such an interesting one that I wish someone would put together a tutorial on
how to do that.

~~~
pmjordan
For embedding a web page display, you're probably best off looking at
Webkit/Gecko wrappers for whatever UI toolkit you're using. Getting an image
out of the renderer itself is one thing, but tying it into the surrounding
windowing environment (using the platform's native widgets, responding to
input, etc.) is less trivial. Fortunately, this work has usually already been
done for you, and you'll find toolkit-specific documentation on embedding.

For example, for WebKit there is Cocoa/Carbon integration[1], Cocoa Touch
integration [2], KDE & Qt integration [3], GTK [4], etc. You can probably find
others very easily, likewise for Gecko.

[1]
[http://developer.apple.com/library/mac/#documentation/Cocoa/...](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DisplayWebContent/DisplayWebContent.html#//apple_ref/doc/uid/10000164i)

[2]
[http://developer.apple.com/library/ios/#documentation/uikit/...](http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html)

[3] [http://api.kde.org/4.5-api/kdelibs-
apidocs/kdewebkit/html/in...](http://api.kde.org/4.5-api/kdelibs-
apidocs/kdewebkit/html/index.html)

[4] <http://webkitgtk.org/>

~~~
palish
Thanks for the info. However, what I really want is a simple "here is how to
render a webpage with webkit" tutorial.

(FYI I would be using .NET WinForms, so I doubt there's much open-source
love.)

~~~
mullr
When faced with this problem, I used the Qt port of webkit (QtWebkit) to make
an ActiveX control which I can use from windows forms. It doesn't work
instantly out of the box, but with a bit of massaging you can probably get
what you want.

Cool bonus feature: you can mark any objects you want to expose to the browser
via javascript with the COM interop attribute and send them over to your
homebrewed browser control. Qt's COM interop layer turns translates the Qt
flavor of dynamic dispatch calls into IDispatch calls. So it works pretty
seamlessly.

------
olalonde
I've recently ported the code to Node.js. I'll write about that whenever I
have some time.

<https://github.com/olalonde/node-notify>

Also available through NPM:

    
    
        npm install notify

~~~
pmjordan
Looks nice! I recently used node to add a web interface to a C++ app myself
and got annoyed with the amount of boilerplate code required for passing
function arguments (type checking, unboxing, boxing return values) so I
started a mechanism for automating it:

<https://github.com/pmj/node-method-wrapper>

It too is still work in progress, but it works pretty well so far. Note that
it currently superficially relies on some node-specific extensions, though
they should be pretty easy to remove, in order to use it with V8 alone.

