]>
Commit | Line | Data |
---|---|---|
c90f71dd RD |
1 | /* methodcmd8.swg : Tcl8.x method invocation */ |
2 | ||
3 | static int Tcl@CLASS@MethodCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) { | |
4 | int (*cmd)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*) = 0; | |
5 | char *_str; | |
6 | int rcode; | |
7 | Tcl_Obj **objv; | |
8 | Tcl_Obj *oldarg,*tcl_result,*obj; | |
9 | int length; | |
10 | char c; | |
11 | ||
12 | tcl_result = Tcl_GetObjResult(interp); | |
13 | objv = (Tcl_Obj **) _objv; | |
14 | if (objc < 2) { | |
15 | Tcl_SetStringObj(tcl_result,"@CLASS@ methods : { @METHODLIST@ }",-1); | |
16 | return TCL_ERROR; | |
17 | } | |
18 | obj = Tcl_NewObj(); | |
19 | SWIG_SetPointerObj(obj,(void *) clientData,"@CLASSMANGLE@"); | |
20 | _str = Tcl_GetStringFromObj(objv[1],&length); | |
21 | c = *_str; | |
22 | if (0); | |
23 | @METHODS@ | |
24 | else if ((c == 'c') && (strncmp(_str,"configure",length) == 0) && (length >= 2)) { | |
25 | int i = 2; | |
26 | cmd = 0; | |
27 | while (i+1 < objc) { | |
28 | _str = Tcl_GetStringFromObj(objv[i],&length); | |
29 | @CONFIGMETHODS@ | |
30 | if (cmd) { | |
31 | oldarg = objv[i]; | |
32 | objv[i] = obj; | |
33 | rcode = (*cmd)(clientData,interp,3,&objv[i-1]); | |
34 | objv[i] = oldarg; | |
35 | if (rcode == TCL_ERROR) { | |
36 | Tcl_DecrRefCount(obj); | |
37 | return rcode; | |
38 | } | |
39 | cmd = 0; | |
40 | } else { | |
41 | Tcl_SetStringObj(tcl_result,"Invalid configure option. Must be { @CONFIGLIST@ }",-1); | |
42 | Tcl_DecrRefCount(obj); | |
43 | return TCL_ERROR; | |
44 | } | |
45 | i+=2; | |
46 | } | |
47 | if ((i < objc) || (i == 2)) { | |
48 | Tcl_SetStringObj(tcl_result,"{ @CONFIGLIST@ }",-1); | |
49 | Tcl_DecrRefCount(obj); | |
50 | return TCL_ERROR; | |
51 | } | |
52 | Tcl_DecrRefCount(obj); | |
53 | return TCL_OK; | |
54 | } else if ((c == 'c') && (strncmp(_str,"cget",length) == 0) && (length >= 2)) { | |
55 | if (objc == 3) { | |
56 | _str = Tcl_GetStringFromObj(objv[2],&length); | |
57 | if (0) {} | |
58 | @CGETMETHODS@ | |
59 | else if (strcmp(_str,"-this") == 0) { | |
60 | SWIG_SetPointerObj(tcl_result,(void *) clientData, "@CLASSMANGLE@"); | |
61 | Tcl_DecrRefCount(obj); | |
62 | return TCL_OK; | |
63 | } | |
64 | if (cmd) { | |
65 | oldarg = objv[2]; | |
66 | objv[2] = obj; | |
67 | rcode = (*cmd)(clientData,interp,objc-1,&objv[1]); | |
68 | objv[2] = oldarg; | |
69 | Tcl_DecrRefCount(obj); | |
70 | return rcode; | |
71 | } else { | |
72 | Tcl_SetStringObj(tcl_result,"Invalid cget option. Must be { -this @CGETLIST@ }",-1); | |
73 | Tcl_DecrRefCount(obj); | |
74 | return TCL_ERROR; | |
75 | } | |
76 | } else { | |
77 | Tcl_SetStringObj(tcl_result,"{ -this @CGETLIST@ }", -1); | |
78 | Tcl_DecrRefCount(obj); | |
79 | return TCL_ERROR; | |
80 | } | |
81 | } | |
82 | if (!cmd) { | |
83 | Tcl_SetStringObj(tcl_result,"Invalid Method. Must be { @METHODLIST@}",-1); | |
84 | Tcl_DecrRefCount(obj); | |
85 | return TCL_ERROR; | |
86 | } | |
87 | oldarg = objv[1]; | |
88 | objv[1] = obj; | |
89 | rcode = (*cmd)(clientData,interp,objc,objv); | |
90 | objv[1] = oldarg; | |
91 | Tcl_DecrRefCount(obj); | |
92 | return rcode; | |
93 | } | |
94 | ||
95 | ||
96 |