本文整理汇总了C++中v8::FunctionCallbackInfo::IsConstructCall方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::IsConstructCall方法的具体用法?C++ FunctionCallbackInfo::IsConstructCall怎么用?C++ FunctionCallbackInfo::IsConstructCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::IsConstructCall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_scope
void
JavascriptEngineV8::constructSpatialReferenceCallback(const v8::FunctionCallbackInfo<v8::Value> &info)
{
if (!info.IsConstructCall())
{
v8::ThrowException(v8::String::New("Cannot call constructor as function"));
return;
}
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
osgEarth::SpatialReference* srs;
if (info.Length() == 1 && info[0]->IsString())
{
v8::String::Utf8Value utf8_value(info[0]->ToString());
std::string init(*utf8_value);
srs = osgEarth::SpatialReference::create(init);
}
if (!srs)
{
v8::ThrowException(v8::String::New("Unsupported arguments in constructor call"));
return;
}
info.GetReturnValue().Set(JSSpatialReference::WrapSpatialReference(v8::Isolate::GetCurrent(), srs, true));
}
示例2:
static void V8TestInterfaceNamedConstructor2ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (!info.IsConstructCall()) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Audio"));
return;
}
if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::throwException(createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "TestInterfaceNamedConstructor2", 1, info.Length()), info.GetIsolate());
return;
}
V8StringResource<> stringArg;
{
stringArg = info[0];
if (!stringArg.prepare())
return;
}
RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2::createForJSConstructor(stringArg);
v8::Local<v8::Object> wrapper = info.Holder();
wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wrapper);
v8SetReturnValue(info, wrapper);
}
示例3: constructCustomElement
static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
if (!info.IsConstructCall()) {
throwTypeError("DOM object constructor cannot be called as a function.", isolate);
return;
}
if (info.Length() > 0) {
throwTypeError("This constructor should be called without arguments.", isolate);
return;
}
Document* document = V8Document::toNative(V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Callee(), V8HiddenValue::customElementDocument(isolate)).As<v8::Object>());
TOSTRING_VOID(V8StringResource<>, namespaceURI, V8HiddenValue::getHiddenValue(isolate, info.Callee(), V8HiddenValue::customElementNamespaceURI(isolate)));
TOSTRING_VOID(V8StringResource<>, tagName, V8HiddenValue::getHiddenValue(isolate, info.Callee(), V8HiddenValue::customElementTagName(isolate)));
v8::Handle<v8::Value> maybeType = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Callee(), V8HiddenValue::customElementType(isolate));
TOSTRING_VOID(V8StringResource<>, type, maybeType);
ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomElement", info.Holder(), info.GetIsolate());
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI, tagName, maybeType->IsNull() ? nullAtom : type, exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValueFast(info, element.release(), document);
}
示例4: npObjectInvokeDefaultHandler
void npObjectInvokeDefaultHandler(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.IsConstructCall()) {
npObjectInvokeImpl(args, InvokeConstruct);
return;
}
npObjectInvokeImpl(args, InvokeDefault);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:9,代码来源:V8NPObject.cpp
示例5: exceptionState
void V8HTMLElement::HTMLConstructor(
const v8::FunctionCallbackInfo<v8::Value>& info) {
DCHECK(info.IsConstructCall());
v8::Isolate* isolate = info.GetIsolate();
ScriptState* scriptState = ScriptState::current(isolate);
if (!RuntimeEnabledFeatures::customElementsV1Enabled() ||
!scriptState->world().isMainWorld()) {
V8ThrowException::throwTypeError(info.GetIsolate(), "Illegal constructor");
return;
}
LocalDOMWindow* window = scriptState->domWindow();
ScriptCustomElementDefinition* definition =
ScriptCustomElementDefinition::forConstructor(
scriptState, window->customElements(), info.NewTarget());
if (!definition) {
V8ThrowException::throwTypeError(isolate, "Illegal constructor");
return;
}
ExceptionState exceptionState(ExceptionState::ConstructionContext,
"HTMLElement", info.Holder(), isolate);
Element* element;
if (definition->constructionStack().isEmpty()) {
// This is an element being created with 'new' from script
element = definition->createElementForConstructor(*window->document());
} else {
element = definition->constructionStack().last();
if (element) {
// This is an element being upgraded that has called super
definition->constructionStack().last().clear();
} else {
// During upgrade an element has invoked the same constructor
// before calling 'super' and that invocation has poached the
// element.
exceptionState.throwDOMException(InvalidStateError,
"this instance is already constructed");
return;
}
}
const WrapperTypeInfo* wrapperType = element->wrapperTypeInfo();
v8::Local<v8::Object> wrapper = V8DOMWrapper::associateObjectWithWrapper(
isolate, element, wrapperType, info.Holder());
// If the element had a wrapper, we now update and return that
// instead.
v8SetReturnValue(info, wrapper);
wrapper->SetPrototype(scriptState->context(), definition->prototype())
.ToChecked();
}
示例6:
void V8TestInterfaceEventInitConstructor::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (!info.IsConstructCall()) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceEventInitConstructor"));
return;
}
if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
TestInterfaceEventInitConstructorV8Internal::constructor(info);
}
示例7: exceptionState
static void V8TestInterfaceConstructorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (!info.IsConstructCall()) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Audio"));
return;
}
if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor", info.Holder(), info.GetIsolate());
if (UNLIKELY(info.Length() < 1)) {
setMinimumArityTypeError(exceptionState, 1, info.Length());
exceptionState.throwIfNeeded();
return;
}
V8StringResource<> arg;
V8StringResource<> optArg;
{
TOSTRING_VOID_INTERNAL(arg, info[0]);
if (UNLIKELY(info.Length() <= 1)) {
ScriptState* scriptState = ScriptState::current(info.GetIsolate());
ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::createForJSConstructor(scriptState, executionContext, document, arg, exceptionState);
if (exceptionState.hadException()) {
exceptionState.throwIfNeeded();
return;
}
v8::Local<v8::Object> wrapper = info.Holder();
impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructorConstructor::wrapperTypeInfo, wrapper);
v8SetReturnValue(info, wrapper);
return;
}
TOSTRING_VOID_INTERNAL(optArg, info[1]);
}
ScriptState* scriptState = ScriptState::current(info.GetIsolate());
ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::createForJSConstructor(scriptState, executionContext, document, arg, optArg, exceptionState);
if (exceptionState.hadException()) {
exceptionState.throwIfNeeded();
return;
}
v8::Local<v8::Object> wrapper = info.Holder();
impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructorConstructor::wrapperTypeInfo, wrapper);
v8SetReturnValue(info, wrapper);
}
示例8: throwTypeError
void V8TestInterfaceCustomConstructor::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
if (!info.IsConstructCall()) {
throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceCustomConstructor", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate());
return;
}
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
V8TestInterfaceCustomConstructor::constructorCustom(info);
}
示例9: NewBuilder
void BuilderWrapper::NewBuilder( const v8::FunctionCallbackInfo< v8::Value >& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate);
if( !args.IsConstructCall() )
{
DALI_SCRIPT_EXCEPTION( isolate, "Builder constructor called without 'new'" );
return;
}
Dali::Toolkit::Builder builder = BuilderApi::New( args );
v8::Local<v8::Object> localObject = WrapBuilder( isolate, builder );
args.GetReturnValue().Set( localObject );
}
示例10: throwTypeError
void V8TestEventConstructor::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
{
TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
if (!args.IsConstructCall()) {
throwTypeError(ExceptionMessages::failedToConstruct("TestEventConstructor", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), args.GetIsolate());
return;
}
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
args.GetReturnValue().Set(args.Holder());
return;
}
TestEventConstructorV8Internal::constructor(args);
}
示例11:
void V8TestNode::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
if (!info.IsConstructCall()) {
V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestNode"), info.GetIsolate());
return;
}
if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
TestNodeV8Internal::constructor(info);
}
示例12: newObject
static void newObject(const v8::FunctionCallbackInfo<v8::Value> & args)
{
if (args.IsConstructCall())
{
MethodMan call(args);
if (args.Length() != 2)
{
call.throwException("Wrong number of arguments");
return;
}
// the first parameter is a Cluster object, let's unwrap it to get access to the underlying handle
auto obj = call.checkedArgObject(0);
if (!obj.second)
{
call.throwException("Invalid parameter supplied to object");
return;
}
auto str = call.checkedArgString(1);
if (!str.second)
{
call.throwException("Expected a string as an argument");
return;
}
v8::String::Utf8Value utf8str(str.first);
// get access to the underlying handle
Cluster * c = ObjectWrap::Unwrap<Cluster>(obj.first);
Object * b = new Object(*c, *utf8str);
b->Wrap(args.This());
args.GetReturnValue().Set(args.This());
}
else
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// Invoked as plain function `MyObject(...)`, turn into construct call.
const int argc = 2;
v8::Local<v8::Value> argv[argc] = { args[0], args[1] };
v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
args.GetReturnValue().Set(cons->NewInstance(argc, argv));
}
}
示例13: callingExecutionContext
void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()), UseCounter::TestFeature);
if (!info.IsConstructCall()) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor"));
return;
}
if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
TestInterfaceConstructorV8Internal::constructor(info);
}
示例14: New
static void New(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.IsConstructCall())
{
MethodMan call(args);
if (args.Length() != 1)
{
call.throwException("Wrong number of arguments");
return;
}
auto str = call.checkedArgString(0);
if (!str.second)
{
call.throwException("Expected a connection string as an argument");
return;
}
v8::String::Utf8Value utf8str(str.first);
// create and open handle
qdb_handle_t h = qdb_open_tcp();
const qdb_error_t err = qdb_connect(h, *utf8str);
if (err != qdb_e_ok)
{
qdb_close(h);
call.throwException(qdb_error(err));;
return;
}
// handle is now owned by the cluster object
Cluster * cl = new Cluster(h);
cl->Wrap(args.This());
args.GetReturnValue().Set(args.This());
}
else
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// Invoked as plain function `MyObject(...)`, turn into construct call.
const int argc = 1;
v8::Local<v8::Value> argv[argc] = { args[0] };
v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
args.GetReturnValue().Set(cons->NewInstance(argc, argv));
}
}
示例15:
static void V8TestInterfaceEventTargetConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (!info.IsConstructCall()) {
V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Name"), info.GetIsolate());
return;
}
if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(info, info.Holder());
return;
}
Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
RefPtrWillBeRawPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJSConstructor(document);
v8::Handle<v8::Object> wrapper = info.Holder();
impl->associateWithWrapper(&V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate());
v8SetReturnValue(info, wrapper);
}