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

tag: nhi1-release-250425 More...

#include "LibMkKernel_private_py.h"
#include "misc_check_py.h"
#include "tmpl/mk_misc_ObjAs_lng.h"
#include "tmpl/mk_misc_check_lng.h"
+ Include dependency graph for LibMkKernel_py.c:

Go to the source code of this file.

Data Structures

struct  MkKernelStateS
 

Macros

#define OT_SETUP_hdl
 
#define OT_SETUP_hdl_static
 
#define MkSetupTmpl()
 
#define MkCleanupTmpl()
 
#define ErrorE_FromInt_doc   "MkErrorE ErrorE_FromInt(value:int32)"
 
#define IdSE_FromInt_doc   "MkIdSE IdSE_FromInt(value:int32)"
 
#define TimeoutE_FromInt_doc   "MkTimeoutE TimeoutE_FromInt(value:int32)"
 
#define TypeE_FromInt_doc   "MkTypeE TypeE_FromInt(value:int32)"
 
#define ErrorE_ToInt_doc   "int32 ErrorE_ToInt(value:MkErrorE)"
 
#define ErrorE_ToString_doc   "string ErrorE_ToString(value:MkErrorE)"
 
#define IdSE_ToInt_doc   "int32 IdSE_ToInt(value:MkIdSE)"
 
#define IdSE_ToString_doc   "string IdSE_ToString(value:MkIdSE)"
 
#define TimeoutE_ToInt_doc   "int32 TimeoutE_ToInt(value:MkTimeoutE)"
 
#define TimeoutE_ToString_doc   "string TimeoutE_ToString(value:MkTimeoutE)"
 
#define TypeE_ToInt_doc   "int32 TypeE_ToInt(value:MkTypeE)"
 
#define TypeE_ToString_doc   "string TypeE_ToString(value:MkTypeE)"
 
#define Cleanup_doc   "Cleanup()"
 
#define Setup_doc   "Setup()"
 
#define Debug_doc   "Debug(prefix:str, ?obj:object?)"
 
#define FRAME_init
 

Functions

static enum MkErrorE pymkkernel_LngListToMkBufferListS (MK_RT mkrt, PyObject *argsO, struct MkBufferListS **argsP)
 
enum MkErrorE pymkkernel_LngTupleToMkBufferListS (MK_RT mkrt, Py_ssize_t objc, PyObject *objv, Py_ssize_t *origskip, MK_BFL *argsP)
 
MK_STRN pymkkernel_Get_Call_Proc (Py_ssize_t idx, PyObject **frameP)
 
MK_STRN pymkkernel_Get_Call_Code (Py_ssize_t idx, PyObject **frameP)
 
MK_STRN pymkkernel_Get_Call_Script (Py_ssize_t idx, PyObject **frameP)
 
MK_I32 pymkkernel_Get_Call_Line (Py_ssize_t idx, PyObject **frameP)
 
bool pymkkernel_Get_Call_Stack (MK_RT mkrt, MK_ERR const err, Py_ssize_t idx, PyObject **frameP)
 
const char * pymkkernel_LngObjToString (PyObject *obj)
 
MK_OBJ pymkkernel_LngObjToMqPtr (PyObject *obj)
 
void pymkkernel_LngUnicodeObjToBuffer (PyObject *obj, MK_STR buffer, MK_SIZE sz, MK_STRN def)
 
PyObject * pymkkernel_Debug (OtClass_ARGS)
 
static OT_ProcRet pymkkernel_MkKernel_ErrorE_FromInt (OtClass_ARGS)
  Python: [static] MkErrorE ErrorE_FromInt(value:int32) C-API
return the MkErrorE from integer …
 
static OT_ProcRet pymkkernel_MkKernel_IdSE_FromInt (OtClass_ARGS)
  Python: [static] MkIdSE IdSE_FromInt(value:int32) C-API
return the MkIdSE from integer …
 
static OT_ProcRet pymkkernel_MkKernel_TimeoutE_FromInt (OtClass_ARGS)
  Python: [static] MkTimeoutE TimeoutE_FromInt(value:int32) C-API
return the MkTimeoutE from integer …
 
static OT_ProcRet pymkkernel_MkKernel_TypeE_FromInt (OtClass_ARGS)
  Python: [static] MkTypeE TypeE_FromInt(value:int32) C-API
return the MkTypeE from integer …
 
static OT_ProcRet pymkkernel_MkKernel_ErrorE_ToInt (OtClass_ARGS)
  Python: [static] int32 ErrorE_ToInt(value:MkErrorE) C-API
return the MkErrorE as integer …
 
static OT_ProcRet pymkkernel_MkKernel_ErrorE_ToString (OtClass_ARGS)
  Python: [static] string ErrorE_ToString(value:MkErrorE) C-API
return the MkErrorE as string …
 
static OT_ProcRet pymkkernel_MkKernel_IdSE_ToInt (OtClass_ARGS)
  Python: [static] int32 IdSE_ToInt(value:MkIdSE) C-API
return the MkIdSE as integer …
 
static OT_ProcRet pymkkernel_MkKernel_IdSE_ToString (OtClass_ARGS)
  Python: [static] string IdSE_ToString(value:MkIdSE) C-API
return the MkIdSE as string …
 
static OT_ProcRet pymkkernel_MkKernel_TimeoutE_ToInt (OtClass_ARGS)
  Python: [static] int32 TimeoutE_ToInt(value:MkTimeoutE) C-API
return the MkTimeoutE as integer …
 
static OT_ProcRet pymkkernel_MkKernel_TimeoutE_ToString (OtClass_ARGS)
  Python: [static] string TimeoutE_ToString(value:MkTimeoutE) C-API
return the MkTimeoutE as string …
 
static OT_ProcRet pymkkernel_MkKernel_TypeE_ToInt (OtClass_ARGS)
  Python: [static] int32 TypeE_ToInt(value:MkTypeE) C-API
return the MkTypeE as integer …
 
static OT_ProcRet pymkkernel_MkKernel_TypeE_ToString (OtClass_ARGS)
  Python: [static] string TypeE_ToString(value:MkTypeE) C-API
return the MkTypeE as string …
 
static OT_ProcRet pymkkernel_MkKernel_Cleanup (OtClass_ARGS)
  Python: [static] Cleanup() C-API
cleanup pymkkernel internal memory …
 
static OT_ProcRet pymkkernel_MkKernel_Setup (OtClass_ARGS)
  Python: [static] Setup() C-API
setup pymkkernel internal memory …
 
static MK_UNUSED pid_t pymkkernel_sFork (void)
 
static MK_UNUSED MkKernelStateSpymkkernel_sMkKernelGetState (PyObject *module)
 
static MK_UNUSED int pymkkernel_sMkKernelTraverse (PyObject *module, visitproc visit, void *arg)
 
static MK_UNUSED int pymkkernel_sMkKernelClear (PyObject *module)
 
static void pymkkernel_sMkKernelFree (void *module)
 
static int pymkkernel_sMkKernelExec (PyObject *module)
 
PyMODINIT_FUNC LibMkKernel (void)
 

Variables

OT_OBJ_T pymkkernel_pymkkernel = NULL
 
static PyMethodDef pymkkernel_sMkKernelMethods []
 
__thread MkKernelThreadStateS pymkkernel_MkKernelThreadState = {0}
 
static MK_UNUSED PyModuleDef_Slot pymkkernel_sMkKernelDefSlots []
 
static PyModuleDef pymkkernel_sMkKernelDef
 

Detailed Description

tag: nhi1-release-250425

Definition in file LibMkKernel_py.c.

Macro Definition Documentation

◆ Cleanup_doc

#define Cleanup_doc   "Cleanup()"

Definition at line 160 of file LibMkKernel_py.c.

◆ Debug_doc

#define Debug_doc   "Debug(prefix:str, ?obj:object?)"

Definition at line 165 of file LibMkKernel_py.c.

◆ ErrorE_FromInt_doc

#define ErrorE_FromInt_doc   "MkErrorE ErrorE_FromInt(value:int32)"

doc definition

Definition at line 144 of file LibMkKernel_py.c.

◆ ErrorE_ToInt_doc

#define ErrorE_ToInt_doc   "int32 ErrorE_ToInt(value:MkErrorE)"

Definition at line 150 of file LibMkKernel_py.c.

◆ ErrorE_ToString_doc

#define ErrorE_ToString_doc   "string ErrorE_ToString(value:MkErrorE)"

Definition at line 151 of file LibMkKernel_py.c.

◆ FRAME_init

#define FRAME_init
Value:
OT_OBJ_T stack = 0; \
if (frameP == NULL || *frameP == 0) { \
LngErrorCheckN(stack = PyObject_CallNoArgs(NS(MkKernelThreadState).inspect_stack)); \
if (frameP != NULL) *frameP = stack; \
} else { \
stack = *frameP; \
} \
#define NS(n)
PyObject * OT_OBJ_T

Definition at line 278 of file LibMkKernel_py.c.

278#define FRAME_init \
279 OT_OBJ_T stack = 0; \
280 if (frameP == NULL || *frameP == 0) { \
281 LngErrorCheckN(stack = PyObject_CallNoArgs(NS(MkKernelThreadState).inspect_stack)); \
282 if (frameP != NULL) *frameP = stack; \
283 } else { \
284 stack = *frameP; \
285 } \
286

◆ IdSE_FromInt_doc

#define IdSE_FromInt_doc   "MkIdSE IdSE_FromInt(value:int32)"

Definition at line 145 of file LibMkKernel_py.c.

◆ IdSE_ToInt_doc

#define IdSE_ToInt_doc   "int32 IdSE_ToInt(value:MkIdSE)"

Definition at line 152 of file LibMkKernel_py.c.

◆ IdSE_ToString_doc

#define IdSE_ToString_doc   "string IdSE_ToString(value:MkIdSE)"

Definition at line 153 of file LibMkKernel_py.c.

◆ MkCleanupTmpl

#define MkCleanupTmpl ( )

Definition at line 26 of file LibMkKernel_py.c.

◆ MkSetupTmpl

#define MkSetupTmpl ( )

Definition at line 25 of file LibMkKernel_py.c.

◆ OT_SETUP_hdl

#define OT_SETUP_hdl
Value:
#define MK_ERROR_PRINT
#define MkRtSetup_NULL
object header …

Definition at line 14 of file LibMkKernel_py.c.

14#define OT_SETUP_hdl MkRtSetup_NULL; \
15 MK_OBJ hdl = MK_ERROR_PRINT;

◆ OT_SETUP_hdl_static

#define OT_SETUP_hdl_static
Value:
__attribute__((unused)) MK_RT mkrt = MkRT; \
__attribute__((unused)) MK_ERR hdl = &MkERROR;
#define MkERROR
#define MkRT
The data-type to store and handle the error-condition …
The MkRuntimeS provide a per-thread environment for pymkkernel …

Definition at line 16 of file LibMkKernel_py.c.

16#define OT_SETUP_hdl_static __attribute__((unused)) MK_RT mkrt = MkRT; \
17 __attribute__((unused)) MK_ERR hdl = &MkERROR;

◆ Setup_doc

#define Setup_doc   "Setup()"

Definition at line 161 of file LibMkKernel_py.c.

◆ TimeoutE_FromInt_doc

#define TimeoutE_FromInt_doc   "MkTimeoutE TimeoutE_FromInt(value:int32)"

Definition at line 146 of file LibMkKernel_py.c.

◆ TimeoutE_ToInt_doc

#define TimeoutE_ToInt_doc   "int32 TimeoutE_ToInt(value:MkTimeoutE)"

Definition at line 154 of file LibMkKernel_py.c.

◆ TimeoutE_ToString_doc

#define TimeoutE_ToString_doc   "string TimeoutE_ToString(value:MkTimeoutE)"

Definition at line 155 of file LibMkKernel_py.c.

◆ TypeE_FromInt_doc

#define TypeE_FromInt_doc   "MkTypeE TypeE_FromInt(value:int32)"

Definition at line 147 of file LibMkKernel_py.c.

◆ TypeE_ToInt_doc

#define TypeE_ToInt_doc   "int32 TypeE_ToInt(value:MkTypeE)"

Definition at line 156 of file LibMkKernel_py.c.

◆ TypeE_ToString_doc

#define TypeE_ToString_doc   "string TypeE_ToString(value:MkTypeE)"

Definition at line 157 of file LibMkKernel_py.c.

Function Documentation

◆ LibMkKernel()

PyMODINIT_FUNC LibMkKernel ( void )

Public API

Definition at line 1044 of file LibMkKernel_py.c.

1045{
1046 // Multi-phase initialization
1047 return PyModuleDef_Init(&NS(sMkKernelDef));
1048}

◆ pymkkernel_Debug()

PyObject * pymkkernel_Debug ( OtClass_ARGS )

Method definition

Definition at line 479 of file LibMkKernel_py.c.

479 {
480 PyObject *strO=NULL, *utf8=NULL;
483 MK_STRN prefix=NULL;
485 OT_SETUP_OBJ(obj,class)
488 LngErrorCheckN(strO = PyObject_Repr(obj));
489 LngErrorCheckN(utf8 = PyUnicode_AsUTF8String(strO));
490 MkLogV_4M(hdl,prefix,0,"%s, type=%s, refCnt=%-3zi\n",
491 PyBytes_AsString(utf8), Py_TYPE(obj)->tp_name, Py_REFCNT(obj)-1);
493 goto end;
494error:
496end:
497 Py_CLEAR(strO);
498 Py_CLEAR(utf8);
499 return retObj;
500}
#define Debug_doc
#define OT_SETUP_hdl
#define LngErrorCheckN(PROC)
#define OT_SETUP_VARARGS(min, max, d)
#define OT_SETUP_OBJ(o, v)
#define OT_retObj_SET_Error
#define OT_CHECK_REQUIRED(val)
#define OT_retObj_SET_None
#define OT_CHECK_OPTIONAL(val)
#define OT_CHECK_NOARGS
const MK_STRB * MK_STRN
constant string pointer data-type
#define MkLogV_4M(x, callfunc, debug, printfmt,...)
#define OT_CHECK_STR(val)
#define OT_CHECK_LNG_T(val)

◆ pymkkernel_Get_Call_Code()

MK_STRN pymkkernel_Get_Call_Code ( Py_ssize_t idx,
PyObject ** frameP )

Definition at line 310 of file LibMkKernel_py.c.

310 {
311 PyObject *frameO=NULL, *valO = NULL, *lstO=NULL;
313 if (!PyList_Check(stack)) goto error;
314 LngErrorCheckN(frameO = PyList_GET_ITEM(stack,idx));
315 if (!PyObject_HasAttrString(frameO,"code_context")) goto error;
316 LngErrorCheckN(lstO = PyObject_GetAttrString(frameO,"code_context"));
317 if (!PyList_Check(lstO)) goto error;
318 LngErrorCheckN(valO = PyList_GET_ITEM(lstO,0));
319
320error:
321 if (valO != NULL) {
322 static __thread char buffer[256];
323 NS(LngUnicodeObjToBuffer)(valO,buffer,256,"none");
324 Py_CLEAR(lstO);
325 char *bufP = buffer, *endP=buffer+strlen(buffer)-1;
326 while (isspace(*bufP) && *bufP != '\0') bufP++;
327 while (isspace(*endP) && endP > bufP) endP--;
328 *(endP+1) = '\0';
329 return bufP;
330 } else {
331 return "none";
332 }
333}
#define FRAME_init

◆ pymkkernel_Get_Call_Line()

MK_I32 pymkkernel_Get_Call_Line ( Py_ssize_t idx,
PyObject ** frameP )

Definition at line 353 of file LibMkKernel_py.c.

353 {
354 PyObject *frameO=NULL, *valO = NULL;
356 LngErrorCheckN(frameO = PyList_GET_ITEM(stack,idx));
357 LngErrorCheckN(valO = PyObject_GetAttrString(frameO,"lineno"));
358error:
359 if (valO != NULL && CHECK_LONG(valO)) {
360 MK_I32 ret = (int) PyLong_AsLong(valO);
361 Py_CLEAR(valO);
362 return ret;
363 } else {
364 return -1;
365 }
366}
signed int MK_I32
4 byte integer data-type

◆ pymkkernel_Get_Call_Proc()

MK_STRN pymkkernel_Get_Call_Proc ( Py_ssize_t idx,
PyObject ** frameP )

Definition at line 287 of file LibMkKernel_py.c.

287 {
288 PyObject *frameO=NULL, *valO = NULL;
290 if (!PyList_Check(stack)) goto error;
291 LngErrorCheckN(frameO = PyList_GET_ITEM(stack,idx));
292 if (!PyObject_HasAttrString(frameO,"function")) goto error;
293 LngErrorCheckN(valO = PyObject_GetAttrString(frameO,"function"));
294
295error:
296 if (valO != NULL) {
297 static __thread char buffer[256];
298 NS(LngUnicodeObjToBuffer)(valO,buffer,256,"none");
299 Py_CLEAR(valO);
300 char *bufP = buffer, *endP=buffer+strlen(buffer)-1;
301 while (isspace(*bufP) && *bufP != '\0') bufP++;
302 while (isspace(*endP) && endP > bufP) endP--;
303 *(endP+1) = '\0';
304 return bufP;
305 } else {
306 return "none";
307 }
308}

◆ pymkkernel_Get_Call_Script()

MK_STRN pymkkernel_Get_Call_Script ( Py_ssize_t idx,
PyObject ** frameP )

Definition at line 335 of file LibMkKernel_py.c.

335 {
336 PyObject *frameO=NULL, *valO = NULL;
338 if (!PyList_Check(stack)) goto error;
339 LngErrorCheckN(frameO = PyList_GET_ITEM(stack,idx));
340 if (!PyObject_HasAttrString(frameO,"filename")) goto error;
341 LngErrorCheckN(valO = PyObject_GetAttrString(frameO,"filename"));
342error:
343 if (valO != NULL) {
344 static __thread char buffer[256];
345 NS(LngUnicodeObjToBuffer)(valO,buffer,256,"none");
346 Py_CLEAR(valO);
347 return buffer;
348 } else {
349 return "none";
350 }
351}

◆ pymkkernel_Get_Call_Stack()

bool pymkkernel_Get_Call_Stack ( MK_RT mkrt,
MK_ERR const err,
Py_ssize_t idx,
PyObject ** frameP )

Definition at line 368 of file LibMkKernel_py.c.

368 {
370//printV("idx=%zd, PyList_GET_SIZE=%zd\n", idx, PyList_GET_SIZE(*stackOP))
371 if (idx >= PyList_GET_SIZE(stack)) return false;
373 NS(Get_Call_Code)(idx,&stack),
374 NS(Get_Call_Script)(idx,&stack),
375 NS(Get_Call_Line)(idx,&stack)
376 );
377 return true;
378error:
379 return false;
380}
#define MkErrorStackFormat(...)

◆ pymkkernel_LngListToMkBufferListS()

static enum MkErrorE pymkkernel_LngListToMkBufferListS ( MK_RT mkrt,
PyObject * argsO,
struct MkBufferListS ** argsP )
static

Definition at line 173 of file LibMkKernel_py.c.

177 {
178 enum MkErrorE ret = MK_OK;
179 PyObject *item=NULL, *strO=NULL, *iterator=NULL;
180 MK_BFL args = *argsP;
181 MK_BFL orig = args;
182 if (argsO == NULL) {
183 return MK_OK;
184 } else {
185 *argsP = NULL;
186 if (args == NULL) {
187 args = MkBufferListCreate ((MK_NUM)PyList_GET_SIZE(argsO));
188 }
189 iterator = PyObject_GetIter(argsO);
190 while ((item = PyIter_Next(iterator))) {
191 LngErrorCheckN (strO = PyObject_Str(item))
192 MkBufferListAppendSTR(args, PyUnicode_AsUTF8(strO));
193 Py_CLEAR(strO);
194 Py_CLEAR(item);
195 }
196 Py_CLEAR(iterator);
197 }
198 *argsP = args;
199end:
200 Py_CLEAR(strO);
201 Py_CLEAR(item);
202 Py_CLEAR(iterator);
203 return ret;
204error:
205 if (args && args != orig) MkBufferListDelete (args);
206 *argsP = orig;
207 ret = MK_ERROR;
208 goto end;
209}
#define MkBufferListAppendSTR(...)
#define MkBufferListCreate(...)
#define MkBufferListDelete(x)
MkErrorE
collection for the different error-codes …
@ MK_ERROR
(persistent) raise an error-event, the calling-fucntion is interrupted.
@ MK_OK
(persistent) everything is OK.
int32_t MK_NUM
array size data-type ('num' items in array …
The CLASS used to store a list of MkBufferS items into a flat array…

◆ pymkkernel_LngObjToMqPtr()

MK_OBJ pymkkernel_LngObjToMqPtr ( PyObject * obj)

Definition at line 456 of file LibMkKernel_py.c.

456 {
457 if (OT_LNG_OBJECT_IS(obj)) {
458 return VAL2OBJ(obj);
459 } else {
460 return NULL;
461 }
462}
#define OT_LNG_OBJECT_IS(objV)
#define VAL2OBJ(val)

◆ pymkkernel_LngObjToString()

const char * pymkkernel_LngObjToString ( PyObject * obj)

Definition at line 431 of file LibMkKernel_py.c.

431 {
432 if (obj == NULL ) {
433 return "NULL";
434 } else if (obj == Py_None) {
435 return "None";
436 } else if (PyUnicode_Check(obj)) {
437 return PyUnicode_AsUTF8(obj);
438 }
439
440 static __thread char buffer[1000];
441 PyObject *strO=PyObject_Str(obj);
442 check_NULL(strO) goto error;
443 MK_STRN str = PyUnicode_AsUTF8(strO);
444 check_NULL(str) goto error;
445 strncpy(buffer,str,1000);
446 buffer[1000-1] = '\0';
447 goto end;
448error:
449 strncpy(buffer,"*ERROR*",1000);
450end:
451 Py_CLEAR(strO);
452 return buffer;
453}
#define check_NULL(E)

◆ pymkkernel_LngTupleToMkBufferListS()

enum MkErrorE pymkkernel_LngTupleToMkBufferListS ( MK_RT mkrt,
Py_ssize_t objc,
PyObject * objv,
Py_ssize_t * origskip,
MK_BFL * argsP )

Definition at line 211 of file LibMkKernel_py.c.

217 {
218 enum MkErrorE ret = MK_OK;
219 PyObject *strO=NULL;
220 struct MkBufferListS * orig = *argsP;
221 struct MkBufferListS * args = orig;
222 Py_ssize_t __skip;
223 if (origskip==NULL) {
224 __skip = 0;
225 objc = PyTuple_GET_SIZE(objv);
226 } else {
227 __skip = *origskip;
228 }
229 if (objv == NULL) {
230 return MK_OK;
231 } else {
232 *argsP = NULL;
233 if (args == NULL)
234 args = MkBufferListCreate ((MK_NUM)(objc-__skip));
235 for (; __skip < objc; __skip++) {
236 LngErrorCheckN (strO = PyObject_Str(PyTuple_GET_ITEM(objv,__skip)))
237 MkBufferListAppendSTR(args, PyUnicode_AsUTF8(strO));
238 Py_CLEAR(strO);
239 }
240 }
241 *origskip = __skip;
242 *argsP = args;
243 goto end;
244error:
245 if (args && args != orig) {
246 MkRtSetup_XN(args);
247 MkBufferListDelete(args);
248 }
249 *argsP = orig;
250 ret = MK_ERROR;
251end:
252 Py_CLEAR(strO);
253 return ret;
254}
#define MkRtSetup_XN(x)

◆ pymkkernel_LngUnicodeObjToBuffer()

void pymkkernel_LngUnicodeObjToBuffer ( PyObject * obj,
MK_STR buffer,
MK_SIZE sz,
MK_STRN def )

Definition at line 465 of file LibMkKernel_py.c.

465 {
466 MK_STRN str=PyUnicode_Check(obj) ? PyUnicode_AsUTF8(obj) : def;
467 strncpy(buffer,str,(size_t)sz-1);
468 buffer[sz-2] = '~';
469 buffer[sz-1] = '\0';
470}

◆ pymkkernel_sFork()

static MK_UNUSED pid_t pymkkernel_sFork ( void )
static

Definition at line 785 of file LibMkKernel_py.c.

785 {
786 PyObject* ret = PyObject_CallNoArgs(MkLal.SysForkData);
787 if (ret == NULL) {
790 return -1;
791 }
792 return (pid_t) PyLong_AS_LONG(ret);
793}
#define OT_ERROR_LNG_2_META(m)
struct MkLalS MkLal
Language Abstraction Layer in duty.
MK_PTR SysForkData

◆ pymkkernel_sMkKernelClear()

static MK_UNUSED int pymkkernel_sMkKernelClear ( PyObject * module)
static

Definition at line 852 of file LibMkKernel_py.c.

853{
854 // BEGIN-EnumClear - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
855
856 Py_CLEAR(MkErrorE_lngO);
857 Py_CLEAR(MkIdSE_lngO);
858 Py_CLEAR(MkTimeoutE_lngO);
859 Py_CLEAR(MkTypeE_lngO);
860
861 // END-EnumClear - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
862 // BEGIN-ClassClear - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
863
864 Py_CLEAR(MkObjectC_MK_NULL);
865 Py_CLEAR(MkBufferC_MK_NULL);
866 Py_CLEAR(MkBufferStreamC_MK_NULL);
867 Py_CLEAR(MkBufferListC_MK_NULL);
868 Py_CLEAR(MkLogFileC_MK_NULL);
869 Py_CLEAR(MkErrorC_MK_NULL);
870 Py_CLEAR(MkRuntimeC_MK_NULL);
871
872 // END-ClassClear - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
873
874 Py_CLEAR(NS(MkKernelThreadState).MkExceptionC);
875 Py_CLEAR(NS(MkKernelThreadState).InitError);
876 Py_CLEAR(NS(MkKernelThreadState).InitSoftError);
877 Py_CLEAR(NS(MkKernelThreadState).inspect_stack);
878 Py_CLEAR(NS(MkKernelThreadState).emptyTuple);
879 return 0;
880}
#define MkIdSE_lngO
#define MkObjectC_MK_NULL
#define MkLogFileC_MK_NULL
#define MkTimeoutE_lngO
#define MkBufferListC_MK_NULL
#define MkErrorE_lngO
#define MkRuntimeC_MK_NULL
#define MkErrorC_MK_NULL
#define MkBufferC_MK_NULL
#define MkBufferStreamC_MK_NULL
#define MkTypeE_lngO

◆ pymkkernel_sMkKernelExec()

static int pymkkernel_sMkKernelExec ( PyObject * module)
static

Definition at line 893 of file LibMkKernel_py.c.

894{
895 MkSetup();
897
898 NS(MkKernelThreadState) = (MkKernelThreadStateS) {0};
899
900 MkKernelStateS *state = NS(sMkKernelGetState)(module);
901 state->mkrt = MK_RT_PTR;
902
903 PyObject *tmpO;
904 PyObject *mainM = PyImport_AddModule("__main__");
905 NS(pymkkernel) = module;
906
907 // BEGIN-CLASS-DEF - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
908
909 OtErrorCheckLng( NS(pMkObjectC_Init) (MK_RT_CALL module) ) ;
910 OtErrorCheckLng( NS(pMkBufferC_Init) (MK_RT_CALL module) ) ;
911 OtErrorCheckLng( NS(pMkBufferStreamC_Init) (MK_RT_CALL module) ) ;
912 OtErrorCheckLng( NS(pMkBufferListC_Init) (MK_RT_CALL module) ) ;
913 OtErrorCheckLng( NS(pMkLogFileC_Init) (MK_RT_CALL module) ) ;
914 OtErrorCheckLng( NS(pMkErrorC_Init) (MK_RT_CALL module) ) ;
915 OtErrorCheckLng( NS(pMkRuntimeC_Init) (MK_RT_CALL module) ) ;
916
917 // END-CLASS-DEF - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
918
919 LngErrorCheckN(tmpO = PyErr_NewException("pymkkernel.MkExceptionC", NULL, NULL));
920 OtErrorCheckLng(PyModule_AddObjectRef(module, "MkExceptionC", tmpO));
921 NS(MkKernelThreadState).MkExceptionC = tmpO;
922 // no Py_XDECREF(NS(MkExceptionC)) because I require TWO references 1xPyErr_NewException, 1xPyModule_AddObjectRef
923
924 // init ENUM
925 MK_STR enumCode =
926 "from enum import IntEnum, IntFlag\n"
927
928 // BEGIN-EnumCode - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
929
930 "class MkErrorE(IntEnum):\n"
931 " OK = 0\n"
932 " CONTINUE = 1\n"
933 " ERROR = 2\n"
934
935 "class MkIdSE(IntEnum):\n"
936 " UNUSED = 0\n"
937 " PROCESS = 1\n"
938 " THREAD = 2\n"
939
940 "class MkTimeoutE(IntEnum):\n"
941 " INIT = 900\n"
942 " LONG = 180\n"
943 " NORMAL = 90\n"
944 " SHORT = 20\n"
945 " SOCKET = 10\n"
946 " VERYSHORT = 5\n"
947 " DEFAULT = -1\n"
948 " USER = -2\n"
949 " MAX = -3\n"
950
951 "class MkTypeE(IntEnum):\n"
952 " I8T = 17\n"
953 " BOLT = 33\n"
954 " I16T = 50\n"
955 " I32T = 68\n"
956 " FLTT = 84\n"
957 " I64T = 104\n"
958 " DBLT = 120\n"
959 " BINT = 128\n"
960 " STRT = 144\n"
961 " LSTT = 160\n"
962
963 // END-EnumCode - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
964 ;
965
966 PyObject *mainD = PyModule_GetDict(mainM);
967 PyObject *myD = PyModule_GetDict(module);
968 tmpO = PyRun_String(enumCode, Py_file_input, mainD, myD);
969 LngErrorCheckN(tmpO);
970 Py_CLEAR(tmpO);
971
972 // BEGIN-EnumSet - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
973
974 MkErrorE_lngO = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MkErrorE"));
975 MkIdSE_lngO = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MkIdSE"));
976 MkTimeoutE_lngO = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MkTimeoutE"));
977 MkTypeE_lngO = (PyTypeObject*) Py_NewRef(PyDict_GetItemString(myD,"MkTypeE"));
978
979 // END-EnumSet - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
980
981 PyObject *nameO = PyObject_GetAttrString(mainM,"__name__");
982
983 if (strcmp(PyUnicode_AsUTF8(nameO),"__main__") == 0) {
984 // ONLY the first __main__ interpreter can FORK
985 tmpO = PyImport_ImportModule("os");
986 LngErrorCheckN(MkLal.SysForkData = PyObject_GetAttrString(tmpO,"fork"));
987 Py_CLEAR(tmpO);
988 MkLal.SysFork = NS(sFork);
989 }
990
991 // additional error classes
992 MK_STR errorCode = \
993 "class InitError(Exception):\n"
994 " pass\n"
995 "class InitSoftError(Exception):\n"
996 " pass\n"
997 ;
998 tmpO = PyRun_String(errorCode, Py_file_input, mainD, myD);
999 LngErrorCheckN(tmpO);
1000 Py_CLEAR(tmpO);
1001
1002 NS(MkKernelThreadState).InitError = Py_NewRef(PyDict_GetItemString(myD,"InitError"));
1003 NS(MkKernelThreadState).InitSoftError = Py_NewRef(PyDict_GetItemString(myD,"InitSoftError"));
1004
1005 // misc setup
1006 LngErrorCheckN(tmpO = PyImport_ImportModule("inspect"));
1007 LngErrorCheckN(NS(MkKernelThreadState).inspect_stack = PyObject_GetAttrString(tmpO,"stack"));
1008 Py_CLEAR(tmpO);
1009
1010 LngErrorCheckN(NS(MkKernelThreadState).emptyTuple = PyTuple_New(0));
1011
1012 //PyErr_SetString(PyExc_RuntimeError,"this is a test");
1013 return 0;
1014error:
1015 return -1;
1016}
#define OtErrorCheckLng(PROC)
void MkSetup(void)
setup pymkkernel internal memory …
MK_STRB * MK_STR
string pointer data-type with UTF8 ecoding (string)
#define MK_RT_PTR
#define MK_RT_CALL
MkSysForkF SysFork
fork syscall …

◆ pymkkernel_sMkKernelFree()

static void pymkkernel_sMkKernelFree ( void * module)
static

Definition at line 883 of file LibMkKernel_py.c.

884{
885 NS(sMkKernelClear)((PyObject *)module);
886
887 //MkLal.SysFork = NULL;
888
889 NS(MkKernelThreadState) = (MkKernelThreadStateS) {0};
890}

◆ pymkkernel_sMkKernelGetState()

static MK_UNUSED MkKernelStateS * pymkkernel_sMkKernelGetState ( PyObject * module)
inlinestatic

Definition at line 812 of file LibMkKernel_py.c.

813{
814 void *state = PyModule_GetState(module);
815 assert(state != NULL);
816 return (MkKernelStateS*)state;
817}

◆ pymkkernel_sMkKernelTraverse()

static MK_UNUSED int pymkkernel_sMkKernelTraverse ( PyObject * module,
visitproc visit,
void * arg )
static

Definition at line 820 of file LibMkKernel_py.c.

821{
822//mk_dbg_color_ln(MK_COLOR_GREEN,"module=%s", PyModule_GetName(module));
823 // BEGIN-EnumTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
824
825 Py_VISIT(MkErrorE_lngO);
826 Py_VISIT(MkIdSE_lngO);
827 Py_VISIT(MkTimeoutE_lngO);
828 Py_VISIT(MkTypeE_lngO);
829
830 // END-EnumTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
831 // BEGIN-ClassTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
832
833 Py_VISIT(MkObjectC_MK_NULL);
834 Py_VISIT(MkBufferC_MK_NULL);
835 Py_VISIT(MkBufferStreamC_MK_NULL);
836 Py_VISIT(MkBufferListC_MK_NULL);
837 Py_VISIT(MkLogFileC_MK_NULL);
838 Py_VISIT(MkErrorC_MK_NULL);
839 Py_VISIT(MkRuntimeC_MK_NULL);
840
841 // END-ClassTraverse - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
842
843 Py_VISIT(NS(MkKernelThreadState).MkExceptionC);
844 Py_VISIT(NS(MkKernelThreadState).InitError);
845 Py_VISIT(NS(MkKernelThreadState).InitSoftError);
846 Py_VISIT(NS(MkKernelThreadState).inspect_stack);
847 Py_VISIT(NS(MkKernelThreadState).emptyTuple);
848 return 0;
849}

Variable Documentation

◆ pymkkernel_MkKernelThreadState

__thread MkKernelThreadStateS pymkkernel_MkKernelThreadState = {0}

Public API

Definition at line 805 of file LibMkKernel_py.c.

805{0} ;

◆ pymkkernel_pymkkernel

OT_OBJ_T pymkkernel_pymkkernel = NULL

Definition at line 28 of file LibMkKernel_py.c.

◆ pymkkernel_sMkKernelDef

PyModuleDef pymkkernel_sMkKernelDef
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
.m_name = "pymkkernel",
.m_doc = "python language binding for 'theKernel'",
.m_size = sizeof(MkKernelStateS),
}
static void pymkkernel_sMkKernelFree(void *module)
static MK_UNUSED PyModuleDef_Slot pymkkernel_sMkKernelDefSlots[]
static PyMethodDef pymkkernel_sMkKernelMethods[]
static MK_UNUSED int pymkkernel_sMkKernelTraverse(PyObject *module, visitproc visit, void *arg)
static MK_UNUSED int pymkkernel_sMkKernelClear(PyObject *module)

Definition at line 1024 of file LibMkKernel_py.c.

1024 {
1025 PyModuleDef_HEAD_INIT,
1026 .m_name = "pymkkernel",
1027 .m_doc = "python language binding for 'theKernel'",
1028 .m_size = sizeof(MkKernelStateS),
1029 .m_methods = NS(sMkKernelMethods),
1030 .m_slots = NS(sMkKernelDefSlots),
1031 .m_traverse = NS(sMkKernelTraverse), // garbage collection
1032 .m_clear = NS(sMkKernelClear),
1033 .m_free = NS(sMkKernelFree),
1034};

◆ pymkkernel_sMkKernelDefSlots

MK_UNUSED PyModuleDef_Slot pymkkernel_sMkKernelDefSlots[]
static
Initial value:
= {
{Py_mod_exec, pymkkernel_sMkKernelExec },
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
}
static int pymkkernel_sMkKernelExec(PyObject *module)

Definition at line 1018 of file LibMkKernel_py.c.

1018 {
1019 {Py_mod_exec, NS(sMkKernelExec)},
1020 {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
1021 {0, NULL}
1022};

◆ pymkkernel_sMkKernelMethods

PyMethodDef pymkkernel_sMkKernelMethods[]
static

Type definition

Definition at line 749 of file LibMkKernel_py.c.

749 {
750 { "Debug", NS(Debug), METH_VARARGS, Debug_doc },
751
752 // BEGIN-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
753
754 // doc-key: MkKernel,EnumFunc,sco
755 { "ErrorE_FromInt" , (PyCFunction) NS(MkKernel_ErrorE_FromInt) , METH_O , ErrorE_FromInt_doc },
756 { "IdSE_FromInt" , (PyCFunction) NS(MkKernel_IdSE_FromInt) , METH_O , IdSE_FromInt_doc },
757 { "TimeoutE_FromInt" , (PyCFunction) NS(MkKernel_TimeoutE_FromInt) , METH_O , TimeoutE_FromInt_doc },
758 { "TypeE_FromInt" , (PyCFunction) NS(MkKernel_TypeE_FromInt) , METH_O , TypeE_FromInt_doc },
759
760 // doc-key: MkKernel,EnumFunc,sm_
761 { "ErrorE_ToInt" , (PyCFunction) NS(MkKernel_ErrorE_ToInt) , METH_O , ErrorE_ToInt_doc },
762 { "ErrorE_ToString" , (PyCFunction) NS(MkKernel_ErrorE_ToString) , METH_O , ErrorE_ToString_doc },
763 { "IdSE_ToInt" , (PyCFunction) NS(MkKernel_IdSE_ToInt) , METH_O , IdSE_ToInt_doc },
764 { "IdSE_ToString" , (PyCFunction) NS(MkKernel_IdSE_ToString) , METH_O , IdSE_ToString_doc },
765 { "TimeoutE_ToInt" , (PyCFunction) NS(MkKernel_TimeoutE_ToInt) , METH_O , TimeoutE_ToInt_doc },
766 { "TimeoutE_ToString" , (PyCFunction) NS(MkKernel_TimeoutE_ToString) , METH_O , TimeoutE_ToString_doc },
767 { "TypeE_ToInt" , (PyCFunction) NS(MkKernel_TypeE_ToInt) , METH_O , TypeE_ToInt_doc },
768 { "TypeE_ToString" , (PyCFunction) NS(MkKernel_TypeE_ToString) , METH_O , TypeE_ToString_doc },
769
770 // doc-key: MkKernel,Setup,sm_
771 { "Cleanup" , (PyCFunction) NS(MkKernel_Cleanup) , METH_NOARGS , Cleanup_doc },
772 { "Setup" , (PyCFunction) NS(MkKernel_Setup) , METH_NOARGS , Setup_doc },
773
774 // END-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
775
776 // BEGIN-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
777
778 // → no data
779
780 // END-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
781
782 {NULL, NULL, 0, NULL} /* Sentinel */
783};
#define IdSE_ToString_doc
#define TimeoutE_FromInt_doc
#define IdSE_ToInt_doc
#define ErrorE_ToString_doc
#define ErrorE_FromInt_doc
#define ErrorE_ToInt_doc
#define TypeE_ToInt_doc
#define TypeE_FromInt_doc
#define TimeoutE_ToString_doc
#define Cleanup_doc
#define Setup_doc
#define IdSE_FromInt_doc
#define TimeoutE_ToInt_doc
#define TypeE_ToString_doc