How to add functions to Stacksmith
There are three ways to implement functions in Stacksmith:
Built-in functions - These look and are called like any function handler implemented in Hammer, but actually compile to an instruction you define. However, they are limited to taking no parameters, and you can currently only add one by directly editing the built-in function table in CParser.cpp.
Host functions - These follow fairly freeform syntax, and are defined like host commands, using a table you pass to LEOAddHostFunctionsAndOffsetInstructions, and compile to an instruction as well. The return value of the function must be pushed on the stack by your instruction after all parameters have been removed.
Provide a callNonexistentHandlerProc to the LEOContext and at that point handle any function for which no handler exists in the current message path. The number of parameters and the parameters themselves will have been pushed on the stack, and can be accessed using the utility function LEOGetParameterAtIndexFromEndOfStack. Once you are done, use the utility function LEOCleanUpHandlerParametersFromEndOfStack to remove your parameters from the stack.
See How to add commands to Stacksmith on how to create your own instructions, and how the general process of specifying a syntax table work in Stacksmith.