theKernel 10.0
Loading...
Searching...
No Matches
MkRuntimeC_py.c
Go to the documentation of this file.
1
9/* LABEL-START */
10
11#define META_FILE_NAME "MkRuntimeC_py.c"
12
14
15// PY class
16#define OT_CLASS (&NS(MkRuntimeCR))
17#define OT_CLASS_NAME "MkRuntimeC"
18
19#define OT_LNG2META(O) MkRt(VAL2MNG(O))
20
21#define OT_retObj_CONSTR(mng) OT_retObj_SET(NS(MkRuntimeC_CTOR)(MK_RT_CALL (PyTypeObject*)class,mng))
22
23#define OT_SETUP_hdl OT_SETUP_hdl_tmpl(MkRuntimeC)
24#define OT_SETUP_hdl__null_allow OT_SETUP_hdl_tmpl__null_allow(MkRuntimeC)
25#define OT_SETUP_hdl_constr MK_RT_UNUSED AllRtSetup_NULL; \
26 MK_RT hdl = (MK_RT) OT_CLASS;
27#define OT_SETUP_hdl_destr OT_SETUP_hdl_tmpl__null_allow(MkRuntimeC)
28#define OT_SETUP_hdl_static MK_RT_UNUSED AllRtSetup_NULL; \
29 __attribute__((unused)) MK_TYP hdl = MkRuntimeC##_TT;
30
31#define OT_SETUP_hdl_static_constr OT_SETUP_hdl_static
32
33#if !defined(SetupRtFromObj_X)
34 #define SetupRtFromObj_X(hdl) AllRtSetup_X(hdl)
35 #define SetupRtFromObj_XN(hdl) AllRtSetup_XN(hdl)
36#endif
37
38// MO class
39#undef MkRuntimeCTT
40#define MkRuntimeCTT MK(MkKernelThreadState).MkRuntimeCTT
41/* MkRuntimeC_MK_NULL defined in LibMkKernel_py.h */
42
43__attribute__((unused)) mk_inline
44OT_OBJ_T NS(MkRuntimeC_CTOR) (MK_RT_ARGS OT_CLS_T type, MK_RT hdl) {
45 return MK(AtomCreate)(MK_RT_CALL type,MkRuntimeC_X2obj(hdl));
46}
47
48// helper: mk_dbg_color_ln(MK_COLOR_YELLOW,"hdl<%p>, self<%p>", obj, self);
49
50// META: ObjNew feature: selfCreate will be called from "ObjNew->MkSelfNew" if MkObj need a SELF pointer
51static MK_PTR NS(MkRuntimeC_selfCreate) (MK_RT_ARGS MK_OBJ const obj, MK_PTR const env) {
52 return MK(AtomCreate) (MK_RT_CALL OT_CLASS,obj);
53}
54// META: called if MkObj must be destroyed and if the SELF is still alive → goal: destroy the SELF
55static void NS(MkRuntimeC_selfDelete) (MK_RT_ARGS MK_PTR self, MK_PTR const env) {
56 MK(AtomDeleteHard) (MK_RT_CALL OT_SELF);
57}
58// META: called to destroy link from SELF to META
59static void NS(MkRuntimeC_selfUnlink) (MK_RT_ARGS MK_PTR self, MK_PTR const env) {
60 MkObjectC_Obj *selfO = (MkObjectC_Obj*) self;
61 selfO->hdl = NULL;
62}
63
64// initialize the PY and MO class specific object
65#define ClassInit \
66 /* if not already done, initialize NEW META type */ \
67 if (MkRuntimeCTT == NULL) MkRuntimeCTT = MkRuntimeSTT; \
68 \
69 /* protect against double call */ \
70 if (MkRuntimeCTT->selfCreate == NS(MkRuntimeC_selfCreate)) return MK_OK; \
71 \
72 /* add "selfCreate" and "selfDelete" feature to the META-Class */ \
73 MkRuntimeCTT->selfCreate = NS(MkRuntimeC_selfCreate); \
74 MkRuntimeCTT->selfDelete = NS(MkRuntimeC_selfDelete); \
75 MkRuntimeCTT->selfUnlink = NS(MkRuntimeC_selfUnlink); \
76 \
77 if (!PyType_HasFeature(OT_CLASS,Py_TPFLAGS_READY)) { \
78 NS(MkRuntimeCR).tp_base = MkRuntimeC_base; \
79 OtErrorCheckLng (PyType_Ready(OT_CLASS)); \
80 } \
81 OtErrorCheckLng(PyModule_AddObjectRef(m, "MkRuntimeC", (PyObject *)OT_CLASS)); \
82 \
83 /* define the "NULL" object */ \
84 MkRuntimeC_MK_NULL = Py_NewRef(MK(AtomCreate) (MK_RT_CALL OT_CLASS, NULL /*obj*/));
85
86/* LABEL-END */
87
88#define META_CONTEXT_S MK_ERROR_DEFAULT
89
95
96// BEGIN-DOC - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
97
98// doc-key: MkRuntimeC,MkRuntime,sm_,func
99#define DebugGet_doc "int32 MkRuntimeC.DebugGet()"
100#define DebugSet_doc "MkRuntimeC.DebugSet(dbg:int32)"
101#define ErrorGetCode_doc "MkErrorE MkRuntimeC.ErrorGetCode()"
102#define IsSilentGet_doc "bool MkRuntimeC.IsSilentGet()"
103#define IsSilentSet_doc "MkRuntimeC.IsSilentSet(silent:bool)"
104#define Log0_doc "MkRuntimeC.Log0(?fmtobj:MkObjectC=None?, ?debug:int32=0?, ?callfunc:string=\"MK_NULL\"?, ?lvl:int32=0?) (const)"
105#define LogTargetGet_doc "string MkRuntimeC.LogTargetGet()"
106#define LogTargetReset_doc "MkRuntimeC.LogTargetReset()"
107#define LogTargetSet_doc "MkRuntimeC.LogTargetSet(logTgt:string)"
108#define NoDecoSet_doc "MkRuntimeC.NoDecoSet(noDeco:bool)"
109
110// END-DOC - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
111
112// ---------------------------------------------------------------------------------------
113
114// vim: Marker(m)
120
121// ---------------------------------------------------------------------------------------
122
123// BEGIN-MkRuntimeC - created by 'py_MqC.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
124
128
129// doc-key: MkRuntimeC,MkRuntimeC-Config,sm_
130
132static OT_ProcRet NS(MkRuntimeC_DebugGet) (OtClass_ARGS) {
137 goto end;
138 error:
140 end:
142}
143
145static OT_ProcRet NS(MkRuntimeC_DebugSet) (OtClass_ARGS) {
148 MK_I32 dbg = 0;
151 MkRuntimeDebugSet (dbg);
153 goto end;
154 error:
156 end:
158}
159
161static OT_ProcRet NS(MkRuntimeC_ErrorGetCode) (OtClass_ARGS) {
166 goto end;
167 error:
169 end:
171}
172
174static OT_ProcRet NS(MkRuntimeC_IsSilentGet) (OtClass_ARGS) {
179 goto end;
180 error:
182 end:
184}
185
187static OT_ProcRet NS(MkRuntimeC_IsSilentSet) (OtClass_ARGS) {
190 MK_BOOL silent = 0;
193 MkRuntimeIsSilentSet (silent);
195 goto end;
196 error:
198 end:
200}
201
203static OT_ProcRet NS(MkRuntimeC_LogTargetGet) (OtClass_ARGS) {
208 goto end;
209 error:
211 end:
213}
214
228
230static OT_ProcRet NS(MkRuntimeC_LogTargetSet) (OtClass_ARGS) {
233 MK_STRN logTgt = 0;
238 goto end;
239 error:
241 end:
243}
244
246static OT_ProcRet NS(MkRuntimeC_NoDecoSet) (OtClass_ARGS) {
249 MK_BOOL noDeco = 0;
252 MkRuntimeNoDecoSet (noDeco);
254 goto end;
255 error:
257 end:
259}
260
262// MkRuntimeC_Config_PY_API
263
267
268// doc-key: MkRuntimeC,MkRuntimeC-Info,sm_
269
271static OT_ProcRet NS(MkRuntimeC_Log0) (OtClass_ARGS) {
274 MK_OBJN fmtobj = NULL;
276 MK_DBG debug = 0;
278 MK_STRN callfunc = NULL;
280 MK_I32 lvl = 0;
283 if (debug > MkRuntimeDebugGet()) {
285 goto end;
286 }
287 if (MkSysStringIsNULL(callfunc)) {callfunc = OT_GET_CALL_PROC;}
288 MkRuntimeLog0 (fmtobj, debug, callfunc, lvl);
290 goto end;
291 error:
293 end:
296}
297
299// MkRuntimeC_Info_PY_API
300
301// END-MkRuntimeC - created by 'py_MqC.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
302
308
309static PyMethodDef MkRuntimeC_Methods[] = {
310
311 // BEGIN-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
312
313 // doc-key: MkRuntimeC,MkRuntime,sm_
314 { "DebugGet" , (PyCFunction) NS(MkRuntimeC_DebugGet) , METH_NOARGS|METH_CLASS , DebugGet_doc },
315 { "DebugSet" , (PyCFunction) NS(MkRuntimeC_DebugSet) , METH_O|METH_CLASS , DebugSet_doc },
316 { "ErrorGetCode" , (PyCFunction) NS(MkRuntimeC_ErrorGetCode) , METH_NOARGS|METH_CLASS , ErrorGetCode_doc },
317 { "IsSilentGet" , (PyCFunction) NS(MkRuntimeC_IsSilentGet) , METH_NOARGS|METH_CLASS , IsSilentGet_doc },
318 { "IsSilentSet" , (PyCFunction) NS(MkRuntimeC_IsSilentSet) , METH_O|METH_CLASS , IsSilentSet_doc },
319 { "Log0" , (PyCFunction) NS(MkRuntimeC_Log0) , METH_VARARGS|METH_CLASS , Log0_doc },
320 { "LogTargetGet" , (PyCFunction) NS(MkRuntimeC_LogTargetGet) , METH_NOARGS|METH_CLASS , LogTargetGet_doc },
321 { "LogTargetReset" , (PyCFunction) NS(MkRuntimeC_LogTargetReset) , METH_NOARGS|METH_CLASS , LogTargetReset_doc },
322 { "LogTargetSet" , (PyCFunction) NS(MkRuntimeC_LogTargetSet) , METH_O|METH_CLASS , LogTargetSet_doc },
323 { "NoDecoSet" , (PyCFunction) NS(MkRuntimeC_NoDecoSet) , METH_O|METH_CLASS , NoDecoSet_doc },
324
325 // END-CLASS - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
326
327 // BEGIN-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
328
329 // → no data
330
331 // END-OBJ - created by 'py_MqS.tcl -i NHI1_HOME/theKernel/c/gen/c_mkkernel.meta' - DO NOT change
332
333 {NULL, NULL, 0, NULL} /* Sentinel */
334};
340
342 PyVarObject_HEAD_INIT(NULL, 0)
343 .tp_name = "pymkkernel.MkRuntimeC",
344 .tp_doc = "PyMkKernel MkRuntimeC Type",
345 .tp_basicsize = sizeof(MkRuntimeC_Obj),
346 .tp_itemsize = 0,
347 .tp_flags = Py_TPFLAGS_DEFAULT,
348 .tp_methods = MkRuntimeC_Methods,
349 .tp_base = NULL
350};
351
352int NS(pMkRuntimeC_Init) ( MK_RT_ARGS PyObject* m)
353{
355
356 return 0;
357error:
358 return -1;
359}
360
361// vim: nowrap
tag: nhi1-release-250425
#define OT_CHECK_bool(val)
#define OT_SELF
#define MK(n)
#define OT_SETUP_VARARGS(min, max, d)
#define OT_retObj_SET_BOL(nat)
#define OT_SETUP_NOARG(d)
#define OT_SETUP_ONEARG(d)
#define OT_CHECK_NI4(val)
#define OT_retObj_SET_Error
#define OT_FRAME_CLEANUP
#define OT_CHECK_REQUIRED(val)
#define OT_retObj_SET_None
#define OT_retObj_SET_I32(nat)
PyTypeObject * OT_CLS_T
struct MkRuntimeC_Obj MkRuntimeC_Obj
#define NS(n)
#define OT_retObj_RETURN
#define OT_GET_CALL_PROC
PyObject * OT_OBJ_T
#define OT_retObj_SET_STR(nat)
#define OT_CLASS_TYPE_REF
#define OT_NEW_Mk_enum_OBJ(typ, val)
#define OT_CHECK_OPTIONAL(val)
#define OT_retObj_SET(val)
#define OT_CHECK_NOARGS
#define MkErrorC_Check(mng, PROC)
#define OT_ProcRet
#define OtClass_ARGS
#define OT_CHECK_STRN(val)
#define ErrorGetCode_doc
#define Log0_doc
#define IsSilentGet_doc
#define IsSilentSet_doc
#define NoDecoSet_doc
static PyMethodDef MkRuntimeC_Methods[]
#define LogTargetReset_doc
#define OT_CLASS
#define OT_SETUP_hdl_static
#define DebugGet_doc
#define DebugSet_doc
#define LogTargetGet_doc
#define ClassInit
#define LogTargetSet_doc
#define MK_ERROR_FORMAT
#define mk_inline
#define MK_NULL_YES
flag, allow NULL
MK_PTRB * MK_PTR
generic pointer data-type
const MK_STRB * MK_STRN
constant string pointer data-type
bool MK_BOOL
real bool data-type
signed int MK_I32
4 byte integer data-type
int MK_DBG
debug-level data-type …
static bool MkSysStringIsNULL(MK_STRN str)
test if string is NULL or EMPTY …
#define MkRuntimeC_X2obj(x)
#define MkRuntimeLogTargetReset()
#define MkRuntimeErrorGetCode()
static void MkRuntimeDebugSet(MK_I32 dbg)
set the MkRuntimeS::debug value …
static bool MkRuntimeIsSilentGet(void)
get the MkRuntimeS::isSilent value …
#define MkRuntimeLogTargetSet(...)
#define MkRuntimeNoDecoSet(...)
static MK_I32 MkRuntimeDebugGet(void)
get the MkRuntimeS::debug value …
#define MkRuntimeIsSilentSet(...)
static MK_STRN MkRuntimeLogTargetGet(void)
get the MkLogDataS::logNAME value …
#define MkRuntimeLog0(...)
#define MK_RT_CALL
#define MK_RT_ARGS
#define OT_CHECK_OBJN(val, nullB)
PyObject_HEAD MK_OBJ hdl
object header …
The MkRuntimeS provide a per-thread environment for pymkkernel …