mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 05:51:23 +00:00
Transform Reflect into a namespace
This commit is contained in:
@ -2233,163 +2233,164 @@ extern "C" {
|
|||||||
pub fn new(message: &str) -> ReferenceError;
|
pub fn new(message: &str) -> ReferenceError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reflect
|
#[allow(non_snake_case)]
|
||||||
#[wasm_bindgen]
|
pub mod Reflect {
|
||||||
extern "C" {
|
use super::*;
|
||||||
#[wasm_bindgen(extends = Object)]
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
||||||
pub type Reflect;
|
|
||||||
|
|
||||||
/// The static `Reflect.apply()` method calls a target function with
|
// Reflect
|
||||||
/// arguments as specified.
|
#[wasm_bindgen]
|
||||||
///
|
extern "C" {
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
|
/// The static `Reflect.apply()` method calls a target function with
|
||||||
#[wasm_bindgen(static_method_of = Reflect, catch)]
|
/// arguments as specified.
|
||||||
pub fn apply(
|
///
|
||||||
target: &Function,
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply)
|
||||||
this_argument: &JsValue,
|
#[wasm_bindgen(js_namespace = Reflect, catch)]
|
||||||
arguments_list: &Array,
|
pub fn apply(
|
||||||
) -> Result<JsValue, JsValue>;
|
target: &Function,
|
||||||
|
this_argument: &JsValue,
|
||||||
|
arguments_list: &Array,
|
||||||
|
) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.construct()` method acts like the new operator, but
|
/// The static `Reflect.construct()` method acts like the new operator, but
|
||||||
/// as a function. It is equivalent to calling `new target(...args)`. It
|
/// as a function. It is equivalent to calling `new target(...args)`. It
|
||||||
/// gives also the added option to specify a different prototype.
|
/// gives also the added option to specify a different prototype.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, catch)]
|
||||||
pub fn construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>;
|
pub fn construct(target: &Function, arguments_list: &Array) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.construct()` method acts like the new operator, but
|
/// The static `Reflect.construct()` method acts like the new operator, but
|
||||||
/// as a function. It is equivalent to calling `new target(...args)`. It
|
/// as a function. It is equivalent to calling `new target(...args)`. It
|
||||||
/// gives also the added option to specify a different prototype.
|
/// gives also the added option to specify a different prototype.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = construct, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = construct, catch)]
|
||||||
pub fn construct_with_new_target(
|
pub fn construct_with_new_target(
|
||||||
target: &Function,
|
target: &Function,
|
||||||
arguments_list: &Array,
|
arguments_list: &Array,
|
||||||
new_target: &Function,
|
new_target: &Function,
|
||||||
) -> Result<JsValue, JsValue>;
|
) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.defineProperty()` method is like
|
/// The static `Reflect.defineProperty()` method is like
|
||||||
/// `Object.defineProperty()` but returns a `Boolean`.
|
/// `Object.defineProperty()` but returns a `Boolean`.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = defineProperty, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = defineProperty, catch)]
|
||||||
pub fn define_property(
|
pub fn define_property(
|
||||||
target: &Object,
|
target: &Object,
|
||||||
property_key: &JsValue,
|
property_key: &JsValue,
|
||||||
attributes: &Object,
|
attributes: &Object,
|
||||||
) -> Result<bool, JsValue>;
|
) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.deleteProperty()` method allows to delete
|
/// The static `Reflect.deleteProperty()` method allows to delete
|
||||||
/// properties. It is like the `delete` operator as a function.
|
/// properties. It is like the `delete` operator as a function.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = deleteProperty, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = deleteProperty, catch)]
|
||||||
pub fn delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>;
|
pub fn delete_property(target: &Object, key: &JsValue) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.get()` method works like getting a property from
|
/// The static `Reflect.get()` method works like getting a property from
|
||||||
/// an object (`target[propertyKey]`) as a function.
|
/// an object (`target[propertyKey]`) as a function.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, catch)]
|
||||||
pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
|
pub fn get(target: &JsValue, key: &JsValue) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The same as [`Reflect::get`](#method.get) except the key is an `f64`, which is slightly faster.
|
/// The same as [`Reflect::get`](#method.get) except the key is an `f64`, which is slightly faster.
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = "get", catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
|
||||||
pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
|
pub fn get_f64(target: &JsValue, key: f64) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The same as [`Reflect::get`](#method.get) except the key is a `u32`, which is slightly faster.
|
/// The same as [`Reflect::get`](#method.get) except the key is a `u32`, which is slightly faster.
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = "get", catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = "get", catch)]
|
||||||
pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
|
pub fn get_u32(target: &JsValue, key: u32) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
|
/// The static `Reflect.getOwnPropertyDescriptor()` method is similar to
|
||||||
/// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
|
/// `Object.getOwnPropertyDescriptor()`. It returns a property descriptor
|
||||||
/// of the given property if it exists on the object, `undefined` otherwise.
|
/// of the given property if it exists on the object, `undefined` otherwise.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = getOwnPropertyDescriptor, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = getOwnPropertyDescriptor, catch)]
|
||||||
pub fn get_own_property_descriptor(
|
pub fn get_own_property_descriptor(
|
||||||
target: &Object,
|
target: &Object,
|
||||||
property_key: &JsValue,
|
property_key: &JsValue,
|
||||||
) -> Result<JsValue, JsValue>;
|
) -> Result<JsValue, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.getPrototypeOf()` method is almost the same
|
/// The static `Reflect.getPrototypeOf()` method is almost the same
|
||||||
/// method as `Object.getPrototypeOf()`. It returns the prototype
|
/// method as `Object.getPrototypeOf()`. It returns the prototype
|
||||||
/// (i.e. the value of the internal `[[Prototype]]` property) of
|
/// (i.e. the value of the internal `[[Prototype]]` property) of
|
||||||
/// the specified object.
|
/// the specified object.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = getPrototypeOf, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = getPrototypeOf, catch)]
|
||||||
pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
|
pub fn get_prototype_of(target: &JsValue) -> Result<Object, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.has()` method works like the in operator as a
|
/// The static `Reflect.has()` method works like the in operator as a
|
||||||
/// function.
|
/// function.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, catch)]
|
||||||
pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
|
pub fn has(target: &JsValue, property_key: &JsValue) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.isExtensible()` method determines if an object is
|
/// The static `Reflect.isExtensible()` method determines if an object is
|
||||||
/// extensible (whether it can have new properties added to it). It is
|
/// extensible (whether it can have new properties added to it). It is
|
||||||
/// similar to `Object.isExtensible()`, but with some differences.
|
/// similar to `Object.isExtensible()`, but with some differences.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = isExtensible, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = isExtensible, catch)]
|
||||||
pub fn is_extensible(target: &Object) -> Result<bool, JsValue>;
|
pub fn is_extensible(target: &Object) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.ownKeys()` method returns an array of the
|
/// The static `Reflect.ownKeys()` method returns an array of the
|
||||||
/// target object's own property keys.
|
/// target object's own property keys.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = ownKeys, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = ownKeys, catch)]
|
||||||
pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
|
pub fn own_keys(target: &JsValue) -> Result<Array, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.preventExtensions()` method prevents new
|
/// The static `Reflect.preventExtensions()` method prevents new
|
||||||
/// properties from ever being added to an object (i.e. prevents
|
/// properties from ever being added to an object (i.e. prevents
|
||||||
/// future extensions to the object). It is similar to
|
/// future extensions to the object). It is similar to
|
||||||
/// `Object.preventExtensions()`, but with some differences.
|
/// `Object.preventExtensions()`, but with some differences.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = preventExtensions, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = preventExtensions, catch)]
|
||||||
pub fn prevent_extensions(target: &Object) -> Result<bool, JsValue>;
|
pub fn prevent_extensions(target: &Object) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.set()` method works like setting a
|
/// The static `Reflect.set()` method works like setting a
|
||||||
/// property on an object.
|
/// property on an object.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, catch)]
|
||||||
pub fn set(target: &JsValue, property_key: &JsValue, value: &JsValue) -> Result<bool, JsValue>;
|
pub fn set(target: &JsValue, property_key: &JsValue, value: &JsValue) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The same as [`Reflect::set`](#method.set) except the key is an `f64`, which is slightly faster.
|
/// The same as [`Reflect::set`](#method.set) except the key is an `f64`, which is slightly faster.
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = "set", catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
|
||||||
pub fn set_f64(target: &JsValue, property_key: f64, value: &JsValue) -> Result<bool, JsValue>;
|
pub fn set_f64(target: &JsValue, property_key: f64, value: &JsValue) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The same as [`Reflect::set`](#method.set) except the key is a `u32`, which is slightly faster.
|
/// The same as [`Reflect::set`](#method.set) except the key is a `u32`, which is slightly faster.
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = "set", catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = "set", catch)]
|
||||||
pub fn set_u32(target: &JsValue, property_key: u32, value: &JsValue) -> Result<bool, JsValue>;
|
pub fn set_u32(target: &JsValue, property_key: u32, value: &JsValue) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.set()` method works like setting a
|
/// The static `Reflect.set()` method works like setting a
|
||||||
/// property on an object.
|
/// property on an object.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = set, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = set, catch)]
|
||||||
pub fn set_with_receiver(
|
pub fn set_with_receiver(
|
||||||
target: &JsValue,
|
target: &JsValue,
|
||||||
property_key: &JsValue,
|
property_key: &JsValue,
|
||||||
value: &JsValue,
|
value: &JsValue,
|
||||||
receiver: &JsValue,
|
receiver: &JsValue,
|
||||||
) -> Result<bool, JsValue>;
|
) -> Result<bool, JsValue>;
|
||||||
|
|
||||||
/// The static `Reflect.setPrototypeOf()` method is the same
|
/// The static `Reflect.setPrototypeOf()` method is the same
|
||||||
/// method as `Object.setPrototypeOf()`. It sets the prototype
|
/// method as `Object.setPrototypeOf()`. It sets the prototype
|
||||||
/// (i.e., the internal `[[Prototype]]` property) of a specified
|
/// (i.e., the internal `[[Prototype]]` property) of a specified
|
||||||
/// object to another object or to null.
|
/// object to another object or to null.
|
||||||
///
|
///
|
||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf)
|
||||||
#[wasm_bindgen(static_method_of = Reflect, js_name = setPrototypeOf, catch)]
|
#[wasm_bindgen(js_namespace = Reflect, js_name = setPrototypeOf, catch)]
|
||||||
pub fn set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>;
|
pub fn set_prototype_of(target: &Object, prototype: &JsValue) -> Result<bool, JsValue>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegExp
|
// RegExp
|
||||||
|
@ -229,18 +229,6 @@ fn set_prototype_of() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
|
||||||
fn reflect_extends() {
|
|
||||||
#[wasm_bindgen]
|
|
||||||
extern "C" {
|
|
||||||
#[wasm_bindgen(js_name = Reflect)]
|
|
||||||
static reflect: Reflect;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert!(reflect.is_instance_of::<Object>());
|
|
||||||
let _: &Object = reflect.as_ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn reflect_bindings_handle_proxies_that_just_throw_for_everything() {
|
fn reflect_bindings_handle_proxies_that_just_throw_for_everything() {
|
||||||
let p = throw_all_the_time();
|
let p = throw_all_the_time();
|
||||||
|
Reference in New Issue
Block a user