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

Commit

Permalink
chakrashim: Updating shim to fix build break
Browse files Browse the repository at this point in the history
  • Loading branch information
MSLaguana committed Oct 31, 2017
1 parent 3b38e14 commit 5fed2d6
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 28 deletions.
97 changes: 88 additions & 9 deletions deps/chakrashim/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ namespace uvimpl {
class Work;
};

namespace v8 {
class PropertyDescriptor;
}

namespace jsrt {
JsErrorCode CreateV8PropertyDescriptor(JsValueRef descriptor,
v8::PropertyDescriptor* result);
}

namespace v8 {

class AccessorSignature;
Expand Down Expand Up @@ -216,6 +225,11 @@ typedef void (*NamedPropertyDeleterCallback)(
Local<String> property, const PropertyCallbackInfo<Boolean>& info);
typedef void (*NamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
typedef void (*NamedPropertyDescriptorCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
typedef void (*NamedPropertyDefinerCallback)(
Local<Name> property, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);

typedef void (*GenericNamedPropertyGetterCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
Expand All @@ -228,6 +242,11 @@ typedef void (*GenericNamedPropertyDeleterCallback)(
Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
typedef void (*GenericNamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
typedef void (*GenericNamedPropertyDescriptorCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
typedef void (*GenericNamedPropertyDefinerCallback)(
Local<Name> property, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);

typedef void (*IndexedPropertyGetterCallback)(
uint32_t index, const PropertyCallbackInfo<Value>& info);
Expand All @@ -239,6 +258,11 @@ typedef void (*IndexedPropertyDeleterCallback)(
uint32_t index, const PropertyCallbackInfo<Boolean>& info);
typedef void (*IndexedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
typedef void (*IndexedPropertyDefinerCallback)(
uint32_t index, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);
typedef void (*IndexedPropertyDescriptorCallback)(
uint32_t index, const PropertyCallbackInfo<Value>& info);

typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
typedef void (*FatalErrorCallback)(const char *location, const char *message);
Expand Down Expand Up @@ -337,6 +361,9 @@ class Local {
friend class Value;
friend class JSON;
friend class uvimpl::Work;
friend JsErrorCode jsrt::CreateV8PropertyDescriptor(
JsValueRef descriptor,
v8::PropertyDescriptor* result);
template <class F> friend class FunctionCallbackInfo;
template <class F> friend class MaybeLocal;
template <class F> friend class PersistentBase;
Expand Down Expand Up @@ -1406,9 +1433,9 @@ class V8_EXPORT Object : public Value {
Local<Context> context, Local<Value> key);

V8_DEPRECATE_SOON("Use maybe version",
Local<Value> GetOwnPropertyDescriptor(Local<String> key));
Local<Value> GetOwnPropertyDescriptor(Local<Name> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
Local<Context> context, Local<String> key);
Local<Context> context, Local<Name> key);

V8_DEPRECATE_SOON("Use maybe version", bool Has(Handle<Value> key));
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
Expand Down Expand Up @@ -1916,6 +1943,8 @@ class V8_EXPORT PropertyDescriptor {
struct PrivateData;
PrivateData* get_private() const { return private_; }

PropertyDescriptor & operator=(PropertyDescriptor &&);

PropertyDescriptor(const PropertyDescriptor&) = delete;
void operator=(const PropertyDescriptor&) = delete;

Expand Down Expand Up @@ -2251,16 +2280,39 @@ struct NamedPropertyHandlerConfiguration {
query(query),
deleter(deleter),
enumerator(enumerator),
definer(0),
descriptor(0),
data(data),
flags(flags) {}

GenericNamedPropertyGetterCallback getter;
GenericNamedPropertySetterCallback setter;
GenericNamedPropertyQueryCallback query;
GenericNamedPropertyDeleterCallback deleter;
GenericNamedPropertyEnumeratorCallback enumerator;
Handle<Value> data;
PropertyHandlerFlags flags;
NamedPropertyHandlerConfiguration(
GenericNamedPropertyGetterCallback getter,
GenericNamedPropertySetterCallback setter,
GenericNamedPropertyDescriptorCallback descriptor,
GenericNamedPropertyDeleterCallback deleter,
GenericNamedPropertyEnumeratorCallback enumerator,
GenericNamedPropertyDefinerCallback definer,
Local<Value> data = Local<Value>(),
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
: getter(getter),
setter(setter),
query(0),
deleter(deleter),
enumerator(enumerator),
definer(definer),
descriptor(descriptor),
data(data),
flags(flags) {}

GenericNamedPropertyGetterCallback getter;
GenericNamedPropertySetterCallback setter;
GenericNamedPropertyQueryCallback query;
GenericNamedPropertyDeleterCallback deleter;
GenericNamedPropertyEnumeratorCallback enumerator;
GenericNamedPropertyDefinerCallback definer;
GenericNamedPropertyDescriptorCallback descriptor;
Local<Value> data;
PropertyHandlerFlags flags;
};

struct IndexedPropertyHandlerConfiguration {
Expand All @@ -2277,6 +2329,27 @@ struct IndexedPropertyHandlerConfiguration {
query(query),
deleter(deleter),
enumerator(enumerator),
definer(0),
descriptor(0),
data(data),
flags(flags) {}

IndexedPropertyHandlerConfiguration(
IndexedPropertyGetterCallback getter = 0,
IndexedPropertySetterCallback setter = 0,
IndexedPropertyDescriptorCallback descriptor = 0,
IndexedPropertyDeleterCallback deleter = 0 ,
IndexedPropertyEnumeratorCallback enumerator = 0,
IndexedPropertyDefinerCallback definer = 0,
Local<Value> data = Local<Value>(),
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
: getter(getter),
setter(setter),
query(0),
deleter(deleter),
enumerator(enumerator),
definer(definer),
descriptor(descriptor),
data(data),
flags(flags) {}

Expand All @@ -2285,6 +2358,8 @@ struct IndexedPropertyHandlerConfiguration {
IndexedPropertyQueryCallback query;
IndexedPropertyDeleterCallback deleter;
IndexedPropertyEnumeratorCallback enumerator;
IndexedPropertyDefinerCallback definer;
IndexedPropertyDescriptorCallback descriptor;
Handle<Value> data;
PropertyHandlerFlags flags;
};
Expand Down Expand Up @@ -2321,6 +2396,8 @@ class V8_EXPORT ObjectTemplate : public Template {
NamedPropertyQueryCallback query = 0,
NamedPropertyDeleterCallback deleter = 0,
NamedPropertyEnumeratorCallback enumerator = 0,
NamedPropertyDefinerCallback definer = 0,
NamedPropertyDescriptorCallback descriptor = 0,
Handle<Value> data = Handle<Value>());
void SetHandler(const NamedPropertyHandlerConfiguration& configuration);

Expand All @@ -2331,6 +2408,8 @@ class V8_EXPORT ObjectTemplate : public Template {
IndexedPropertyQueryCallback query = 0,
IndexedPropertyDeleterCallback deleter = 0,
IndexedPropertyEnumeratorCallback enumerator = 0,
IndexedPropertyDefinerCallback definer = 0,
IndexedPropertyDescriptorCallback descriptor = 0,
Handle<Value> data = Handle<Value>());

void SetAccessCheckCallbacks(
Expand Down
2 changes: 1 addition & 1 deletion deps/chakrashim/src/inspector/v8-console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ V8Console::CommandLineAPIScope::~CommandLineAPIScope() {
v8::Local<v8::Value> descriptor;
bool success = m_global
->GetOwnPropertyDescriptor(
m_context, v8::Local<v8::String>::Cast(name))
m_context, v8::Local<v8::Name>::Cast(name))
.ToLocal(&descriptor);
DCHECK(success);
USE(success);
Expand Down
75 changes: 75 additions & 0 deletions deps/chakrashim/src/jsrtutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,81 @@ JsErrorCode CreatePropertyDescriptor(v8::PropertyAttribute attributes,
descriptor);
}

JsErrorCode CreateV8PropertyDescriptor(
JsValueRef descriptor,
v8::PropertyDescriptor* result) {
IsolateShim * isolateShim = IsolateShim::GetCurrent();
JsPropertyIdRef valueIdRef = isolateShim
->GetCachedPropertyIdRef(CachedPropertyIdRef::value);
bool hasProperty = false;
IfJsErrorRet(JsHasProperty(descriptor, valueIdRef, &hasProperty));

v8::PropertyDescriptor desc;
if (hasProperty) {
JsValueRef value;
IfJsErrorRet(JsGetProperty(descriptor, valueIdRef, &value));

JsPropertyIdRef writableIdRef = isolateShim
->GetCachedPropertyIdRef(CachedPropertyIdRef::writable);
IfJsErrorRet(JsHasProperty(descriptor, writableIdRef, &hasProperty));

if (hasProperty) {
JsValueRef writableVar = JS_INVALID_REFERENCE;
IfJsErrorRet(JsGetProperty(descriptor, writableIdRef, &writableVar));

bool writable = false;
IfJsErrorRet(ValueToBoolLikely(writableVar, &writable));
desc = v8::PropertyDescriptor(
v8::Local<v8::Value>::New(value), writable);
} else {
desc = v8::PropertyDescriptor(
v8::Local<v8::Value>::New(value));
}
} else {
JsPropertyIdRef getIdRef = isolateShim
->GetCachedPropertyIdRef(CachedPropertyIdRef::get);
JsPropertyIdRef setIdRef = isolateShim
->GetCachedPropertyIdRef(CachedPropertyIdRef::set);

JsValueRef getValue = JS_INVALID_REFERENCE;
JsValueRef setValue = JS_INVALID_REFERENCE;

IfJsErrorRet(JsGetProperty(descriptor, getIdRef, &getValue));
IfJsErrorRet(JsGetProperty(descriptor, setIdRef, &setValue));

desc = v8::PropertyDescriptor(
v8::Local<v8::Value>::New(getValue),
v8::Local<v8::Value>::New(setValue));
}

JsPropertyIdRef enumerableIdRef = isolateShim
->GetCachedPropertyIdRef(CachedPropertyIdRef::enumerable);
JsPropertyIdRef configurableIdRef = isolateShim
->GetCachedPropertyIdRef(CachedPropertyIdRef::configurable);

IfJsErrorRet(JsHasProperty(descriptor, enumerableIdRef, &hasProperty));
if (hasProperty) {
JsValueRef enumerableVar = JS_INVALID_REFERENCE;
IfJsErrorRet(JsGetProperty(descriptor, enumerableIdRef, &enumerableVar));
bool enumerable = false;
IfJsErrorRet(ValueToBoolLikely(enumerableVar, &enumerable));
desc.set_enumerable(enumerable);
}

IfJsErrorRet(JsHasProperty(descriptor, configurableIdRef, &hasProperty));
if (hasProperty) {
JsValueRef configurableVar = JS_INVALID_REFERENCE;
IfJsErrorRet(JsGetProperty(descriptor, configurableIdRef,
&configurableVar));
bool configurable = false;
IfJsErrorRet(ValueToBoolLikely(configurableVar, &configurable));
desc.set_configurable(configurable);
}

*result = std::move(desc);
return JsNoError;
}

JsErrorCode DefineProperty(JsValueRef object,
JsPropertyIdRef propertyIdRef,
PropertyDescriptorOptionValues writable,
Expand Down
3 changes: 3 additions & 0 deletions deps/chakrashim/src/jsrtutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ JsErrorCode CreatePropertyDescriptor(v8::PropertyAttribute attributes,
JsValueRef setter,
JsValueRef *descriptor);

JsErrorCode CreateV8PropertyDescriptor(JsValueRef descriptor,
v8::PropertyDescriptor* result);

JsErrorCode DefineProperty(JsValueRef object,
const char * propertyName,
PropertyDescriptorOptionValues writable,
Expand Down
10 changes: 10 additions & 0 deletions deps/chakrashim/src/v8chakra.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ class ObjectData: public ExternalData {
NamedPropertyQueryCallback namedPropertyQuery;
NamedPropertyDeleterCallback namedPropertyDeleter;
NamedPropertyEnumeratorCallback namedPropertyEnumerator;
NamedPropertyDefinerCallback namedPropertyDefiner;
NamedPropertyDescriptorCallback namedPropertyDescriptor;
Persistent<Value> namedPropertyInterceptorData;
IndexedPropertyGetterCallback indexedPropertyGetter;
IndexedPropertySetterCallback indexedPropertySetter;
IndexedPropertyQueryCallback indexedPropertyQuery;
IndexedPropertyDeleterCallback indexedPropertyDeleter;
IndexedPropertyEnumeratorCallback indexedPropertyEnumerator;
IndexedPropertyDefinerCallback indexedPropertyDefiner;
IndexedPropertyDescriptorCallback indexedPropertyDescriptor;
Persistent<Value> indexedPropertyInterceptorData;
int internalFieldCount;
FieldValue* internalFields;
Expand Down Expand Up @@ -206,6 +210,12 @@ class Utils {
JsValueRef *arguments,
unsigned short argumentCount, // NOLINT(runtime/int)
void *callbackState);
static JsValueRef CHAKRA_CALLBACK DefinePropertyCallback(
JsValueRef callee,
bool isConstructCall,
JsValueRef *arguments,
unsigned short argumentCount, // NOLINT(runtime/int)
void *callbackState);

static void CHAKRA_CALLBACK WeakReferenceCallbackWrapperCallback(
JsRef ref, void *data);
Expand Down
4 changes: 2 additions & 2 deletions deps/chakrashim/src/v8object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ PropertyAttribute Object::GetPropertyAttributes(Handle<Value> key) {
}

MaybeLocal<Value> Object::GetOwnPropertyDescriptor(Local<Context> context,
Local<String> key) {
Local<Name> key) {
JsValueRef result;
if (jsrt::GetOwnPropertyDescriptor(this, *key, &result) != JsNoError) {
return Local<Value>();
}
return Local<Value>::New(result);
}

Local<Value> Object::GetOwnPropertyDescriptor(Local<String> key) {
Local<Value> Object::GetOwnPropertyDescriptor(Local<Name> key) {
return FromMaybe(GetOwnPropertyDescriptor(Local<Context>(), key));
}

Expand Down
Loading

0 comments on commit 5fed2d6

Please sign in to comment.