theKernel 10.0
Loading...
Searching...
No Matches
MkCall_py.c
Go to the documentation of this file.
1
9/* LABEL-NO */
10
11#include "LibMkKernel_py.h"
12#include "misc_check_py.h"
13
16 MK_CBP *retP
17) {
18 assert(retP);
19 if ((*skipP) >= objc) {
20 WrongNumArgs(hdl,(*skipP), objc, -999, +999, arg);
21 goto error;
22 }
23 PyObject *val = OT_TUPLE_GET_ITEM(objv,(*skipP)++);
24 if (!PyCallable_Check(val)) {
25 if (val == Py_None) {
26 *retP = NULL;
27 return MK_OK;
28 } else if (PyUnicode_Check(val)) {
29 Py_ssize_t size=0;
30 const char * tmp = PyUnicode_AsUTF8AndSize(val, &size);
31 if (tmp[0] == '\0' || MK_NULL_STR_CHECK(tmp,size)) {
32 *retP = NULL;
33 return MK_OK;
34 }
36 } else {
37 WrongCallableError(OT_OBJ_TYPE_STRING(val));
38 }
39 }
40 if (*retP != NULL) {
41 MkCallS *cbS = *retP;
42 cbS->mkrt = MK_RT_PTR;
43 cbS->hdl = hdl;
44 cbS->callable = Py_NewRef(val);
45 } else {
46 *retP = (MK_CBP)Py_NewRef(val);
47//printP(*retP)
48 }
49 return MK_OK;
50error:
51 return OT_ERROR_STACK;
52}
53
54// *********************************************************************
55
56/*
57[ObjectDeleteCall signature]
58 callback-args := typeName:MK_STRN[in], typeHdl:MK_HDL[in], objHdl:MK_HDL[in]
59 [static] def callback ( callback-args )
60 [instance] class YYY:
61 def callback ( self, callback-args )
62 [class] class ZZZ:
63 @staticmethod
64 def callback ( callback-args )
65[ObjectDeleteCall signature]
66*/
67
68enum MkErrorE
69NS(ObjectDeleteCall) ( MkObjectDeleteCallF_ARGS )
70{
72
73 // if NO self object is available than NO callback is called
74 if (!MkSelfExists(obj)) return MK_OK;
75
76 // if NO self object is available than NO python callback is called
77 PyObject * const callable = (PyObject*) __data__;
78 PyObject * resultO = NULL;
79
80 PyErr_Clear();
81
82 // call the function
83 resultO = PyObject_CallFunctionObjArgs(callable, STRN2VAL(typeName), HDL2VAL(typeHdl), HDL2VAL(objHdl), NULL);
84
85 // no error return OK
86 if (resultO == NULL) {
88 } else {
89 Py_CLEAR(resultO);
90 }
91
92 return MkErrorStack_0E_Check();
93}
94
95void
96MK_DECL NS(ObjectDeleteFree) ( MkObjectDeleteFreeF_ARGS )
97{
98 MK(CallFree)(dataP);
99}
100
101void
102MK_DECL NS(ObjectDeleteFree2) ( MkObjectDeleteFreeF_ARGS )
103{
104 MK(CallFree)(dataP);
105}
106
107// vim: tags+=$theKenel_SRCDIR/py/tags
tag: nhi1-release-250425
#define HDL2VAL(nat)
#define MK(n)
#define OT_Check_ARGS
#define NS(n)
#define OT_TUPLE_GET_ITEM(_obj, _skip)
#define OT_ERROR_LNG_2_META(m)
#define STRN2VAL(nat)
#define MkErrorStack_0E_Check()
#define MK_DECL
static bool MK_NULL_STR_CHECK(char const *const __str, const long int __len)
check if __str is MK_NULL_STR return true or false …
MkErrorE
collection for the different error-codes …
@ MK_OK
(persistent) everything is OK.
MK_PTRB * MK_CBP
generic pointer to call-back data
#define MkObjectC_TT
class as MkTypeS-class-type, useable in a class-macro as: class##_TT …
static bool MkSelfExists(MK_OBJN obj)
Check if the MkObjectS::self exists …
#define MkObjectDeleteCallF_CHECK
validate call to MkObjectDeleteCallF
#define MkObjectDeleteCallF_ARGS
the MkObjectDeleteCallF arguments with default names
#define MkObjectDeleteFreeF_ARGS
the MkObjectDeleteFreeF arguments with default names
#define MK_RT_PTR
#define OT_ERROR_STACK
#define WrongNumArgs(...)
#define WrongCallableError(got)
MK_EXTERN enum MkErrorE MK_DECL MK CheckCallable(OT_Check_ARGS, MK_CBP *)
OT_OBJ_T callable