本文整理汇总了C++中MessagePortArray::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePortArray::resize方法的具体用法?C++ MessagePortArray::resize怎么用?C++ MessagePortArray::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePortArray
的用法示例。
在下文中一共展示了MessagePortArray::resize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillMessagePortArray
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray)
{
// Convert from the passed-in JS array-like object to a MessagePortArray.
// Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec.
if (value.isUndefinedOrNull()) {
portArray.resize(0);
return;
}
// Validation of sequence types, per WebIDL spec 4.1.13.
unsigned length;
JSObject* object = toJSSequence(exec, value, length);
if (exec->hadException())
return;
portArray.resize(length);
for (unsigned i = 0 ; i < length; ++i) {
JSValue value = object->get(exec, i);
if (exec->hadException())
return;
// Validation of non-null objects, per HTML5 spec 8.3.3.
if (value.isUndefinedOrNull()) {
setDOMException(exec, INVALID_STATE_ERR);
return;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
RefPtr<MessagePort> port = toMessagePort(value);
if (!port) {
throwTypeError(exec);
return;
}
portArray[i] = port.release();
}
}
示例2: getMessagePortArray
bool getMessagePortArray(v8::Local<v8::Value> value, MessagePortArray& portArray)
{
if (isUndefinedOrNull(value)) {
portArray.resize(0);
return true;
}
if (!value->IsObject()) {
throwError("MessagePortArray argument must be an object");
return false;
}
uint32_t length = 0;
v8::Local<v8::Object> ports = v8::Local<v8::Object>::Cast(value);
if (value->IsArray()) {
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
length = array->Length();
} else {
// Sequence-type object - get the length attribute
v8::Local<v8::Value> sequenceLength = ports->Get(v8::String::New("length"));
if (!sequenceLength->IsNumber()) {
throwError("MessagePortArray argument has no length attribute");
return false;
}
length = sequenceLength->Uint32Value();
}
portArray.resize(length);
for (unsigned int i = 0; i < length; ++i) {
v8::Local<v8::Value> port = ports->Get(v8::Integer::New(i));
// Validation of non-null objects, per HTML5 spec 8.3.3.
if (isUndefinedOrNull(port)) {
throwError(INVALID_STATE_ERR);
return false;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
if (!V8MessagePort::HasInstance(port)) {
throwError("MessagePortArray argument must contain only MessagePorts");
return false;
}
portArray[i] = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, v8::Handle<v8::Object>::Cast(port));
}
return true;
}
示例3: getMessagePortArray
bool getMessagePortArray(v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, v8::Isolate* isolate)
{
if (isUndefinedOrNull(value)) {
ports.resize(0);
return true;
}
if (!value->IsArray()) {
throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
return false;
}
bool success = false;
ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, argumentIndex, isolate, &success);
return success;
}
示例4: extractTransferables
bool extractTransferables(v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
{
if (isUndefinedOrNull(value)) {
ports.resize(0);
arrayBuffers.resize(0);
return true;
}
uint32_t length = 0;
if (value->IsArray()) {
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
length = array->Length();
} else if (toV8Sequence(value, length, isolate).IsEmpty()) {
exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex + 1));
return false;
}
v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
// Validate the passed array of transferrables.
for (unsigned int i = 0; i < length; ++i) {
v8::Local<v8::Value> transferrable = transferrables->Get(i);
// Validation of non-null objects, per HTML5 spec 10.3.3.
if (isUndefinedOrNull(transferrable)) {
exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'null'") + " value.");
return false;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
if (V8MessagePort::hasInstance(transferrable, isolate)) {
RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable));
// Check for duplicate MessagePorts.
if (ports.contains(port)) {
exceptionState.throwDOMException(DataCloneError, "Message port at index " + String::number(i) + " is a duplicate of an earlier port.");
return false;
}
ports.append(port.release());
} else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) {
RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable));
if (arrayBuffers.contains(arrayBuffer)) {
exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer.");
return false;
}
arrayBuffers.append(arrayBuffer.release());
} else {
exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " does not have a transferable type.");
return false;
}
}
return true;
}
示例5: fillMessagePortArray
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers)
{
// Convert from the passed-in JS array-like object to a MessagePortArray.
// Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec.
if (value.isUndefinedOrNull()) {
portArray.resize(0);
arrayBuffers.resize(0);
return;
}
// Validation of sequence types, per WebIDL spec 4.1.13.
unsigned length = 0;
JSObject* object = toJSSequence(exec, value, length);
if (exec->hadException())
return;
for (unsigned i = 0 ; i < length; ++i) {
JSValue value = object->get(exec, i);
if (exec->hadException())
return;
// Validation of non-null objects, per HTML5 spec 10.3.3.
if (value.isUndefinedOrNull()) {
setDOMException(exec, INVALID_STATE_ERR);
return;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
RefPtr<MessagePort> port = toMessagePort(value);
if (port) {
// Check for duplicate ports.
if (portArray.contains(port)) {
#if MODIFY(ENGINE) //[2014.03.05][infraware][jungong16] : fix to issue. http://www.w3.org/TR/webmessaging/#dom-window-postmessage
setDOMException(exec, DATA_CLONE_ERR);
#else
setDOMException(exec, INVALID_STATE_ERR);
#endif
return;
}
portArray.append(port.release());
} else {
RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value);
if (arrayBuffer)
arrayBuffers.append(arrayBuffer);
else {
throwTypeError(exec);
return;
}
}
}
}
示例6: extractTransferables
bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, ArrayBufferArray& arrayBuffers)
{
if (isUndefinedOrNull(value)) {
ports.resize(0);
arrayBuffers.resize(0);
return true;
}
if (!value->IsObject()) {
throwError("TransferArray argument must be an object");
return false;
}
uint32_t length = 0;
v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
if (value->IsArray()) {
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
length = array->Length();
} else {
// Sequence-type object - get the length attribute
v8::Local<v8::Value> sequenceLength = transferrables->Get(v8::String::New("length"));
if (!sequenceLength->IsNumber()) {
throwError("TransferArray argument has no length attribute");
return false;
}
length = sequenceLength->Uint32Value();
}
// Validate the passed array of transferrables.
for (unsigned int i = 0; i < length; ++i) {
v8::Local<v8::Value> transferrable = transferrables->Get(i);
// Validation of non-null objects, per HTML5 spec 10.3.3.
if (isUndefinedOrNull(transferrable)) {
throwError(DATA_CLONE_ERR);
return false;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
if (V8MessagePort::HasInstance(transferrable))
ports.append(V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable)));
else if (V8ArrayBuffer::HasInstance(transferrable))
arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable)));
else {
throwError("TransferArray argument must contain only Transferables");
return false;
}
}
return true;
}
示例7: fillMessagePortArray
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers)
{
// Convert from the passed-in JS array-like object to a MessagePortArray.
// Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec.
if (value.isUndefinedOrNull()) {
portArray.resize(0);
arrayBuffers.resize(0);
return;
}
// Validation of sequence types, per WebIDL spec 4.1.13.
unsigned length = 0;
JSObject* object = toJSSequence(exec, value, length);
if (exec->hadException())
return;
for (unsigned i = 0 ; i < length; ++i) {
JSValue value = object->get(exec, i);
if (exec->hadException())
return;
// Validation of non-null objects, per HTML5 spec 10.3.3.
if (value.isUndefinedOrNull()) {
setDOMException(exec, INVALID_STATE_ERR);
return;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
RefPtr<MessagePort> port = JSMessagePort::toWrapped(value);
if (port) {
// Check for duplicate ports.
if (portArray.contains(port)) {
setDOMException(exec, INVALID_STATE_ERR);
return;
}
portArray.append(port.release());
} else {
RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value);
if (arrayBuffer)
arrayBuffers.append(arrayBuffer);
else {
throwTypeError(exec);
return;
}
}
}
}
示例8: extractTransferables
bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, v8::Isolate* isolate)
{
if (isUndefinedOrNull(value)) {
ports.resize(0);
arrayBuffers.resize(0);
return true;
}
uint32_t length = 0;
if (value->IsArray()) {
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
length = array->Length();
} else {
if (toV8Sequence(value, length).IsEmpty())
return false;
}
v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
// Validate the passed array of transferrables.
for (unsigned int i = 0; i < length; ++i) {
v8::Local<v8::Value> transferrable = transferrables->Get(i);
// Validation of non-null objects, per HTML5 spec 10.3.3.
if (isUndefinedOrNull(transferrable)) {
setDOMException(INVALID_STATE_ERR, isolate);
return false;
}
// Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
if (V8MessagePort::HasInstance(transferrable)) {
RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Object>::Cast(transferrable));
// Check for duplicate MessagePorts.
if (ports.contains(port)) {
setDOMException(INVALID_STATE_ERR, isolate);
return false;
}
ports.append(port.release());
} else if (V8ArrayBuffer::HasInstance(transferrable))
arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable)));
else {
throwTypeError();
return false;
}
}
return true;
}