THPDFNativeWorkspaceScope

THPDFNativeWorkspaceScope = class
public
  constructor Create(Module: NativeUInt; Workspace: THPDFWorkspaceAdmission);
  destructor Destroy; override;
  procedure Check;
  procedure Finish;
  function Admissions: UInt64;
  function ChargedBytes: UInt64;
end;

Declared in HPDFNativeWorkspace; borrows one admission owner for the allocator scope exposed by one already loaded native module

The module must expose workspace ABI version 1 and the required scope functions; this class does not load an arbitrary library or turn an ordinary binary into a budget-aware binary

Lifetime and failure

Keep the native module and admission owner alive until the scope has finished; enter, use and leave the scope on the same thread and in native stack order

Check rethrows a retained callback exception after native control has returned to Pascal; callbacks never allow a Pascal exception to cross the C ABI

Finish ends an active scope and reports its retained failure; calling it again is an invalid operation

Free the scope in a finally block even when Check or Finish raises; destruction releases the scope storage and any unreported retained exception

Counters

Admissions reports native callback admissions, which include allocation charges and operation polls; it is not a count of every process heap allocation

ChargedBytes reports the native scope byte charges; freeing native allocations does not reset the caller's cumulative admission ledger

Use HPDFStartNativeWorkspace when an optional borrowed owner should preserve the nil-workspace path

The workspace-aware shaping entry points manage their own scopes; a caller does not need to add a manual scope around those calls