theLink 10.0
Loading...
Searching...
No Matches
MqCall_tcl.c
Go to the documentation of this file.
1
9/* LABEL-NO */
10
12
13#define mqctx hdl
14
15//#undef META_CONTEXT_S
16//#define META_CONTEXT_S mqctx
17
18/*****************************************************************************/
19/* */
20/* Proc-Call */
21/* */
22/*****************************************************************************/
23
24#if 1
25
26static enum MkErrorE NS(SetupMy)(OT_Prefix_ARGS struct TclContextS *tclctx, MQ_CTX mqctx, OT_SELF_T object) {
27 if (tclctx->my != NULL) return MK_OK;
28 if (object == NULL) {
29 NS(MqContextC_ObjNew)(MK_RT_CALL interp,mqctx);
30 object = (OT_SELF_T) (MkOBJ_R(mqctx).self);
31 }
32 check_NULL(object) goto error;
33 tclctx->my = MK(GetMyFromObject)(interp, object);
34 check_NULL(tclctx->my) goto error;
35 Tcl_IncrRefCount(tclctx->my);
36
37 return MK_OK;
38error:
40 return MK_ERROR;
41}
42
43// TODO: free tclctx->my at cleanup
44#define SETUP_my \
45 SETUP_tclctx; \
46 if (tclctx->my == NULL) { \
47 check_META(NS(SetupMy)(OT_Prefix_CALL tclctx,mqctx,selfO)) goto error; \
48 }
49
50#endif
51
52// ************************************************************************************************
53
54/*
55[ServiceCall signature]
56 1. The *service-ctx* is the *context* for which the service was defined.
57 2. If the *callback* is **not** an instance of the calling *context*, the *service-ctx* is added as an argument.
58
59 callback-args := service-ctx:MqContextC[in]
60 [static] proc callback { callback-args ?additional-args...? } ...
61 [own] ::oo::class create XXX {
62 superclass MqContextC
63 method callback { ?additional-args...? } ...
64 [instance] ::oo::class create YYY {
65 method callback { callback-args ?additional-args...? } ...
66 [class] ::oo::class create ZZZ {
67 self method callback { callback-args ?additional-args...? } ...
68[ServiceCall signature]
69*/
70
71
72enum MkErrorE NS(ServiceCall) ( MQ_SERVICE_CALL_ARGS )
73{
75
76 // 1. setup environment
78 if (interp==NULL || Tcl_InterpDeleted(interp) ) return MK_OK;
79
80 // 2. setup arguments
81 struct MkCallS *call = __data__;
83 int objc = 0;
84
85//colorBLUE("call<%p>, type<%d>, nsO<%p>",call,call->type,call->nsO);
86
87 // 3. setup my
88rescan:
89 switch (call->type) {
90 case MkCallS_own_method: {
91//printLTxt("MkCallS_own_method");
92 // this is a instance->method
95 objv[objc++] = tclctx->my;
96 break;
97 }
99 case MkCallS_static:
100//printLTxt("MkCallS_other_method OR MkCallS_static");
101 objv[objc++] = call->my;
102 break;
103 case MkCallS_proc:
104//printLTxt("MkCallS_proc");
105 break;
106 case MkCallS_init: {
107 check_META(MK(ProcResolve)(MK_RT_CALL interp, MkOBJ(mqctx), call)) goto error_mq;
108 goto rescan;
109 }
110 case MkCallS_error:
111//printLTxt("MkCallS_error");
112 goto error;
113 case MkCallS_null:
114//printLTxt("MkCallS_null");
115 return MK_OK;
116 }
117
118 // 4. setup methode
119 if (call->mth) objv[objc++] = call->mth;
120
121 // 5. setup CTX arg
122 switch (call->type) {
124 break;
126 case MkCallS_static:
127 case MkCallS_proc:
128 objv[objc++] = META2VAL_X(mqctx);
129 break;
130 case MkCallS_init:
131 break;
132 case MkCallS_error:
133 goto error;
134 case MkCallS_null:
135 return MK_OK;
136 }
137
138 if (call->args) MK(ProcResolveAppendArgs)(call,&objc,objv);
139
140//printAryL("__data__", objc, objv);
141
142 // 3. call the callback
143 //int ret = Tcl_EvalObjv (interp, objc, objv, TCL_EVAL_GLOBAL);
144 int ret = MK(EvalObjv) (interp, objc, objv, TCL_EVAL_GLOBAL);
145
146//printV("ret=%i, code=%s\n", ret, MkLogErrorE(MkErrorGetCode_0E()))
147
148 if (ret == TCL_OK) {
149 Tcl_ResetResult(interp);
150 return MkErrorGetCode_0E();
151 }
152
153error:
154//ME
156//MkErrorLog_0E();
157
158error_mq:
159 return MkErrorStack_0E();
160}
161
162void NS(ServiceFree) ( MQ_SERVICE_FREE_ARGS )
163{
165 if ( interp == NULL || Tcl_InterpDeleted(interp)) return;
166
167 MK(CallFree) (dataP);
168}
169
170void NS(ServiceCopy) ( MQ_SERVICE_COPY_ARGS )
171{
172 MK(CallCopy)(MK_RT_CALL MkOBJ(mqctx), dataP);
173}
174
#define check_NULL(code)
#define MK(n)
#define SETUP_selfO
#define check_META(code)
#define META2VAL_X(x)
#define OT_ERROR_LNG_2_META(m)
Tcl_Object OT_SELF_T
#define MkProcResolve_maxArgsLen
#define OT_Prefix_ARGS
Tcl_Obj * OT_OBJ_T
#define SETUP_interp
tag: nhi1-release-250425
#define NS(n)
#define SETUP_my
Definition MqCall_tcl.c:44
#define mqctx
Definition MqCall_tcl.c:13
#define error
Definition high_lng.h:339
#define MkErrorGetCode_0E()
#define MkErrorStack_0E()
MkErrorE
MK_ERROR
MK_OK
#define MkOBJ(x)
#define MkOBJ_R(x)
#define MK_RT_CALL
#define MQ_SERVICE_CALL_CHECK
#define MQ_SERVICE_FREE_ARGS
the MqDataFreeF arguments with default names
#define MQ_SERVICE_CALL_ARGS
the MqTokenF arguments with default names
#define MQ_SERVICE_COPY_ARGS
the MqDataFreeF arguments with default names
enum MqCallE call
OT_OBJ_T mth
OT_ENV_T interp
PUBLIC data structure for the tclmqmsgque-specific-data
OT_OBJ_T my
"my" command of "mqctx"