Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim: fix lint issues
Browse files Browse the repository at this point in the history
* Also include `unordered_set` in `v8-tracing.h` to match v8
* Fixed `int64`->`double` implicit cast in `v8-platform.h`
  • Loading branch information
kfarnung committed Feb 14, 2018
1 parent 8e5490c commit dccccfc
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
2 changes: 2 additions & 0 deletions deps/chakrashim/include/libplatform/v8-tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include <fstream>
#include <memory>
#include <unordered_set>
#include <vector>

#include "v8-platform.h"

namespace v8 {
Expand Down
5 changes: 3 additions & 2 deletions deps/chakrashim/include/v8-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ class Platform {

protected:
static double SystemClockTimeMillis() {
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
return std::chrono::duration_cast<
std::chrono::duration<double, std::milli>>(
std::chrono::system_clock::now().time_since_epoch()).count();
}
};

Expand Down
15 changes: 7 additions & 8 deletions deps/chakrashim/src/v8arraybuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,14 @@ ArrayBuffer::Contents ArrayBuffer::GetContents() {
}

Contents contents;
if (buffer == nullptr)
{
if (buffer == nullptr) {
CHAKRA_ASSERT(bufferLength == 0);
// v8's version of ArrayBuffer will return a non-null pointer even in the case of
// an empty ArrayBuffer, and this behavior is relied upon by some of the i18n code.
// To support that, if we would otherwise return a null buffer, as long as the
// length is 0 we instead return a valid pointer to something, on the understanding
// that nobody will actually try to read it.
buffer = (BYTE*)this;
// v8's version of ArrayBuffer will return a non-null pointer even in the
// case of an empty ArrayBuffer, and this behavior is relied upon by some of
// the i18n code. To support that, if we would otherwise return a null
// buffer, as long as the length is 0 we instead return a valid pointer to
// something, on the understanding that nobody will actually try to read it.
buffer = reinterpret_cast<BYTE*>(this);
}
contents.data_ = buffer;
contents.byte_length_ = bufferLength;
Expand Down
8 changes: 5 additions & 3 deletions deps/chakrashim/src/v8promise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ Promise::Promise() { }

Local<Value> Promise::Result() {
JsValueRef value;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::value, &value) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::value,
&value) != JsNoError) {
return Local<Value>();
}
return Local<Value>::New(value);
}

Promise::PromiseState Promise::State() {
JsValueRef state;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::state, &state) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::state,
&state) != JsNoError) {
return PromiseState::kPending;
}
int stateNumber;
if (JsNumberToInt(state, &stateNumber) != JsNoError) {
return PromiseState::kPending;
}
switch(stateNumber) {
switch (stateNumber) {
case 1: return PromiseState::kFulfilled;
case 2: return PromiseState::kRejected;
default: return PromiseState::kPending;
Expand Down
47 changes: 30 additions & 17 deletions deps/chakrashim/src/v8resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ namespace v8 {
return Local<Resolver>();
}

if (jsrt::SetProperty(resolver, jsrt::CachedPropertyIdRef::promise, promise) != JsNoError) {
if (jsrt::SetProperty(resolver, jsrt::CachedPropertyIdRef::promise,
promise) != JsNoError) {
return Local<Resolver>();
}

if (jsrt::SetProperty(resolver, jsrt::CachedPropertyIdRef::resolve, resolve) != JsNoError) {
if (jsrt::SetProperty(resolver, jsrt::CachedPropertyIdRef::resolve,
resolve) != JsNoError) {
return Local<Resolver>();
}

if (jsrt::SetProperty(resolver, jsrt::CachedPropertyIdRef::reject, reject) != JsNoError) {
if (jsrt::SetProperty(resolver, jsrt::CachedPropertyIdRef::reject,
reject) != JsNoError) {
return Local<Resolver>();
}

JsValueRef state;
jsrt::UintToValue(0, &state);
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value, state) != JsNoError) {
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value,
state) != JsNoError) {
return Local<Resolver>();
}

Expand All @@ -62,7 +66,8 @@ namespace v8 {

Local<Promise> Resolver::GetPromise() {
JsValueRef promise;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::promise, &promise) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::promise,
&promise) != JsNoError) {
return Local<Promise>();
}
return Local<Promise>::New(static_cast<Promise*>(promise));
Expand All @@ -74,28 +79,32 @@ namespace v8 {

Maybe<bool> Resolver::Resolve(Local<Context> context, Local<Value> value) {
JsValueRef resolve;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::resolve, &resolve) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::resolve,
&resolve) != JsNoError) {
return Nothing<bool>();
}

JsValueRef promise;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::promise, &promise) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::promise,
&promise) != JsNoError) {
return Nothing<bool>();
}

if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value, *value) != JsNoError) {
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value,
*value) != JsNoError) {
return Nothing<bool>();
}

JsValueRef state;
jsrt::UintToValue(1, &state);
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value, state) != JsNoError) {
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value,
state) != JsNoError) {
return Nothing<bool>();
}

JsValueRef result;
JsValueRef args[2];
args[0] = this; // ? What is the "this" of the resolver here?
args[0] = this; // ? What is the "this" of the resolver here?
args[1] = reinterpret_cast<JsValueRef>(*value);

if (JsCallFunction(resolve, args, 2, &result) != JsNoError) {
Expand All @@ -112,28 +121,32 @@ namespace v8 {

Maybe<bool> Resolver::Reject(Local<Context> context, Local<Value> value) {
JsValueRef reject;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::reject, &reject) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::reject,
&reject) != JsNoError) {
return Nothing<bool>();
}

JsValueRef promise;
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::promise, &promise) != JsNoError) {
if (jsrt::GetProperty(this, jsrt::CachedPropertyIdRef::promise,
&promise) != JsNoError) {
return Nothing<bool>();
}

if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value, *value) != JsNoError) {
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value,
*value) != JsNoError) {
return Nothing<bool>();
}

JsValueRef state;
jsrt::UintToValue(2, &state);
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value, state) != JsNoError) {
if (jsrt::SetProperty(promise, jsrt::CachedPropertyIdRef::value,
state) != JsNoError) {
return Nothing<bool>();
}

JsValueRef result;
JsValueRef args[2];
args[0] = this; // ? What is the "this" of the resolver here?
args[0] = this; // ? What is the "this" of the resolver here?
args[1] = reinterpret_cast<JsValueRef>(*value);

if (JsCallFunction(reject, args, 2, &result) != JsNoError) {
Expand Down

0 comments on commit dccccfc

Please sign in to comment.