[Gin] Allow ObjectTemplateBuilder and Wrappable to provide a typename
ObjectTemplateBuilder (and Wrappable) allow setting functions that are
exposed in JS and then forwarded to the type in C++. If these are C++
member functions, the context object is retrieved by looking at the
this-object in JavaScript, and trying to convert that to the underlying
C++ type (which will succeed if it was called on the V8 object created
by the Wrappable).
However, these member functions will fail if the JS function is called
on an improper this-object (including null and undefined). This means
that doing things like:
var obj = getObj(); // Some object from a Wrappable
var doFoo = obj.doFoo;
doFoo();
will fail because it's applied on an invalid this-object (undefined),
and the conversion will fail. This makes sense, but unfortunatley the
error gin throws in this case is unhelpful:
"Uncaught TypeError: Error processing argument at index -1, conversion
failure from undefined"
Instead, allow Wrappables and ObjectTemplateBuilders to specify a type
name, which will be surfaced in these errors to provide guidance to
developers. Update the error message to either include the type name or
to match the error message used in similar circumstances in blink
("Illegal invocation").
The new error messages will only be shown for failures in converting to
the context object, not for failure to convert subsequent arguments.
Bug: <File One>
Change-Id: I515a17e92992bfcb709b97455b9167b350e931f2
Reviewed-on: https://chromium-review.googlesource.com/987304
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by:
Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549219}
Showing
Please register or sign in to comment