theLink 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - py - rb - jv - cc
Loading...
Searching...
No Matches
MqFactoryC_py.c
Go to the documentation of this file.
1
12/* LABEL-START */
13
14#define META_FILE_NAME "MqFactoryC_py.c"
15
16#include "LibMqMsgque_private_py.h"
17
18// PY class
19#define OT_CLASS (&NS(MqFactoryCR))
20#define OT_CLASS_NAME "MqFactoryC"
21
22#define OT_LNG2META(O) MqFct(VAL2MNG(O))
23
24#define OT_retObj_CONSTR(mng) OT_retObj_SET(NS(MqFactoryC_CTOR)(MK_RT_CALL (PyTypeObject*)class,mng))
25
26#define OT_SETUP_hdl OT_SETUP_hdl_tmpl(MqFactoryC)
27#define OT_SETUP_hdl__null_allow OT_SETUP_hdl_tmpl__null_allow(MqFactoryC)
28#define OT_SETUP_hdl_constr MK_RT_UNUSED AllRtSetup_NULL; \
29 MQ_FCT hdl = (MQ_FCT) &MkERROR;
30#define OT_SETUP_hdl_destr OT_SETUP_hdl_tmpl__null_allow(MqFactoryC)
31#define OT_SETUP_hdl_static MK_RT_UNUSED AllRtSetup_NULL; \
32 __attribute__((unused)) MK_TYP hdl = MqFactoryC##_TT;
33
34#define OT_SETUP_hdl_static_constr OT_SETUP_hdl_static
35
36#if !defined(SetupRtFromObj_X)
37 #define SetupRtFromObj_X(hdl) AllRtSetup_X(hdl)
38 #define SetupRtFromObj_XN(hdl) AllRtSetup_XN(hdl)
39#endif
40
41// MO class
42#undef MqFactoryCTT
43#define MqFactoryCTT MQ(MqMsgqueThreadState).MqFactoryCTT
44/* MqFactoryC_MK_NULL defined in LibMqMsgque_py.h */
45
46__attribute__((unused)) mk_inline
47OT_LNG_T NS(MqFactoryC_CTOR) (MK_RT_ARGS OT_LNG_CLASS_T type, MQ_FCT hdl) {
48 return MK(AtomCreate)(MK_RT_CALL type,MqFactoryC_X2obj(hdl),true);
49}
50
51// helper: mk_debug_color(MK_COLOR_YELLOW,"hdl<%p>, self<%p>", obj, self);
52
53// MQ: ObjNew feature: selfCreate will be called from "ObjNew->MkSelfNew" if MkObj need a SELF pointer
54static MK_PTR NS(MqFactoryC_selfCreate) (MK_RT_ARGS MK_OBJ const obj, MK_PTR const env) {
55 return MK(AtomCreate) (MK_RT_CALL OT_CLASS,obj,true);
56}
57// MQ: called if MkObj must be destroyed and if the SELF is still alive → goal: destroy the SELF
58static void NS(MqFactoryC_selfDelete) (MK_RT_ARGS MK_PTR self, MK_PTR const env) {
59 OT_OBJECT_DELETE_HARD(OT_SELF);
60}
61// MQ: called to destroy link from SELF to META
62static void NS(MqFactoryC_selfUnlink) (MK_RT_ARGS MK_PTR self, MK_PTR const env) {
63 MkObjectC_Obj *selfO = (MkObjectC_Obj*) self;
64 selfO->hdl = NULL;
65}
66
67// initialize the PY and MO class specific object
68#define ClassInit \
69 /* if not already done, initialize NEW MQ type */ \
70 if (MqFactoryCTT == NULL) MqFactoryCTT = MqFactorySTT; \
71 \
72 /* protect against double call */ \
73 if (MqFactoryCTT->selfCreate == NS(MqFactoryC_selfCreate)) return MK_OK; \
74 \
75 /* add "selfCreate" and "selfDelete" feature to the MQ-Class */ \
76 MqFactoryCTT->selfCreate = NS(MqFactoryC_selfCreate); \
77 MqFactoryCTT->selfDelete = NS(MqFactoryC_selfDelete); \
78 MqFactoryCTT->selfUnlink = NS(MqFactoryC_selfUnlink); \
79 \
80 if (!PyType_HasFeature(OT_CLASS,Py_TPFLAGS_READY)) { \
81 NS(MqFactoryCR).tp_base = OT_MqFactoryC_base; \
82 LngErrorCheck (PyType_Ready(OT_CLASS)); \
83 } \
84 LngErrorCheck(PyModule_AddObjectRef(m, "MqFactoryC", (PyObject *)OT_CLASS)); \
85 \
86 /* define the "NULL" object */ \
87 MqFactoryC_MK_NULL = Py_NewRef(MK(AtomCreate) (MK_RT_CALL OT_CLASS, NULL /*obj*/, false));
88
89/* LABEL-END */
90
91#define SetupRtFromObj_XN(hdl) AllRtSetup_XN(hdl)
92
93#undef OT_SETUP_hdl
94#define OT_SETUP_hdl OT_SETUP_hdl_tmpl(MqFactoryC) \
95 bool is_constr_hard = false;
96#undef OT_SETUP_hdl_constr
97#define OT_SETUP_hdl_constr MK_RT_UNUSED AllRtSetup_NULL; \
98 __attribute__((unused)) MK_TYP hdl = MqFactoryC##_TT; \
99 bool is_constr_hard = true;
100#undef OT_SETUP_hdl_static
101#define OT_SETUP_hdl_static MK_RT_UNUSED AllRtSetup_NULL; \
102 __attribute__((unused)) MK_TYP hdl = MqFactoryC##_TT; \
103 bool is_constr_hard = false;
104#undef OT_SETUP_hdl_static_constr
105#define OT_SETUP_hdl_static_constr MK_RT_UNUSED AllRtSetup_NULL; \
106 __attribute__((unused)) MK_TYP hdl = MqFactoryC##_TT; \
107 bool is_constr_hard = true;
108
109#undef OT_retObj_RETURN
110#define OT_retObj_RETURN \
111if (is_constr_hard) { \
112 /* BUG-FIX */ \
113 /* the factory is always global and has NO link to an external variable… */ \
114 /* need "Py_INCREF" to keep the factory alive */ \
115 /* test: Nhi1Exec server.py */ \
116 Py_INCREF (retObj); \
117} \
118 return ((PyObject*)retObj);
119
125
126// BEGIN-DOC - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
127
128// doc-key: MqFactoryC,MqFactory,sCc,func
129#define Add_doc "MqFactoryC MqFactoryC.Add(constructor:class, ?ident:string=\"MK_NULL\"?)"
130#define new_doc "MqFactoryC MqFactoryC.new(constructor:class, ?ident:string=\"MK_NULL\"?)"
131
132// doc-key: MqFactoryC,MqFactory,sc_,func
133#define Get_doc "MqFactoryC MqFactoryC.Get(?ident:string=\"\"?)"
134#define GetCalled_doc "MqFactoryC MqFactoryC.GetCalled(?ident:string=\"\"?)"
135#define GetCalledL_doc "MqFactoryC MqFactoryC.GetCalledL(largs:MkBufferListC)"
136#define GetNull_doc "MqFactoryC MqFactoryC.GetNull()"
137#define HandleResolve_doc "MqFactoryC MqFactoryC.HandleResolve(netHdl:MK_HDL)"
138#define Instances_doc "MqFactoryC MqFactoryC.Instances()"
139
140// doc-key: MqFactoryC,MqFactory,sm_,func
141#define DefaultIdent_doc "string MqFactoryC.DefaultIdent()"
142#define InitialIdent_doc "string MqFactoryC.InitialIdent()"
143#define LogAll_doc "MqFactoryC.LogAll(?callfunc:string=\"MK_NULL\"?)"
144
145// doc-key: MqFactoryC,MqFactory,oCx,func
146#define Dup2_doc "MqFactoryC fct.Dup2(ident:string) (const)"
147
148// doc-key: MqFactoryC,MqFactory,oc_,func
149#define Default_doc "MqFactoryC fct.Default()"
150#define Initial_doc "MqFactoryC fct.Initial()"
151#define Next_doc "MqFactoryC fct.Next()"
152#define Prev_doc "MqFactoryC fct.Prev()"
153
154// doc-key: MqFactoryC,MqFactory,oco,func
155#define New_doc "MqContextC fct.New()"
156
157// doc-key: MqFactoryC,MqFactory,om_,func
158#define GetOriginalIdent_doc "string fct.GetOriginalIdent() (const)"
159#define HandleGet_doc "MK_HDL fct.HandleGet()"
160#define Log_doc "fct.Log(?fmtobj:MkObjectC=None?, ?debug:int32=0?, ?callfunc:string=\"MK_NULL\"?, ?lvl:int32=0?) (const)"
161
162// END-DOC - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
163
169
170static enum MkErrorE
172{
173 MQ_CTX mqctx = NULL;
174 enum MkErrorE ret = MK_OK;
175 PyObject* argsO=NULL, *resultO=NULL;
176 PyObject* typeO = fct->fct_ctor.data;
177 PyObject* tmplO = (tmpl ? MkOBJ_R(tmpl).self : NULL);
178
179//printXV(tmpl, "PYTH: Factory[%s] -> %s\n", MqFactoryGetOriginalIdent(fct), MqLogFactoryE(create))
180 if (create == MQ_FACTORY_NEW_THREAD) {
181#if 0
182 ret = MkErrorSetC_1E("internal error: MQ_FACTORY_NEW_THREAD not supported");
183 goto error;
184#else
185
186 static PyInterpreterConfig config = {
187 .use_main_obmalloc = 0,
188 .allow_fork = 0,
189 .allow_exec = 0,
190 .allow_threads = 1,
191 .allow_daemon_threads = 0,
192 .check_multi_interp_extensions = 1,
193 .gil = PyInterpreterConfig_OWN_GIL,
194 };
195
196 PyThreadState *tstate = NULL;
197 PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
198 MK_RT_REF.threadData = tstate;
199
200mk_debug_color(MK_COLOR_YELLOW,"MQ_FACTORY_NEW_THREAD -> thread<%p>", tstate);
201
202 if (PyStatus_Exception(status)) {
203 return MkErrorSetC_3_NULL(status.err_msg, status.func, 300+status.exitcode);
204 }
205
206 Py_XINCREF(typeO);
207 Py_XINCREF(tmplO);
208
209 // mark new interpreter as "MQ_STARTUP_IS_THREAD"
210 PyObject *mainM = PyImport_AddModule("__main__");
211 PyObject *strO = PyUnicode_FromString("MQ_STARTUP_IS_THREAD");
212 PyObject_SetAttrString(mainM,"__name__", strO);
213 Py_CLEAR(strO);
214
215 // source initial script
217 FILE *FH = fopen(fn, "r");
218 PyObject * mD = PyModule_GetDict(mainM);
219 PyObject *retO = PyRun_FileEx(FH,fn,Py_file_input,mD,mD,true);
220 if (retO == NULL) {
221 ret = MkErrorSetC_1E("MQ_FACTORY_NEW_THREAD failed");
222 //PyGILState_Release(gilstate);
223 goto error3;
224 }
225 Py_CLEAR(retO);
226
227 // type is from the "wrong" interpreter → try to figure out the right one
228 PyObject* QualNameO = PyType_GetQualName((PyTypeObject*)typeO);
229 if (QualNameO == NULL) goto error2;
230
231 Py_CLEAR(typeO);
232 typeO = PyObject_GetAttr(mainM,QualNameO);
233 Py_CLEAR(QualNameO);
234
235 if (typeO == NULL) goto error2;
236
237 // need a NEW template class because the OLD class has a TYPE in the WRONG interpreter.
238 Py_CLEAR(tmplO);
239 tmplO = MK(AtomCreate)(MK_RT_CALL (PyTypeObject*)typeO,MkOBJ(tmpl),false);
240
241 goto cont;
242
243 error2:
244 ret = MkErrorSetC_1E("internal error: unable to resolve type");
245 error3:
246 goto error;
247 cont:
248#endif
249 } else {
250
251 Py_XINCREF(typeO);
252 Py_XINCREF(tmplO);
253 }
254
255 // get typeO from "parent"
257 Py_CLEAR(typeO);
258 typeO = Py_NewRef(Py_TYPE(tmplO));
259 }
260
261 // setup argsO
262 if (create & MQ_FACTORY_NEW_INIT) {
263 argsO = PyTuple_New(0);
264 } else {
265 argsO = PyTuple_New(1);
266 PyTuple_SET_ITEM(argsO, 0, tmplO);
267 Py_INCREF(tmplO);
268 }
269
270 if (typeO == NULL) {
271 PyErr_SetString(PyExc_RuntimeError,"internal error: factory object constructor is 'NULL'");
272 goto error;
273 } else {
274 // call constructor
275 resultO = PyObject_Call(typeO, argsO, NULL);
276 check_NULL(resultO) goto error;
277 }
278
279 // right typeO?
280 if (!PyObject_IsInstance(resultO, (PyObject*) &NS(MqContextCR))) goto error;
281 mqctx = VAL2CTX(resultO);
282
283 // check for MQ error
284 MkErrorCheck(MkErrorGetCode_0E());
285
286 // copy and initialize "setup" data
287 if (create & (MQ_FACTORY_NEW_CHILD)) {
288 // !Attention!. the ctxId would be set later… in MqLinkCreate…
289 MqSetupDup(mqctx, tmpl);
290 }
291
292 // a MQ_FACTORY_NEW_FILTER has "MkOBJ_R(mqctx).self" as ONLY reference… incr "refCnt"
293 // related to "NS(sFactoryDTor)→MQ_FACTORY_NEW_INIT→Py_XINCREF"
294 if (create & MQ_FACTORY_NEW_FILTER) {
295 Py_XINCREF(resultO);
296 }
297
298 *contextP = mqctx;
299
300end:
301//printTxt("OK")
302 // not used anymore because "Py_INCREF(self)" in "MqContextC_New" was deleted
303 //Py_CLEAR(resultO);
304 Py_CLEAR(argsO);
305 Py_CLEAR(tmplO);
306 Py_CLEAR(typeO);
307//printXLngObj(mqctx,resultO)
308
309 return ret;
310
311error:
312//printTxt("ERROR")
313 Py_CLEAR(resultO);
314 *contextP = NULL;
315 OT_ERROR_LNG_2_MQ(MK_ERROR_DEFAULT);
316 ret = MkErrorStack_0E();
317 goto end;
318}
319
320static void MK_DECL
321NS(sFactoryDTor) (
323 MQ_CTX context,
324 bool doFactoryDelete,
325 MQ_FCT const data
326) {
327
328 // related to "NS(sFactoryCTor)→MQ_FACTORY_NEW_INIT→Py_XINCREF"
329 if (doFactoryDelete && context->setup.factoryCall == MQ_FACTORY_NEW_FILTER) {
330 OT_LNG_T selfO = OT_SELF_X(context);
331 Py_CLEAR (selfO);
332 }
333
334 // do a 'hard'-delete if 'Py_CLEAR' does NOT call the destructor
335 MqContextDelete (context);
336}
337
338static void MK_DECL
339NS(sFactoryDataFree) (
341 MK_PTR *dataP
342) {
343 if (_Py_IsFinalizing()) return;
344 Py_CLEAR(*dataP);
345}
346
347static void MK_DECL
348NS(sFactoryDataCopy) (
350 MK_PTR *dataP
351) {
352 PyObject *arg = *dataP;
353 Py_INCREF(arg);
354}
355
361
362// BEGIN-MqFactoryC - created by 'py_MqC.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
363
367
368// doc-key: MqFactoryC,MqFactoryC-Class-Export,sc_
369
371static OT_ProcRet NS(MqFactoryC_HandleResolve) (OtClass_ARGS) {
373 OT_SETUP_ONEARG(HandleResolve_doc)
374 MK_HDL netHdl = 0;
375 OT_CHECK_REQUIRED(OT_CHECK_NIH (netHdl))
376 OT_CHECK_NOARGS
377 MQ_FCT retVal = MqFactoryHandleResolve (netHdl);
378 OT_retObj_SET_FCT(retVal)
379 goto end;
380 error:
381 OT_retObj_SET_Error
382 end:
384}
385
386// doc-key: MqFactoryC,MqFactoryC-Class-Export,om_
387
388// skip class-overload: HandleGet = MqFactoryHandleGet → MkObjectHandleGet
389
391// MqFactoryC_Class_PY_API
392
396
397// doc-key: MqFactoryC,MqFactoryC-Class-Introspection,oc_
398
400static OT_ProcRet NS(MqFactoryC_Next) (MqFactoryC_ARGS) {
402 OT_SETUP_NOARG(Next_doc)
403 OT_CHECK_NOARGS
404 MQ_FCT retVal = MqFactoryNext (hdl);
405 OT_retObj_SET_FCT(retVal)
406 goto end;
407 error:
408 OT_retObj_SET_Error
409 end:
411}
412
414static OT_ProcRet NS(MqFactoryC_Prev) (MqFactoryC_ARGS) {
416 OT_SETUP_NOARG(Prev_doc)
417 OT_CHECK_NOARGS
418 MQ_FCT retVal = MqFactoryPrev (hdl);
419 OT_retObj_SET_FCT(retVal)
420 goto end;
421 error:
422 OT_retObj_SET_Error
423 end:
425}
426
427// doc-key: MqFactoryC,MqFactoryC-Class-Introspection,sc_
428
430static OT_ProcRet NS(MqFactoryC_Instances) (OtClass_ARGS) {
432 OT_SETUP_NOARG(Instances_doc)
433 OT_CHECK_NOARGS
434 MQ_FCT retVal = MqFactoryInstances ();
435 OT_retObj_SET_FCT(retVal)
436 goto end;
437 error:
438 OT_retObj_SET_Error
439 end:
441}
442
444// MqFactoryC_Class_PY_API
445
449
450// doc-key: MqFactoryC,MqFactoryC-Class-Misc,sc_
451
453static OT_ProcRet NS(MqFactoryC_GetNull) (OtClass_ARGS) {
455 OT_SETUP_NOARG(GetNull_doc)
456 OT_CHECK_NOARGS
457 MQ_FCT retVal = MqFactoryGetNull ();
458 OT_retObj_SET_FCT(retVal)
459 goto end;
460 error:
461 OT_retObj_SET_Error
462 end:
464}
465
467// MqFactoryC_Class_PY_API
468
472
473// doc-key: MqFactoryC,MqFactoryC-Get,sc_
474
476static OT_ProcRet NS(MqFactoryC_Get) (OtClass_ARGS) {
478 OT_SETUP_VARARGS(0,1,Get_doc)
479 MK_STRN ident = "";
480 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
481 OT_CHECK_NOARGS
482 MQ_FCT retVal = MqFactoryGet (ident);
483 OT_retObj_SET_FCT(retVal)
484 goto end;
485 error:
486 OT_retObj_SET_Error
487 end:
489}
490
492static OT_ProcRet NS(MqFactoryC_GetCalled) (OtClass_ARGS) {
494 OT_SETUP_VARARGS(0,1,GetCalled_doc)
495 MK_STRN ident = "";
496 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
497 OT_CHECK_NOARGS
498 MQ_FCT retVal = MqFactoryGetCalled (ident);
499 OT_retObj_SET_FCT(retVal)
500 goto end;
501 error:
502 OT_retObj_SET_Error
503 end:
505}
506
508static OT_ProcRet NS(MqFactoryC_GetCalledL) (OtClass_ARGS) {
510 OT_SETUP_ONEARG(GetCalledL_doc)
511 MkBufferListCreateTLS_T(largs,10);
512 OT_CHECK_REQUIRED(OT_CHECK_BFLN (largs,MK_NULL_NO))
513 OT_CHECK_NOARGS
514 MQ_FCT retVal = MqFactoryGetCalledL (largs);
515 OT_retObj_SET_FCT(retVal)
516 goto end;
517 error:
518 OT_retObj_SET_Error
519 end:
521}
522
523// doc-key: MqFactoryC,MqFactoryC-Get,om_
524
526static OT_ProcRet NS(MqFactoryC_GetOriginalIdent) (MqFactoryC_ARGS) {
528 OT_SETUP_NOARG(GetOriginalIdent_doc)
529 OT_CHECK_NOARGS
530 OT_retObj_SET_STR(MqFactoryGetOriginalIdent (hdl))
531 goto end;
532 error:
533 OT_retObj_SET_Error
534 end:
536}
537
539// MqFactoryC_Get_PY_API
540
544
545// doc-key: MqFactoryC,MqFactoryC-Misc,oc_
546
548static OT_ProcRet NS(MqFactoryC_Default) (MqFactoryC_ARGS) {
550 OT_SETUP_NOARG(Default_doc)
551 OT_CHECK_NOARGS
552 MQ_FCT retVal = MqFactoryDefault (hdl);
553 OT_retObj_SET_FCT(retVal)
554 goto end;
555 error:
556 OT_retObj_SET_Error
557 end:
559}
560
562static OT_ProcRet NS(MqFactoryC_Initial) (MqFactoryC_ARGS) {
564 OT_SETUP_NOARG(Initial_doc)
565 OT_CHECK_NOARGS
566 MQ_FCT retVal = MqFactoryInitial (hdl);
567 OT_retObj_SET_FCT(retVal)
568 goto end;
569 error:
570 OT_retObj_SET_Error
571 end:
573}
574
575// doc-key: MqFactoryC,MqFactoryC-Misc,oco
576
578static OT_ProcRet NS(MqFactoryC_New) (MqFactoryC_ARGS) {
580 OT_SETUP_NOARG(New_doc)
581 OT_CHECK_NOARGS
582 MQ_CTX val_out;
583 MkErrorC_Check(hdl,MqFactoryNew (hdl, NULL, &val_out));
584 OT_retObj_SET_CTX(val_out)
585 goto end;
586 error:
587 OT_retObj_SET_Error
588 end:
590}
591
592// doc-key: MqFactoryC,MqFactoryC-Misc,om_
593
594// skip class-overload: Log = MqFactoryLog → MkObjectLog
595
596// doc-key: MqFactoryC,MqFactoryC-Misc,sm_
597
599static OT_ProcRet NS(MqFactoryC_DefaultIdent) (OtClass_ARGS) {
601 OT_SETUP_NOARG(DefaultIdent_doc)
602 OT_CHECK_NOARGS
603 OT_retObj_SET_STR(MqFactoryDefaultIdent ())
604 goto end;
605 error:
606 OT_retObj_SET_Error
607 end:
609}
610
612static OT_ProcRet NS(MqFactoryC_InitialIdent) (OtClass_ARGS) {
614 OT_SETUP_NOARG(InitialIdent_doc)
615 OT_CHECK_NOARGS
616 OT_retObj_SET_STR(MqFactoryInitialIdent ())
617 goto end;
618 error:
619 OT_retObj_SET_Error
620 end:
622}
623
625static OT_ProcRet NS(MqFactoryC_LogAll) (OtClass_ARGS) {
627 OT_SETUP_VARARGS(0,1,LogAll_doc)
628 MK_STRN callfunc = NULL;
629 OT_CHECK_OPTIONAL(OT_CHECK_STRN (callfunc))
630 OT_CHECK_NOARGS
631 if (MkSysStringIsNULL(callfunc)) {callfunc = OT_GET_CALL_PROC;}
632 OT_FRAME_CLEANUP;
633 MqFactoryLogAll (callfunc);
634 OT_retObj_SET_None
635 goto end;
636 error:
637 OT_retObj_SET_Error
638 end:
640}
641
643// MqFactoryC_Misc_PY_API
644
648
649// doc-key: MqFactoryC,MqFactoryC-TOR,oCx
650
652static OT_ProcRet NS(MqFactoryC_Dup2) (MqFactoryC_ARGS) {
654 OT_SETUP_ONEARG(Dup2_doc)
655 MK_STRN ident = 0;
656 OT_CHECK_REQUIRED(OT_CHECK_STRN (ident))
657 OT_CHECK_NOARGS
658 MQ_FCT retVal = MqFactoryDup2 (hdl, ident);
659 if (retVal == NULL) {
660 OT_ERROR_CONSTRUCTOR(MqFactoryC)
661 goto error;
662 }
663 OT_retObj_SET_FCT(retVal)
664 goto end;
665 error:
666 OT_retObj_SET_Error
667 end:
669}
670
671// doc-key: MqFactoryC,MqFactoryC-TOR,sCc
672
674static OT_ProcRet NS(MqFactoryC_Add) (OtClass_ARGS) {
676 OT_SETUP_VARARGS(1,2,Add_doc)
677 MK_CCP constructor = 0;
678 OT_CHECK_REQUIRED(OT_CHECK_CONSTRUCTOR(constructor))
679 MK_STRN ident = NULL;
680 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
681 OT_CHECK_NOARGS
682 if (MkSysStringIsNULL(ident)) {ident = OT_GET_CONSTR_NAME(constructor);}
683 MQ_FCT retVal = MqFactoryAdd (NULL, NS(sFactoryCTor), constructor, NS(sFactoryDataFree), NS(sFactoryDataCopy), NS(sFactoryDTor), NULL, NULL, NULL, ident);
684 if (retVal == NULL) {
685 OT_ERROR_CONSTRUCTOR(MqFactoryC)
686 goto error;
687 }
688 OT_CONSTRUCTOR_POST(retVal)
689 OT_retObj_SET_FCT(retVal)
690 goto end;
691 error:
692 OT_retObj_SET_Error
693 end:
695}
696
698static OT_ProcRet NS(MqFactoryC_new) (CONSTR_ARGS) {
700 OT_SETUP_CONSTRUCTOR_ARGS(1,2,new_doc)
701 MK_CCP constructor = 0;
702 OT_CHECK_REQUIRED(OT_CHECK_CONSTRUCTOR(constructor))
703 MK_STRN ident = NULL;
704 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
705 if (MkSysStringIsNULL(ident)) {ident = OT_GET_CONSTR_NAME(constructor);}
706 MQ_FCT retVal = MqFactoryAdd (NULL, NS(sFactoryCTor), constructor, NS(sFactoryDataFree), NS(sFactoryDataCopy), NS(sFactoryDTor), NULL, NULL, NULL, ident);
707 if (retVal == NULL) {
708 OT_ERROR_CONSTRUCTOR(MqFactoryC)
709 goto error;
710 }
711 OT_CONSTRUCTOR_POST(retVal)
712 OT_retObj_CONSTR(retVal)
713 goto end;
714 error:
715 OT_retObj_SET_Error
716 end:
718}
719
721// MqFactoryC_TOR_PY_API
722
723// END-MqFactoryC - created by 'py_MqC.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
724
730
731static PyMethodDef NS(MqFactoryC_Methods)[] = {
732 // BEGIN-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
733
734 // doc-key: MqFactoryC,MqFactory,sCc
735 { "Add" , (PyCFunction) NS(MqFactoryC_Add) , METH_VARARGS|METH_CLASS , Add_doc },
736
737 // doc-key: MqFactoryC,MqFactory,sc_
738 { "Get" , (PyCFunction) NS(MqFactoryC_Get) , METH_VARARGS|METH_CLASS , Get_doc },
739 { "GetCalled" , (PyCFunction) NS(MqFactoryC_GetCalled) , METH_VARARGS|METH_CLASS , GetCalled_doc },
740 { "GetCalledL" , (PyCFunction) NS(MqFactoryC_GetCalledL) , METH_O|METH_CLASS , GetCalledL_doc },
741 { "GetNull" , (PyCFunction) NS(MqFactoryC_GetNull) , METH_NOARGS|METH_CLASS , GetNull_doc },
742 { "HandleResolve" , (PyCFunction) NS(MqFactoryC_HandleResolve) , METH_O|METH_CLASS , HandleResolve_doc },
743 { "Instances" , (PyCFunction) NS(MqFactoryC_Instances) , METH_NOARGS|METH_CLASS , Instances_doc },
744
745 // doc-key: MqFactoryC,MqFactory,sm_
746 { "DefaultIdent" , (PyCFunction) NS(MqFactoryC_DefaultIdent) , METH_NOARGS|METH_CLASS , DefaultIdent_doc },
747 { "InitialIdent" , (PyCFunction) NS(MqFactoryC_InitialIdent) , METH_NOARGS|METH_CLASS , InitialIdent_doc },
748 { "LogAll" , (PyCFunction) NS(MqFactoryC_LogAll) , METH_VARARGS|METH_CLASS , LogAll_doc },
749
750 // END-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
751
752 // BEGIN-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
753
754 // doc-key: MqFactoryC,MqFactory,oCx
755 { "Dup2" , (PyCFunction) NS(MqFactoryC_Dup2) , METH_O , Dup2_doc },
756
757 // doc-key: MqFactoryC,MqFactory,oc_
758 { "Default" , (PyCFunction) NS(MqFactoryC_Default) , METH_NOARGS , Default_doc },
759 { "Initial" , (PyCFunction) NS(MqFactoryC_Initial) , METH_NOARGS , Initial_doc },
760 { "Next" , (PyCFunction) NS(MqFactoryC_Next) , METH_NOARGS , Next_doc },
761 { "Prev" , (PyCFunction) NS(MqFactoryC_Prev) , METH_NOARGS , Prev_doc },
762
763 // doc-key: MqFactoryC,MqFactory,oco
764 { "New" , (PyCFunction) NS(MqFactoryC_New) , METH_NOARGS , New_doc },
765
766 // doc-key: MqFactoryC,MqFactory,om_
767 { "GetOriginalIdent" , (PyCFunction) NS(MqFactoryC_GetOriginalIdent) , METH_NOARGS , GetOriginalIdent_doc },
768 // skip class-overload: MqFactoryHandleGet → HandleGet, NS(MqFactoryC_HandleGet)
769 // skip class-overload: MqFactoryLog → Log, NS(MqFactoryC_Log)
770
771 // END-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
772
773 {NULL, NULL, 0, NULL} /* Sentinel */
774};
775
776static PyObject* NS(sMqFactoryC_Str) (MqFactoryC_Obj *self) {
777 MkRtSetup_X(self->hdl);
778 return STRN2VAL(MkSysPrintF("MqFactoryC[%s]", self->hdl ? self->hdl->originalIdent : NULL));
779}
780
781// vim: Marker(p)
787
788int
789NS(pMqFactoryC_Setup) (MQ_RT_ARGS OT_LNG_T m)
790{
791 if (!strcmp(MqFactoryDefaultIdent(), "libmqmsgque")) {
792 if ( MqFactoryDefault(
795 NS(sFactoryCTor), (MK_PTR)&NS(MqContextCR), NULL, NULL,
796 NS(sFactoryDTor), NULL, NULL, NULL,
797 "pymqmsgque"
798 )
799 )
800 ) == NULL
801 )
802 {
803 PyErr_SetString(PyExc_RuntimeError, "MqFactoryS exception");
804 goto error;
805 }
806 }
807
808 return 0;
809error:
810 return -1;
811}
812
813// OT_CLASS_TYPE_REF NS(MqFactoryCR) = {0};
814OT_CLASS_TYPE_REF NS(MqFactoryCR) = {
815 PyVarObject_HEAD_INIT(NULL, 0)
816 .tp_name = "pymqmsgque.MqFactoryC",
817 .tp_doc = "PyMqMsgque MqFactoryC Type",
818 .tp_itemsize = sizeof(MqFactoryC_Obj),
819 .tp_itemsize = 0,
820 .tp_new = (newfunc) NS(MqFactoryC_new),
821 .tp_methods = NS(MqFactoryC_Methods),
822 .tp_flags = Py_TPFLAGS_DEFAULT,
823 .tp_base = NULL,
824 .tp_str = (reprfunc) NS(sMqFactoryC_Str)
825};
826
827int
828NS(pMqFactoryC_Init) (MQ_RT_ARGS OT_LNG_T m)
829{
831 MqFactoryCTT->noSelf = true;
832
833 return 0;
834error:
835 return -1;
836}
837
838// vim: nowrap
#define Instances_doc
#define Initial_doc
#define OT_SETUP_hdl_static_constr
#define GetOriginalIdent_doc
#define OT_SETUP_hdl
#define New_doc
#define OT_retObj_CONSTR(mng)
#define Get_doc
#define LogAll_doc
#define GetNull_doc
#define Next_doc
#define OT_retObj_RETURN
#define HandleResolve_doc
#define GetCalledL_doc
#define DefaultIdent_doc
#define Prev_doc
#define InitialIdent_doc
#define OT_CLASS
#define OT_SETUP_hdl_static
#define OT_SETUP_hdl_constr
#define GetCalled_doc
#define MqFactoryCTT
#define Dup2_doc
#define new_doc
#define Add_doc
#define Default_doc
#define ClassInit
#define error
#define mqctx
#define MkBufferListCreateTLS_T(name, num)
#define MkErrorGetCode_0E()
#define MkErrorStack_0E()
#define MkErrorSetC_3_NULL(...)
#define MkErrorSetC_1E(message)
#define MK_ERROR_DEFAULT
#define MK_ERROR_FORMAT
#define MK_DECL
#define mk_inline
#define MK_NULL_NO
MkErrorE
MK_OK
MK_PTRB * MK_PTR
const MK_STRB * MK_STRN
MK_PTRB * MK_CCP
int32_t MK_HDL
#define MkOBJ(x)
#define MkOBJ_R(x)
#define MkSysPrintF(...)
bool MkSysStringIsNULL(MK_STRN str)
#define MK_RT_CALL
#define MkRtSetup_X(x)
#define MK_RT_ARGS
#define MK_RT_REF
#define MqSetupDup(...)
#define MqContextDelete(x)
#define MQ_CALLBACK_FACTORY_CTOR_ARGS
the MqFactoryCTorF arguments with default names
#define MqFactoryInstances()
MQ_FCT MqFactoryPrev(MQ_FCT const fct)
get previous instance from linked-list of MqFactoryS type
#define MqFactoryHandleResolve(...)
MQ_FCT MqFactoryGetNull(void)
Null-Slot - return a MqFactoryC typed NULL instance …
MQ_FCT MqFactoryNext(MQ_FCT const fct)
get next instance from linked-list of MqFactoryS type
#define MqFactoryC_X2obj(x)
#define MqFactoryGetCalledL(...)
MQ_EXTERN MK_STRN MqFactoryGetOriginalIdent(MQ_FCTN const fct)
helper function to return MqFactoryS::originalIdent
MQ_EXTERN MQ_FCT MqFactoryGetCalled(MK_STRN const ident)
returns the MqFactoryC identified by ident …
MQ_EXTERN MQ_FCT MqFactoryGet(MK_STRN const ident)
return the MqFactoryC
MQ_EXTERN MK_STRN MqFactoryDefaultIdent(void)
return the factory-identifier of the default MqFactoryC
MQ_EXTERN MQ_FCT MqFactoryDefault(MQ_FCT const fct)
set the default-attribute to the factory …
#define MqFactoryLogAll(...)
MQ_EXTERN MQ_FCT MqFactoryInitial(MQ_FCT const fct)
set the initial-attribut to fct …
#define MqFactoryNew(...)
MQ_EXTERN MK_STRN MqFactoryInitialIdent(void)
return the factory-identifier of the initial MqFactoryC
#define MqFactoryDup2(...)
#define MqFactoryAdd(...)
@ MQ_FACTORY_NEW_FILTER
create object as a filter
@ MQ_FACTORY_NEW_THREAD
create object as a thread
@ MQ_FACTORY_NEW_INIT
initial object, nothing else is known
@ MQ_FACTORY_NEW_SLAVE
create object as a slave of an other object
@ MQ_FACTORY_NEW_CHILD
create object as a child of an other object
MQ_EXTERN MK_BFL MqInitGetArg0(void)
get the process startup-prefix argument
#define MQ_RT_ARGS
MK_BUF * data
union MkBufferU first
struct MkBufferS::@5 storage
PUBLIC data structure for the pymqmsgque-specific-data
data used to define a factory
MK_STRN C