Hi Stephan,

Thank you for your inputs.
Leaving aside those C/C++ details like passing parameters as
references instead of copy-constructor, you are perfectly right: I do
want to really get my hands dirty with the heavy code before adopting
such a wrapping library. This way, when that lib blows out in my face,
I at least know how the problem might be :)

My example was a simple snippet from my spaghetti-build-only-for-
testing-stuff kind of code :)

I thank you all very much for your inputs. I'm now starting to distill/
solidify the knowledge accumulated :)

On Apr 16, 5:01 pm, Stephan Beal <[email protected]> wrote:
> On Sat, Apr 16, 2011 at 1:43 PM, crtmpserver <[email protected]> wrote:
> > Assuming the point is created with var p=new Point(...);, Here is my
> > revised code.
>
> >http://pastebin.com/UWYi403p
>
> Some terribly minor suggestions:
>
> ------------- #1
> bool V8AppVirtualMachine::BindAPIPointClass(Handle<ObjectTemplate> global)
>
> Though, for this purpose, it is functionally identical, i recommend changing
> the parameter type to:
>
> (Handle<ObjectTemplate> & global)
>
> (note the '&'). This is cheaper, in terms of function call costs, as it
> avoids copying the Handle (which, granted, is actually just a very small
> wrapper object).
>
> ------------- #2
> //3. Set its class name
>         functionTemplate->SetClassName(String::New("Point"));
>
> that isn't strictly necessary, just FYI. It doesn't change how the class
> behaves, nor its name as it appears in the JS engine (that is set via Set(),
> as you do further down).
>
> ------------- #3
>  Handle<Value> getPointX(Local<String> property, const AccessorInfo &info) {
>         //1. For brevity, this is hard-coded
>         return Number::New(666.777);
>
> }
>
> When you get around to actually implementing the accessors and binding
> member functions and whatnot, there are several libraries which take much of
> the tedium out of that process by creating these bindings via C++ templates
> or (in more limited cases) macros. The libraries (which i know about) which
> fall into that category:
>
> http://code.google.com/p/v8-juice/(that one's 
> mine)https://github.com/tsa/vu8http://code.google.com/p/cproxyv8/http://code.google.com/p/v8cgi/http://nodejs.org/
>
> (That said, i'm assuming you are a new adopter of v8, and i think it's good
> that you write them by hand before using such a library, to better
> understand how v8 works.)
>
> --
> ----- stephan bealhttp://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to