14#include "LibMqMsgque_py.h"
15#include "misc_check_py.h"
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;
23#define MqCleanupTmpl()
131int NS(pMqContextC_Init) (
MQ_RT_ARGS OT_LNG_T) ;
132int NS(pMqFactoryC_Init) (
MQ_RT_ARGS OT_LNG_T) ;
136int NS(pMqFactoryC_Setup) (
MQ_RT_ARGS OT_LNG_T) ;
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)"
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)"
166#define Help_doc "string Help(tool:string)"
167#define HelpMsgque_doc "string HelpMsgque()"
170#define InitGetArg0_doc "MkBufferListC InitGetArg0()"
171#define InitResetArg0_doc "MkBufferListC InitResetArg0()"
172#define InitSetArg0_doc "InitSetArg0(?bfl:MkBufferListC...=None?)"
175#define Cleanup_doc "Cleanup()"
176#define Setup_doc "Setup()"
180#define Debug_doc "Debug(prefix:str, ?obj:object?"
188#include "tmpl/mq_misc_check_lng.h"
194 if ((*skipP) >= objc) {
195 WrongNumArgs(hdl,(*skipP), objc, -999, +999, arg);
198 PyObject *objV = OT_LNG_OBJV((*skipP)++);
199 if (PyObject_IsSubclass(objV,(OT_LNG_T)&NS(
MqContextCR)) == 1) {
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));
205 WrongTypeOfArgError(OT_LNG_NAME_FROM_CLASS(&NS(
MqContextCR)), OT_LNG_TYPE_STRING(objV));
209 return OT_ERROR_STACK;
227static OT_ProcRet NS(MqMsgque_IdentE_FromInt) (OtClass_ARGS) {
231 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
235 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(IdentE,value_out))
244static OT_ProcRet NS(MqMsgque_SlaveE_FromInt) (OtClass_ARGS) {
248 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
252 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(SlaveE,value_out))
261static OT_ProcRet NS(MqMsgque_StartE_FromInt) (OtClass_ARGS) {
265 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
269 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(StartE,value_out))
278static OT_ProcRet NS(MqMsgque_StatusIsEF_FromInt) (OtClass_ARGS) {
282 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
286 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(StatusIsEF,value_out))
295static OT_ProcRet NS(MqMsgque_WaitOnEventE_FromInt) (OtClass_ARGS) {
299 OT_CHECK_REQUIRED(OT_CHECK_NI4 (value))
303 OT_retObj_SET(OT_NEW_Mq_enum_OBJ(WaitOnEventE,value_out))
314static OT_ProcRet NS(MqMsgque_IdentE_ToInt) (OtClass_ARGS) {
318 OT_CHECK_REQUIRED(OT_CHECK_ENUM (
MqIdentE,value))
329static OT_ProcRet NS(MqMsgque_IdentE_ToString) (OtClass_ARGS) {
333 OT_CHECK_REQUIRED(OT_CHECK_ENUM (
MqIdentE,value))
344static OT_ProcRet NS(MqMsgque_SlaveE_ToInt) (OtClass_ARGS) {
348 OT_CHECK_REQUIRED(OT_CHECK_ENUM (
MqSlaveE,value))
359static OT_ProcRet NS(MqMsgque_SlaveE_ToString) (OtClass_ARGS) {
363 OT_CHECK_REQUIRED(OT_CHECK_ENUM (
MqSlaveE,value))
374static OT_ProcRet NS(MqMsgque_StartE_ToInt) (OtClass_ARGS) {
378 OT_CHECK_REQUIRED(OT_CHECK_ENUM (
MqStartE,value))
389static OT_ProcRet NS(MqMsgque_StartE_ToString) (OtClass_ARGS) {
393 OT_CHECK_REQUIRED(OT_CHECK_ENUM (
MqStartE,value))
404static OT_ProcRet NS(MqMsgque_StatusIsEF_ToInt) (OtClass_ARGS) {
419static OT_ProcRet NS(MqMsgque_StatusIsEF_ToString) (OtClass_ARGS) {
434static OT_ProcRet NS(MqMsgque_WaitOnEventE_ToInt) (OtClass_ARGS) {
449static OT_ProcRet NS(MqMsgque_WaitOnEventE_ToString) (OtClass_ARGS) {
473static OT_ProcRet NS(MqMsgque_Help) (OtClass_ARGS) {
477 OT_CHECK_REQUIRED(OT_CHECK_STRN (tool))
479 OT_retObj_SET_STR(
MqHelp (tool))
488static OT_ProcRet NS(MqMsgque_HelpMsgque) (OtClass_ARGS) {
510static OT_ProcRet NS(MqMsgque_InitGetArg0) (OtClass_ARGS) {
523static OT_ProcRet NS(MqMsgque_InitResetArg0) (OtClass_ARGS) {
536static OT_ProcRet NS(MqMsgque_InitSetArg0) (OtClass_ARGS) {
540 OT_CHECK_OPTIONAL(OT_CHECK_BAC (bfl))
561static OT_ProcRet NS(MqMsgque_Cleanup) (OtClass_ARGS) {
575static OT_ProcRet NS(MqMsgque_Setup) (OtClass_ARGS) {
600static PyMethodDef NS(sMqMsgqueMethods)[] = {
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 },
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 },
620 {
"WaitOnEventE_ToInt" , (PyCFunction) NS(MqMsgque_WaitOnEventE_ToInt) , METH_O ,
WaitOnEventE_ToInt_doc },
624 {
"Help" , (PyCFunction) NS(MqMsgque_Help) , METH_O ,
Help_doc },
625 {
"HelpMsgque" , (PyCFunction) NS(MqMsgque_HelpMsgque) , METH_NOARGS ,
HelpMsgque_doc },
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 },
633 {
"Cleanup" , (PyCFunction) NS(MqMsgque_Cleanup) , METH_NOARGS ,
Cleanup_doc },
634 {
"Setup" , (PyCFunction) NS(MqMsgque_Setup) , METH_NOARGS ,
Setup_doc },
644 {NULL, NULL, 0, NULL}
662 PyGILState_STATE gilstate;
664 gilstate = PyGILState_Ensure();
665 Py_BEGIN_ALLOW_THREADS
669 ret = (*save_SysServerThread)(
MK_RT_CALL context, argP, name, thread_status, idP);
673 PyGILState_Release(gilstate);
699} NS(sMqMsgqueStateS);
701MK_UNUSED static inline NS(sMqMsgqueStateS)*
702NS(sMqMsgqueGetState)(PyObject *module)
704 void *state = PyModule_GetState(module);
705 assert(state != NULL);
706 return (NS(sMqMsgqueStateS)*)state;
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)
713#define myTrace2(col,str)
718NS(sMqMsgqueTraverse)(PyObject *module, visitproc visit,
void *arg)
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);
733 Py_VISIT(MqDumpC_MK_NULL);
734 Py_VISIT(MqContextC_MK_NULL);
735 Py_VISIT(MqFactoryC_MK_NULL);
743NS(sMqMsgqueClear)(PyObject *module)
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);
758 Py_CLEAR(MqDumpC_MK_NULL);
759 Py_CLEAR(MqContextC_MK_NULL);
760 Py_CLEAR(MqFactoryC_MK_NULL);
768NS(sMqMsgqueFree)(
void *module)
771 NS(sMqMsgqueStateS) *state = NS(sMqMsgqueGetState)(module);
772 NS(sMqMsgqueClear)((PyObject *)module);
773 if (state && state->mkrt) {
774 state->mkrt->threadData = NULL;
780NS(sMqMsgqueExec)(PyObject *module)
788 NS(sMqMsgqueStateS) *state = NS(sMqMsgqueGetState)(module);
793 PyObject *mainM = PyImport_AddModule(
"__main__");
796 LngErrorCheckN(mkM = PyImport_ImportModule(
"pymkkernel"));
797 LngErrorCheck(PyObject_SetAttrString(mainM,
"pymkkernel",mkM));
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) ) ;
810 "from enum import IntEnum, IntFlag\n"
814 "class MqIdentE(IntEnum):\n"
818 "class MqSlaveE(IntEnum):\n"
826 "class MqStartE(IntEnum):\n"
832 "class MqStatusIsEF(IntFlag):\n"
839 "class MqWaitOnEventE(IntEnum):\n"
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);
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"));
870 if (strcmp(PyModule_GetName(mainM),
"__main__") == 0) {
878 if (
MqInitGetArg0() == NULL && Py_GetProgramName() != NULL) {
879 char *py = Py_EncodeLocale(Py_GetProgramName(),NULL);
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);
896 LngErrorCheck (NS(pMqFactoryC_Setup) (
MQ_RT_CALL module));
907MK_UNUSED static PyModuleDef_Slot NS(sMqMsgqueDefSlots)[] = {
908 {Py_mod_exec, NS(sMqMsgqueExec)},
909 {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
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),
921 .m_clear = NS(sMqMsgqueClear),
922 .m_free = NS(sMqMsgqueFree),
932__attribute__ ((visibility(
"default"))) PyMODINIT_FUNC
936 return PyModuleDef_Init(&NS(sMqMsgqueDef));
#define StartE_ToString_doc
PyMODINIT_FUNC PyInit_pymqmsgque(void)
#define WaitOnEventE_ToInt_doc
#define WaitOnEventE_ToString_doc
#define IdentE_ToString_doc
#define SlaveE_ToString_doc
#define StatusIsEF_FromInt_doc
#define StatusIsEF_ToString_doc
#define StatusIsEF_ToInt_doc
#define OT_SETUP_hdl_static
#define myTrace2(col, str)
#define InitResetArg0_doc
#define IdentE_FromInt_doc
#define SlaveE_FromInt_doc
#define WaitOnEventE_FromInt_doc
static typeof(MqLal.SysServerThread) save_SysServerThread
#define StartE_FromInt_doc
#define MkBufferListCreateTLS_T(name, num)
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.
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 …