sml/funcsig.h File Reference

#include <mi32/stddefns.h>
Include dependency graph for funcsig.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  SML

Defines

#define ARGT_b   1
#define ARGT_c   8
#define ARGT_cc   9
#define ARGT_cU   7
#define ARGT_d   2
#define ARGT_i   3
#define ARGT_pv   5
#define ARGT_pva   10
#define ARGT_U   6
#define ARGT_u   4
#define ARGT_v   0
#define DEFSIG
#define DEFSIG0(ret)   (ret)
#define DEFSIG1(ret, a)   (a << 4) | ret
#define DEFSIG2(ret, a, b)   (b << 8) | (a << 4) | ret
#define DEFSIG3(ret, a, b, c)   (c << 12) | (b << 8) | (a << 4) | ret
#define DEFSIG4(ret, a, b, c, d)   (d << 16) | (c << 12) | (b << 8) | (a << 4) | ret
#define DEFSIG_0(LHS, TYPE, RHS, N)   LHS##TYPE = (RHS | (ARGT_##TYPE << ((N)*4))),
#define DEFSIG_1(LHS, TYPE, RHS, N)
#define DEFSIG_2(LHS, TYPE, RHS, N)

Typedefs

typedef bool(* FUNCPTR_b )()
typedef char *(* FUNCPTR_c )()
typedef const char *(* FUNCPTR_cc )()
typedef const MIUNICODE *(* FUNCPTR_cU )()
typedef double(* FUNCPTR_d )()
typedef INT32(* FUNCPTR_i )()
typedef MIUNICODE *(* FUNCPTR_U )()
typedef UINT32(* FUNCPTR_u )()
typedef void(* FUNCPTR_v )()
typedef void(* FUNCPTR_v_b )(bool)
typedef void *(* FUNCPTR_vp )()
typedef enum::SMLFUNCSIG SML::FUNCSIG

Enumerations

enum  SMLFUNCSIG {
  SIG_OldStyle = 0, SIG_v_i_i_b = DEFSIG3(ARGT_v, ARGT_i, ARGT_i, ARGT_b), SIG_v_i_i_i = DEFSIG3(ARGT_v, ARGT_i, ARGT_i, ARGT_i), SIG_v_i_i_i_b = DEFSIG4(ARGT_v, ARGT_i, ARGT_i, ARGT_i, ARGT_b),
  SIG_v_d_d_b = DEFSIG3(ARGT_v, ARGT_d, ARGT_d, ARGT_b), SIG_v_d_d_d = DEFSIG3(ARGT_v, ARGT_d, ARGT_d, ARGT_d), SIG_v_d_d_d_d = DEFSIG4(ARGT_v, ARGT_d, ARGT_d, ARGT_d, ARGT_d), SIG_v_pv_cU_i = DEFSIG3(ARGT_v, ARGT_pv, ARGT_cU, ARGT_i),
  SIG_v_pv_pv_pv = DEFSIG3(ARGT_v, ARGT_pv, ARGT_pv, ARGT_pv), SIG_v_pv_pv_d = DEFSIG3(ARGT_v, ARGT_pv, ARGT_pv, ARGT_d), SIG_i_pv_b_pv = DEFSIG3(ARGT_i, ARGT_pv, ARGT_b, ARGT_pv), SIG_i_pv_pv_pv_d = DEFSIG4(ARGT_i, ARGT_pv, ARGT_pv, ARGT_pv, ARGT_d),
  SIG_i_u_pv_pv = DEFSIG3(ARGT_i, ARGT_u, ARGT_pv, ARGT_pv), SIG_i_i_d_d = DEFSIG3(ARGT_i, ARGT_i, ARGT_d, ARGT_d), SIG_i_i_i_d = DEFSIG3(ARGT_i, ARGT_i, ARGT_i, ARGT_d), SIG_i_pv_d_d = DEFSIG3(ARGT_i, ARGT_pv, ARGT_d, ARGT_d),
  SIG_i_d_d_d = DEFSIG3(ARGT_i, ARGT_d, ARGT_d, ARGT_d), SIG_i_d_pv_d_d = DEFSIG4(ARGT_i, ARGT_d, ARGT_pv, ARGT_d, ARGT_d), SIG_i_pv_pv_b = DEFSIG3(ARGT_i, ARGT_pv, ARGT_pv, ARGT_b), SIG_LAST
}

Functions

int SML::FUNCSIG_GetNumParms (SMLFUNCSIG sig)
SMLFUNCSIG SML::FUNCSIG_GetParmType (SMLFUNCSIG sig, int n)
SMLFUNCSIG SML::FUNCSIG_GetRetType (SMLFUNCSIG sig)

Define Documentation

#define ARGT_b   1
#define ARGT_c   8
#define ARGT_cc   9
#define ARGT_cU   7
#define ARGT_d   2
#define ARGT_i   3
#define ARGT_pv   5
#define ARGT_pva   10
#define ARGT_U   6
#define ARGT_u   4
#define ARGT_v   0

Limit of 16 basic arg types A signiture is a 32-bit integer 0xHGFEDCBA where A = return type B = type of arg 1, C = type of arg 2, D = etc.

..

NOTE: you can pass an MISTRING& by using pv in the SIG_ and STYPE_String in the SMLPARM array for the parameter

#define DEFSIG
Value:
DEFSIG_2(SIG_, v, 0, 0) \
                DEFSIG_2(SIG_, d, 0, 0) \
                DEFSIG_2(SIG_, b, 0, 0) \
                DEFSIG_2(SIG_, i, 0, 0) \
                DEFSIG_2(SIG_, u, 0, 0) \
                DEFSIG_2(SIG_, pv, 0, 0) \
                DEFSIG_2(SIG_, U, 0, 0) \
                DEFSIG_2(SIG_, cU, 0, 0) \
                DEFSIG_2(SIG_, c, 0, 0) \
                DEFSIG_2(SIG_, cc, 0, 0) \
                DEFSIG_2(SIG_, pva, 0, 0)
#define DEFSIG0 ( ret   )     (ret)
#define DEFSIG1 ( ret,
 )     (a << 4) | ret
#define DEFSIG2 ( ret,
a,
 )     (b << 8) | (a << 4) | ret
#define DEFSIG3 ( ret,
a,
b,
 )     (c << 12) | (b << 8) | (a << 4) | ret
#define DEFSIG4 ( ret,
a,
b,
c,
 )     (d << 16) | (c << 12) | (b << 8) | (a << 4) | ret
#define DEFSIG_0 ( LHS,
TYPE,
RHS,
 )     LHS##TYPE = (RHS | (ARGT_##TYPE << ((N)*4))),

Function signatures.

#define DEFSIG_1 ( LHS,
TYPE,
RHS,
 ) 
Value:
LHS##TYPE  = (RHS | (ARGT_##TYPE << ((N)*4))),  \
   DEFSIG_0(LHS##TYPE##_, d,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, b,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, i,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, u,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, pv, (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, U,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, cU, (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, c,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_0(LHS##TYPE##_, cc, (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
#define DEFSIG_2 ( LHS,
TYPE,
RHS,
 ) 
Value:
LHS##TYPE  = (RHS | (ARGT_##TYPE << ((N)*4))),  \
   DEFSIG_1(LHS##TYPE##_, d,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, b,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, i,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, u,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, pv, (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, U,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, cU, (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, c,  (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \
   DEFSIG_1(LHS##TYPE##_, cc, (RHS | (ARGT_##TYPE << ((N) * 4))), N+1)  \

Typedef Documentation

typedef bool(* FUNCPTR_b)()

Function pointer for a function returning bool.

typedef char*(* FUNCPTR_c)()

Function pointer for a function returning char*.

typedef const char*(* FUNCPTR_cc)()

Function pointer for a function returning const char*.

typedef const MIUNICODE*(* FUNCPTR_cU)()

Function pointer for a function returning const MIUNICODE*.

typedef double(* FUNCPTR_d)()

Function pointer for a function returning double.

typedef INT32(* FUNCPTR_i)()

Function pointer for a function returning INT32.

typedef MIUNICODE*(* FUNCPTR_U)()

Function pointer for a function returning MIUNICODE*.

typedef UINT32(* FUNCPTR_u)()

Function pointer for a function returning UINT32.

typedef void(* FUNCPTR_v)()

Function pointer for a void function.

typedef void(* FUNCPTR_v_b)(bool)

Function pointer for a void function that takes a bool.

typedef void*(* FUNCPTR_vp)()

Function pointer for a function returning void*.


Enumeration Type Documentation

enum SMLFUNCSIG

Function signatures.

Function signatures look like SIG_v_d_d the valid type codes are...

  • v = void
  • b = bool
  • d = double
  • i = INT32
  • u = UINT32
  • pv = (void *) -- Any pointer (For return values, will not be free)
  • U = (MIUNICODE*) -- If retval, caller will free it
  • cU = (const MIUNICODE*) -- if retval, caller will not free
  • c = (char*) -- if retval, caller will free it
  • cc = (const char*) -- if retval, caller will not free
  • pva = (void*) -- return type only. Caller will free.

First letter is return type, after that they're parameter types All combinations of up to two parameters are defined even though the documentation doesn't show them (sneeky preprocessor macros at work)

NOTE: you can pass an MISTRING& by using pv in the SIG_ and STYPE_String in the SMLPARM array for the parameter

Enumerator:
SIG_OldStyle 
SIG_v_i_i_b 

Note: the DEFSIG macro above defines all combinations for all return values up to 2 parametes.

Unfortunately, if I try to expand it any further, VC++ complains. If I go one level deeper, it gives an error about the ammount of space in the deubg table being exhausted, and two levels deeper makes the pre processor run out of heap. So if you need to define any other parameter cominations, add them by hand (See example below)

Note, the SML runtime engine has implementations for all combinations of up to 4 parameters. If you need more than that, you'll have to add methods the old way.

SIG_v_i_i_i 
SIG_v_i_i_i_b 
SIG_v_d_d_b 
SIG_v_d_d_d 
SIG_v_d_d_d_d 
SIG_v_pv_cU_i 
SIG_v_pv_pv_pv 
SIG_v_pv_pv_d 
SIG_i_pv_b_pv 
SIG_i_pv_pv_pv_d 
SIG_i_u_pv_pv 
SIG_i_i_d_d 
SIG_i_i_i_d 
SIG_i_pv_d_d 
SIG_i_d_d_d 
SIG_i_d_pv_d_d 
SIG_i_pv_pv_b 
SIG_LAST 

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