THPDFQuickJS.InstallRetiredValueRegistry
Unit: HPDFQuickJS
Declaration
function InstallRetiredValueRegistry(Callback: THPDFQJSRetiredCallback;
Opaque: Pointer): Boolean;
THPDFQJSRetiredCallback = function(Opaque: Pointer; Operation: Integer;
Key: Pointer; KeyLength: NativeUInt): Integer; cdecl;
Behavior and ownership
Installs the optional HPDFQJS_InstallRetiredValueRegistry bridge callback and returns True on success; False indicates unavailable support, an invalid callback, a busy engine or installation failure
The callback and Opaque storage must remain valid for the engine lifetime or until replaced by another successful installation of this mode. One engine is not reentrant; do not evaluate or destroy it from the callback, and do not allow native exceptions to escape the callback
The callback consumes the explicit-length opaque key synchronously and must copy any bytes it retains before returning. The buffer can contain NUL and is not necessarily text or NUL-terminated; an empty key is valid
| Operation | Positive result | Zero result | Negative result |
|---|---|---|---|
| 0: membership lookup | The key exists | The key is absent | Host failure |
| 1: insertion | A new key was inserted | The key already existed | Host failure |
A failed host operation becomes a JavaScript error. The XFA Session additionally latches storage errors so that catching the error in JavaScript cannot commit a partial event
Exact scalar key format
The installed function exposes an immutable, nonenumerable own data property scalarValues=true for primitive strings, numbers, BigInts, booleans, null and undefined. Version 2.1141.0 bridges also expose strongValues=true for exact object, function and Symbol identity membership
The XFA handle layer requires each capability to be an own data property with the exact Boolean value true; it also checks the descriptor object's own value property. Inherited properties, accessors and inherited descriptor values do not enable a mode or invoke a capability getter
| Value | Opaque bytes in hexadecimal or ASCII |
|---|---|
| Empty string or string not starting with NUL | Original CESU-8 bytes |
| String starting with NUL | 00 53 followed by all original CESU-8 bytes |
| Number | 00 4E followed by eight big-endian IEEE 754 binary64 bytes |
| BigInt | 00 49 followed by its canonical decimal ASCII representation |
| Boolean | 00 42 followed by 00 or 01 |
| null | 00 4C |
| undefined | 00 55 |
Number keys implement SameValueZero: positive and negative zero share the all-zero number payload, every NaN uses 7FF8000000000000, and equivalent integer and double representations share a key. Other number bits remain exact; numeric 1, BigInt 1n and string "1" remain distinct
Exact reference keys and strong ownership
| Reference value | Opaque bytes |
|---|---|
| Object, including a function, boxed value or Proxy | 00 4F, engine uintptr_t, native JSValue identity uintptr_t |
| Symbol | 00 59, engine uintptr_t, native JSValue identity uintptr_t |
Each pointer field uses exactly sizeof(uintptr_t) big-endian bytes, giving an 18-byte descriptor on 64-bit targets and a 10-byte descriptor on 32-bit targets. These engine-local descriptors are opaque, are separate from string and scalar namespaces, and never use ToString, user coercion or Proxy traps
A strong provider must use a fresh, engine-private, append-only namespace with no preloaded reference descriptors. Membership and insertion results must be coherent and serialized. Reinstallation may replace the callback only while preserving that same logical namespace; do not clear it while retaining the engine or reuse it after engine destruction, rebuild or a later engine, because native addresses may be recycled
Reference insertion first asks the host for membership. For a missing identity it reserves native root-vector capacity under the normal engine memory budget, then requests insertion; only a positive insertion result duplicates the JSValue and adds one strong root. Duplicate insertion returns false without adding another root, and allocation or host failure publishes no new root
The dense root vector preserves strong Set-style lifetime until engine teardown. Teardown releases the owned JSValues and vector before freeing the context without reading or enumerating the provider. The vector and retained object payload remain linear in admitted reference data; no engine or journal hard limit is raised
Compatibility and mode isolation
The required bridge ABI and the original InstallRetiredRegistry string-only callback remain unchanged. V1 and this value registry retain independent callback and Opaque fields; reinstallation updates the corresponding mode's held functions
Use separate backing stores or explicitly partition namespaces for V1 raw keys and typed value keys. A raw V1 string can otherwise equal an encoded V2 key. Scalar wire formats are unchanged. The XFA Session installs one preferred mode per engine and clears its own index before rebuilding
Earlier V2 bridges with only scalarValues keep references in the Session's strong JavaScript Set, while V1 bridges retain the string-only native mode and existing nonstring fallback. The optional export alone does not prove strong reference support
The registry does not provide enumeration, persistence across engines or a general JavaScript Set API
Related APIs
Native retired value registry and XFA retired identity storage