本文整理汇总了C++中v8::Arguments::IsConstructCall方法的典型用法代码示例。如果您正苦于以下问题:C++ Arguments::IsConstructCall方法的具体用法?C++ Arguments::IsConstructCall怎么用?C++ Arguments::IsConstructCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Arguments
的用法示例。
在下文中一共展示了Arguments::IsConstructCall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClientWrap
v8::Handle<v8::Value> ClientWrap::New( v8::Arguments const &args )
{
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
FABRIC_ASSERT( args.IsConstructCall() );
v8::HandleScope v8HandleScope;
int compileGuarded = -1;
int logWarnings = -1;
if ( args.Length() > 0 && args[0]->IsObject() )
{
v8::Handle<v8::Object> opts = v8::Handle<v8::Object>::Cast( args[0] );
v8::Handle<v8::Value> logWarnings_ = opts->Get( v8::String::New( "logWarnings" ) );
if ( logWarnings_->IsBoolean() )
logWarnings = logWarnings_->BooleanValue();
v8::Handle<v8::Value> guarded = opts->Get( v8::String::New( "guarded" ) );
if ( guarded->IsBoolean() )
compileGuarded = guarded->BooleanValue();
}
ClientWrap *clientWrap = new ClientWrap( compileGuarded );
clientWrap->Wrap(args.This());
if ( logWarnings > -1 )
clientWrap->m_client->getContext()->setLogWarnings( logWarnings );
return v8HandleScope.Close( args.This() );
}
示例2: throwError
v8::Handle<v8::Value> V8AudioContext::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.AudioContext.Contructor");
if (!args.IsConstructCall())
return throwError("AudioContext constructor cannot be called as a function.", V8Proxy::TypeError);
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
return throwError("AudioContext constructor associated frame is unavailable", V8Proxy::ReferenceError);
Document* document = frame->document();
if (!document)
return throwError("AudioContext constructor associated document is unavailable", V8Proxy::ReferenceError);
RefPtr<AudioContext> audioContext;
if (!args.Length()) {
// Constructor for default AudioContext which talks to audio hardware.
audioContext = AudioContext::create(document);
if (!audioContext.get())
return throwError("audio resources unavailable for AudioContext construction", V8Proxy::SyntaxError);
} else {
// Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
// new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
if (args.Length() < 3)
return throwError("Not enough arguments", V8Proxy::SyntaxError);
bool ok = false;
int32_t numberOfChannels = toInt32(args[0], ok);
if (!ok || numberOfChannels <= 0 || numberOfChannels > 10)
return throwError("Invalid number of channels", V8Proxy::SyntaxError);
int32_t numberOfFrames = toInt32(args[1], ok);
if (!ok || numberOfFrames <= 0)
return throwError("Invalid number of frames", V8Proxy::SyntaxError);
float sampleRate = toFloat(args[2]);
if (sampleRate <= 0)
return throwError("Invalid sample rate", V8Proxy::SyntaxError);
ExceptionCode ec = 0;
audioContext = AudioContext::createOfflineContext(document, numberOfChannels, numberOfFrames, sampleRate, ec);
if (ec)
return throwError(ec);
}
if (!audioContext.get())
return throwError("Error creating AudioContext", V8Proxy::SyntaxError);
// Transform the holder into a wrapper object for the audio context.
V8DOMWrapper::setDOMWrapper(args.Holder(), &info, audioContext.get());
audioContext->ref();
return args.Holder();
}
示例3: throwError
v8::Handle<v8::Value> V8WebKitPoint::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.WebKitPoint.Constructor");
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
float x = 0;
float y = 0;
if (args.Length() > 1) {
if (!args[0]->IsUndefined()) {
x = toFloat(args[0]);
if (isnan(x))
x = 0;
}
if (!args[1]->IsUndefined()) {
y = toFloat(args[1]);
if (isnan(y))
y = 0;
}
}
RefPtr<WebKitPoint> point = WebKitPoint::create(x, y);
V8DOMWrapper::setDOMWrapper(args.Holder(), &info, point.get());
V8DOMWrapper::setJSWrapperForDOMObject(point.release(), v8::Persistent<v8::Object>::New(args.Holder()));
return args.Holder();
}
示例4: throwTypeError
void V8WebCL::constructorCustom(const v8::Arguments& args)
{
if (!args.IsConstructCall())
{ throwTypeError("DOM object constructor cannot be called as a function.",args.GetIsolate()); return; }
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
v8SetReturnValue(args, args.Holder());
return;
}
// Get the script execution context.
ScriptExecutionContext* context = (ScriptExecutionContext*)getExecutionContext(); //getScriptExecutionContext();
// if (!context)
//{ throwError(ReferenceError, "WebCL constructor's associated frame is not available", args.GetIsolate()); return; }
RefPtr<WebCL> computeContext = WebCL::create(context);
const WrapperTypeInfo &info = wrapperTypeInfo; // ScalableVision
V8DOMWrapper::setNativeInfo(args.Holder(), &info, computeContext.get());
//lifetime LT;
//V8DOMWrapper::setJSWrapperForActiveDOMObject(computeContext.release(), v8::Persistent<v8::Object>::New(args.Holder()), args.GetIsolate());
V8DOMWrapper::associateObjectWithWrapper<V8WebCL, WebCL>(computeContext.release(),&info, /*v8::Persistent<v8::Object>::New(*/args.Holder()/*)*/, args.GetIsolate(),WrapperConfiguration::Dependent );//ÅáÓ¨
v8SetReturnValue(args, args.Holder());
return;
}
示例5: throwTypeError
static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestNamedConstructor.Constructor");
if (!args.IsConstructCall())
return throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Document* document = currentDocument(BindingState::instance());
// Make sure the document is added to the DOM Node map. Otherwise, the TestNamedConstructor instance
// may end up being the only node in the map and get garbage-collected prematurely.
toV8(document, args.Holder(), args.GetIsolate());
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
ExceptionCode ec = 0;
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str2, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str3, MAYBE_MISSING_PARAMETER(args, 2, DefaultIsNullString));
RefPtr<TestNamedConstructor> impl = TestNamedConstructor::createForJSConstructor(document, str1, str2, str3, ec);
v8::Handle<v8::Object> wrapper = args.Holder();
if (ec)
goto fail;
V8DOMWrapper::setDOMWrapper(wrapper, &V8TestNamedConstructorConstructor::info, impl.get());
V8DOMWrapper::setJSWrapperForActiveDOMObject(impl.release(), wrapper, args.GetIsolate());
return wrapper;
fail:
return setDOMException(ec, args.GetIsolate());
}
示例6: throwTypeError
v8::Handle<v8::Value> V8RTCIceCandidate::constructorCallback(const v8::Arguments& args)
{
if (!args.IsConstructCall())
return throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
ExceptionCode ec = 0;
V8TRYCATCH(Dictionary, dictionary, Dictionary(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined), args.GetIsolate()));
if (!dictionary.isUndefinedOrNull() && !dictionary.isObject())
return throwTypeError("Not an object.", args.GetIsolate());
RefPtr<RTCIceCandidate> impl = RTCIceCandidate::create(dictionary, ec);
v8::Handle<v8::Object> wrapper = args.Holder();
if (ec)
goto fail;
V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate());
return wrapper;
fail:
return setDOMException(ec, args.GetIsolate());
}
示例7: npObjectInvokeImpl
v8::Handle<v8::Value> npObjectInvokeDefaultHandler(const v8::Arguments& args)
{
if (args.IsConstructCall())
return npObjectInvokeImpl(args, InvokeConstruct);
else
return npObjectInvokeImpl(args, InvokeDefault);
}
示例8: throwError
v8::Handle<v8::Value> V8Custom::v8HTMLAudioElementConstructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.HTMLAudioElement.Contructor");
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.");
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
return throwError("Audio constructor associated frame is unavailable", V8Proxy::ReferenceError);
Document* document = frame->document();
if (!document)
return throwError("Audio constructor associated document is unavailable", V8Proxy::ReferenceError);
// Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance
// may end up being the only node in the map and get garbage-ccollected prematurely.
V8DOMWrapper::convertNodeToV8Object(document);
RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
audio->setAutobuffer(true);
if (args.Length() > 0) {
audio->setSrc(toWebCoreString(args[0]));
audio->scheduleLoad();
}
V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::NODE), audio.get());
audio->ref();
V8DOMWrapper::setJSWrapperForDOMNode(audio.get(), v8::Persistent<v8::Object>::New(args.Holder()));
return args.Holder();
}
示例9: if
v8::Handle<v8::Value> V8ArrayBuffer::constructor(const v8::Arguments& args) {
if (!args.IsConstructCall())
return v8::ThrowException(v8::String::New("Cannot call constructor as function"));
uscxml::ArrayBuffer* localInstance = NULL;
if (false) {
} else if (args.Length() == 1 &&
args[0]->IsUint32()) {
unsigned long localLength = args[0]->ToNumber()->Uint32Value();
localInstance = new uscxml::ArrayBuffer(localLength);
}
if (!localInstance) {
throw V8Exception("Parameter mismatch while calling constructor for ArrayBuffer");
return v8::Undefined();
}
v8::Handle<v8::Function> retCtor = V8ArrayBuffer::getTmpl()->GetFunction();
v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate();
retPrivData->nativeObj = localInstance;
retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
retObj.MakeWeak(0, V8ArrayBuffer::jsDestructor);
return retObj;
}
示例10: throwError
static v8::Handle<v8::Value> v8HTMLAudioElementConstructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.HTMLAudioElement.Contructor");
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.");
Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
if (!frame)
return throwError("Audio constructor associated frame is unavailable", V8Proxy::ReferenceError);
Document* document = frame->document();
if (!document)
return throwError("Audio constructor associated document is unavailable", V8Proxy::ReferenceError);
// Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance
// may end up being the only node in the map and get garbage-collected prematurely.
toV8(document);
String src;
if (args.Length() > 0)
src = toWebCoreString(args[0]);
RefPtr<HTMLAudioElement> audio = HTMLAudioElement::createForJSConstructor(document, src);
V8DOMWrapper::setDOMWrapper(args.Holder(), &V8HTMLAudioElementConstructor::info, audio.get());
audio->ref();
V8DOMWrapper::setJSWrapperForDOMNode(audio.get(), v8::Persistent<v8::Object>::New(args.Holder()));
return args.Holder();
}
示例11: throwTypeError
v8::Handle<v8::Value> V8MutationObserver::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.MutationObserver.Constructor");
if (!args.IsConstructCall())
return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
v8::Local<v8::Value> arg = args[0];
if (!arg->IsObject())
return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());
ScriptExecutionContext* context = getScriptExecutionContext();
RefPtr<MutationCallback> callback = V8MutationCallback::create(arg, context);
RefPtr<MutationObserver> observer = MutationObserver::create(callback.release());
v8::Handle<v8::Object> wrapper = args.Holder();
V8DOMWrapper::setDOMWrapper(wrapper, &info, observer.get());
V8DOMWrapper::setJSWrapperForDOMObject(observer.release(), wrapper);
return wrapper;
}
示例12: throwError
v8::Handle<v8::Value> V8PeerConnection::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.PeerConnection.Constructor");
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
int argLength = args.Length();
if (argLength != 2)
return throwError("The PeerConnection constructor takes two arguments.", V8Proxy::TypeError);
v8::TryCatch exceptionCatcher;
String configuration = toWebCoreString(args[0]->ToString());
if (exceptionCatcher.HasCaught())
return throwError(exceptionCatcher.Exception());
bool succeeded = false;
RefPtr<SignalingCallback> signalingCallback = createFunctionOnlyCallback<V8SignalingCallback>(args[1], succeeded);
if (!succeeded || !signalingCallback)
return throwError("The PeerConnection constructor must be given a SignalingCallback callback.", V8Proxy::TypeError);
Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
MediaStreamFrameController* frameController = frame ? frame->mediaStreamFrameController() : 0;
RefPtr<PeerConnection> peerConnection;
if (frameController)
peerConnection = frameController->createPeerConnection(configuration, signalingCallback);
if (!peerConnection)
return v8::Undefined();
V8DOMWrapper::setDOMWrapper(args.Holder(), &info, peerConnection.get());
return toV8(peerConnection.release(), args.Holder());
}
示例13: throwTypeError
v8::Handle<v8::Value> V8DOMFormData::constructorCallback(const v8::Arguments& args)
{
if (!args.IsConstructCall())
return throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
return V8DOMFormData::constructorCallbackCustom(args);
}
示例14: ThrowException
v8::Handle<v8::Value> ParmenidesConstructorHelper(const v8::Arguments & args) {
__android_log_write(ANDROID_LOG_DEBUG, "Pender NDK", "PARMENIDES CONSTRUCTOR HELPER");
using namespace v8;
// throw if called without `new'
if (!args.IsConstructCall()) {
return ThrowException(String::New("Cannot call constructor as function, use with new"));
}
HandleScope scope;
return v8::String::New("demicanadian battle-felon");
}
示例15: key
v8::Handle<v8::Value> SecureCellSeal::New(const v8::Arguments& args) {
v8::HandleScope scope;
if (args.IsConstructCall()) {
std::vector<uint8_t> key((uint8_t*)(node::Buffer::Data(args[0])), (uint8_t*)(node::Buffer::Data(args[0])+node::Buffer::Length(args[0])));
SecureCellSeal* obj = new SecureCellSeal(key);
obj->Wrap(args.This());
return args.This();
} else {
const int argc = 1;
v8::Local<v8::Value> argv[argc] = { args[0]};
return scope.Close(constructor->NewInstance(argc, argv));
}
}