Let task.execute accept raw UTF-8 bytes, for the sake of the tests. Missing #include. Minor cleanup.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3359 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
5c855afbb3
commit
4313cfbc4f
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
require("encoding-indexes");
|
require("encoding-indexes");
|
||||||
require("encoding");
|
require("encoding");
|
||||||
|
|
||||||
|
@ -82,9 +82,9 @@ bool Serialize::storeInternal(Task* task, std::vector<char>& buffer, v8::Handle<
|
|||||||
buffer.insert(buffer.end(), *utf8, *utf8 + utf8.length());
|
buffer.insert(buffer.end(), *utf8, *utf8 + utf8.length());
|
||||||
} else if (value->IsUint8Array()) {
|
} else if (value->IsUint8Array()) {
|
||||||
writeInt32(buffer, kUint8Array);
|
writeInt32(buffer, kUint8Array);
|
||||||
v8::Handle<v8::ArrayBuffer> array = v8::Handle<v8::ArrayBuffer>::Cast(value);
|
v8::Handle<v8::Uint8Array> array = v8::Handle<v8::Uint8Array>::Cast(value);
|
||||||
char* data = reinterpret_cast<char*>(array->GetContents().Data());
|
char* data = reinterpret_cast<char*>(array->Buffer()->GetContents().Data());
|
||||||
size_t length = array->GetContents().ByteLength();
|
size_t length = array->Buffer()->GetContents().ByteLength();
|
||||||
writeInt32(buffer, length);
|
writeInt32(buffer, length);
|
||||||
buffer.insert(buffer.end(), data, data + length);
|
buffer.insert(buffer.end(), data, data + length);
|
||||||
} else if (value->IsArray()) {
|
} else if (value->IsArray()) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef INCLUDED_Socket
|
#ifndef INCLUDED_Socket
|
||||||
#define INCLUDED_Socket
|
#define INCLUDED_Socket
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#include <v8.h>
|
#include <v8.h>
|
||||||
|
15
src/Task.cpp
15
src/Task.cpp
@ -676,9 +676,20 @@ void Task::onReceivePacket(int packetType, const char* begin, size_t length, voi
|
|||||||
tryCatch.SetVerbose(true);
|
tryCatch.SetVerbose(true);
|
||||||
v8::Handle<v8::Value> value = Serialize::load(to, from, std::vector<char>(begin + sizeof(promiseid_t), begin + length));
|
v8::Handle<v8::Value> value = Serialize::load(to, from, std::vector<char>(begin + sizeof(promiseid_t), begin + length));
|
||||||
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
|
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
|
||||||
v8::Handle<v8::String> source = v8::Handle<v8::String>::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "source")));
|
v8::Handle<v8::Value> source = v8::Handle<v8::Value>::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "source")));
|
||||||
|
v8::Handle<v8::String> stringSource;
|
||||||
|
if (source->IsArrayBufferView()) {
|
||||||
|
v8::Handle<v8::ArrayBufferView> array = v8::Handle<v8::ArrayBufferView>::Cast(source);
|
||||||
|
stringSource = v8::String::NewFromUtf8(
|
||||||
|
to->_isolate,
|
||||||
|
reinterpret_cast<const char*>(array->Buffer()->GetContents().Data()),
|
||||||
|
v8::String::kNormalString,
|
||||||
|
array->Buffer()->GetContents().ByteLength());
|
||||||
|
} else if (source->IsString()) {
|
||||||
|
stringSource = v8::Handle<v8::String>::Cast(source);
|
||||||
|
}
|
||||||
v8::Handle<v8::String> name = v8::Handle<v8::String>::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "name")));
|
v8::Handle<v8::String> name = v8::Handle<v8::String>::Cast(object->Get(v8::String::NewFromUtf8(to->_isolate, "name")));
|
||||||
to->executeSource(source, name);
|
to->executeSource(stringSource, name);
|
||||||
if (tryCatch.HasCaught()) {
|
if (tryCatch.HasCaught()) {
|
||||||
sendPromiseReject(to, from, promise, Serialize::store(to, tryCatch));
|
sendPromiseReject(to, from, promise, Serialize::store(to, tryCatch));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user