libmkkernel 9.0
Loading...
Searching...
No Matches
Functions

managed-object details More...

+ Collaboration diagram for MkObjectC_Obj_C_API:

Functions

MK_EXTERN MK_OBJ MkObjCopy_RT (MK_RT const mkrt, MK_OBJ const tgtmng, MK_OBJN const srcmng) MK_RT_ATTR_HDL
 call the copy from the object
 
MK_EXTERN void MkObjReset_RT (MK_RT const mkrt, MK_OBJ const obj) MK_RT_ATTR_HDL
 free the internal memory of an object and initialize the local variables to default values
 

MkRef…

reference management functions

void MkRefIncr (MK_OBJ obj)
 increment the reference-count
 
MK_EXTERN void MkRefDecr_RT (MK_RT const mkrt, MK_OBJ obj) MK_RT_ATTR_HDL
 decrement the reference-count
 
MK_ATTR_HDL void MkRefIncrSelf (MK_OBJ const obj, MK_PTR const self, MK_PTR const env)
 ATOMIC operation -> link self with reference-count.
 
MK_EXTERN MK_OBJ MkRefDecrWithoutSelf_RT (MK_RT const mkrt, MK_OBJ const obj) MK_RT_ATTR_HDL
 ATOMIC operation -> unlink self with reference-count.
 
MK_ATTR_HDL MK_INT MkRefGet (MK_OBJ const obj)
 get the reference-count
 
MK_ATTR_HDL MK_INT MkRefLock (MK_OBJ const obj)
 lock the object
 
MK_ATTR_HDL bool MkRefIsLocked (MK_OBJ const obj)
 check if object is locked
 
MK_EXTERN MK_NUM MkRefCidN_RT (MK_RT_PARSER_ONLY)
 return the reference-count-recursion-level
 
#define MkRefLOCK   999999
 unchangeable reference
 
#define MkRefIncr_1X(x)   MkRefIncr(MkOBJ(x))
 
#define MkRefIncr_1M(m)   MkRefIncr(MkObj(m))
 
#define MkRefIncr_FX(x)   MkRefIncr(MkOBJ(x))
 protect code-block, do not call the destructor…
 
#define MkRefDecr_O(o)   do { MkRefDecr_RT(MK_RT_CALL o); o=NULL; } while (0)
 
#define MkRefDecr_X(x)   do { MkRefDecr_RT(MK_RT_CALL MkOBJ(x)); x=NULL; } while (0)
 
#define MkRefDecr_X_NULL(x)   do { MkRefDecr_RT(MK_RT_NULL MkOBJ(x)); x=NULL; } while (0)
 
#define MkRefDecr_M(m)   do { MkRefDecr_RT(MK_RT_CALL MkObj(m)); m=NULL; } while (0)
 
#define MkRefDecr_M_NULL(m)   do { MkRefDecr_RT(MK_RT_NULL MkObj(m)); m=NULL; } while (0)
 
#define MkRefDecr_FX(x)   do { --(MkOBJ_R(x).refCount); } while(0)
 protect code-block, do not call the destructor…
 
#define MkRefIncrSelf_2X(x, s)   MkRefIncrSelf(MkOBJ(x),s)
 
#define MkRefDecrWithoutSelf_NULL(o)   MkRefDecrWithoutSelf_RT(MK_RT_NULL o)
 
#define MkRefGet_1X(x)   MkRefGet(MkOBJ(x))
 
#define MkRefLock_1X(x)   MkRefLock(MkOBJ(x))
 
#define MkRefIsLocked_1X(x)   MkRefIsLocked(MkOBJ(x))
 
#define MkRefSet(target, source)
 update target with source and keep the MkObjectS::refCount in sync
 
#define MkRefCidN_NULL()   MkRefCidN_RT(MK_RT_CALL_NULL_ONLY)
 

MkSelf

MK_ATTR_HDL void MkSelfSet (MK_OBJ const obj, MK_PTR const self, MK_PTR const env)
 set the MkObjectS::self value
 
MK_PTR MkSelfGet (MK_OBJ const obj)
 get the MkObjectS::self value
 
mk_attr_hot enum MkErrorE MkSelfNew_RT (MK_RT const mkrt, MK_OBJ obj, MK_PTR *self_out, MK_PTR const env)
 return the self pointer for a given obj
 
MK_EXTERN MK_PTR MkSelfCreate_RT (MK_RT const mkrt, MK_OBJ const obj, MK_PTR const env) MK_RT_ATTR_HDL
 create the MkObjectS::self value
 
MK_EXTERN bool MkSelfDelete_RT (MK_RT const mkrt, MK_OBJ const obj) MK_RT_ATTR_HDL
 delete the MkObjectS::self value
 
MK_EXTERN bool MkSelfDeleteForce_RT (MK_RT const mkrt, MK_OBJ obj) MK_RT_ATTR_HDL
 force delete an instance, last step in instance-destructor
 
MK_EXTERN void MkSelfUnlink_RT (MK_RT const mkrt, MK_OBJ obj) MK_RT_ATTR_HDL
 Run the MkTypeS::selfUnlink slot from the instance...
 
#define MkSelfSet_3X(x, self, env)   MkSelfSet(MkOBJ(x),self,env)
 
#define MkSelfGet_1X(x)   MkSelfGet(MkOBJ(x))
 
#define MkSelfNew_3X(x, self_out, env)   MkSelfNew(MkOBJ(x),self_out,env)
 
#define MkSelfNew_NULL(...)   MkSelfNew_RT(MK_RT_NULL __VA_ARGS__)
 
#define MkSelfCreate_2X(x, env)   MkSelfCreate(MkOBJ(x),env)
 
#define MkSelfDelete_1X(x)   MkSelfDelete_RT(MK_RT_CALL MkOBJ(x))
 
#define MkSelfDeleteForce_1X(x)   MkSelfDeleteForce(MkOBJ(x))
 
#define MkSelfUnlink_1X(x)   MkSelfUnlink(MkOBJ(x))
 

MkType…

reference management functions

MK_TYP MkTypeCreate (MK_MACRO_TYP const cls, MK_MACRO_TYP const basic, MK_STRN const ident)
 create a new type …
 
MK_EXTERN MK_TYP MkTypeDup2_RT (MK_RT const mkrt, MK_TYPN const typ, MK_STRN const ident) MK_RT_ATTR_HDL
 duplicate a type type as duplicate from existing type but the new name …
 
MK_EXTERN MK_OBJ MkTypeAlloc (MK_RT const mkrt, MK_TYPN const typ) MK_RT_ATTR_HDL
 alloc instance-memory for MkTypeS
 
MK_EXTERN MK_TYP MkTypeResolve (MK_RT const mkrt, MK_TYPN const typ) MK_RT_ATTR_HDL
 resolve a new type
 
MK_EXTERN void MkTypeDelete_RT (MK_RT const mkrt, MK_TYP const typ) MK_RT_ATTR_HDL
 delete a type object
 
MK_EXTERN void MkTypeLog_RT (MK_RT const mkrt, MK_TYPN const typ, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_INT const lvl)
 log the MkTypeS
 
#define MkTypeCreate(clsV, basicV, identV)
 

Overload

#define MkObjCopy(...)   MkObjCopy_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkRefDecrWithoutSelf(...)   MkRefDecrWithoutSelf_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkTypeAlloc_1(typ)   MkTypeAlloc(MK_RT_CALL,typ)
 
#define MkObjReset(...)   MkObjReset_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkSelfNew(...)   MkSelfNew_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkSelfNew_E(...)   MkErrorCheck(MkSelfNew(__VA_ARGS__))
 
#define MkSelfNew_C(...)   if (MkErrorCheckI(MkSelfNew(__VA_ARGS__)))
 
#define MkRefCidN()   MkRefCidN_RT(MK_RT_CALL_ONLY)
 
#define MkRefDecr(...)   MkRefDecr_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkSelfCreate(...)   MkSelfCreate_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkSelfDelete(...)   MkSelfDelete_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkSelfDeleteForce(...)   MkSelfDeleteForce_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkSelfUnlink(...)   MkSelfUnlink_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkTypeDelete(...)   MkTypeDelete_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkTypeDup2(...)   MkTypeDup2_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkTypeLog(...)   MkTypeLog_RT(MK_RT_CALL __VA_ARGS__)
 
#define MkTypeLog_4(typ, fmtobj, debug, callfunc)   MkTypeLog(typ,fmtobj,debug,callfunc,0)
 
#define MkTypeLog_3(typ, fmtobj, debug)   MkTypeLog(typ,fmtobj,debug,__func__,0)
 
#define MkTypeLog_2(typ, fmtobj)   MkTypeLog(typ,fmtobj,0,__func__,0)
 
#define MkTypeLog_1(typ)   MkTypeLog(typ,NULL,0,__func__,0)
 
#define MkTypeResolve_1(typ)   MkTypeResolve(MK_RT_CALL,typ)
 

Detailed Description

managed-object details

The Programming-Language-Micro-Kernel using the manged-object technology to create a class-system with MkObjectS as the root-class.
The MkObjectS is the FIRST and REQUIRED attribute in the super-union.

  1. The instance-type is a composition of one or more super-classes and instance-attributes.
  2. All super-classes are grouped into a annonymous union called super.
  3. Only the super-class struct MkObjectS obj is required for object-management, all other super-classes are optional.
  4. The name of the super-class like obj or buf is fix and is required by tool-macros and functions.
// instance-type: MyFeatureS
struct MyStructS {
// instance super-class
union {
struct MkObjectS obj; // 'object' instance-type (required)
struct MkBufferS buf; // 'buffer' instance-type (optional,example)
} super;
// instance attribute
int myInt; …
}
The ABSTRACT-CLASS used to store a native-type-data-item defined by PRIMITIVE TYPE …
Definition kernel_mk.h:6194
object header …
Definition kernel_mk.h:4442

A class is a link (MkObjectS::type) between:

instance-type(example: MkBufferS)
type-type(example: MkBufferSTTMkDefTypeSTTMkTypeSTT)

A class is identified by the signature (MkObjectS::signature) located at the FIRST int32 bits of the class-instance.

There are two possible "cast" operations on a managed-object :

  1. A "cast" from a pointer of unknown origin (example: MK_MNG).
  2. A "cast" from an already known managed object pointer (example: MK_BUS).

In (1) the "cast" is checked using the "signature" and in (2) the "cast" is simply resolved within the "super-class".

Example: "cast" a pointer into a MkBufferS

Example from kernel_mk.h A full class example from MkBufferS

struct MkBufferS {
// BEGIN-MkBufferS-super - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
union {
struct MkObjectS obj; // base CLASS \MkObjectS
} super;
// END-MkBufferS-super - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
// instance attributes
struct {
MK_NUM cursize;
enum MkTypeE type;
} var;
// instance storage
struct {
union MkBufferU first;
bool doBufferFree;
} storage;
struct ilsS {
} ils;
#define MkBufferS_ils_size 0
};
// BEGIN-MkBufferS-ClassDef - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
// Signature --------------------------------------------------------------
#define MkBufferC_SIGNATURE (MkObjectC_SIGNATURE ^ (1u<<10))
#define MkBufferC_MASK (((1u<<22)-1)<<10)
// Signature --------------------------------------------------------------
#define MkBufferC_X2buf(x) (x)
#define MkBufferC_X2obj(x) MkOBJ(x)
// TypeDef --------------------------------------------------------------
__parser__(ignore) typedef struct MkBufferS MkBufferCR;
__parser__(ignore) typedef const struct MkBufferS MkBufferCNR;
#define MkBufferC_T (&MK_RT_REF._MkBufferC_T)
#define MkBufferC_TT (MkTYP(MkBufferC_T))
#define MkBufferST MkBufferC_T
#define MkBufferSTT (MkTYP(MkBufferST))
#define MkBufferC_type MK_BUF
#define MkBufferCT_X(instance) ( (struct MkDefTypeS *) (MkOBJ_R(instance).type) )
#define MkBufferCTT_X(instance) (MkOBJ_R(instance).type)
#define MkBufferCT_TT(typ) ( (struct MkDefTypeS *) (typ) )
#define MkBufferC_NS MK
#define MkBufferCTT MkBufferCTT
#define MkBufferCT ( (struct MkDefTypeS *) MkBufferCTT )
// TypeCheck --------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
__parser__(class=MkBufferC,static,hide)
return MkSanitizeCheck(MkBufferC,mng);
}
#pragma GCC diagnostic pop
#define MkBufferC_Check(mng) MkBufCheck(mng)
// ObjectCast --------------------------------------------------------------
__parser__push__(prefix=Cast);
__parser__(class=MkBufferC,hide,static)
META_ATTRIBUTE_SANITIZE
return (MkBufCheck(mng) ? (MK_BUF)mng : NULL);
}
__parser__(ignore)
META_ATTRIBUTE_SANITIZE
return (MkBufCheck(mng) ? (MK_BUFN)mng : NULL);
}
#define MkBufRaise(_buf) if (!_MkCheckX(MkBufferC,_buf)) { \
MkErrorSetC_1E("'MkBufferC' hdl is NULL"); \
goto error ; \
}
#define MkBUF_R(x) (*(x)).super.buf
#define MkBUF(x) (&MkBUF_R(x))
// END-MkBufferS-ClassDef - created by 'cls_MqS.tcl -i NHI1_HOME/theKernel/libmkkernel/.libmkkernel.meta' - DO NOT change
bool MkBufCheck(MK_MNGN mng)
check MkBufferS%->Mk{ObjectS::signature} …
Definition kernel_mk.h:6286
MK_BUF MkBuf(MK_MNG mng)
cast a unknown-object into an MkBufferS pointer or NULL if not possible
Definition kernel_mk.h:6305
MK_BUFN MkBufN(MK_MNGN mng)
(const) cast a unknown-object into an MkBufferS pointer or NULL if not possible
Definition kernel_mk.h:6312
#define mk_inline
Definition kernel_mk.h:2144
MkTypeE
basic data-types supported by Programming-Language-Micro-Kernel …
Definition kernel_mk.h:3299
const MK_PTRB * MK_MNGN
const - a managed object pointer, datatype will be checked on runtime
Definition kernel_mk.h:2731
int32_t MK_NUM
array size data-type ('num' items in array …
Definition kernel_mk.h:2679
MK_PTRB * MK_MNG
managed object pointer, datatype will be checked on runtime
Definition kernel_mk.h:2728
unsigned char MK_BINB
byte-array type data-type
Definition kernel_mk.h:2706
#define MkSanitizeCheck(_root, _m)
Definition kernel_mk.h:4412
#define MkBufferS_ils_size
ILS size
Definition kernel_mk.h:6217
#define __parser__pop__
Definition kernel_mk.h:318
#define __parser__push__(...)
Definition kernel_mk.h:317
#define __parser__(...)
Definition kernel_mk.h:314
MK_NUM offset
offset from start of MkBufferS to the start of MkBufferS::ils_data
Definition kernel_mk.h:6215
MK_NUM size
size of the MkBufferS::ils_data
Definition kernel_mk.h:6214
struct MkObjectS obj
Definition kernel_mk.h:6197
union MkBufferU first
POINTER to native data representation (ILS or malloc)
Definition kernel_mk.h:6208
struct MkBufferS::ilsS ils
ILS = predefined storage used for MkBufferS::storage->first.
struct MkBufferS::@4 storage
MK_BINB ils_data[MkBufferS_ils_size]
ILS storage
Definition kernel_mk.h:6218
struct MkBufferS::@3 var
variable part of the instance-data
union MkBufferS::@2 super
MK_NUM size
the size of the data-segment
Definition kernel_mk.h:6209
bool doBufferFree
should the data be freed? -> example: pBufferRefInit
Definition kernel_mk.h:6210
a union for all data items supported by MkBufferS …
Definition kernel_mk.h:3435

Macro Definition Documentation

◆ MkObjCopy

#define MkObjCopy (   ...)    MkObjCopy_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1343 of file kernel_overload_mk.h.

◆ MkObjReset

#define MkObjReset (   ...)    MkObjReset_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1352 of file kernel_overload_mk.h.

◆ MkRefCidN

#define MkRefCidN ( )    MkRefCidN_RT(MK_RT_CALL_ONLY)

Definition at line 1359 of file kernel_overload_mk.h.

◆ MkRefCidN_NULL

#define MkRefCidN_NULL ( )    MkRefCidN_RT(MK_RT_CALL_NULL_ONLY)

Definition at line 5410 of file kernel_mk.h.

◆ MkRefDecr

#define MkRefDecr (   ...)    MkRefDecr_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1360 of file kernel_overload_mk.h.

◆ MkRefDecr_FX

#define MkRefDecr_FX (   x)    do { --(MkOBJ_R(x).refCount); } while(0)

protect code-block, do not call the destructor…

Only call MkRefIncr_FX and MkRefDecr_FX together

MkRefIncr_FX(instance);
// do some operation which COULD call the destructor
MkRefDecr_FX(instance);
if (instance->refCount <= 0) {
// instance have to be deleted → clean up!!
MkSelfDeleteForce(instance); // DELETE!
}
#define MkSelfDeleteForce(...)
#define MkRefDecr_FX(x)
protect code-block, do not call the destructor…
Definition kernel_mk.h:5324
#define MkRefIncr_FX(x)
protect code-block, do not call the destructor…
Definition kernel_mk.h:5301

Definition at line 5324 of file kernel_mk.h.

◆ MkRefDecr_M

#define MkRefDecr_M (   m)    do { MkRefDecr_RT(MK_RT_CALL MkObj(m)); m=NULL; } while (0)

Definition at line 5320 of file kernel_mk.h.

◆ MkRefDecr_M_NULL

#define MkRefDecr_M_NULL (   m)    do { MkRefDecr_RT(MK_RT_NULL MkObj(m)); m=NULL; } while (0)

Definition at line 5321 of file kernel_mk.h.

◆ MkRefDecr_O

#define MkRefDecr_O (   o)    do { MkRefDecr_RT(MK_RT_CALL o); o=NULL; } while (0)

Definition at line 5317 of file kernel_mk.h.

◆ MkRefDecr_X

#define MkRefDecr_X (   x)    do { MkRefDecr_RT(MK_RT_CALL MkOBJ(x)); x=NULL; } while (0)

Definition at line 5318 of file kernel_mk.h.

◆ MkRefDecr_X_NULL

#define MkRefDecr_X_NULL (   x)    do { MkRefDecr_RT(MK_RT_NULL MkOBJ(x)); x=NULL; } while (0)

Definition at line 5319 of file kernel_mk.h.

◆ MkRefDecrWithoutSelf

#define MkRefDecrWithoutSelf (   ...)    MkRefDecrWithoutSelf_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1344 of file kernel_overload_mk.h.

◆ MkRefDecrWithoutSelf_NULL

#define MkRefDecrWithoutSelf_NULL (   o)    MkRefDecrWithoutSelf_RT(MK_RT_NULL o)

Definition at line 5362 of file kernel_mk.h.

◆ MkRefGet_1X

#define MkRefGet_1X (   x)    MkRefGet(MkOBJ(x))

Definition at line 5375 of file kernel_mk.h.

◆ MkRefIncr_1M

#define MkRefIncr_1M (   m)    MkRefIncr(MkObj(m))

Definition at line 5286 of file kernel_mk.h.

◆ MkRefIncr_1X

#define MkRefIncr_1X (   x)    MkRefIncr(MkOBJ(x))

Definition at line 5285 of file kernel_mk.h.

◆ MkRefIncr_FX

#define MkRefIncr_FX (   x)    MkRefIncr(MkOBJ(x))

protect code-block, do not call the destructor…

Only call MkRefIncr_FX and MkRefDecr_FX together

MkRefIncr_FX(instance);
// do some operation which COULD call the destructor
MkRefDecr_FX(instance);
if (instance->refCount <= 0) {
// instance have to be deleted → clean up!!
MkSelfDeleteForce(instance); // DELETE!
}

Definition at line 5301 of file kernel_mk.h.

◆ MkRefIncrSelf_2X

#define MkRefIncrSelf_2X (   x,
 
)    MkRefIncrSelf(MkOBJ(x),s)

Definition at line 5341 of file kernel_mk.h.

◆ MkRefIsLocked_1X

#define MkRefIsLocked_1X (   x)    MkRefIsLocked(MkOBJ(x))

Definition at line 5394 of file kernel_mk.h.

◆ MkRefLOCK

#define MkRefLOCK   999999

unchangeable reference

Definition at line 5276 of file kernel_mk.h.

◆ MkRefLock_1X

#define MkRefLock_1X (   x)    MkRefLock(MkOBJ(x))

Definition at line 5384 of file kernel_mk.h.

◆ MkRefSet

#define MkRefSet (   target,
  source 
)
Value:
({ \
if (target != source) { \
typeof(target) targetSave=target; \
target = source;\
MkRefDecr_X(targetSave);\
MkRefIncr_1X(target);\
} \
target;\
})

update target with source and keep the MkObjectS::refCount in sync

Definition at line 5397 of file kernel_mk.h.

◆ MkSelfCreate

#define MkSelfCreate (   ...)    MkSelfCreate_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1361 of file kernel_overload_mk.h.

◆ MkSelfCreate_2X

#define MkSelfCreate_2X (   x,
  env 
)    MkSelfCreate(MkOBJ(x),env)

Definition at line 5495 of file kernel_mk.h.

◆ MkSelfDelete

#define MkSelfDelete (   ...)    MkSelfDelete_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1362 of file kernel_overload_mk.h.

◆ MkSelfDelete_1X

#define MkSelfDelete_1X (   x)    MkSelfDelete_RT(MK_RT_CALL MkOBJ(x))

Definition at line 5511 of file kernel_mk.h.

◆ MkSelfDeleteForce

#define MkSelfDeleteForce (   ...)    MkSelfDeleteForce_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1363 of file kernel_overload_mk.h.

◆ MkSelfDeleteForce_1X

#define MkSelfDeleteForce_1X (   x)    MkSelfDeleteForce(MkOBJ(x))

Definition at line 5535 of file kernel_mk.h.

◆ MkSelfGet_1X

#define MkSelfGet_1X (   x)    MkSelfGet(MkOBJ(x))

Definition at line 5443 of file kernel_mk.h.

◆ MkSelfNew

#define MkSelfNew (   ...)    MkSelfNew_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1353 of file kernel_overload_mk.h.

◆ MkSelfNew_3X

#define MkSelfNew_3X (   x,
  self_out,
  env 
)    MkSelfNew(MkOBJ(x),self_out,env)

Definition at line 5476 of file kernel_mk.h.

◆ MkSelfNew_C

#define MkSelfNew_C (   ...)    if (MkErrorCheckI(MkSelfNew(__VA_ARGS__)))

Definition at line 1355 of file kernel_overload_mk.h.

◆ MkSelfNew_E

#define MkSelfNew_E (   ...)    MkErrorCheck(MkSelfNew(__VA_ARGS__))

Definition at line 1354 of file kernel_overload_mk.h.

◆ MkSelfNew_NULL

#define MkSelfNew_NULL (   ...)    MkSelfNew_RT(MK_RT_NULL __VA_ARGS__)

Definition at line 5478 of file kernel_mk.h.

◆ MkSelfSet_3X

#define MkSelfSet_3X (   x,
  self,
  env 
)    MkSelfSet(MkOBJ(x),self,env)

Definition at line 5433 of file kernel_mk.h.

◆ MkSelfUnlink

#define MkSelfUnlink (   ...)    MkSelfUnlink_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1364 of file kernel_overload_mk.h.

◆ MkSelfUnlink_1X

#define MkSelfUnlink_1X (   x)    MkSelfUnlink(MkOBJ(x))

Definition at line 5559 of file kernel_mk.h.

◆ MkTypeAlloc_1

#define MkTypeAlloc_1 (   typ)    MkTypeAlloc(MK_RT_CALL,typ)

Definition at line 1348 of file kernel_overload_mk.h.

◆ MkTypeCreate

#define MkTypeCreate (   clsV,
  basicV,
  identV 
)
Value:
({ \
MK_TYP ret = MkTypeDup2(basicV ## _TT,identV); \
ret->objsig = clsV ## _SIGNATURE; \
ret->objmask = clsV ## _MASK; \
ret->objsize = sizeof(clsV##R); \
ret ; \
})
#define MkTypeDup2(...)
define a Type object …
Definition kernel_mk.h:4745
size_t objsize
the size of the new object created with this type, used in malloc
Definition kernel_mk.h:4759
MK_SIG objsig
public st signatur of the type-instance
Definition kernel_mk.h:4755
MK_SIG objmask
public object signatur-mask of the type-instance
Definition kernel_mk.h:4756

Definition at line 5588 of file kernel_mk.h.

◆ MkTypeDelete

#define MkTypeDelete (   ...)    MkTypeDelete_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1365 of file kernel_overload_mk.h.

◆ MkTypeDup2

#define MkTypeDup2 (   ...)    MkTypeDup2_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1366 of file kernel_overload_mk.h.

◆ MkTypeLog

#define MkTypeLog (   ...)    MkTypeLog_RT(MK_RT_CALL __VA_ARGS__)

Definition at line 1367 of file kernel_overload_mk.h.

◆ MkTypeLog_1

#define MkTypeLog_1 (   typ)    MkTypeLog(typ,NULL,0,__func__,0)

Definition at line 1371 of file kernel_overload_mk.h.

◆ MkTypeLog_2

#define MkTypeLog_2 (   typ,
  fmtobj 
)    MkTypeLog(typ,fmtobj,0,__func__,0)

Definition at line 1370 of file kernel_overload_mk.h.

◆ MkTypeLog_3

#define MkTypeLog_3 (   typ,
  fmtobj,
  debug 
)    MkTypeLog(typ,fmtobj,debug,__func__,0)

Definition at line 1369 of file kernel_overload_mk.h.

◆ MkTypeLog_4

#define MkTypeLog_4 (   typ,
  fmtobj,
  debug,
  callfunc 
)    MkTypeLog(typ,fmtobj,debug,callfunc,0)

Definition at line 1368 of file kernel_overload_mk.h.

◆ MkTypeResolve_1

#define MkTypeResolve_1 (   typ)    MkTypeResolve(MK_RT_CALL,typ)

Definition at line 1372 of file kernel_overload_mk.h.

Function Documentation

◆ MkObjCopy_RT()

MK_EXTERN MK_OBJ MkObjCopy_RT ( MK_RT const  mkrt,
MK_OBJ const  tgtmng,
MK_OBJN const  srcmng 
)

call the copy from the object

Returns
the new object or NULL if no Merge-Constructor is available
See also
MkObjDup_RT MkObjReset_RT

◆ MkObjReset_RT()

MK_EXTERN void MkObjReset_RT ( MK_RT const  mkrt,
MK_OBJ const  obj 
)

free the internal memory of an object and initialize the local variables to default values

See also
MkObjDup_RT MkObjMerge_RT

◆ MkRefCidN_RT()

MK_EXTERN MK_NUM MkRefCidN_RT ( MK_RT_PARSER_ONLY  )

return the reference-count-recursion-level

◆ MkRefDecr_RT()

MK_EXTERN void MkRefDecr_RT ( MK_RT const  mkrt,
MK_OBJ  obj 
)

decrement the reference-count

  1. MkObjectS::refCount will be decremented
  2. if MkObjectS::refCount <= 0 the destructor will be called.
  3. the object will not be set to NULL use wrapper MkRefDecr_O, MkRefDecr_X or MkRefDecr_M
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API

◆ MkRefDecrWithoutSelf_RT()

MK_EXTERN MK_OBJ MkRefDecrWithoutSelf_RT ( MK_RT const  mkrt,
MK_OBJ const  obj 
)

ATOMIC operation -> unlink self with reference-count.

First the MkObjectS::self and MkObjectS::env will be set to NULL and than RefDecr is called.

This api-function is used to free libmqmsgque ressources on an already destroyed Target-Programming-Language instance.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
always return NULL
See also
MkRefIncr MkSelfSet MkRefIncrSelf

◆ MkRefGet()

MK_ATTR_HDL MK_INT MkRefGet ( MK_OBJ const  obj)
inline

get the reference-count

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the reference-count

Definition at line 5370 of file kernel_mk.h.

+ Here is the caller graph for this function:

◆ MkRefIncr()

void MkRefIncr ( MK_OBJ  obj)
inline

increment the reference-count

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API

Definition at line 5281 of file kernel_mk.h.

◆ MkRefIncrSelf()

MK_ATTR_HDL void MkRefIncrSelf ( MK_OBJ const  obj,
MK_PTR const  self,
MK_PTR const  env 
)
inline

ATOMIC operation -> link self with reference-count.

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]selfthis is the self pointer of the object in the programming-language-shell used for libmkkernel pointer.
[in]envstorage for an application specific environment pointer. (java: JNIEnv*)
See also
MkRefIncr MkSelfSet RefDecrWithoutSelf

Definition at line 5334 of file kernel_mk.h.

◆ MkRefIsLocked()

MK_ATTR_HDL bool MkRefIsLocked ( MK_OBJ const  obj)
inline

check if object is locked

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the boolean value

Definition at line 5390 of file kernel_mk.h.

◆ MkRefLock()

MK_ATTR_HDL MK_INT MkRefLock ( MK_OBJ const  obj)
inline

lock the object

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API

Definition at line 5380 of file kernel_mk.h.

◆ MkSelfCreate_RT()

MK_EXTERN MK_PTR MkSelfCreate_RT ( MK_RT const  mkrt,
MK_OBJ const  obj,
MK_PTR const  env 
)

create the MkObjectS::self value

create the self from the object mng using MkTypeS::selfCreate

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]envstorage for an application specific environment pointer. (java: JNIEnv*)
Returns
the MkObjectS::self value

◆ MkSelfDelete_RT()

MK_EXTERN bool MkSelfDelete_RT ( MK_RT const  mkrt,
MK_OBJ const  obj 
)

delete the MkObjectS::self value

delete the self from the object mng using MkTypeS::selfDelete

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
true if self and mq-obj was deleted and false if self is not available or self-delete does not delete the mq-obj

◆ MkSelfDeleteForce_RT()

MK_EXTERN bool MkSelfDeleteForce_RT ( MK_RT const  mkrt,
MK_OBJ  obj 
)

force delete an instance, last step in instance-destructor

A instance has a MQ-part and a LNG-part, the MQ-part have to be deleted but the deletion of the LNG-part depend on the LNG object-model-philosophy. Some LNG have a HARD-delete some LNG have only a SOFT-delete, read more at ObjectDelete.

This function will do the following steps:

  1. if available -> call MkTypeS::selfDelete if MkTypeS::selfCreate was called first
  2. if 1. was not done and MkTypeS::selfUnlink is available -> unlink the LNG-instance from the MQ-instance.
  3. if non-local -> set the MkObjectS::signature to MK_NULL_SIGNATURE and free the memory
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
1 if instance is global or was already deleted and 0 if local

◆ MkSelfGet()

MK_PTR MkSelfGet ( MK_OBJ const  obj)
inline

get the MkObjectS::self value

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Returns
the MkObjectS::self value

Definition at line 5438 of file kernel_mk.h.

+ Here is the caller graph for this function:

◆ MkSelfNew_RT()

enum MkErrorE MkSelfNew_RT ( MK_RT const  mkrt,
MK_OBJ  obj,
MK_PTR self_out,
MK_PTR const  env 
)
inline

return the self pointer for a given obj

This is an important function because every return of a managed-object in a target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) will call this function to check if the self is already set. If MK_YES the self is returned and if MK_NO a new self is created.

the following steps are done:

  • if obj has a self pointer (MkSelfGet)
    • if refCount > 0 return the self pointer
    • if refCount <= 0 return an error
  • if obj NOT has a self pointer... create a self pointer
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[out]self_outthe new libmkkernel object as return
[in]envstorage for an application specific environment pointer. This pointer will be passed to MkTypeS::selfCreate. (example java: JNIEnv*)
Returns

Definition at line 13339 of file kernel_mk.h.

◆ MkSelfSet()

MK_ATTR_HDL void MkSelfSet ( MK_OBJ const  obj,
MK_PTR const  self,
MK_PTR const  env 
)
inline

set the MkObjectS::self value

Parameters
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
[in]selfthe target-language-self-pointer usually self or this
[in]envstorage for an application specific environment pointer. (java: JNIEnv*)

Definition at line 5427 of file kernel_mk.h.

◆ MkSelfUnlink_RT()

MK_EXTERN void MkSelfUnlink_RT ( MK_RT const  mkrt,
MK_OBJ  obj 
)

Run the MkTypeS::selfUnlink slot from the instance...

An instance has an MQ-part and an LNG-part, both are connected by MkObjectS::self and an LNG-specific proprietary connector. This low-level function will separate the MQpart from the LNG-part, leaving TWO independent objects.

The unlink has the following consequence:

  1. When accessing the LNG-part, a NOT-INITIALIZED-EXCEPTION is generated
  2. The MQ-part can be deleted without deleting the LNG-part
  3. Accessing the MQ-part via the LNG-code creates a new LNG-part connected to the MQ-part
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API
Attention
this function has only an effect if the MkTypeS::selfUnlink slot is available

◆ MkTypeAlloc()

MK_EXTERN MK_OBJ MkTypeAlloc ( MK_RT const  mkrt,
MK_TYPN const  typ 
)

alloc instance-memory for MkTypeS

The following steps are done:

  1. resolve the type to fit into MkRuntimeC
  2. allocate the memory using the allocator from the type -> (MkTypeS::objalloc)
  3. initialize the memory to zero
  4. initialize the instance
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typthe MkTypeS instance to work on (nonnull)

◆ MkTypeCreate()

MK_TYP MkTypeCreate ( MK_MACRO_TYP const  cls,
MK_MACRO_TYP const  basic,
MK_STRN const  ident 
)

create a new type …

The type is created as TypeDup2 from the basic type and by update of the type specific fields objsig, objmask and objsize.

This kind of type is called a fullweight-type, because this type does provide a new signature and mask. In difference to MkTypeCreate the TypeDup2 create a lightweight-type.

Parameters
[in]clsthe type of the new type as C name of the struct (example LcConfgS)
[in]basicthe basic type, have to be MkObjectSTT or a decend of this
[in]identan identifier string
Attention
The newType MkTypeS::base is set to basicType and the MkObjectS::refCount of basicType is incremented.

◆ MkTypeDelete_RT()

MK_EXTERN void MkTypeDelete_RT ( MK_RT const  mkrt,
MK_TYP const  typ 
)

delete a type object

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typthe MkTypeS instance to work on - (nonnull)

◆ MkTypeDup2_RT()

MK_EXTERN MK_TYP MkTypeDup2_RT ( MK_RT const  mkrt,
MK_TYPN const  typ,
MK_STRN const  ident 
)

duplicate a type type as duplicate from existing type but the new name …

This kind of type is called a lightweight-type, because this type does not provide a new signature and mask. In difference to TypeDup2 the MkTypeCreate create a fullweight-type.

call the Dup2-Constructor from the object

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typthe MkTypeS instance to work on
[in]identan identifier string
Attention
The newType MkTypeS::base is set to srcType and the MkObjectS::refCount of srcType is incremented.

◆ MkTypeLog_RT()

MK_EXTERN void MkTypeLog_RT ( MK_RT const  mkrt,
MK_TYPN const  typ,
MK_OBJN  fmtobj,
MK_DBG const  debug,
MK_STRN const  callfunc,
MK_INT const  lvl 
)

log the MkTypeS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typthe MkTypeS instance to work on
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)
See also
MkObjectC_C_API

◆ MkTypeResolve()

MK_EXTERN MK_TYP MkTypeResolve ( MK_RT const  mkrt,
MK_TYPN const  typ 
)

resolve a new type

Every NEW runtime require a new Type, This code is called in a callback registered with MkRuntimeCallbackAdd TODO: htmlcode{mqsetting,resolve_example,create a new type and resolve}

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typthe MkTypeS instance to work on - (nonnull)