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

Commit

Permalink
chakrashim: add newly-used V8 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhorton authored and kfarnung committed Mar 8, 2018
1 parent 59ed9d2 commit 58dd7b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 36 deletions.
2 changes: 2 additions & 0 deletions deps/chakrashim/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,8 @@ class V8_EXPORT Value : public Data {
bool IsRegExp() const;
bool IsAsyncFunction() const;
bool IsGeneratorObject() const;
bool IsGeneratorFunction() const;
bool IsWebAssemblyCompiledModule() const;
bool IsExternal() const;
bool IsArrayBuffer() const;
bool IsArrayBufferView() const;
Expand Down
11 changes: 9 additions & 2 deletions deps/chakrashim/lib/chakra_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,7 @@
};

utils.isAsyncFunction = function(obj) {
// CHAKRA-TODO
return false;
return compareType(obj, 'AsyncFunction');
};

utils.isSet = function(obj) {
Expand All @@ -604,6 +603,14 @@
return compareType(obj, 'Generator');
};

utils.isGeneratorFunction = function(obj) {
return compareType(obj, 'GeneratorFunction');
};

utils.isWebAssemblyCompiledModule = function(obj) {
return compareType(obj, 'WebAssembly.Module');
};

utils.isWeakMap = function(obj) {
return compareType(obj, 'WeakMap');
};
Expand Down
2 changes: 2 additions & 0 deletions deps/chakrashim/src/jsrtcachedpropertyidref.inc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ DEF_IS_TYPE(isStringObject)
DEF_IS_TYPE(isNumberObject)
DEF_IS_TYPE(isArgumentsObject)
DEF_IS_TYPE(isGeneratorObject)
DEF_IS_TYPE(isGeneratorFunction)
DEF_IS_TYPE(isWebAssemblyCompiledModule)
DEF_IS_TYPE(isWeakMap)
DEF_IS_TYPE(isWeakSet)
DEF_IS_TYPE(isSymbolObject)
Expand Down
51 changes: 17 additions & 34 deletions deps/chakrashim/src/v8value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,20 @@ bool Value::IsFalse() const {
return this == jsrt::GetFalse();
}

bool Value::IsString() const {
return IsOfType(this, JsValueType::JsString);
#define ISJSVALUETYPE(Type) \
bool Value::Is##Type() const { \
return IsOfType(this, JsValueType::Js##Type); \
}

bool Value::IsSymbol() const {
return IsOfType(this, JsValueType::JsSymbol);
}

bool Value::IsFunction() const {
return IsOfType(this, JsValueType::JsFunction);
}

bool Value::IsArray() const {
return IsOfType(this, JsValueType::JsArray);
}
ISJSVALUETYPE(String)
ISJSVALUETYPE(Symbol)
ISJSVALUETYPE(Function)
ISJSVALUETYPE(Array)
ISJSVALUETYPE(ArrayBuffer)
ISJSVALUETYPE(TypedArray)
ISJSVALUETYPE(DataView)
ISJSVALUETYPE(Boolean)
ISJSVALUETYPE(Number)

bool Value::IsObject() const {
JsValueType type;
Expand All @@ -93,14 +92,6 @@ bool Value::IsExternal() const {
return External::IsExternal(this);
}

bool Value::IsArrayBuffer() const {
return IsOfType(this, JsValueType::JsArrayBuffer);
}

bool Value::IsTypedArray() const {
return IsOfType(this, JsValueType::JsTypedArray);
}

#define DEFINE_TYPEDARRAY_CHECK(ArrayType) \
bool Value::Is##ArrayType##Array() const { \
JsTypedArrayType typedArrayType; \
Expand All @@ -125,18 +116,6 @@ bool Value::IsArrayBufferView() const {
return IsTypedArray() || IsDataView();
}

bool Value::IsDataView() const {
return IsOfType(this, JsValueType::JsDataView);
}

bool Value::IsBoolean() const {
return IsOfType(this, JsValueType::JsBoolean);
}

bool Value::IsNumber() const {
return IsOfType(this, JsValueType::JsNumber);
}

bool Value::IsInt32() const {
if (!IsNumber()) {
return false;
Expand Down Expand Up @@ -175,8 +154,10 @@ if (errorCode != JsNoError) { \
return false; \
} \
return Local<Value>(resultRef)->BooleanValue(); \
} \
}

// Refer to jsrtcachedpropertyidref.inc for the full list
// DEF_IS_TYPE is not structured correctly in order to be used here
IS_TYPE_FUNCTION(IsBooleanObject, isBooleanObject)
IS_TYPE_FUNCTION(IsDate, isDate)
IS_TYPE_FUNCTION(IsMap, isMap)
Expand All @@ -192,6 +173,8 @@ IS_TYPE_FUNCTION(IsMapIterator, isMapIterator)
IS_TYPE_FUNCTION(IsSetIterator, isSetIterator)
IS_TYPE_FUNCTION(IsArgumentsObject, isArgumentsObject)
IS_TYPE_FUNCTION(IsGeneratorObject, isGeneratorObject)
IS_TYPE_FUNCTION(IsGeneratorFunction, isGeneratorFunction)
IS_TYPE_FUNCTION(IsWebAssemblyCompiledModule, isWebAssemblyCompiledModule)
IS_TYPE_FUNCTION(IsWeakMap, isWeakMap)
IS_TYPE_FUNCTION(IsWeakSet, isWeakSet)
IS_TYPE_FUNCTION(IsSymbolObject, isSymbolObject)
Expand Down

0 comments on commit 58dd7b5

Please sign in to comment.