A super-combined HaxeScript runtime for SeiunEngine — built on hscript-iris 1.1.3 as the base, fused with hscript-improved and hscript-plus. All three are MIT-licensed; attribution is kept in NOTICE.
Packages start at hscript: the merged runtime lives in hscript.*
(hscript.Parser, hscript.Interp, ...), with the iris utilities under
hscript.iris.*. The upstream crowplexus prefix is gone.
import+ aliases (import Foo as Bar),package,usingfinalconstants,enum,typedefredirects- null coalescing
??/??= - improved error handling and
showPosOnLog - for-loop iterator caching and other performance/memory optimizations
- Script classes:
class Foo { ... },new Foo(), fields/methods/this - CUSTOM_CLASSES macro: script classes can
extendsengine classes (e.g.class MySprite extends FlxSprite);_HSXshadow classes are generated at compile time and engine methods can be overridden at runtime scriptObject(parent binding,thisresolution)static/publicvariables and functions (staticVariables/publicVariables,allowStaticVariables/allowPublicVariables)errorHandler,importFailedCallback,importBlocklist,importRedirectsgetRedirects/setRedirects,@:bypassAccessor_HSCshadow classes forAbstract/Enum(UsingHandler macro)
- Script-to-script inheritance:
class Dog extends Animal {}(both script classes), instances are Dynamic objects with a__sname__+superchain; method overrides, inherited fields andsuper.method()all work - access modifiers:
public/private/static/override/dynamic/inline
- Key-value for loops:
for (k => v in map) - Script-class static variables are truly shared across instances
- Class-field assignment syncs locals and the variable table, so
obj.fieldalways reads the freshest value
- String interpolation:
"v=$x","v=${x + 2}","${obj.field}";$$is the escaped dollar, just like Haxe cast: bothcast (x, T)(checked against resolvable classes, raises "Cast error" on mismatch) andcast x(unchecked)untyped: parsed and evaluated as the wrapped expression- Generic constructor type parameters:
new Array<Int>(),new Array<Array<Int>>()(types are discarded, like a compile-time concept) - Object shorthand (Haxe 4):
{x}means{x: x} - Destructuring declarations (Haxe 4):
var [a, b] = arr;andvar {x, y} = obj; - Spread calls and rest args:
f(...arr)andfunction f(a, ...rest) - Static members via the class name:
M.staticMethod(),S.staticVar,S.staticVar = 9— static fields are evaluated once at class declaration - Switch guards:
case v if (v > 3):bindsvto the switched value
Also fixed while testing: ++/-- on local variables, default values for
optional arguments, ?. null-safe calls, and error propagation without
-D hscriptPos.
Scripts get Haxe-style conditional execution (parsed at runtime — this is not compile-time conditional compilation):
#if android
var plat = "android";
#elseif ios
var plat = "ios";
#else
var plat = "other";
#endSupports #if / #elseif / #else / #end, !, &&, || and parentheses.
A key counts as "defined" when it is present in Parser.preprocessorValues
(the value is irrelevant — same semantics as Haxe #if); nested #if blocks and
multi-branch #elseif chains pair correctly.
Engine hosts (e.g. SeiunEngine's HScript) inject platform keys by default:
android / ios / windows / linux / mac / web / html5 /
desktop / mobile / sys, plus engine / engineName / hscript.
Custom keys are easy to add:
parser.preprocessorValues.set("myFeature", true);The historical misspelled alias preprocesorValues (missing an "s") still works,
and writes to it are synced into preprocessorValues.
haxelib git hscript-seiun https://github.com/mohong2/hscript-seiun.gitor, for local development:
haxelib dev hscript-seiun <path-to-repo>Then, in project.xml:
<haxelib name="hscript-seiun"/>
<!-- optional: enable script classes extending engine classes -->
<define name="CUSTOM_CLASSES"/>The extraParams.hxml at the repo root automatically injects the two compile-time
macros (UsingHandler.init() / ClassExtendMacro.init()), so no manual setup is
needed. See docs/SETUP.md for Haxe / OpenFL / Flixel examples.
haxe -cp . -cp test -D hscriptPos -D CUSTOM_CLASSES ^
--macro hscript.macros.UsingHandler.init() ^
--macro hscript.macros.ClassExtendMacro.init() ^
-main TestMain --interpCovers: iris syntax, script classes, script-to-script inheritance, shared statics,
error handlers, import callbacks, blocklist, scriptObject, redirects, using,
macro-extended classes (extends engine classes), Bytes roundtrip, Printer,
key-value for loops and the runtime #if preprocessor.
hscript.Config controls the package prefixes scanned by the two macros
(defaults aligned with SeiunEngine's own package layout):
ALLOWED_CUSTOM_CLASSES: packages whose classes get_HSXshadows (defaultflixel/openfl/script/states/substates/backend/options/editors/mohong)ALLOWED_ABSTRACT_AND_ENUM: packages whose abstracts/enums get_HSCshadowsDISALLOW_CUSTOM_CLASSES/DISALLOW_ABSTRACT_AND_ENUM: module-level blocklist
Warning: do not add whole packages like haxe or lime — the macros would
process std classes and can break abstracts such as haxe.Int64; add specific
classes instead.
Async.hx/Checker.hxalready had compile issues in hscript-iris 1.1.3 (type mismatches underhscriptPos); the engine runtime does not reference them. This library only applies minor fixes (EField args).using StringToolsrelies on static-method reflection, which is unavailable underneko --interp(upstream behavior); it works on native cpp targets.- Script-class constructor chains: with
class Child extends Parent, parent fields are re-evaluated on the child instance and the parent constructor runs only once; explicitsuper.new()is not guaranteed to bind to the child instance (same behavior as hscript-improved upstream).
MIT. This library is a merged derivative of four MIT projects: hscript / hscript-iris / hscript-improved / hscript-plus. Copyright and attribution are documented in NOTICE and LICENSE.