Owned Native FormCalc Execution

Version 2.1206.0 adds native validation-picture matching before scriptTest, with independent policies, inherited messages and rollback on refusal

Version 2.1205.7 skips validate/script execution for empty or explicitly null field and exclusion-group values, including direct HPDFXFAEvaluateFieldScript calls and prepared standalone contexts; skipped results succeed with no executed script

Nonempty values, including a preserved space, retain normal script validation; valueless subform containers are not treated as empty scalar fields, and foreign or detached field/data nodes retain their live-document diagnostic

This empty-value rule does not add full nullTest or calculated-input override handling: ordinary clearing is not an explicit nullTest trigger, and the script API remains distinct from complete form validation

The native getElement path can create event and script properties whose handlers execute through actual input, focus and initialization consumers, including sparse overrides and save/reload

With JavaScript disabled and a non-nil TXFAWidgetRuntimeOptions.RetainedMemoryBudget, native FormCalc events use owned parser, evaluator, value and action producers whose retained allocations are admitted through that family before publication

Calculated fields, validation, binding predicates, computed input-reference matching and legacy field layout queries share the runtime operation ledger and absolute deadline; they do not receive a fresh transaction allowance for each nested evaluation

A nil retained family keeps the ordinary event and predicate compatibility routes, while the existing Data semantic properties, property attribute methods, NodeList operations and batch layout context remain available

Explicit field result ownership

The runtime accepts actual Field and Data nodes, including a nonvisual field without a widget, through this method

procedure TXFAWidgetRuntime.EvaluateFieldScript(
  AFieldNode, ADataNode: TXFANode;
  Kind: TXFAFieldScriptKind;
  var Remaining: Integer;
  Deadline: Int64;
  out Evaluation: TXFAFieldScriptEvaluation;
  var ResultOwner: IXFANativeOwnedValue);

Use HPDFXFANativeValueOwner for the result-owner interface and HPDFXFA for the field evaluation types; the nodes must belong to the runtime's live document and the runtime must have an accepted layout

Keep ResultOwner alive while reading or retaining aliases of Evaluation.Value; the owner can outlive the runtime, and its retained lease is released only after the last owner reference is released

Runtime.EvaluateFieldScript(FieldNode, DataNode, xfskCalculate,
  Remaining, Deadline, Evaluation, ResultOwner);
try
  if not Evaluation.Succeeded then
    raise Exception.Create(Evaluation.Diagnostic);
  ConsumeResult(Evaluation.Value);
finally
  Evaluation.Value := '';
  ResultOwner := nil;
end;

Clear every borrowed string alias before releasing its owner; an ordinary copied string variable is not itself a retained-memory owner

Initial retained-funded native setup omits unused ordinary Template attribute snapshots; live attribute reads and typed writes use the current DOM, while namespace and declaration preparation stays unchanged

Custom attribute tables, custom clocks and external operation consumers retain full snapshot preparation, as do later model append and refresh operations

Eligible complete literal this.presence assignments can prepare one existing listener binding after charged qualification of an ordinary bounded model; the full original parser, evaluator and typed action pipeline still execute the script

Frozen event-plan entries are matched by node, data scope and widget state, with listener and source checked separately; compact execution validates model generations after callback-capable admissions, and all other scripts retain full setup with qualification charges preserved

Compatibility and admission boundaries

Native attribute availability checks can exclude a missing attribute before walking ordinary node ownership when both the name and the ordinary attribute table are bounded; matching candidates still receive full ownership checks

Custom monotonic clocks, external operation consumers, custom attribute tables and NodeList proof paths retain the original order; an unrelated ownership-depth error is no longer triggered by a skipped node that cannot supply the requested attribute, and the new classification remains charged

Native ownership checks reuse a bounded proof that a node already reached its document root while the whole binding generation is unchanged, so an index rebuild or a repeated reference, refresh or node read does not walk the same ownership chain again

Proofs are keyed by node identity and compared against the root they reached, charge their own operation on a hit, stop growing at a fixed capacity and are discarded wholesale on any mutation, remerge, rebuild or calculation-structure change; retired, removed, proof-bearing and detached-root cases keep their existing checks

Native choice mutations admit the provisional DOM their payload builds, covering the node instances, the attribute and child lists each node owns, the root attribute entry, the root child array growth and the text child inserted for every non-empty value

Only physical allocations are charged, string payloads stay shared by reference count except the operation attribute, and no operation tick is added, so script operation consumption and the serializer output leases are unchanged

The replay side of the same mutation reserves the tree it parses back out of the payload, so one choice mutation is metered on both halves rather than only where the payload is built

That reservation is one scoped lease sized from the payload length and released once the parsed tree is freed; execution without a configured budget charges nothing and keeps its previous behaviour

Layout predicate evaluation reserves the parsed script tree it caches, which was retained for the runtime lifetime outside the retained-memory budget

That reservation grows one persistent lease held by the runtime and is released with it, while the entry-count and script value regimes are unchanged

Constant integer counted loops with one local numeric addition can use direct accumulation when the bounds, positive step, iteration count and every intermediate sum are proven exact; the final accumulator, counter and implicit result are preserved for subsequent statements and closures

The bounded eligibility analysis is charged, and dynamic or fractional expressions, reference assignments, nonlocal accumulators, control transfers and depth-limit failures keep the ordinary interpreter; no configured operation limit is raised

Initial retained-funded native evaluation and listener matching seed Data binding identities and semantic classes without producing unused provider value, default-value or XML snapshots; native Data reads and XML methods read the current document instead

JavaScript provider, unfunded compatibility, legacy layout queries and refreshed contexts retain complete snapshots; unused initial payload production no longer triggers its incidental serialization or payload-length diagnostics, and requested reads or XML methods retain their own limits

With the built-in property resolver, no custom scope or clock callback and no record provider, lifecycle dispatch can skip full scope and effective-definition resolution when a bounded charged scan of both Template and Form trees proves the phase absent; possible events, complex bindings and uncertain or changed generations keep the original search

The scan is repeated for the relevant phase and does not retain a negative result across document changes; it reduces ordinary work without changing the configured operation allowance or establishing a general memory cap

Skipping an unrelated scope search also skips the lazy Data metadata reconciliation and semantic validation that search would incidentally perform; errors from that omitted traversal are not guaranteed to appear during a phase with no matching event

Data writes can exclude an unaffected field before repeating an accepted-reference target search when the Form merge generation and binding descriptor remain current; the accepted target identity must differ from both the written ordinary Data node and its parent

Older saved generations, changed descriptors, record providers, exclusion-group members and Data text-unit writes keep full resolution; the optimization charges eligibility and descriptor classification before merge-metadata access, including fields that need fallback, and preserves reference targets rather than guessing from names or current paths

Native dispatch also reserves its own path slices, event fullText decoding and concatenation buffers, UTF-8 result conversions and class-collection handle arrays; somExpression escapes each measured segment without repeated character-by-character string growth

Instance operations and getElement creation prepay their temporary identity maps, method arguments and bounded schema-default buffers, while passive choice-state reconstruction uses measured output storage and preserves duplicate or empty export-value behavior

Native SOM queries also reserve parser strings, step/filter arrays, traversal and binding buffers, identity maps, refresh remapping, result arrays and explicit query callback objects before allocation; these reservations remain charged through result consumption in the caller query scope

Direct resolver callers can supply the optional synchronous Reserve callback; nil callbacks preserve the ordinary allocation route, and the existing query results, operation charges and syntax rules remain unchanged

Native reference and attribute handles, reference vectors, manager membership arrays, choice item/selection workspace, Host remerge maps and pageContent result buffers are admitted before allocation and stay charged through their consuming caller scope

Temporary arrays returned by native choice selection share the existing caller lifetime, and legacy field layout queries keep their argument-vector lease until all owned arguments and the answer are cleared

Persistent native Host storage participates in retained funding, including the bounded query/context stacks, each query-frame slot array, binding identity keys and detached-root identity tables; capacity is admitted before growth, with the old allocation held until replacement succeeds

Cloning and creating Data nodes reserve their identity-table destination before the document mutation, and budget callbacks cannot recursively rebuild an active identity index or resume a query with a retired target generation

Existing standalone functions returning only TXFAFieldScriptEvaluation continue to return ordinary caller-owned strings; those compatibility exports make an independent copy and do not retain family accounting for the exported string

The owned execution path does not establish a complete physical memory cap for every host container, binding table, DOM allocation or snapshot-recovery workspace; configure application limits as well as the retained family and do not treat retained allocation totals as total process memory

Admission failures follow the transaction's rollback path and support retry on the same runtime; a retained result owner remains necessary even after the document or runtime is released

See Portable XFA runtime and Native FormCalc Data properties