theLink 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - py - rb - jv - cc
Loading...
Searching...
No Matches
LibMqMsgque_py.c
Go to the documentation of this file.
1
12/* LABEL-NO */
13
14#include "LibMqMsgque_py.h"
15#include "misc_check_py.h"
16
17#define OT_SETUP_hdl AllRtSetup_NULL; \
18 MK_OBJ hdl = MK_ERROR_PRINT;
19#define OT_SETUP_hdl_static __attribute__((unused)) MK_RT mkrt = MkRT; \
20 __attribute__((unused)) MK_ERR hdl = &MkERROR;
21
22#define MqSetupTmpl()
23#define MqCleanupTmpl()
24
25// MARK_D ################################################################
26// -----------------------------------------------------------------------
27// documentation order
28
39
52
76
85
94
102
111
119
120// --------------------------------------------------------------------------------
121
122// BEGIN-EnumDef - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
123
124// UNDEF
125
126// END-EnumDef - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
127
128// BEGIN-CLASS-DEC - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
129
130int NS(pMqDumpC_Init) (MQ_RT_ARGS OT_LNG_T) ;
131int NS(pMqContextC_Init) (MQ_RT_ARGS OT_LNG_T) ;
132int NS(pMqFactoryC_Init) (MQ_RT_ARGS OT_LNG_T) ;
133
134// END-CLASS-DEC - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
135
136int NS(pMqFactoryC_Setup) (MQ_RT_ARGS OT_LNG_T) ;
137
143
144// BEGIN-DOC - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
145
146// doc-key: MqMsgque,EnumFunc,sco,func
147#define IdentE_FromInt_doc "MqIdentE IdentE_FromInt(value:int32)"
148#define SlaveE_FromInt_doc "MqSlaveE SlaveE_FromInt(value:int32)"
149#define StartE_FromInt_doc "MqStartE StartE_FromInt(value:int32)"
150#define StatusIsEF_FromInt_doc "MqStatusIsEF StatusIsEF_FromInt(value:int32)"
151#define WaitOnEventE_FromInt_doc "MqWaitOnEventE WaitOnEventE_FromInt(value:int32)"
152
153// doc-key: MqMsgque,EnumFunc,sm_,func
154#define IdentE_ToInt_doc "int32 IdentE_ToInt(value:MqIdentE)"
155#define IdentE_ToString_doc "string IdentE_ToString(value:MqIdentE)"
156#define SlaveE_ToInt_doc "int32 SlaveE_ToInt(value:MqSlaveE)"
157#define SlaveE_ToString_doc "string SlaveE_ToString(value:MqSlaveE)"
158#define StartE_ToInt_doc "int32 StartE_ToInt(value:MqStartE)"
159#define StartE_ToString_doc "string StartE_ToString(value:MqStartE)"
160#define StatusIsEF_ToInt_doc "int32 StatusIsEF_ToInt(value:MqStatusIsEF)"
161#define StatusIsEF_ToString_doc "string StatusIsEF_ToString(value:MqStatusIsEF)"
162#define WaitOnEventE_ToInt_doc "int32 WaitOnEventE_ToInt(value:MqWaitOnEventE)"
163#define WaitOnEventE_ToString_doc "string WaitOnEventE_ToString(value:MqWaitOnEventE)"
164
165// doc-key: MqMsgque,MqHelp,sm_,func
166#define Help_doc "string Help(tool:string)"
167#define HelpMsgque_doc "string HelpMsgque()"
168
169// doc-key: MqMsgque,MqInit,sm_,func
170#define InitGetArg0_doc "MkBufferListC InitGetArg0()"
171#define InitResetArg0_doc "MkBufferListC InitResetArg0()"
172#define InitSetArg0_doc "InitSetArg0(?bfl:MkBufferListC...=None?)"
173
174// doc-key: MqMsgque,Setup,sm_,func
175#define Cleanup_doc "Cleanup()"
176#define Setup_doc "Setup()"
177
178// END-DOC - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
179
180#define Debug_doc "Debug(prefix:str, ?obj:object?"
181
182/*****************************************************************************/
183/* */
184/* Check */
185/* */
186/*****************************************************************************/
187
188#include "tmpl/mq_misc_check_lng.h"
189
190enum MkErrorE NS(CheckConstructor) (
191 OT_Check_ARGS,
192 MK_CCP *retP
193) {
194 if ((*skipP) >= objc) {
195 WrongNumArgs(hdl,(*skipP), objc, -999, +999, arg);
196 goto error;
197 }
198 PyObject *objV = OT_LNG_OBJV((*skipP)++);
199 if (PyObject_IsSubclass(objV,(OT_LNG_T)&NS(MqContextCR)) == 1) {
200 Py_INCREF(objV);
201 *retP = (MK_CCP)objV;
202 } else if (PyObject_IsSubclass(objV,(OT_LNG_T)&MK(MkObjectCR)) == 1) {
203 WrongTypeOfArgError(OT_LNG_NAME_FROM_CLASS(&NS(MqContextCR)), OT_LNG_NAME_FROM_CLASS((OT_LNG_CLASS_T)objV));
204 } else {
205 WrongTypeOfArgError(OT_LNG_NAME_FROM_CLASS(&NS(MqContextCR)), OT_LNG_TYPE_STRING(objV));
206 }
207 return MK_OK;
208error:
209 return OT_ERROR_STACK;
210}
211
217
218// BEGIN-MqMsgque - created by 'py_MqC.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
219
223
224// doc-key: MqMsgque,MqMsgque-Enum,sco
225
227static OT_ProcRet NS(MqMsgque_IdentE_FromInt) (OtClass_ARGS) {
229 OT_SETUP_ONEARG(IdentE_FromInt_doc)
230 MK_I32 value = 0;
231 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
232 OT_CHECK_NOARGS
233 enum MqIdentE value_out;
234 MkErrorC_Check(MK_ERROR_FORMAT,MqIdentE_FromInt (value, &value_out));
235 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(IdentE,value_out))
236 goto end;
237 error:
238 OT_retObj_SET_Error
239 end:
241}
242
244static OT_ProcRet NS(MqMsgque_SlaveE_FromInt) (OtClass_ARGS) {
246 OT_SETUP_ONEARG(SlaveE_FromInt_doc)
247 MK_I32 value = 0;
248 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
249 OT_CHECK_NOARGS
250 enum MqSlaveE value_out;
251 MkErrorC_Check(MK_ERROR_FORMAT,MqSlaveE_FromInt (value, &value_out));
252 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(SlaveE,value_out))
253 goto end;
254 error:
255 OT_retObj_SET_Error
256 end:
258}
259
261static OT_ProcRet NS(MqMsgque_StartE_FromInt) (OtClass_ARGS) {
263 OT_SETUP_ONEARG(StartE_FromInt_doc)
264 MK_I32 value = 0;
265 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
266 OT_CHECK_NOARGS
267 enum MqStartE value_out;
268 MkErrorC_Check(MK_ERROR_FORMAT,MqStartE_FromInt (value, &value_out));
269 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(StartE,value_out))
270 goto end;
271 error:
272 OT_retObj_SET_Error
273 end:
275}
276
278static OT_ProcRet NS(MqMsgque_StatusIsEF_FromInt) (OtClass_ARGS) {
280 OT_SETUP_ONEARG(StatusIsEF_FromInt_doc)
281 MK_I32 value = 0;
282 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
283 OT_CHECK_NOARGS
284 enum MqStatusIsEF value_out;
285 MkErrorC_Check(MK_ERROR_FORMAT,MqStatusIsEF_FromInt (value, &value_out));
286 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(StatusIsEF,value_out))
287 goto end;
288 error:
289 OT_retObj_SET_Error
290 end:
292}
293
295static OT_ProcRet NS(MqMsgque_WaitOnEventE_FromInt) (OtClass_ARGS) {
297 OT_SETUP_ONEARG(WaitOnEventE_FromInt_doc)
298 MK_I32 value = 0;
299 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
300 OT_CHECK_NOARGS
301 enum MqWaitOnEventE value_out;
302 MkErrorC_Check(MK_ERROR_FORMAT,MqWaitOnEventE_FromInt (value, &value_out));
303 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(WaitOnEventE,value_out))
304 goto end;
305 error:
306 OT_retObj_SET_Error
307 end:
309}
310
311// doc-key: MqMsgque,MqMsgque-Enum,sm_
312
314static OT_ProcRet NS(MqMsgque_IdentE_ToInt) (OtClass_ARGS) {
316 OT_SETUP_ONEARG(IdentE_ToInt_doc)
317 enum MqIdentE value = 0;
318 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqIdentE,value))
319 OT_CHECK_NOARGS
320 OT_retObj_SET_I32(MqIdentE_ToInt (value))
321 goto end;
322 error:
323 OT_retObj_SET_Error
324 end:
326}
327
329static OT_ProcRet NS(MqMsgque_IdentE_ToString) (OtClass_ARGS) {
331 OT_SETUP_ONEARG(IdentE_ToString_doc)
332 enum MqIdentE value = 0;
333 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqIdentE,value))
334 OT_CHECK_NOARGS
335 OT_retObj_SET_STR(MqIdentE_ToString (value))
336 goto end;
337 error:
338 OT_retObj_SET_Error
339 end:
341}
342
344static OT_ProcRet NS(MqMsgque_SlaveE_ToInt) (OtClass_ARGS) {
346 OT_SETUP_ONEARG(SlaveE_ToInt_doc)
347 enum MqSlaveE value = 0;
348 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqSlaveE,value))
349 OT_CHECK_NOARGS
350 OT_retObj_SET_I32(MqSlaveE_ToInt (value))
351 goto end;
352 error:
353 OT_retObj_SET_Error
354 end:
356}
357
359static OT_ProcRet NS(MqMsgque_SlaveE_ToString) (OtClass_ARGS) {
361 OT_SETUP_ONEARG(SlaveE_ToString_doc)
362 enum MqSlaveE value = 0;
363 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqSlaveE,value))
364 OT_CHECK_NOARGS
365 OT_retObj_SET_STR(MqSlaveE_ToString (value))
366 goto end;
367 error:
368 OT_retObj_SET_Error
369 end:
371}
372
374static OT_ProcRet NS(MqMsgque_StartE_ToInt) (OtClass_ARGS) {
376 OT_SETUP_ONEARG(StartE_ToInt_doc)
377 enum MqStartE value = 0;
378 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqStartE,value))
379 OT_CHECK_NOARGS
380 OT_retObj_SET_I32(MqStartE_ToInt (value))
381 goto end;
382 error:
383 OT_retObj_SET_Error
384 end:
386}
387
389static OT_ProcRet NS(MqMsgque_StartE_ToString) (OtClass_ARGS) {
391 OT_SETUP_ONEARG(StartE_ToString_doc)
392 enum MqStartE value = 0;
393 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqStartE,value))
394 OT_CHECK_NOARGS
395 OT_retObj_SET_STR(MqStartE_ToString (value))
396 goto end;
397 error:
398 OT_retObj_SET_Error
399 end:
401}
402
404static OT_ProcRet NS(MqMsgque_StatusIsEF_ToInt) (OtClass_ARGS) {
406 OT_SETUP_ONEARG(StatusIsEF_ToInt_doc)
407 enum MqStatusIsEF value = 0;
408 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqStatusIsEF,value))
409 OT_CHECK_NOARGS
410 OT_retObj_SET_I32(MqStatusIsEF_ToInt (value))
411 goto end;
412 error:
413 OT_retObj_SET_Error
414 end:
416}
417
419static OT_ProcRet NS(MqMsgque_StatusIsEF_ToString) (OtClass_ARGS) {
421 OT_SETUP_ONEARG(StatusIsEF_ToString_doc)
422 enum MqStatusIsEF value = 0;
423 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqStatusIsEF,value))
424 OT_CHECK_NOARGS
425 OT_retObj_SET_STR(MqStatusIsEF_ToString (value))
426 goto end;
427 error:
428 OT_retObj_SET_Error
429 end:
431}
432
434static OT_ProcRet NS(MqMsgque_WaitOnEventE_ToInt) (OtClass_ARGS) {
436 OT_SETUP_ONEARG(WaitOnEventE_ToInt_doc)
437 enum MqWaitOnEventE value = 0;
438 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqWaitOnEventE,value))
439 OT_CHECK_NOARGS
440 OT_retObj_SET_I32(MqWaitOnEventE_ToInt (value))
441 goto end;
442 error:
443 OT_retObj_SET_Error
444 end:
446}
447
449static OT_ProcRet NS(MqMsgque_WaitOnEventE_ToString) (OtClass_ARGS) {
451 OT_SETUP_ONEARG(WaitOnEventE_ToString_doc)
452 enum MqWaitOnEventE value = 0;
453 OT_CHECK_REQUIRED(OT_CHECK_ENUM (MqWaitOnEventE,value))
454 OT_CHECK_NOARGS
455 OT_retObj_SET_STR(MqWaitOnEventE_ToString (value))
456 goto end;
457 error:
458 OT_retObj_SET_Error
459 end:
461}
462
464// MqMsgque_Enum_PY_API
465
469
470// doc-key: MqMsgque,MqMsgque-Help,sm_
471
473static OT_ProcRet NS(MqMsgque_Help) (OtClass_ARGS) {
475 OT_SETUP_ONEARG(Help_doc)
476 MK_STRN tool = 0;
477 OT_CHECK_REQUIRED(OT_CHECK_STRN (tool))
478 OT_CHECK_NOARGS
479 OT_retObj_SET_STR(MqHelp (tool))
480 goto end;
481 error:
482 OT_retObj_SET_Error
483 end:
485}
486
488static OT_ProcRet NS(MqMsgque_HelpMsgque) (OtClass_ARGS) {
490 OT_SETUP_NOARG(HelpMsgque_doc)
491 OT_CHECK_NOARGS
492 OT_retObj_SET_STR(MqHelpMsgque ())
493 goto end;
494 error:
495 OT_retObj_SET_Error
496 end:
498}
499
501// MqMsgque_Help_PY_API
502
506
507// doc-key: MqMsgque,MqMsgque-Init,sm_
508
510static OT_ProcRet NS(MqMsgque_InitGetArg0) (OtClass_ARGS) {
512 OT_SETUP_NOARG(InitGetArg0_doc)
513 OT_CHECK_NOARGS
514 OT_retObj_SET_BFL(MqInitGetArg0 ())
515 goto end;
516 error:
517 OT_retObj_SET_Error
518 end:
520}
521
523static OT_ProcRet NS(MqMsgque_InitResetArg0) (OtClass_ARGS) {
525 OT_SETUP_NOARG(InitResetArg0_doc)
526 OT_CHECK_NOARGS
527 OT_retObj_SET_BFL(MqInitResetArg0 ())
528 goto end;
529 error:
530 OT_retObj_SET_Error
531 end:
533}
534
536static OT_ProcRet NS(MqMsgque_InitSetArg0) (OtClass_ARGS) {
538 OT_SETUP_VARARGS(0,99,InitSetArg0_doc)
540 OT_CHECK_OPTIONAL(OT_CHECK_BAC (bfl))
541 OT_CHECK_NOARGS
542 MqInitSetArg0 (bfl);
543 OT_retObj_SET_None
544 goto end;
545 error:
546 OT_retObj_SET_Error
547 end:
549}
550
552// MqMsgque_Init_PY_API
553
557
558// doc-key: MqMsgque,MqMsgque-Setup,sm_
559
561static OT_ProcRet NS(MqMsgque_Cleanup) (OtClass_ARGS) {
563 OT_SETUP_NOARG(Cleanup_doc)
564 OT_CHECK_NOARGS
565 MqCleanupTmpl ();
566 OT_retObj_SET_None
567 goto end;
568 error:
569 OT_retObj_SET_Error
570 end:
572}
573
575static OT_ProcRet NS(MqMsgque_Setup) (OtClass_ARGS) {
577 OT_SETUP_NOARG(Setup_doc)
578 OT_CHECK_NOARGS
579 MqSetupTmpl ();
580 OT_retObj_SET_None
581 goto end;
582 error:
583 OT_retObj_SET_Error
584 end:
586}
587
589// MqMsgque_Setup_PY_API
590
591// END-MqMsgque - created by 'py_MqC.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
592
593// vim: Marker(t)
599
600static PyMethodDef NS(sMqMsgqueMethods)[] = {
601
602 // BEGIN-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
603
604 // doc-key: MqMsgque,EnumFunc,sco
605 { "IdentE_FromInt" , (PyCFunction) NS(MqMsgque_IdentE_FromInt) , METH_O , IdentE_FromInt_doc },
606 { "SlaveE_FromInt" , (PyCFunction) NS(MqMsgque_SlaveE_FromInt) , METH_O , SlaveE_FromInt_doc },
607 { "StartE_FromInt" , (PyCFunction) NS(MqMsgque_StartE_FromInt) , METH_O , StartE_FromInt_doc },
608 { "StatusIsEF_FromInt" , (PyCFunction) NS(MqMsgque_StatusIsEF_FromInt) , METH_O , StatusIsEF_FromInt_doc },
609 { "WaitOnEventE_FromInt" , (PyCFunction) NS(MqMsgque_WaitOnEventE_FromInt) , METH_O , WaitOnEventE_FromInt_doc },
610
611 // doc-key: MqMsgque,EnumFunc,sm_
612 { "IdentE_ToInt" , (PyCFunction) NS(MqMsgque_IdentE_ToInt) , METH_O , IdentE_ToInt_doc },
613 { "IdentE_ToString" , (PyCFunction) NS(MqMsgque_IdentE_ToString) , METH_O , IdentE_ToString_doc },
614 { "SlaveE_ToInt" , (PyCFunction) NS(MqMsgque_SlaveE_ToInt) , METH_O , SlaveE_ToInt_doc },
615 { "SlaveE_ToString" , (PyCFunction) NS(MqMsgque_SlaveE_ToString) , METH_O , SlaveE_ToString_doc },
616 { "StartE_ToInt" , (PyCFunction) NS(MqMsgque_StartE_ToInt) , METH_O , StartE_ToInt_doc },
617 { "StartE_ToString" , (PyCFunction) NS(MqMsgque_StartE_ToString) , METH_O , StartE_ToString_doc },
618 { "StatusIsEF_ToInt" , (PyCFunction) NS(MqMsgque_StatusIsEF_ToInt) , METH_O , StatusIsEF_ToInt_doc },
619 { "StatusIsEF_ToString" , (PyCFunction) NS(MqMsgque_StatusIsEF_ToString) , METH_O , StatusIsEF_ToString_doc },
620 { "WaitOnEventE_ToInt" , (PyCFunction) NS(MqMsgque_WaitOnEventE_ToInt) , METH_O , WaitOnEventE_ToInt_doc },
621 { "WaitOnEventE_ToString" , (PyCFunction) NS(MqMsgque_WaitOnEventE_ToString) , METH_O , WaitOnEventE_ToString_doc },
622
623 // doc-key: MqMsgque,MqHelp,sm_
624 { "Help" , (PyCFunction) NS(MqMsgque_Help) , METH_O , Help_doc },
625 { "HelpMsgque" , (PyCFunction) NS(MqMsgque_HelpMsgque) , METH_NOARGS , HelpMsgque_doc },
626
627 // doc-key: MqMsgque,MqInit,sm_
628 { "InitGetArg0" , (PyCFunction) NS(MqMsgque_InitGetArg0) , METH_NOARGS , InitGetArg0_doc },
629 { "InitResetArg0" , (PyCFunction) NS(MqMsgque_InitResetArg0) , METH_NOARGS , InitResetArg0_doc },
630 { "InitSetArg0" , (PyCFunction) NS(MqMsgque_InitSetArg0) , METH_VARARGS , InitSetArg0_doc },
631
632 // doc-key: MqMsgque,Setup,sm_
633 { "Cleanup" , (PyCFunction) NS(MqMsgque_Cleanup) , METH_NOARGS , Cleanup_doc },
634 { "Setup" , (PyCFunction) NS(MqMsgque_Setup) , METH_NOARGS , Setup_doc },
635
636 // END-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
637
638 // BEGIN-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
639
640// → no data
641
642 // END-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
643
644 {NULL, NULL, 0, NULL} /* Sentinel */
645};
646
648// MODULE
649
650static typeof(MqLal.SysServerThread) save_SysServerThread = NULL;
651MK_UNUSED static int num = 0;
652
653MK_UNUSED static enum MkErrorE NS(PyServerThread) (
655 MQ_CTX const context,
656 struct MqSysServerThreadMainS * const argP,
657 MK_STRN name,
658 int thread_status,
659 struct MkIdS * idP
660) {
661 enum MkErrorE ret;
662 PyGILState_STATE gilstate;
663
664 gilstate = PyGILState_Ensure();
665 Py_BEGIN_ALLOW_THREADS
666
667//num++;
668//printV("START num<%d>, ts<%p>, gil<%o>",num,_save,gilstate);
669 ret = (*save_SysServerThread)(MK_RT_CALL context, argP, name, thread_status, idP);
670//printV("END num<%d>, ts<%p>, gil<%o>",num,_save,gilstate);
671
672 Py_END_ALLOW_THREADS
673 PyGILState_Release(gilstate);
674
675 return ret;
676}
677
678/*
679MK_UNUSED MK_NO_RETURN
680static void NS(PyExit) (
681 int isThread,
682 int num
683) {
684 if (isThread) {
685 pthread_exit(NULL);
686 //printTxt("skip: pthread_exit")
687 } else {
688 exit(num);
689 }
690}
691*/
692
693// ----------------------------------------------------------------------------------------------
694
695MkThreadLocal MqMsgqueThreadStateS MQ(MqMsgqueThreadState) = {0};
696
697typedef struct {
699} NS(sMqMsgqueStateS);
700
701MK_UNUSED static inline NS(sMqMsgqueStateS)*
702NS(sMqMsgqueGetState)(PyObject *module)
703{
704 void *state = PyModule_GetState(module);
705 assert(state != NULL);
706 return (NS(sMqMsgqueStateS)*)state;
707}
708
709#if 0
710#define myTrace2(col,str) mk_debug_color(col,"%s module<%p> refCnty<%zd>",str,module,Py_REFCNT(module));
711#define myTrace(str) myTrace2(MK_COLOR_ORANGE,str)
712#else
713#define myTrace2(col,str)
714#define myTrace(str)
715#endif
716
717MK_UNUSED static int
718NS(sMqMsgqueTraverse)(PyObject *module, visitproc visit, void *arg)
719{
720myTrace("TRAVERSE")
721
722 // BEGIN-EnumTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
723
724 Py_VISIT(OT_MqIdentE);
725 Py_VISIT(OT_MqSlaveE);
726 Py_VISIT(OT_MqStartE);
727 Py_VISIT(OT_MqStatusIsEF);
728 Py_VISIT(OT_MqWaitOnEventE);
729
730 // END-EnumTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
731 // BEGIN-ClassTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
732
733 Py_VISIT(MqDumpC_MK_NULL);
734 Py_VISIT(MqContextC_MK_NULL);
735 Py_VISIT(MqFactoryC_MK_NULL);
736
737 // END-ClassTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
738
739 return 0;
740}
741
742MK_UNUSED static int
743NS(sMqMsgqueClear)(PyObject *module)
744{
745myTrace("CLEAR")
746
747 // BEGIN-EnumClear - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
748
749 Py_CLEAR(OT_MqIdentE);
750 Py_CLEAR(OT_MqSlaveE);
751 Py_CLEAR(OT_MqStartE);
752 Py_CLEAR(OT_MqStatusIsEF);
753 Py_CLEAR(OT_MqWaitOnEventE);
754
755 // END-EnumClear - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
756 // BEGIN-ClassClear - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
757
758 Py_CLEAR(MqDumpC_MK_NULL);
759 Py_CLEAR(MqContextC_MK_NULL);
760 Py_CLEAR(MqFactoryC_MK_NULL);
761
762 // END-ClassClear - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
763
764 return 0;
765}
766
767static void
768NS(sMqMsgqueFree)(void *module)
769{
770myTrace("FREE")
771 NS(sMqMsgqueStateS) *state = NS(sMqMsgqueGetState)(module);
772 NS(sMqMsgqueClear)((PyObject *)module);
773 if (state && state->mkrt) {
774 state->mkrt->threadData = NULL;
775 state->mkrt=NULL;
776 }
777}
778
779static int
780NS(sMqMsgqueExec)(PyObject *module)
781{
782myTrace2(MK_COLOR_BLUE,"START")
783//printV("#1 PyThreadState_Get<%p>", PyThreadState_Get())
784
785 MqSetup();
787
788 NS(sMqMsgqueStateS) *state = NS(sMqMsgqueGetState)(module);
789 state->mkrt = MK_RT_PTR;
790
791// MK_RT_REF.threadData = PyThreadState_Get();
792
793 PyObject *mainM = PyImport_AddModule("__main__");
794
795 PyObject *mkM;
796 LngErrorCheckN(mkM = PyImport_ImportModule("pymkkernel"));
797 LngErrorCheck(PyObject_SetAttrString(mainM,"pymkkernel",mkM));
798 Py_CLEAR(mkM);
799
800 // BEGIN-CLASS-DEF - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
801
802 LngErrorCheck( NS(pMqDumpC_Init) (MQ_RT_CALL module) ) ;
803 LngErrorCheck( NS(pMqContextC_Init) (MQ_RT_CALL module) ) ;
804 LngErrorCheck( NS(pMqFactoryC_Init) (MQ_RT_CALL module) ) ;
805
806 // END-CLASS-DEF - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
807
808 // init ENUM
809 MK_STR enumCode =
810 "from enum import IntEnum, IntFlag\n"
811
812 // BEGIN-EnumCode - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
813
814 "class MqIdentE(IntEnum):\n"
815 " PREFIX = 0\n"
816 " FACTORY = 1\n"
817
818 "class MqSlaveE(IntEnum):\n"
819 " LOOPBACK = 0\n"
820 " FILTER = 1\n"
821 " MASTER = 1\n"
822 " OTHER = 1\n"
823 " USER = 10\n"
824 " MAX = 1024\n"
825
826 "class MqStartE(IntEnum):\n"
827 " DEFAULT = 0\n"
828 " FORK = 1\n"
829 " THREAD = 2\n"
830 " SPAWN = 3\n"
831
832 "class MqStatusIsEF(IntFlag):\n"
833 " INITIAL = 0\n"
834 " DUP = 1\n"
835 " THREAD = 2\n"
836 " FORK = 4\n"
837 " SPAWN = 8\n"
838
839 "class MqWaitOnEventE(IntEnum):\n"
840 " NO = 0\n"
841 " ONCE = 1\n"
842 " OWN = 2\n"
843 " FOREVER = 3\n"
844
845 // END-EnumCode - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
846 ;
847
848 PyObject *myD, *mainD, *tmpO;
849 mainD = PyModule_GetDict(mainM);
850 myD = PyModule_GetDict(module);
851 tmpO = PyRun_String(enumCode, Py_file_input, mainD, myD);
852 LngErrorCheckN(tmpO);
853 Py_CLEAR(tmpO);
854
855 // BEGIN-EnumSet - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
856
857 OT_MqIdentE = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MqIdentE"));
858 OT_MqSlaveE = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MqSlaveE"));
859 OT_MqStartE = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MqStartE"));
860 OT_MqStatusIsEF = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MqStatusIsEF"));
861 OT_MqWaitOnEventE = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MqWaitOnEventE"));
862
863 // END-EnumSet - created by 'py_MqS.tcl -i NHI1_HOME/theLink/c/gen/c_mqmsgque.meta' - DO NOT change
864
865 // every new thread source the script
866 // "from pymqmsgque import" is calling "PyInit_pymqmsgque"
867 // → check if we on "thread" : __name__=__main__
868
869 // only ONCE on INITIAL setup
870 if (strcmp(PyModule_GetName(mainM),"__main__") == 0) {
871
872 // set the thread startup
873 //save_SysServerThread = MqLal.SysServerThread;
874 //MqLal.SysServerThread = NS(PyServerThread);
875 //MkLal.SysExit = NS(PyExit);
876
877 // init libmqmsgque global data
878 if (MqInitGetArg0() == NULL && Py_GetProgramName() != NULL) {
879 char *py = Py_EncodeLocale(Py_GetProgramName(),NULL);
880
881 PyObject *sysO = PyImport_ImportModule("sys");
882 LngErrorCheckN(sysO);
883 PyObject *argvO = PyObject_GetAttrString(sysO, "argv");
884 LngErrorCheckN(argvO);
885 PyObject *itmO = PyList_GetItem(argvO, 0);
886 LngErrorCheckN(itmO);
887
888 MqInitSetArg0VA(py, PyUnicode_AsUTF8(itmO), NULL);
889
890 Py_CLEAR(argvO);
891 Py_CLEAR(sysO);
892 PyMem_Free(py);
893 }
894
895 // create the default-factory
896 LngErrorCheck (NS(pMqFactoryC_Setup) (MQ_RT_CALL module));
897 }
898
899 //PyErr_SetString(PyExc_RuntimeError,"this is a test");
900
901//mk_debug_color(MK_COLOR_BLUE,"END module<%p>",module);
902 return 0;
903error:
904 return -1;
905}
906
907MK_UNUSED static PyModuleDef_Slot NS(sMqMsgqueDefSlots)[] = {
908 {Py_mod_exec, NS(sMqMsgqueExec)},
909 {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
910 {0, NULL}
911};
912
913static PyModuleDef NS(sMqMsgqueDef) = {
914 PyModuleDef_HEAD_INIT,
915 .m_name = "pymqmsgque",
916 .m_doc = "python language binding 'MqMsgque'",
917 .m_size = sizeof(NS(sMqMsgqueStateS)),
918 .m_methods = NS(sMqMsgqueMethods),
919 .m_slots = NS(sMqMsgqueDefSlots),
920 .m_traverse = NS(sMqMsgqueTraverse), // garbage collection
921 .m_clear = NS(sMqMsgqueClear),
922 .m_free = NS(sMqMsgqueFree),
923};
924
925// MARK_P
931
932__attribute__ ((visibility("default"))) PyMODINIT_FUNC
934{
935 // Multi-phase initialization
936 return PyModuleDef_Init(&NS(sMqMsgqueDef));
937}
938
939// vim: nowrap
#define AllRtSetup_NULL
#define MqCleanupTmpl()
#define StartE_ToString_doc
static MK_UNUSED int num
PyMODINIT_FUNC PyInit_pymqmsgque(void)
#define WaitOnEventE_ToInt_doc
#define WaitOnEventE_ToString_doc
#define IdentE_ToInt_doc
#define IdentE_ToString_doc
#define InitGetArg0_doc
#define SlaveE_ToString_doc
#define StatusIsEF_FromInt_doc
#define StatusIsEF_ToString_doc
#define MqSetupTmpl()
#define StatusIsEF_ToInt_doc
#define HelpMsgque_doc
#define Help_doc
#define OT_SETUP_hdl_static
#define InitSetArg0_doc
#define myTrace2(col, str)
#define InitResetArg0_doc
#define StartE_ToInt_doc
#define Cleanup_doc
#define IdentE_FromInt_doc
#define SlaveE_ToInt_doc
#define myTrace(str)
#define SlaveE_FromInt_doc
#define Setup_doc
#define WaitOnEventE_FromInt_doc
static typeof(MqLal.SysServerThread) save_SysServerThread
#define StartE_FromInt_doc
#define OT_retObj_RETURN
#define error
#define MkBufferListCreateTLS_T(name, num)
#define MK_ERROR_FORMAT
#define MK_UNUSED
MkErrorE
MK_OK
const MK_STRB * MK_STRN
MK_STRB * MK_STR
MK_PTRB * MK_CCP
signed int MK_I32
#define MkThreadLocal
#define MK_RT_PTR
#define MK_RT_CALL
#define MK_RT_ARGS
MQ_EXTERN MK_STRN MqStatusIsEF_ToString(enum MqStatusIsEF value)
return the MqStatusIsEF as string …
MQ_EXTERN MK_STRN MqStartE_ToString(enum MqStartE value)
return the MqStartE as string …
MK_I32 MqIdentE_ToInt(enum MqIdentE value)
return the MqIdentE as integer …
MQ_EXTERN enum MkErrorE MqStatusIsEF_FromInt(MK_I32 const value, enum MqStatusIsEF *value_out)
return the MqStatusIsEF from integer …
MqWaitOnEventE
wait for an event? …
MqSlaveE
predefined slave-id for well known slaves …
MK_I32 MqSlaveE_ToInt(enum MqSlaveE value)
return the MqSlaveE as integer …
MqIdentE
identify the application using prefix (default) or factory …
MQ_EXTERN MK_STRN MqWaitOnEventE_ToString(enum MqWaitOnEventE value)
return the MqWaitOnEventE as string …
MQ_EXTERN enum MkErrorE MqStartE_FromInt(MK_I32 const value, enum MqStartE *value_out)
return the MqStartE from integer …
MK_I32 MqStartE_ToInt(enum MqStartE value)
return the MqStartE as integer …
MqStartE
User preferences on HOWTO start a new entity.
MqStatusIsEF
Information about how the context was created.
MQ_EXTERN MK_STRN MqIdentE_ToString(enum MqIdentE value)
return the MqIdentE as string …
MQ_EXTERN enum MkErrorE MqSlaveE_FromInt(MK_I32 const value, enum MqSlaveE *value_out)
return the MqSlaveE from integer …
MK_I32 MqStatusIsEF_ToInt(enum MqStatusIsEF value)
return the MqStatusIsEF as integer …
MQ_EXTERN enum MkErrorE MqIdentE_FromInt(MK_I32 const value, enum MqIdentE *value_out)
return the MqIdentE from integer …
MK_I32 MqWaitOnEventE_ToInt(enum MqWaitOnEventE value)
return the MqWaitOnEventE as integer …
MQ_EXTERN enum MkErrorE MqWaitOnEventE_FromInt(MK_I32 const value, enum MqWaitOnEventE *value_out)
return the MqWaitOnEventE from integer …
MQ_EXTERN MK_STRN MqSlaveE_ToString(enum MqSlaveE value)
return the MqSlaveE as string …
MQ_EXTERN MK_STR MqHelpMsgque(void)
return a page with the usage of all pymqmsgque specific options
MQ_EXTERN MK_STR MqHelp(MK_STRN tool)
write pymqmsgque specific user-help to stderr
MQ_EXTERN void MqInitSetArg0(MK_BAC bfl)
set the process startup-prefix argument to bfl
MQ_EXTERN MK_BFL MqInitGetArg0(void)
get the process startup-prefix argument
MQ_EXTERN MK_BFL MqInitResetArg0(void)
Reset the process-startup-prefix argument to an empty list …
MQ_EXTERN void MqInitSetArg0VA(MK_STRN arg0,...)
set the process startup-prefix to a args
MQ_EXTERN void MqSetup(void)
setup pymqmsgque internal memory …
MQ_EXTERN_DATA struct MqLalS MqLal
Language Abstraction Layer in duty.
#define MQ_RT_ARGS
#define MQ_RT_CALL
PUBLIC data structure for the pymqmsgque-specific-data
enum MkErrorE(* SysServerThread)(MK_RT mkrt, MQ_CTX const ctx, struct MqSysServerThreadMainS *const argP, MK_STRN name, int state, struct MkIdS *val_out)
thread server create syscall with pymqmsgque error plugin
data used to initialize a new created thread …