theLink 10.0
Loading...
Searching...
No Matches
MqCall_py.c
Go to the documentation of this file.
1
9/* LABEL-NO */
10
12#include "misc_check_py.h"
13/*
14[ServiceCall signature]
15 1. The *service-ctx* is the *context* for which the service was defined.
16
17 callback-args := service-ctx:MqContextC[in]
18 [static] def callback ( callback-args )
19 [instance] class YYY:
20 def callback ( self, callback-args )
21 [class] class ZZZ:
22 @staticmethod
23 def callback ( callback-args )
24[ServiceCall signature]
25*/
26
27enum MkErrorE
28NS(ServiceCall) ( MQ_SERVICE_CALL_ARGS )
29{
31
32 PyObject * const callable = (PyObject*) __data__;
33 PyObject * selfarg = OT_SELF_X(mqctx);
34 PyObject * resultO = NULL;
35
36 // test if already deleted
37 if (VAL2CTX(selfarg) == NULL) {
38 return MkErrorSetC_2M(mqctx, "object is NULL");
39 } else if (Py_REFCNT(selfarg) == 0) {
40 return MK_OK;
41 }
42
43// PyThreadState* ts = PyThreadState_Swap(MK_RT_REF.mkThreadData.ptr);
44//printV("ts start: %p → %p", ts, MK_RT_REF.mkThreadData.ptr);
45
46 PyErr_Clear();
47
48 // for methods of the instance 'self' the argument 'self' is already set
49 if (PyMethod_Check(callable)) {
50 PyObject* mself = PyMethod_Self(callable);
51 if (mself == selfarg) {
52 selfarg = NULL;
53 }
54 }
55
56 // call the function
57 resultO = PyObject_CallFunctionObjArgs(callable, selfarg, NULL);
58
59 // no error return OK
60 if (resultO == NULL) goto error;
61
62 Py_CLEAR(resultO);
63 return MkErrorGetCodeI(&MkERROR); /* MkErrorGetCode_0E() */
64
65error:
67
68 return MkErrorStack_0E_Check();
69}
70
71void
72MK_DECL NS(ServiceFree) (
74 MQ_CTX const context,
75 MK_PTR *dataP
76)
77{
78 MK(CallFree)(dataP);
79}
80
81void
82MK_DECL NS(ServiceCopy) (
84 MQ_CTX const context,
85 MK_PTR *dataP
86)
87{
88 PyObject* self = (PyObject*)MkOBJ_R(context).self;
89
90//printSelf(self)
91
92 PyObject* callable = (PyObject*)(*dataP);
93 if (PyMethod_Check(callable)) {
94 //PyObject* oldself = PyMethod_Self(callable);
95//printSelf(oldself)
96 PyObject* const function = PyMethod_Function(callable);
97 if (function == NULL) {
98 MkPanicC_4M(context,__func__,-1,"unable to 'PyMethod_Function'");
99 } else {
100 callable = PyMethod_New(function, self);
101 if (callable == NULL) {
102 MkPanicC_4M(context,__func__,-1,"unable to 'PyMethod_New'");
103 } else {
104 *dataP = callable;
105 }
106 }
107 }
108 Py_INCREF(*dataP);
109}
110
#define MK(n)
#define OT_SELF_X(x)
#define OT_ERROR_LNG_2_META(m)
tag: nhi1-release-250425
#define NS(n)
#define VAL2CTX(val)
#define error
Definition high_lng.h:339
#define mqctx
#define MkErrorGetCodeI(e)
#define MkErrorStack_0E_Check()
#define MkPanicC_4M(errobj, callfunc, errnum, message)
#define MkErrorSetC_2M(err, message)
#define MkERROR
#define MK_DECL
MkErrorE
MK_OK
MK_PTRB * MK_PTR
#define MkOBJ_R(x)
#define MK_RT_ARGS
#define MQ_SERVICE_CALL_CHECK
#define MQ_SERVICE_CALL_ARGS
the MqTokenF arguments with default names
PUBLIC data structure for the pymqmsgque-specific-data