15.3. Macro Plugins

Macro plugins a java classes that implements the IMacro interface:

public interface IMacro {
   String getName();
   byte[] execute(IValue[] parameters, IEngine engine);
}

A simple example of a macro is:

import kickass.plugins.interf.*;

public class MyMacro implements IMacro{
   @Override
   public String getName() {
      return "MyMacro";
   }

   @Override
   public byte[] execute(IValue[] parameters, IEngine engine) {
      engine.print(“Hello world from MyMacro!”);
      return new byte[0];
   }
}

You execute it as a normal macro:

.plugin "test.plugins.macros.MyMacro"
:MyMacro()

And get the expected output ‘Hello World from MyMacro!’. The ‘arguments’ parameter is the parameters parsed to the macro. The result is returned as a byte array and the ‘engine’ parameter is used to do additional communication with the Kick Assembler engine. The interfaces of the two parameters are described in the following sections.