theKernel 10.0
Loading...
Searching...
No Matches
MkCall_py.c File Reference

tag: nhi1-release-250425 More...

#include "LibMkKernel_py.h"
#include "misc_check_py.h"
+ Include dependency graph for MkCall_py.c:

Go to the source code of this file.

Functions

enum MkErrorE pymkkernel_CheckCallable (OT_Check_ARGS, MK_CBP *retP)
 
enum MkErrorE pymkkernel_ObjectDeleteCall (MK_RT mkrt, MK_OBJN const obj, MK_STRN const typeName, MK_HDL const typeHdl, MK_HDL const objHdl, MK_CBP const __data__)
 
void pymkkernel_ObjectDeleteFree (MkObjectDeleteFreeF_ARGS)
 
void pymkkernel_ObjectDeleteFree2 (MkObjectDeleteFreeF_ARGS)
 

Detailed Description

tag: nhi1-release-250425

Definition in file MkCall_py.c.

Function Documentation

◆ pymkkernel_CheckCallable()

enum MkErrorE pymkkernel_CheckCallable ( OT_Check_ARGS ,
MK_CBP * retP )

Definition at line 14 of file MkCall_py.c.

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}
#define OT_TUPLE_GET_ITEM(_obj, _skip)
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 …
@ MK_OK
(persistent) everything is OK.
MK_PTRB * MK_CBP
generic pointer to call-back data
#define MK_RT_PTR
#define OT_ERROR_STACK
#define WrongNumArgs(...)
#define WrongCallableError(got)
OT_OBJ_T callable

◆ pymkkernel_ObjectDeleteCall()

enum MkErrorE pymkkernel_ObjectDeleteCall ( MK_RT mkrt,
MK_OBJN const obj,
MK_STRN const typeName,
MK_HDL const typeHdl,
MK_HDL const objHdl,
MK_CBP const __data__ )

Definition at line 69 of file MkCall_py.c.

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}
#define HDL2VAL(nat)
#define OT_ERROR_LNG_2_META(m)
#define STRN2VAL(nat)
#define MkErrorStack_0E_Check()
#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

◆ pymkkernel_ObjectDeleteFree()

void pymkkernel_ObjectDeleteFree ( MkObjectDeleteFreeF_ARGS )

Definition at line 96 of file MkCall_py.c.

97{
98 MK(CallFree)(dataP);
99}
#define MK(n)

◆ pymkkernel_ObjectDeleteFree2()

void pymkkernel_ObjectDeleteFree2 ( MkObjectDeleteFreeF_ARGS )

Definition at line 102 of file MkCall_py.c.

103{
104 MK(CallFree)(dataP);
105}