mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-23 15:50:11 -05:00
add all value checkers (#163)
This commit is contained in:
parent
e501f6d854
commit
8d6ad51662
3 changed files with 621 additions and 12 deletions
158
src/binding.cc
158
src/binding.cc
|
@ -288,15 +288,167 @@ bool v8__Value__IsNullOrUndefined(const v8::Value& self) {
|
|||
return self.IsNullOrUndefined();
|
||||
}
|
||||
|
||||
bool v8__Value__IsTrue(const v8::Value& self) { return self.IsTrue(); }
|
||||
|
||||
bool v8__Value__IsFalse(const v8::Value& self) { return self.IsFalse(); }
|
||||
|
||||
bool v8__Value__IsName(const v8::Value& self) { return self.IsName(); }
|
||||
|
||||
bool v8__Value__IsString(const v8::Value& self) { return self.IsString(); }
|
||||
|
||||
bool v8__Value__IsNumber(const v8::Value& self) { return self.IsNumber(); }
|
||||
bool v8__Value__IsSymbol(const v8::Value& self) { return self.IsSymbol(); }
|
||||
|
||||
bool v8__Value__IsObject(const v8::Value& self) { return self.IsObject(); }
|
||||
bool v8__Value__IsFunction(const v8::Value& self) { return self.IsFunction(); }
|
||||
|
||||
bool v8__Value__IsArray(const v8::Value& self) { return self.IsArray(); }
|
||||
|
||||
bool v8__Value__IsFunction(const v8::Value& self) { return self.IsFunction(); }
|
||||
bool v8__Value__IsObject(const v8::Value& self) { return self.IsObject(); }
|
||||
|
||||
bool v8__Value__IsBigInt(const v8::Value& self) { return self.IsBigInt(); }
|
||||
|
||||
bool v8__Value__IsBoolean(const v8::Value& self) { return self.IsBoolean(); }
|
||||
|
||||
bool v8__Value__IsNumber(const v8::Value& self) { return self.IsNumber(); }
|
||||
|
||||
bool v8__Value__IsExternal(const v8::Value& self) { return self.IsExternal(); }
|
||||
|
||||
bool v8__Value__IsInt32(const v8::Value& self) { return self.IsInt32(); }
|
||||
|
||||
bool v8__Value__IsUint32(const v8::Value& self) { return self.IsUint32(); }
|
||||
|
||||
bool v8__Value__IsDate(const v8::Value& self) { return self.IsDate(); }
|
||||
|
||||
bool v8__Value__IsArgumentsObject(const v8::Value& self) {
|
||||
return self.IsArgumentsObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsBigIntObject(const v8::Value& self) {
|
||||
return self.IsBigIntObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsBooleanObject(const v8::Value& self) {
|
||||
return self.IsBooleanObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsNumberObject(const v8::Value& self) {
|
||||
return self.IsNumberObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsStringObject(const v8::Value& self) {
|
||||
return self.IsStringObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsSymbolObject(const v8::Value& self) {
|
||||
return self.IsSymbolObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsNativeError(const v8::Value& self) {
|
||||
return self.IsNativeError();
|
||||
}
|
||||
|
||||
bool v8__Value__IsRegExp(const v8::Value& self) { return self.IsRegExp(); }
|
||||
|
||||
bool v8__Value__IsAsyncFunction(const v8::Value& self) {
|
||||
return self.IsAsyncFunction();
|
||||
}
|
||||
|
||||
bool v8__Value__IsGeneratorFunction(const v8::Value& self) {
|
||||
return self.IsGeneratorFunction();
|
||||
}
|
||||
|
||||
bool v8__Value__IsGeneratorObject(const v8::Value& self) {
|
||||
return self.IsGeneratorObject();
|
||||
}
|
||||
|
||||
bool v8__Value__IsPromise(const v8::Value& self) { return self.IsPromise(); }
|
||||
|
||||
bool v8__Value__IsMap(const v8::Value& self) { return self.IsMap(); }
|
||||
|
||||
bool v8__Value__IsSet(const v8::Value& self) { return self.IsSet(); }
|
||||
|
||||
bool v8__Value__IsMapIterator(const v8::Value& self) {
|
||||
return self.IsMapIterator();
|
||||
}
|
||||
|
||||
bool v8__Value__IsSetIterator(const v8::Value& self) {
|
||||
return self.IsSetIterator();
|
||||
}
|
||||
|
||||
bool v8__Value__IsWeakMap(const v8::Value& self) { return self.IsWeakMap(); }
|
||||
|
||||
bool v8__Value__IsWeakSet(const v8::Value& self) { return self.IsWeakSet(); }
|
||||
|
||||
bool v8__Value__IsArrayBuffer(const v8::Value& self) {
|
||||
return self.IsArrayBuffer();
|
||||
}
|
||||
|
||||
bool v8__Value__IsArrayBufferView(const v8::Value& self) {
|
||||
return self.IsArrayBufferView();
|
||||
}
|
||||
|
||||
bool v8__Value__IsTypedArray(const v8::Value& self) {
|
||||
return self.IsTypedArray();
|
||||
}
|
||||
|
||||
bool v8__Value__IsUint8Array(const v8::Value& self) {
|
||||
return self.IsUint8Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsUint8ClampedArray(const v8::Value& self) {
|
||||
return self.IsUint8ClampedArray();
|
||||
}
|
||||
|
||||
bool v8__Value__IsInt8Array(const v8::Value& self) {
|
||||
return self.IsInt8Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsUint16Array(const v8::Value& self) {
|
||||
return self.IsUint16Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsInt16Array(const v8::Value& self) {
|
||||
return self.IsInt16Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsUint32Array(const v8::Value& self) {
|
||||
return self.IsUint32Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsInt32Array(const v8::Value& self) {
|
||||
return self.IsInt32Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsFloat32Array(const v8::Value& self) {
|
||||
return self.IsFloat32Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsFloat64Array(const v8::Value& self) {
|
||||
return self.IsFloat64Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsBigInt64Array(const v8::Value& self) {
|
||||
return self.IsBigInt64Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsBigUint64Array(const v8::Value& self) {
|
||||
return self.IsBigUint64Array();
|
||||
}
|
||||
|
||||
bool v8__Value__IsDataView(const v8::Value& self) { return self.IsDataView(); }
|
||||
|
||||
bool v8__Value__IsSharedArrayBuffer(const v8::Value& self) {
|
||||
return self.IsSharedArrayBuffer();
|
||||
}
|
||||
|
||||
bool v8__Value__IsProxy(const v8::Value& self) { return self.IsProxy(); }
|
||||
|
||||
bool v8__Value__IsWebAssemblyCompiledModule(const v8::Value& self) {
|
||||
return self.IsWebAssemblyCompiledModule();
|
||||
}
|
||||
|
||||
bool v8__Value__IsModuleNamespaceObject(const v8::Value& self) {
|
||||
return self.IsModuleNamespaceObject();
|
||||
}
|
||||
|
||||
bool v8__Value__StrictEquals(const v8::Value& self, v8::Value* that) {
|
||||
return self.StrictEquals(ptr_to_local(that));
|
||||
|
|
302
src/value.rs
302
src/value.rs
|
@ -10,11 +10,58 @@ extern "C" {
|
|||
fn v8__Value__IsUndefined(this: &Value) -> bool;
|
||||
fn v8__Value__IsNull(this: &Value) -> bool;
|
||||
fn v8__Value__IsNullOrUndefined(this: &Value) -> bool;
|
||||
fn v8__Value__IsTrue(this: &Value) -> bool;
|
||||
fn v8__Value__IsFalse(this: &Value) -> bool;
|
||||
fn v8__Value__IsName(this: &Value) -> bool;
|
||||
fn v8__Value__IsString(this: &Value) -> bool;
|
||||
fn v8__Value__IsNumber(this: &Value) -> bool;
|
||||
fn v8__Value__IsArray(this: &Value) -> bool;
|
||||
fn v8__Value__IsSymbol(this: &Value) -> bool;
|
||||
fn v8__Value__IsFunction(this: &Value) -> bool;
|
||||
fn v8__Value__IsArray(this: &Value) -> bool;
|
||||
fn v8__Value__IsObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsBigInt(this: &Value) -> bool;
|
||||
fn v8__Value__IsBoolean(this: &Value) -> bool;
|
||||
fn v8__Value__IsNumber(this: &Value) -> bool;
|
||||
fn v8__Value__IsExternal(this: &Value) -> bool;
|
||||
fn v8__Value__IsInt32(this: &Value) -> bool;
|
||||
fn v8__Value__IsUint32(this: &Value) -> bool;
|
||||
fn v8__Value__IsDate(this: &Value) -> bool;
|
||||
fn v8__Value__IsArgumentsObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsBigIntObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsBooleanObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsNumberObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsStringObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsSymbolObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsNativeError(this: &Value) -> bool;
|
||||
fn v8__Value__IsRegExp(this: &Value) -> bool;
|
||||
fn v8__Value__IsAsyncFunction(this: &Value) -> bool;
|
||||
fn v8__Value__IsGeneratorFunction(this: &Value) -> bool;
|
||||
fn v8__Value__IsGeneratorObject(this: &Value) -> bool;
|
||||
fn v8__Value__IsPromise(this: &Value) -> bool;
|
||||
fn v8__Value__IsMap(this: &Value) -> bool;
|
||||
fn v8__Value__IsSet(this: &Value) -> bool;
|
||||
fn v8__Value__IsMapIterator(this: &Value) -> bool;
|
||||
fn v8__Value__IsSetIterator(this: &Value) -> bool;
|
||||
fn v8__Value__IsWeakMap(this: &Value) -> bool;
|
||||
fn v8__Value__IsWeakSet(this: &Value) -> bool;
|
||||
fn v8__Value__IsArrayBuffer(this: &Value) -> bool;
|
||||
fn v8__Value__IsArrayBufferView(this: &Value) -> bool;
|
||||
fn v8__Value__IsTypedArray(this: &Value) -> bool;
|
||||
fn v8__Value__IsUint8Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsUint8ClampedArray(this: &Value) -> bool;
|
||||
fn v8__Value__IsInt8Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsUint16Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsInt16Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsUint32Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsInt32Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsFloat32Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsFloat64Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsBigInt64Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsBigUint64Array(this: &Value) -> bool;
|
||||
fn v8__Value__IsDataView(this: &Value) -> bool;
|
||||
fn v8__Value__IsSharedArrayBuffer(this: &Value) -> bool;
|
||||
fn v8__Value__IsProxy(this: &Value) -> bool;
|
||||
fn v8__Value__IsWebAssemblyCompiledModule(this: &Value) -> bool;
|
||||
fn v8__Value__IsModuleNamespaceObject(this: &Value) -> bool;
|
||||
fn v8__Value__StrictEquals(this: &Value, that: &Value) -> bool;
|
||||
fn v8__Value__SameValue(this: &Value, that: &Value) -> bool;
|
||||
fn v8__Value__ToString(this: &Value, context: *mut Context) -> *mut String;
|
||||
|
@ -39,33 +86,274 @@ impl Value {
|
|||
unsafe { v8__Value__IsNullOrUndefined(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is true.
|
||||
/// This is not the same as `BooleanValue()`. The latter performs a
|
||||
/// conversion to boolean, i.e. the result of `Boolean(value)` in JS, whereas
|
||||
/// this checks `value === true`.
|
||||
pub fn is_true(&self) -> bool {
|
||||
unsafe { v8__Value__IsTrue(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is false.
|
||||
/// This is not the same as `!BooleanValue()`. The latter performs a
|
||||
/// conversion to boolean, i.e. the result of `!Boolean(value)` in JS, whereas
|
||||
/// this checks `value === false`.
|
||||
pub fn is_false(&self) -> bool {
|
||||
unsafe { v8__Value__IsFalse(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a symbol or a string.
|
||||
/// This is equivalent to
|
||||
/// `typeof value === 'string' || typeof value === 'symbol'` in JS.
|
||||
pub fn is_name(&self) -> bool {
|
||||
unsafe { v8__Value__IsName(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an instance of the String type.
|
||||
/// See ECMA-262 8.4.
|
||||
pub fn is_string(&self) -> bool {
|
||||
unsafe { v8__Value__IsString(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a symbol.
|
||||
/// This is equivalent to `typeof value === 'symbol'` in JS.
|
||||
pub fn is_symbol(&self) -> bool {
|
||||
unsafe { v8__Value__IsSymbol(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a function.
|
||||
pub fn is_function(&self) -> bool {
|
||||
unsafe { v8__Value__IsFunction(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an array. Note that it will return false for
|
||||
/// an Proxy for an array.
|
||||
pub fn is_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsArray(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a function.
|
||||
pub fn is_function(&self) -> bool {
|
||||
unsafe { v8__Value__IsFunction(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an object.
|
||||
pub fn is_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a bigint.
|
||||
/// This is equivalent to `typeof value === 'bigint'` in JS.
|
||||
pub fn is_big_int(&self) -> bool {
|
||||
unsafe { v8__Value__IsBigInt(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is boolean.
|
||||
/// This is equivalent to `typeof value === 'boolean'` in JS.
|
||||
pub fn is_boolean(&self) -> bool {
|
||||
unsafe { v8__Value__IsBoolean(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a number.
|
||||
pub fn is_number(&self) -> bool {
|
||||
unsafe { v8__Value__IsNumber(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an `External` object.
|
||||
pub fn is_external(&self) -> bool {
|
||||
unsafe { v8__Value__IsExternal(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a 32-bit signed integer.
|
||||
pub fn is_int32(&self) -> bool {
|
||||
unsafe { v8__Value__IsInt32(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a 32-bit unsigned integer.
|
||||
pub fn is_uint32(&self) -> bool {
|
||||
unsafe { v8__Value__IsUint32(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Date.
|
||||
pub fn is_date(&self) -> bool {
|
||||
unsafe { v8__Value__IsDate(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Arguments object.
|
||||
pub fn is_arguments_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsArgumentsObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a BigInt object.
|
||||
pub fn is_big_int_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsBigIntObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Boolean object.
|
||||
pub fn is_boolean_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsBooleanObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Number object.
|
||||
pub fn is_number_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsNumberObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a String object.
|
||||
pub fn is_string_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsStringObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Symbol object.
|
||||
pub fn is_symbol_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsSymbolObject(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a NativeError.
|
||||
pub fn is_native_error(&self) -> bool {
|
||||
unsafe { v8__Value__IsNativeError(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a RegExp.
|
||||
pub fn is_reg_exp(&self) -> bool {
|
||||
unsafe { v8__Value__IsRegExp(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an async function.
|
||||
pub fn is_async_function(&self) -> bool {
|
||||
unsafe { v8__Value__IsAsyncFunction(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Generator function.
|
||||
pub fn is_generator_function(&self) -> bool {
|
||||
unsafe { v8__Value__IsGeneratorFunction(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Promise.
|
||||
pub fn is_promise(&self) -> bool {
|
||||
unsafe { v8__Value__IsPromise(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Map.
|
||||
pub fn is_map(&self) -> bool {
|
||||
unsafe { v8__Value__IsMap(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Set.
|
||||
pub fn is_set(&self) -> bool {
|
||||
unsafe { v8__Value__IsSet(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Map Iterator.
|
||||
pub fn is_map_iterator(&self) -> bool {
|
||||
unsafe { v8__Value__IsMapIterator(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Set Iterator.
|
||||
pub fn is_set_iterator(&self) -> bool {
|
||||
unsafe { v8__Value__IsSetIterator(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a WeakMap.
|
||||
pub fn is_weak_map(&self) -> bool {
|
||||
unsafe { v8__Value__IsWeakMap(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a WeakSet.
|
||||
pub fn is_weak_set(&self) -> bool {
|
||||
unsafe { v8__Value__IsWeakSet(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an ArrayBuffer.
|
||||
pub fn is_array_buffer(&self) -> bool {
|
||||
unsafe { v8__Value__IsArrayBuffer(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an ArrayBufferView.
|
||||
pub fn is_array_buffer_view(&self) -> bool {
|
||||
unsafe { v8__Value__IsArrayBufferView(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is one of TypedArrays.
|
||||
pub fn is_typed_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsTypedArray(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Uint8Array.
|
||||
pub fn is_uint8_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsUint8Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Uint8ClampedArray.
|
||||
pub fn is_uint8_clamped_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsUint8ClampedArray(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Int8Array.
|
||||
pub fn is_int8_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsInt8Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Uint16Array.
|
||||
pub fn is_uint16_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsUint16Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Int16Array.
|
||||
pub fn is_int16_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsInt16Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Uint32Array.
|
||||
pub fn is_uint32_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsUint32Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is an Int32Array.
|
||||
pub fn is_int32_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsInt32Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Float32Array.
|
||||
pub fn is_float32_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsFloat32Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a Float64Array.
|
||||
pub fn is_float64_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsFloat64Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a BigInt64Array.
|
||||
pub fn is_big_int64_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsBigInt64Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a BigUint64Array.
|
||||
pub fn is_big_uint64_array(&self) -> bool {
|
||||
unsafe { v8__Value__IsBigUint64Array(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a DataView.
|
||||
pub fn is_data_view(&self) -> bool {
|
||||
unsafe { v8__Value__IsDataView(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a SharedArrayBuffer.
|
||||
/// This is an experimental feature.
|
||||
pub fn is_shared_array_buffer(&self) -> bool {
|
||||
unsafe { v8__Value__IsSharedArrayBuffer(self) }
|
||||
}
|
||||
|
||||
/// Returns true if this value is a JavaScript Proxy.
|
||||
pub fn is_proxy(&self) -> bool {
|
||||
unsafe { v8__Value__IsProxy(self) }
|
||||
}
|
||||
|
||||
pub fn is_web_assembly_compiled_module(&self) -> bool {
|
||||
unsafe { v8__Value__IsWebAssemblyCompiledModule(self) }
|
||||
}
|
||||
|
||||
/// Returns true if the value is a Module Namespace Object.
|
||||
pub fn is_module_namespace_object(&self) -> bool {
|
||||
unsafe { v8__Value__IsModuleNamespaceObject(self) }
|
||||
}
|
||||
|
||||
pub fn strict_equals<'sc>(&self, that: Local<'sc, Value>) -> bool {
|
||||
unsafe { v8__Value__StrictEquals(self, &that) }
|
||||
}
|
||||
|
|
|
@ -1636,7 +1636,7 @@ fn shared_array_buffer() {
|
|||
global.create_data_property(
|
||||
context,
|
||||
v8_str(s, "shared").into(),
|
||||
sab.into()
|
||||
sab.into(),
|
||||
),
|
||||
v8::MaybeBool::JustTrue
|
||||
);
|
||||
|
@ -1644,7 +1644,7 @@ fn shared_array_buffer() {
|
|||
s,
|
||||
"sharedBytes = new Uint8Array(shared); sharedBytes[2] = 16; sharedBytes[14] = 62; sharedBytes[5] + sharedBytes[12]",
|
||||
)
|
||||
.unwrap();
|
||||
.unwrap();
|
||||
let mut script = v8::Script::compile(s, context, source, None).unwrap();
|
||||
source.to_rust_string_lossy(s);
|
||||
let result = script.run(s, context).unwrap();
|
||||
|
@ -1659,3 +1659,172 @@ fn shared_array_buffer() {
|
|||
isolate.exit();
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn value_checker() {
|
||||
let g = setup();
|
||||
let mut params = v8::Isolate::create_params();
|
||||
params.set_array_buffer_allocator(v8::new_default_allocator());
|
||||
let mut isolate = v8::Isolate::new(params);
|
||||
isolate.enter();
|
||||
let mut locker = v8::Locker::new(&isolate);
|
||||
{
|
||||
let mut hs = v8::HandleScope::new(&mut locker);
|
||||
let scope = hs.enter();
|
||||
let mut context = v8::Context::new(scope);
|
||||
context.enter();
|
||||
|
||||
let value = eval(scope, context, "undefined").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
assert!(value.is_null_or_undefined());
|
||||
|
||||
let value = eval(scope, context, "null").unwrap();
|
||||
assert!(value.is_null());
|
||||
assert!(value.is_null_or_undefined());
|
||||
|
||||
let value = eval(scope, context, "true").unwrap();
|
||||
assert!(value.is_boolean());
|
||||
assert!(value.is_true());
|
||||
assert!(!value.is_false());
|
||||
|
||||
let value = eval(scope, context, "false").unwrap();
|
||||
assert!(value.is_boolean());
|
||||
assert!(!value.is_true());
|
||||
assert!(value.is_false());
|
||||
|
||||
let value = eval(scope, context, "'name'").unwrap();
|
||||
assert!(value.is_name());
|
||||
assert!(value.is_string());
|
||||
|
||||
let value = eval(scope, context, "Symbol()").unwrap();
|
||||
assert!(value.is_name());
|
||||
assert!(value.is_symbol());
|
||||
|
||||
let value = eval(scope, context, "() => 0").unwrap();
|
||||
assert!(value.is_function());
|
||||
|
||||
let value = eval(scope, context, "async () => 0").unwrap();
|
||||
assert!(value.is_async_function());
|
||||
|
||||
let value = eval(scope, context, "[]").unwrap();
|
||||
assert!(value.is_array());
|
||||
|
||||
let value = eval(scope, context, "BigInt('9007199254740995')").unwrap();
|
||||
assert!(value.is_big_int());
|
||||
|
||||
let value = eval(scope, context, "123").unwrap();
|
||||
assert!(value.is_number());
|
||||
|
||||
let value = eval(scope, context, "123").unwrap();
|
||||
assert!(value.is_number());
|
||||
assert!(value.is_int32());
|
||||
assert!(value.is_uint32());
|
||||
|
||||
let value = eval(scope, context, "-123").unwrap();
|
||||
assert!(value.is_number());
|
||||
assert!(!value.is_uint32());
|
||||
|
||||
let value = eval(scope, context, "new Date()").unwrap();
|
||||
assert!(value.is_date());
|
||||
|
||||
let value =
|
||||
eval(scope, context, "(function(){return arguments})()").unwrap();
|
||||
assert!(value.is_arguments_object());
|
||||
|
||||
let value = eval(scope, context, "new Promise(function(){})").unwrap();
|
||||
assert!(value.is_promise());
|
||||
|
||||
let value = eval(scope, context, "new Map()").unwrap();
|
||||
assert!(value.is_map());
|
||||
|
||||
let value = eval(scope, context, "new Set").unwrap();
|
||||
assert!(value.is_set());
|
||||
|
||||
let value = eval(scope, context, "new Map().entries()").unwrap();
|
||||
assert!(value.is_map_iterator());
|
||||
|
||||
let value = eval(scope, context, "new Set().entries()").unwrap();
|
||||
assert!(value.is_set_iterator());
|
||||
|
||||
let value = eval(scope, context, "new WeakMap()").unwrap();
|
||||
assert!(value.is_weak_map());
|
||||
|
||||
let value = eval(scope, context, "new WeakSet()").unwrap();
|
||||
assert!(value.is_weak_set());
|
||||
|
||||
let value = eval(scope, context, "new ArrayBuffer(8)").unwrap();
|
||||
assert!(value.is_array_buffer());
|
||||
|
||||
let value = eval(scope, context, "new Uint8Array([])").unwrap();
|
||||
assert!(value.is_uint8_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Uint8ClampedArray([])").unwrap();
|
||||
assert!(value.is_uint8_clamped_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Int8Array([])").unwrap();
|
||||
assert!(value.is_int8_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Uint16Array([])").unwrap();
|
||||
assert!(value.is_uint16_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Int16Array([])").unwrap();
|
||||
assert!(value.is_int16_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Uint32Array([])").unwrap();
|
||||
assert!(value.is_uint32_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Int32Array([])").unwrap();
|
||||
assert!(value.is_int32_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Float32Array([])").unwrap();
|
||||
assert!(value.is_float32_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new Float64Array([])").unwrap();
|
||||
assert!(value.is_float64_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new BigInt64Array([])").unwrap();
|
||||
assert!(value.is_big_int64_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new BigUint64Array([])").unwrap();
|
||||
assert!(value.is_big_uint64_array());
|
||||
assert!(value.is_array_buffer_view());
|
||||
assert!(value.is_typed_array());
|
||||
|
||||
let value = eval(scope, context, "new SharedArrayBuffer(64)").unwrap();
|
||||
assert!(value.is_shared_array_buffer());
|
||||
|
||||
let value = eval(scope, context, "new Proxy({},{})").unwrap();
|
||||
assert!(value.is_proxy());
|
||||
|
||||
// Other checker, Just check if it can be called
|
||||
value.is_external();
|
||||
value.is_web_assembly_compiled_module();
|
||||
value.is_module_namespace_object();
|
||||
|
||||
context.exit();
|
||||
}
|
||||
drop(locker);
|
||||
isolate.exit();
|
||||
drop(g);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue