Briefly (i am on a tablet) : this can be done a few different ways, but
getting at the code is really tedious on a tablet :-\. I will post some
links to examples for you tomorrow. One quick idea: have the bound ctor
allow only some weird arguments and throw for everything else (and don't
document them in the js interface) . Your c++ code can then pass the weird
args to FunctionTemplate::NewInstace(). Example: require the args (null,
undefined, the real args...). Then throw if the args do not comply. There
are other (cleaner) ways, too, e.g. passing a v8::External to the ctor (js
code cannot create these).
On Jul 10, 2012 10:34 PM, "Kevin James" <[email protected]> wrote:

> I want to write bindings for C++ objects whose constructors can't be
> called directly. Examples of what I'm talking about in a browser would
> be Element, ImageData, and Canvas. These are defined as functions in the
> global namespace, but if a script tries to call "new Element()", an
> exception is thrown. Instead an appropriate function has to be called, for
> example "document.createElement()".
>
> How are the bindings for these objects are written? If I create a
> FunctionTemplate, I can have it's constructor always throw an "Illegal
> Constructor" exception, but then how will my C++ code instantiate one of
> these objects?
>
> Thanks.
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

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

Reply via email to