ammer

Sublibraries

For better code organisation, it is possible to split a library definition into multiple classes. If the separate class consists of static functions and not "instance" methods (in which case a library datatype definition might be more appropriate), it can be defined as a sublibrary.

To define a sublibrary, extend ammer.def.Sublibrary<...> with a Haxe class. The type parameter for ammer.def.Sublibrary should be the ammer library this class belongs to.

Example: sublibrary definition

@:ammer.sub((_ : FoobarSub))
class Foobar extends ammer.def.Library<"foobar"> {}

class FoobarSub extends ammer.def.Sublibrary<Foobar> {
  // ...
}

In this example, FoobarSub is a sublibrary belonging to Foobar.

Apart from forming a separate Haxe class, sublibraries behave identically to libraries.

Linking

Sublibraries should be linked with the parent library using the @:ammer.sub(...) metadata to avoid compilation errors. See linking subdefinitions.

Metadata applicable to sublibraries

« Previous: Variables Next: Datatypes »