SML::FUNC Class Reference

Structure for defining an SML function. More...

#include <sml/function.h>

Inheritance diagram for SML::FUNC:
Inheritance graph
[legend]

List of all members.

Public Member Functions

const PARMGetCallbackParms () const
int GetFuncGroupNum () const

Public Attributes

const char * ClassName
INT32 CreateDate
const char * description
UINT32 flags
VOIDFUNC func
int maxparms
METHODPTR method
int minparms
INT32 ModDate
const char * name
PARMparms
SMLFUNCSIG signature
int sizeofSMLFUNC
int sizeofSMLPARM
STYPE type

Detailed Description

Structure for defining an SML function.

You don't normally define one of these directly. Instead, you use macros to define them.

Example:

In the following code, "MyFunction" is the name the function will show to SML users. There are several things you need to define using names based on the function name and a fixed suffix. Note, that the descriptions you give here are used to create smlfuncs.txt, which can then be translated to other lanugages.

      // An example SML::FLAG so we can show how to create a flags parameter
      // See SML::FLAG for details.  (You don't have to have one of these)
      static SML::FLAG MyFunction_Flags[] = {
         { "flag1",  1, "Description of flag1" },
         { "flag2",  2, "Description of flag2" },
         { NULL }    // Very important!
         };

      static SML::PARM MyFunction_Parms[] = {
         { "parm1",   STYPE_String, 0, "Describe the parm here", NULL, NULL },
         { "color",   STYPE_Class,  0, "a color", NULL, "COLOR" },
         { "flags",   STYPE_String, PARM_Optional, "describe flags here", MyFunction_Flags, NULL },
         { NULL }    // Very important!
         };

      #define MyFunction_FuncType    STYPE_BFunction
      #define MyFunction_CreateDate  20000517   // YYYYMMDD format
      #define MyFunction_ModDate     0          // Havn't changed it yet
    // Note, if the function returns a class, you would also have...
      #define MyFunction_RetVal      "COLOR"   // The name of the class we return

      static double MyFunction (int numargs, SML::ARG *args, UINT8 *type, SML::CONTEXT *context) {
         ...
         return(something);
         }

Then later, you have...

      static SML::FUNC MyFunctionList[] = {
         SMLFUNCDEF2 (MyFunction),
         { NULL }    // Very important!
         };

      ...

      context->InstallFunctions("My Function Group", MyFunctionList);

There is more documentation for creating function in sml.h but not yet readable through the Doxygen-created documentation.


Member Function Documentation

const PARM* SML::FUNC::GetCallbackParms (  )  const

For functions which take a pointer to a function as a parameter, (eg, to set a callback), this function will (maybe) return an SML::PARM array of the parameters that the callback will get.

To set this up the parms member of the SML::FUNC will end in an SML::PARM with a NULL name as usual, but is then followed by the parms for the callback. If we've set them up this way, we also set the flag SML::FUNC_HasProtoParms so that the documentation code will know to look for it.

int SML::FUNC::GetFuncGroupNum (  )  const

Member Data Documentation

const char* SML::FUNC::ClassName

Default used to create smlfuncs.txt.

Note: sizeof(void (SOMECLASS::*METHODPTR)()) varies by system, 16 bytes on Windows, 8 on Linux.

Date in format YYYYMMDD eg: 19980204.

const char* SML::FUNC::name

The documentation for this class was generated from the following file:

Generated on Sun Oct 7 21:39:11 2012 for TNTsdk 2012 by  doxygen 1.6.1