Merge pull request #386 from jannikkeye/bindings-reflect

Reflect.xx bindings
This commit is contained in:
Marcin Baraniecki
2018-07-06 13:34:59 +02:00
committed by GitHub
3 changed files with 710 additions and 0 deletions

108
src/js.rs
View File

@ -1071,6 +1071,114 @@ extern {
pub fn revocable(target: &JsValue, handler: &Object) -> Object;
}
// Reflect
#[wasm_bindgen]
extern "C" {
pub type Reflect;
/// The static Reflect.apply() method calls a target function with arguments as specified.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply
#[wasm_bindgen(static_method_of = Reflect)]
pub fn apply(target: &Function, this_argument: &JsValue, arguments_list: &Array) -> JsValue;
/// The static Reflect.construct() method acts like the new operator, but as a function.
/// It is equivalent to calling new target(...args). It gives also the added option to
/// specify a different prototype.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct
#[wasm_bindgen(static_method_of = Reflect)]
pub fn construct(target: &Function, arguments_list: &Array) -> JsValue;
#[wasm_bindgen(static_method_of = Reflect, js_name = construct)]
pub fn construct_with_new_target(target: &Function, arguments_list: &Array, new_target: &Function) -> JsValue;
/// The static Reflect.defineProperty() method is like Object.defineProperty()
/// but returns a Boolean.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty
#[wasm_bindgen(static_method_of = Reflect, js_name = defineProperty)]
pub fn define_property(target: &Object, property_key: &JsValue, attributes: &Object) -> bool;
/// The static Reflect.deleteProperty() method allows to delete properties.
/// It is like the delete operator as a function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty
#[wasm_bindgen(static_method_of = Reflect, js_name = deleteProperty)]
pub fn delete_property(target: &Object, key: &JsValue) -> bool;
/// The static Reflect.get() method works like getting a property from
/// an object (target[propertyKey]) as a function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get
#[wasm_bindgen(static_method_of = Reflect)]
pub fn get(target: &Object, key: &JsValue) -> JsValue;
/// The static Reflect.getOwnPropertyDescriptor() method is similar to
/// Object.getOwnPropertyDescriptor(). It returns a property descriptor
/// of the given property if it exists on the object, undefined otherwise.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor
#[wasm_bindgen(static_method_of = Reflect, js_name = getOwnPropertyDescriptor)]
pub fn get_own_property_descriptor(target: &Object, property_key: &JsValue) -> JsValue;
/// The static Reflect.getPrototypeOf() method is almost the same
/// method as Object.getPrototypeOf(). It returns the prototype
/// (i.e. the value of the internal [[Prototype]] property) of
/// the specified object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf
#[wasm_bindgen(static_method_of = Reflect, js_name = getPrototypeOf)]
pub fn get_prototype_of(target: &Object) -> Object;
/// The static Reflect.has() method works like the in operator as a function.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has
#[wasm_bindgen(static_method_of = Reflect)]
pub fn has(target: &Object, property_key: &JsValue) -> bool;
/// The static Reflect.isExtensible() method determines if an object is extensible
/// (whether it can have new properties added to it). It is similar to
/// Object.isExtensible(), but with some differences.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible
#[wasm_bindgen(static_method_of = Reflect, js_name = isExtensible)]
pub fn is_extensible(target: &Object) -> bool;
/// The static Reflect.ownKeys() method returns an array of the
/// target object's own property keys.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys
#[wasm_bindgen(static_method_of = Reflect, js_name = ownKeys)]
pub fn own_keys(target: &Object) -> Array;
/// The static Reflect.preventExtensions() method prevents new
/// properties from ever being added to an object (i.e. prevents
/// future extensions to the object). It is similar to
/// Object.preventExtensions(), but with some differences.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions
#[wasm_bindgen(static_method_of = Reflect, js_name = preventExtensions)]
pub fn prevent_extensions(target: &Object) -> bool;
/// The static Reflect.set() method works like setting a
/// property on an object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set
#[wasm_bindgen(static_method_of = Reflect)]
pub fn set(target: &Object, property_key: &JsValue, value: &JsValue) -> bool;
#[wasm_bindgen(static_method_of = Reflect, js_name = set)]
pub fn set_with_receiver(target: &Object, property_key: &JsValue, value: &JsValue, receiver: &Object) -> bool;
/// The static Reflect.setPrototypeOf() method is the same
/// method as Object.setPrototypeOf(). It sets the prototype
/// (i.e., the internal [[Prototype]] property) of a specified
/// object to another object or to null.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf
#[wasm_bindgen(static_method_of = Reflect, js_name = setPrototypeOf)]
pub fn set_prototype_of(target: &Object, prototype: &JsValue) -> bool;
}
// Set
#[wasm_bindgen]
extern {