Skip to content

Exposing abstracts in Hscript

ashley edited this page Aug 7, 2026 · 3 revisions

Important

This feature is very experimental and I plan to replace it with a better alternative soon, so this page may become obsolete

To make an abstract usable in Hscript, include the following metadata in your abstract:

@:build(insanity.backend.macro.AbstractMacro.build())

You can apply this to abstracts from external libraries with Compiler.addMetadata or Compiler.addGlobalMetadata.

Once applied, the abstract can be imported and used in scripts via cast!

Limitations

  • Overload operators currently don't work, and casting from/to types may be amply degraded due to type parameters not being enforced at runtime.
    • This is a limitation with Haxe. Mostlys.
  • The abstract macro currently faces a lot of compilation errors.
    • It's recommended to only expose abstracts that use simple types rather than compound to avoid running into unexpected errors.

Clone this wiki locally