1 | |
---|
2 | /* |
---|
3 | *------------------------------------------------------------------------------- |
---|
4 | * |
---|
5 | * CmdSpec.h -- |
---|
6 | * |
---|
7 | * Generic function prototype of CmdOptions. |
---|
8 | * |
---|
9 | *------------------------------------------------------------------------------- |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef CMDSPEC_H |
---|
13 | #define CMDSPEC_H |
---|
14 | |
---|
15 | namespace Rappture { |
---|
16 | |
---|
17 | /* |
---|
18 | *------------------------------------------------------------------------------- |
---|
19 | * |
---|
20 | * CmdSpec -- |
---|
21 | * |
---|
22 | * Structure to specify a set of operations for a Tcl command. |
---|
23 | * This is passed to the Blt_GetOp procedure to look |
---|
24 | * for a function pointer associated with the operation name. |
---|
25 | * |
---|
26 | *------------------------------------------------------------------------------- |
---|
27 | */ |
---|
28 | typedef struct { |
---|
29 | const char *name; /* Name of operation */ |
---|
30 | int minChars; /* Minimum # characters to disambiguate */ |
---|
31 | Tcl_ObjCmdProc *proc; |
---|
32 | int minArgs; /* Minimum # args required */ |
---|
33 | int maxArgs; /* Maximum # args required */ |
---|
34 | const char *usage; /* Usage message */ |
---|
35 | } CmdSpec; |
---|
36 | |
---|
37 | typedef enum { |
---|
38 | CMDSPEC_ARG0, /* Op is the first argument. */ |
---|
39 | CMDSPEC_ARG1, /* Op is the second argument. */ |
---|
40 | CMDSPEC_ARG2, /* Op is the third argument. */ |
---|
41 | CMDSPEC_ARG3, /* Op is the fourth argument. */ |
---|
42 | CMDSPEC_ARG4 /* Op is the fifth argument. */ |
---|
43 | } CmdSpecIndex; |
---|
44 | |
---|
45 | #define CMDSPEC_LINEAR_SEARCH 1 |
---|
46 | #define CMDSPEC_BINARY_SEARCH 0 |
---|
47 | |
---|
48 | extern Tcl_ObjCmdProc *GetOpFromObj(Tcl_Interp *interp, int nSpecs, |
---|
49 | CmdSpec *specs, int operPos, int objc, Tcl_Obj *const *objv, int flags); |
---|
50 | |
---|
51 | #define NumCmdSpecs(s) (sizeof(s) / sizeof(Rappture::CmdSpec)) |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | #endif /* CMDSPEC_H */ |
---|