glendix/js/reflect

Performs dynamic JavaScript reflection against object handles.

These operations are the interop boundary: they read and write arbitrary properties, invoke methods, and call constructors by name at runtime. They are inherently dynamic and unsafe in the sense that the caller, not the type system, guarantees a property exists, a method is callable, or a value is a constructor. Keep this surface minimal and prefer the data-only glendix/js/object module whenever a plain data object is enough.

The __proto__-as-data guarantee belongs specifically to object.from_entries. set deliberately preserves ordinary JavaScript assignment semantics, so a key such as __proto__ can invoke an inherited setter. Do not pass untrusted property names to reflection operations.

Object handles and values flow through glendix/js/object, so both modules share one typed representation of JavaScript objects and values.

Types

Represents a JavaScript constructor handle.

pub type JsConstructor

Values

pub fn call_method(
  on handle: object.JsObject,
  named method: String,
  with arguments: List(object.JsValue),
) -> object.JsValue

Calls an object method with a list of arguments.

pub fn call_method_without_arguments(
  on handle: object.JsObject,
  named method: String,
) -> object.JsValue

Calls an object method without arguments.

pub fn delete(
  from handle: object.JsObject,
  key key: String,
) -> object.JsObject

Deletes an object property and returns the same object handle.

pub fn get(
  from handle: object.JsObject,
  key key: String,
) -> object.JsValue

Reads an object property.

pub fn has(in handle: object.JsObject, key key: String) -> Bool

Reports whether an object or its prototype chain has the given property.

pub fn new_instance(
  using constructor: JsConstructor,
  with arguments: List(object.JsValue),
) -> object.JsObject

Creates an object with JavaScript’s new operator.

pub fn set(
  on handle: object.JsObject,
  key key: String,
  to value: object.JsValue,
) -> object.JsObject

Mutates an object property and returns the same object handle.

Search Document