pub struct HostBindings { /* private fields */ }Expand description
Host-side state shared by QuickJS binding closures.
Implementations§
Source§impl HostBindings
impl HostBindings
Sourcepub fn set_form_handle(&mut self, form: *mut FormTree, root_id: FormNodeId)
pub fn set_form_handle(&mut self, form: *mut FormTree, root_id: FormNodeId)
Install or clear the form pointer used by host bindings.
Sourcepub fn reset_per_document(&mut self)
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.
Sourcepub fn set_data_handle(&mut self, dom: *const DataDom)
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.
Sourcepub fn reset_per_script(
&mut self,
current_id: FormNodeId,
activity: Option<&str>,
)
pub fn reset_per_script( &mut self, current_id: FormNodeId, activity: Option<&str>, )
Reset per-script state and install the current event context.
Sourcepub fn set_static_page_count(&mut self, page_count: u32)
pub fn set_static_page_count(&mut self, page_count: u32)
Cache the page count visible to read-only page-count bindings.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Current handle generation. Handles capture this and are invalid after a document reset.
Sourcepub fn current_node(&self) -> Option<FormNodeId>
pub fn current_node(&self) -> Option<FormNodeId>
Current script node for this.
Sourcepub fn root_node(&mut self, generation: u64) -> Option<FormNodeId>
pub fn root_node(&mut self, generation: u64) -> Option<FormNodeId>
Root form node for xfa.form.
Sourcepub fn subform_scope_chain(
&mut self,
node_id: FormNodeId,
generation: u64,
) -> Vec<String>
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.
Sourcepub fn take_metadata(&mut self) -> RuntimeMetadata
pub fn take_metadata(&mut self) -> RuntimeMetadata
Read and clear host metadata counters.
Sourcepub fn mutation_log(&self) -> &[MutationLogEntry]
pub fn mutation_log(&self) -> &[MutationLogEntry]
Mutation log for tests and debug reporting.
Sourcepub fn get_raw_value(
&mut self,
node_id: FormNodeId,
generation: u64,
) -> Option<String>
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.
Sourcepub fn node_name(&self, node_id: FormNodeId, generation: u64) -> Option<String>
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.
Sourcepub fn get_occur_property(
&mut self,
node_id: FormNodeId,
generation: u64,
property: &str,
) -> Option<i32>
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.
Sourcepub fn set_occur_property(
&mut self,
node_id: FormNodeId,
generation: u64,
property: &str,
value: &str,
) -> bool
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.
Sourcepub fn set_raw_value(
&mut self,
node_id: FormNodeId,
value: String,
generation: u64,
) -> bool
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.
Sourcepub fn resolve_node(&mut self, path: &str) -> Option<FormNodeId>
pub fn resolve_node(&mut self, path: &str) -> Option<FormNodeId>
Resolve a SOM path to the first field node.
Sourcepub fn resolve_nodes(&mut self, path: &str) -> Vec<FormNodeId>
pub fn resolve_nodes(&mut self, path: &str) -> Vec<FormNodeId>
Resolve a SOM path to field handles, capped at
MAX_RESOLVE_RESULTS.
Sourcepub fn resolve_implicit(
&mut self,
current_id: FormNodeId,
name: &str,
) -> Option<FormNodeId>
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.
Sourcepub fn resolve_implicit_candidates(
&mut self,
current_id: FormNodeId,
name: &str,
) -> Vec<FormNodeId>
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.
Sourcepub fn resolve_child(
&mut self,
parent_id: FormNodeId,
name: &str,
) -> Option<FormNodeId>
pub fn resolve_child( &mut self, parent_id: FormNodeId, name: &str, ) -> Option<FormNodeId>
Resolve a direct child node for chained dotted JavaScript access.
Sourcepub fn resolve_child_candidates(
&mut self,
parent_ids: &[FormNodeId],
name: &str,
) -> Vec<FormNodeId>
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.
Sourcepub fn resolve_scoped_candidates(
&mut self,
scope_ids: &[FormNodeId],
name: &str,
) -> Vec<FormNodeId>
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.
Sourcepub fn instance_count(&mut self, parent_id: FormNodeId) -> u32
pub fn instance_count(&mut self, parent_id: FormNodeId) -> u32
Count live sibling instances with the same name as parent_id.
Sourcepub fn instance_count_for_handle(
&mut self,
parent_id: FormNodeId,
generation: u64,
) -> u32
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.
Sourcepub fn instance_index(&mut self, node_id: FormNodeId) -> u32
pub fn instance_index(&mut self, node_id: FormNodeId) -> u32
Return the zero-based sibling index among instances with the same name.
Sourcepub fn instance_index_for_handle(
&mut self,
node_id: FormNodeId,
generation: u64,
) -> u32
pub fn instance_index_for_handle( &mut self, node_id: FormNodeId, generation: u64, ) -> u32
Return the zero-based sibling index for a JS handle.
Sourcepub fn has_zero_instance_run(
&mut self,
parent_id: FormNodeId,
generation: u64,
name: &str,
) -> bool
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.
Sourcepub fn instance_set(&mut self, parent_id: FormNodeId, n: u32) -> Result<u32, ()>
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.
Sourcepub fn instance_set_for_handle(
&mut self,
parent_id: FormNodeId,
generation: u64,
n: u32,
) -> Result<u32, ()>
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.
Sourcepub fn instance_add(&mut self, parent_id: FormNodeId) -> Result<FormNodeId, ()>
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.
Sourcepub fn instance_add_for_handle(
&mut self,
parent_id: FormNodeId,
generation: u64,
) -> Result<FormNodeId, ()>
pub fn instance_add_for_handle( &mut self, parent_id: FormNodeId, generation: u64, ) -> Result<FormNodeId, ()>
Generation-checked variant used by the QuickJS bridge.
Sourcepub fn instance_remove(
&mut self,
parent_id: FormNodeId,
index: u32,
) -> Result<(), ()>
pub fn instance_remove( &mut self, parent_id: FormNodeId, index: u32, ) -> Result<(), ()>
Remove one live same-name sibling instance by zero-based index.
Sourcepub fn instance_remove_for_handle(
&mut self,
parent_id: FormNodeId,
generation: u64,
index: u32,
) -> Result<(), ()>
pub fn instance_remove_for_handle( &mut self, parent_id: FormNodeId, generation: u64, index: u32, ) -> Result<(), ()>
Generation-checked variant used by the QuickJS bridge.
Sourcepub fn list_clear(&mut self, field_id: FormNodeId) -> Result<(), ()>
pub fn list_clear(&mut self, field_id: FormNodeId) -> Result<(), ()>
Clear all runtime-populated listbox items on a field.
Sourcepub fn list_clear_for_handle(
&mut self,
field_id: FormNodeId,
generation: u64,
) -> Result<(), ()>
pub fn list_clear_for_handle( &mut self, field_id: FormNodeId, generation: u64, ) -> Result<(), ()>
Generation-checked variant used by the QuickJS bridge.
Sourcepub fn list_add(
&mut self,
field_id: FormNodeId,
display: String,
save: Option<String>,
) -> Result<(), ()>
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.
Sourcepub fn list_add_for_handle(
&mut self,
field_id: FormNodeId,
generation: u64,
display: String,
save: Option<String>,
) -> Result<(), ()>
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.
Sourcepub fn bound_item_for_handle(
&mut self,
field_id: FormNodeId,
generation: u64,
display_value: String,
) -> String
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:
- Runtime listbox items populated via D-β
addItem(matched first). - 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.
Sourcepub fn metadata_binding_error(&mut self)
pub fn metadata_binding_error(&mut self)
Record a binding-level failure for explicit no-op stubs.
Sourcepub fn metadata_resolve_failure(&mut self)
pub fn metadata_resolve_failure(&mut self)
Record use of an intentionally approximate read-only stub.
Sourcepub fn data_children(&mut self, raw_id: usize) -> Vec<usize>
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.
Sourcepub fn data_value(&mut self, raw_id: usize) -> Option<String>
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.
Sourcepub fn data_child_by_name(
&mut self,
parent_raw: usize,
name: &str,
) -> Option<usize>
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.
Sourcepub fn data_bound_record(
&mut self,
form_node_id: FormNodeId,
generation: u64,
) -> Option<usize>
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.
Sourcepub fn data_resolve_node(&mut self, path: &str) -> Option<usize>
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.
Sourcepub fn data_resolve_nodes(&mut self, path: &str) -> Vec<usize>
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
impl Debug for HostBindings
Auto Trait Implementations§
impl Freeze for HostBindings
impl RefUnwindSafe for HostBindings
impl !Send for HostBindings
impl !Sync for HostBindings
impl Unpin for HostBindings
impl UnsafeUnpin for HostBindings
impl UnwindSafe for HostBindings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().