Skip to main content

HostBindings

Struct HostBindings 

Source
pub struct HostBindings { /* private fields */ }
Expand description

Host-side state shared by QuickJS binding closures.

Implementations§

Source§

impl HostBindings

Source

pub fn new() -> Self

Create empty host-binding state.

Source

pub fn set_form_handle(&mut self, form: *mut FormTree, root_id: FormNodeId)

Install or clear the form pointer used by host bindings.

Source

pub fn reset_per_document(&mut self)

Reset counters and invalidate all existing handles for a new document.

Note: data_dom is intentionally NOT cleared here. The caller sets it explicitly via set_data_handle before calling apply_dynamic_scripts_with_runtime, and reset_for_new_document (which calls this) runs inside the dispatch function — after set_data_handle. Clearing it here would wipe the pointer before any scripts execute. The caller is responsible for managing DataDom lifetime.

Source

pub fn set_data_handle(&mut self, dom: *const DataDom)

Phase D-γ: install the DataDom pointer for the current document.

§Safety

dom must outlive all script execution for this document.

Source

pub fn reset_per_script( &mut self, current_id: FormNodeId, activity: Option<&str>, )

Reset per-script state and install the current event context.

Source

pub fn set_static_page_count(&mut self, page_count: u32)

Cache the page count visible to read-only page-count bindings.

Source

pub fn generation(&self) -> u64

Current handle generation. Handles capture this and are invalid after a document reset.

Source

pub fn current_node(&self) -> Option<FormNodeId>

Current script node for this.

Source

pub fn root_node(&mut self, generation: u64) -> Option<FormNodeId>

Root form node for xfa.form.

Source

pub fn subform_scope_chain( &mut self, node_id: FormNodeId, generation: u64, ) -> Vec<String>

Return the names of subform ancestors of node_id from innermost to outermost. Used by the implicit-globals proxy to resolve bare names that belong to a <variables> block in an ancestor subform (D-ι.2 scope chain). Iterative DFS from root; O(n) worst case, acceptable for the small form trees XFA templates produce.

Source

pub fn take_metadata(&mut self) -> RuntimeMetadata

Read and clear host metadata counters.

Source

pub fn mutation_log(&self) -> &[MutationLogEntry]

Mutation log for tests and debug reporting.

Source

pub fn get_raw_value( &mut self, node_id: FormNodeId, generation: u64, ) -> Option<String>

Read field.rawValue; returns None for stale handles, missing nodes, and non-field nodes.

Source

pub fn node_name(&self, node_id: FormNodeId, generation: u64) -> Option<String>

Return the name attribute of any live node. Used by D-ι.2 to expose subformHandle.variables as the subform’s own variables namespace.

Source

pub fn get_occur_property( &mut self, node_id: FormNodeId, generation: u64, property: &str, ) -> Option<i32>

Read a property from a node’s XFA occur object.

Source

pub fn set_occur_property( &mut self, node_id: FormNodeId, generation: u64, property: &str, value: &str, ) -> bool

Write a property on a node’s XFA occur object when mutation is allowed.

Source

pub fn set_raw_value( &mut self, node_id: FormNodeId, value: String, generation: u64, ) -> bool

Write field.rawValue when the activity and target are permitted.

Source

pub fn resolve_node(&mut self, path: &str) -> Option<FormNodeId>

Resolve a SOM path to the first field node.

Source

pub fn resolve_nodes(&mut self, path: &str) -> Vec<FormNodeId>

Resolve a SOM path to field handles, capped at MAX_RESOLVE_RESULTS.

Source

pub fn resolve_implicit( &mut self, current_id: FormNodeId, name: &str, ) -> Option<FormNodeId>

Resolve an implicit JavaScript identifier from the current XFA scope.

Adobe’s XFA JavaScript environment makes sibling and ancestor-scoped SOM nodes visible as bare identifiers. This method searches from the supplied current node upward, returning the first descendant with the requested name at each scope.

Source

pub fn resolve_implicit_candidates( &mut self, current_id: FormNodeId, name: &str, ) -> Vec<FormNodeId>

Resolve all viable implicit JavaScript identifier candidates from the current XFA scope. The first candidate is identical to [resolve_implicit]; later candidates preserve same-name alternatives so the JS proxy can filter them when a chained property supplies the next SOM segment.

Source

pub fn resolve_child( &mut self, parent_id: FormNodeId, name: &str, ) -> Option<FormNodeId>

Resolve a direct child node for chained dotted JavaScript access.

Source

pub fn resolve_child_candidates( &mut self, parent_ids: &[FormNodeId], name: &str, ) -> Vec<FormNodeId>

Resolve chained child candidates from an ordered parent candidate set.

Direct children are preferred. If none match, this uses the same bounded descendant heuristic as the implicit resolver inside each parent, which matches the historical permissiveness of XFA SOM dotted access without inventing handles when the form structure is absent.

Source

pub fn resolve_scoped_candidates( &mut self, scope_ids: &[FormNodeId], name: &str, ) -> Vec<FormNodeId>

Resolve a property name from each candidate’s own implicit scope.

This is the last fallback used by JS-side candidate filtering, covering forms that author a later segment as an ancestor-scoped implicit name rather than as a direct child of the previous segment.

Source

pub fn instance_count(&mut self, parent_id: FormNodeId) -> u32

Count live sibling instances with the same name as parent_id.

Source

pub fn instance_count_for_handle( &mut self, parent_id: FormNodeId, generation: u64, ) -> u32

Count live sibling instances for a JS handle with generation checking.

Source

pub fn instance_index(&mut self, node_id: FormNodeId) -> u32

Return the zero-based sibling index among instances with the same name.

Source

pub fn instance_index_for_handle( &mut self, node_id: FormNodeId, generation: u64, ) -> u32

Return the zero-based sibling index for a JS handle.

Source

pub fn has_zero_instance_run( &mut self, parent_id: FormNodeId, generation: u64, name: &str, ) -> bool

Whether parent_id._name refers to an instance run that was explicitly set to zero during this document. This lets the JS shorthand return a read-only empty manager only for a real prior instance run, while keeping unrelated private-looking _id properties hidden.

Source

pub fn instance_set(&mut self, parent_id: FormNodeId, n: u32) -> Result<u32, ()>

Replace the live same-name sibling run with exactly n instances, clamped to the prototype’s occur limits and the sandbox safety cap.

Source

pub fn instance_set_for_handle( &mut self, parent_id: FormNodeId, generation: u64, n: u32, ) -> Result<u32, ()>

Generation-checked variant used by the QuickJS bridge.

Source

pub fn instance_add(&mut self, parent_id: FormNodeId) -> Result<FormNodeId, ()>

Append one cloned instance to the end of the live same-name sibling run.

Source

pub fn instance_add_for_handle( &mut self, parent_id: FormNodeId, generation: u64, ) -> Result<FormNodeId, ()>

Generation-checked variant used by the QuickJS bridge.

Source

pub fn instance_remove( &mut self, parent_id: FormNodeId, index: u32, ) -> Result<(), ()>

Remove one live same-name sibling instance by zero-based index.

Source

pub fn instance_remove_for_handle( &mut self, parent_id: FormNodeId, generation: u64, index: u32, ) -> Result<(), ()>

Generation-checked variant used by the QuickJS bridge.

Source

pub fn list_clear(&mut self, field_id: FormNodeId) -> Result<(), ()>

Clear all runtime-populated listbox items on a field.

Source

pub fn list_clear_for_handle( &mut self, field_id: FormNodeId, generation: u64, ) -> Result<(), ()>

Generation-checked variant used by the QuickJS bridge.

Source

pub fn list_add( &mut self, field_id: FormNodeId, display: String, save: Option<String>, ) -> Result<(), ()>

Append one item to a field’s runtime listbox options.

Source

pub fn list_add_for_handle( &mut self, field_id: FormNodeId, generation: u64, display: String, save: Option<String>, ) -> Result<(), ()>

Generation-checked variant used by the QuickJS bridge.

Source

pub fn bound_item_for_handle( &mut self, field_id: FormNodeId, generation: u64, display_value: String, ) -> String

XFA 3.3 §App A boundItem — listbox display→save lookup.

Returns the save value associated with display_value for a listbox or dropdown field. Lookup order:

  1. Runtime listbox items populated via D-β addItem (matched first).
  2. Static <items> parsed from the template at merge time.

Adobe’s documented behaviour returns the input unchanged when no match exists (passthrough). Empty input returns empty string. Stale or non-field handles return the input unchanged.

Source

pub fn num_pages(&mut self) -> u32

Read-only static page count visible to Phase C scripts.

Source

pub fn metadata_binding_error(&mut self)

Record a binding-level failure for explicit no-op stubs.

Source

pub fn metadata_resolve_failure(&mut self)

Record use of an intentionally approximate read-only stub.

Source

pub fn data_children(&mut self, raw_id: usize) -> Vec<usize>

Phase D-γ: children of a DataDom node, returned as raw indices. Capped at MAX_RESOLVE_RESULTS. Returns empty vec on invalid input.

Source

pub fn data_value(&mut self, raw_id: usize) -> Option<String>

Phase D-γ: text value of a DataValue node. Returns None for DataGroup nodes or out-of-bounds indices.

Source

pub fn data_child_by_name( &mut self, parent_raw: usize, name: &str, ) -> Option<usize>

Phase D-γ: first child of parent_raw whose name matches name. Returns None if not found or parent is out-of-bounds.

Source

pub fn data_bound_record( &mut self, form_node_id: FormNodeId, generation: u64, ) -> Option<usize>

Phase D-γ: raw DataDom index bound to a FormTree node. Returns None when the node is unbound or the handle is stale.

Source

pub fn data_resolve_node(&mut self, path: &str) -> Option<usize>

Phase D-γ: resolve a data SOM path to the first matching node. Consumes one resolve-call budget slot. Returns None on budget exhaustion, parse failure, or no match.

Source

pub fn data_resolve_nodes(&mut self, path: &str) -> Vec<usize>

Phase D-γ: resolve a data SOM path to all matching nodes (capped). Consumes one resolve-call budget slot.

Trait Implementations§

Source§

impl Debug for HostBindings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HostBindings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> ParallelSend for T