14#define META_FILE_NAME "MqFactoryC_py.c"
16#include "LibMqMsgque_private_py.h"
19#define OT_CLASS (&NS(MqFactoryCR))
20#define OT_CLASS_NAME "MqFactoryC"
22#define OT_LNG2META(O) MqFct(VAL2MNG(O))
24#define OT_retObj_CONSTR(mng) OT_retObj_SET(NS(MqFactoryC_CTOR)(MK_RT_CALL (PyTypeObject*)class,mng))
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;
34#define OT_SETUP_hdl_static_constr OT_SETUP_hdl_static
36#if !defined(SetupRtFromObj_X)
37 #define SetupRtFromObj_X(hdl) AllRtSetup_X(hdl)
38 #define SetupRtFromObj_XN(hdl) AllRtSetup_XN(hdl)
43#define MqFactoryCTT MQ(MqMsgqueThreadState).MqFactoryCTT
59 OT_OBJECT_DELETE_HARD(OT_SELF);
63 MkObjectC_Obj *selfO = (MkObjectC_Obj*) self;
70 if (MqFactoryCTT == NULL) MqFactoryCTT = MqFactorySTT; \
73 if (MqFactoryCTT->selfCreate == NS(MqFactoryC_selfCreate)) return MK_OK; \
76 MqFactoryCTT->selfCreate = NS(MqFactoryC_selfCreate); \
77 MqFactoryCTT->selfDelete = NS(MqFactoryC_selfDelete); \
78 MqFactoryCTT->selfUnlink = NS(MqFactoryC_selfUnlink); \
80 if (!PyType_HasFeature(OT_CLASS,Py_TPFLAGS_READY)) { \
81 NS(MqFactoryCR).tp_base = OT_MqFactoryC_base; \
82 LngErrorCheck (PyType_Ready(OT_CLASS)); \
84 LngErrorCheck(PyModule_AddObjectRef(m, "MqFactoryC", (PyObject *)OT_CLASS)); \
87 MqFactoryC_MK_NULL = Py_NewRef(MK(AtomCreate) (MK_RT_CALL OT_CLASS, NULL , false));
91#define SetupRtFromObj_XN(hdl) AllRtSetup_XN(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;
109#undef OT_retObj_RETURN
110#define OT_retObj_RETURN \
111if (is_constr_hard) { \
116 Py_INCREF (retObj); \
118 return ((PyObject*)retObj);
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\"?)"
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()"
141#define DefaultIdent_doc "string MqFactoryC.DefaultIdent()"
142#define InitialIdent_doc "string MqFactoryC.InitialIdent()"
143#define LogAll_doc "MqFactoryC.LogAll(?callfunc:string=\"MK_NULL\"?)"
146#define Dup2_doc "MqFactoryC fct.Dup2(ident:string) (const)"
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()"
155#define New_doc "MqContextC fct.New()"
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)"
175 PyObject* argsO=NULL, *resultO=NULL;
176 PyObject* typeO = fct->fct_ctor.data;
177 PyObject* tmplO = (tmpl ?
MkOBJ_R(tmpl).self : NULL);
182 ret =
MkErrorSetC_1E(
"internal error: MQ_FACTORY_NEW_THREAD not supported");
186 static PyInterpreterConfig config = {
187 .use_main_obmalloc = 0,
191 .allow_daemon_threads = 0,
192 .check_multi_interp_extensions = 1,
193 .gil = PyInterpreterConfig_OWN_GIL,
196 PyThreadState *tstate = NULL;
197 PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
200mk_debug_color(MK_COLOR_YELLOW,
"MQ_FACTORY_NEW_THREAD -> thread<%p>", tstate);
202 if (PyStatus_Exception(status)) {
210 PyObject *mainM = PyImport_AddModule(
"__main__");
211 PyObject *strO = PyUnicode_FromString(
"MQ_STARTUP_IS_THREAD");
212 PyObject_SetAttrString(mainM,
"__name__", strO);
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);
228 PyObject* QualNameO = PyType_GetQualName((PyTypeObject*)typeO);
229 if (QualNameO == NULL)
goto error2;
232 typeO = PyObject_GetAttr(mainM,QualNameO);
235 if (typeO == NULL)
goto error2;
239 tmplO = MK(AtomCreate)(
MK_RT_CALL (PyTypeObject*)typeO,
MkOBJ(tmpl),
false);
258 typeO = Py_NewRef(Py_TYPE(tmplO));
263 argsO = PyTuple_New(0);
265 argsO = PyTuple_New(1);
266 PyTuple_SET_ITEM(argsO, 0, tmplO);
271 PyErr_SetString(PyExc_RuntimeError,
"internal error: factory object constructor is 'NULL'");
275 resultO = PyObject_Call(typeO, argsO, NULL);
276 check_NULL(resultO)
goto error;
280 if (!PyObject_IsInstance(resultO, (PyObject*) &NS(
MqContextCR)))
goto error;
281 mqctx = VAL2CTX(resultO);
324 bool doFactoryDelete,
330 OT_LNG_T selfO = OT_SELF_X(context);
339NS(sFactoryDataFree) (
343 if (_Py_IsFinalizing())
return;
348NS(sFactoryDataCopy) (
352 PyObject *arg = *dataP;
371static OT_ProcRet NS(MqFactoryC_HandleResolve) (OtClass_ARGS) {
375 OT_CHECK_REQUIRED(OT_CHECK_NIH (netHdl))
378 OT_retObj_SET_FCT(retVal)
400static OT_ProcRet NS(MqFactoryC_Next) (MqFactoryC_ARGS) {
405 OT_retObj_SET_FCT(retVal)
414static OT_ProcRet NS(MqFactoryC_Prev) (MqFactoryC_ARGS) {
419 OT_retObj_SET_FCT(retVal)
430static OT_ProcRet NS(MqFactoryC_Instances) (OtClass_ARGS) {
435 OT_retObj_SET_FCT(retVal)
453static OT_ProcRet NS(MqFactoryC_GetNull) (OtClass_ARGS) {
458 OT_retObj_SET_FCT(retVal)
476static OT_ProcRet NS(MqFactoryC_Get) (OtClass_ARGS) {
480 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
483 OT_retObj_SET_FCT(retVal)
492static OT_ProcRet NS(MqFactoryC_GetCalled) (OtClass_ARGS) {
496 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
499 OT_retObj_SET_FCT(retVal)
508static OT_ProcRet NS(MqFactoryC_GetCalledL) (OtClass_ARGS) {
512 OT_CHECK_REQUIRED(OT_CHECK_BFLN (largs,
MK_NULL_NO))
515 OT_retObj_SET_FCT(retVal)
526static OT_ProcRet NS(MqFactoryC_GetOriginalIdent) (MqFactoryC_ARGS) {
548static OT_ProcRet NS(MqFactoryC_Default) (MqFactoryC_ARGS) {
553 OT_retObj_SET_FCT(retVal)
562static OT_ProcRet NS(MqFactoryC_Initial) (MqFactoryC_ARGS) {
567 OT_retObj_SET_FCT(retVal)
578static OT_ProcRet NS(MqFactoryC_New) (MqFactoryC_ARGS) {
584 OT_retObj_SET_CTX(val_out)
599static OT_ProcRet NS(MqFactoryC_DefaultIdent) (OtClass_ARGS) {
612static OT_ProcRet NS(MqFactoryC_InitialIdent) (OtClass_ARGS) {
625static OT_ProcRet NS(MqFactoryC_LogAll) (OtClass_ARGS) {
629 OT_CHECK_OPTIONAL(OT_CHECK_STRN (callfunc))
652static OT_ProcRet NS(MqFactoryC_Dup2) (MqFactoryC_ARGS) {
656 OT_CHECK_REQUIRED(OT_CHECK_STRN (ident))
659 if (retVal == NULL) {
660 OT_ERROR_CONSTRUCTOR(MqFactoryC)
663 OT_retObj_SET_FCT(retVal)
674static OT_ProcRet NS(MqFactoryC_Add) (OtClass_ARGS) {
678 OT_CHECK_REQUIRED(OT_CHECK_CONSTRUCTOR(constructor))
680 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
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)
688 OT_CONSTRUCTOR_POST(retVal)
689 OT_retObj_SET_FCT(retVal)
698static OT_ProcRet NS(MqFactoryC_new) (CONSTR_ARGS) {
700 OT_SETUP_CONSTRUCTOR_ARGS(1,2,
new_doc)
702 OT_CHECK_REQUIRED(OT_CHECK_CONSTRUCTOR(constructor))
704 OT_CHECK_OPTIONAL(OT_CHECK_STRN (ident))
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)
711 OT_CONSTRUCTOR_POST(retVal)
731static PyMethodDef NS(MqFactoryC_Methods)[] = {
735 {
"Add" , (PyCFunction) NS(MqFactoryC_Add) , METH_VARARGS|METH_CLASS ,
Add_doc },
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 },
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 },
755 {
"Dup2" , (PyCFunction) NS(MqFactoryC_Dup2) , METH_O ,
Dup2_doc },
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 },
764 {
"New" , (PyCFunction) NS(MqFactoryC_New) , METH_NOARGS ,
New_doc },
767 {
"GetOriginalIdent" , (PyCFunction) NS(MqFactoryC_GetOriginalIdent) , METH_NOARGS ,
GetOriginalIdent_doc },
773 {NULL, NULL, 0, NULL}
776static PyObject* NS(sMqFactoryC_Str) (MqFactoryC_Obj *self) {
778 return STRN2VAL(
MkSysPrintF(
"MqFactoryC[%s]", self->hdl ? self->hdl->originalIdent : NULL));
796 NS(sFactoryDTor), NULL, NULL, NULL,
803 PyErr_SetString(PyExc_RuntimeError,
"MqFactoryS exception");
815 PyVarObject_HEAD_INIT(NULL, 0)
816 .tp_name =
"pymqmsgque.MqFactoryC",
817 .tp_doc =
"PyMqMsgque MqFactoryC Type",
818 .tp_itemsize =
sizeof(MqFactoryC_Obj),
820 .tp_new = (newfunc) NS(MqFactoryC_new),
821 .tp_methods = NS(MqFactoryC_Methods),
822 .tp_flags = Py_TPFLAGS_DEFAULT,
824 .tp_str = (reprfunc) NS(sMqFactoryC_Str)
#define OT_SETUP_hdl_static_constr
#define GetOriginalIdent_doc
#define OT_retObj_CONSTR(mng)
#define HandleResolve_doc
#define OT_SETUP_hdl_static
#define OT_SETUP_hdl_constr
#define MkBufferListCreateTLS_T(name, num)
#define MkErrorGetCode_0E()
#define MkErrorStack_0E()
#define MkErrorSetC_3_NULL(...)
#define MkErrorSetC_1E(message)
bool MkSysStringIsNULL(MK_STRN str)
#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
struct MkBufferS::@5 storage
PUBLIC data structure for the pymqmsgque-specific-data
data used to define a factory