Expand description
Generate Java visitor support: interface, NodeContext record, VisitResult sealed interface, VisitorBridge (upcall stubs), and convertWithVisitor method.
§Panama FFM upcall strategy
Java cannot expose method references as raw C function pointers. The generated code uses Java 21+ Foreign Function & Memory API (Panama) upcall stubs:
NodeContext: arecordcarrying the fields fromHTMHtmNodeContext.VisitResult: asealed interfacewithContinue,Skip,PreserveHtml,Custom, andErrorimplementations.Visitor: aninterfacewith default no-op methods for all 40 callbacks.VisitorBridge: a package-private class that allocates oneMemorySegmentupcall stub per callback inside aArena.ofConfined()scope, then writes all stubs into a flatMemorySegmentmatchingHTMHtmVisitorCallbacks.convertWithVisitor: static method on the wrapper class that drives the full lifecycle: marshal options → createVisitorBridge→htm_visitor_create→htm_convert_with_visitor→ deserialise JSON result →htm_visitor_free.
Structs§
Constants§
Functions§
- gen_
convert_ with_ visitor_ method - Generate the
convertWithVisitormethod body to inject into the main wrapper class. - gen_
native_ lib_ visitor_ handles - Generate NativeLib method handle declarations for visitor FFI functions.
- gen_
visitor_ files - Returns
(filename, content)pairs for all visitor-related Java files.