theKernel 10.0
Loading...
Searching...
No Matches
MkObjectC_TOR_C_API

MkObjectC - create and destroy a managed-objectMore...

+ Collaboration diagram for MkObjectC_TOR_C_API:

Macros

#define MkObjInit2(rtmkV, rtExtV, sigV, typeV, refCountV, isLocalV)
 Initialize an MkObjectS.
 
#define MkObjInit(rtmkV, rtExtV, cls, refCountV, isLocalV)
 
#define MkObjInitFromType(typeV, isLocalV)
 
#define MkObjInitFromInstance(instV)
 
#define MkObjectDelete_NULL(obj)
 
#define MkObjectDelete_NULL_X(x)
 
#define MkObjectDelete_1X(x)
 
#define MkObjectDeleteToNull(fct, NS, x)
 
#define MkObjectDeleteToNull_X(fct, NS, x)
 
#define MkObjectDispose_NULL(obj)
 
#define MkObjectDispose_NULL_X(x)
 
#define MkObjectDispose_1X(x)
 
#define MkObjectDeleteCallF_CHECK
 validate call to MkObjectDeleteCallF
 
#define MkObjectDeleteCallF_ARGS
 the MkObjectDeleteCallF arguments with default names
 
#define MkObjectDeleteCallF_CALL   MK_RT_CALL obj, __data__
 
#define MkObjectDeleteFreeF_ARGS   MK_RT_ARGS MK_CBP *dataP __parser__(inout)
 the MkObjectDeleteFreeF arguments with default names
 

Typedefs

typedef enum MkErrorE(* MkObjectDeleteCallF) (MK_RT mkrt, MK_OBJN const obj, MK_STRN const typeName, MK_HDL const typeHdl, MK_HDL const objHdl, MK_CBP const __data__)
 static callback to delete an obj
 
typedef void(* MkObjectDeleteFreeF) (MkObjectDeleteFreeF_ARGS)
 

Functions

MK_OBJ MkObjDup_RT (MK_RT mkrt, MK_OBJ const srcobj)
 call the Dup-Constructor from the object
 
MK_OBJ MkObjDup2_RT (MK_RT mkrt, MK_OBJ const srcmng, MK_STRN const ident)
 call the Dup2-Constructor from the object
 
MK_OBJ MkObjMerge_RT (MK_RT mkrt, MK_OBJ const obj)
 Constructor - create a new object as a merge from an existing object
 
MK_OBJ MkObjCreate_RT (MK_RT mkrt, MK_TYP type, MK_PTR nat, MK_PTR lnk)
 call the Constructor from the object
 
void MkObjectDelete_RT (MK_RT mkrt, MK_OBJ obj)
 Delete-Slot - delete an instance.
 
void MkObjectDispose_RT (MK_RT mkrt, MK_OBJ obj)
 Dispose-Slot - untie the connection between the Native-Java-Instance and the jvmkkernel-Instance.
 
enum MkErrorE MkObjectDeleteCallbackSetup_RT (MK_RT mkrt, MK_STRN ident, MkObjectDeleteCallF fCall, MK_CBP callback, MkObjectDeleteFreeF fFree, MK_STRN filter)
 Create/Delete the instance-delete-callback
 
void MkObjectDeleteCallbackCleanup_RT (MK_RT mkrt, MK_STRN ident)
 cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup
 

MkObjectC - MkObjectC_TOR_C_API - overload

#define MkObjDup_NULL(...)
 
#define MkObjDup(...)
 
#define MkObjMerge_NULL(...)
 
#define MkObjMerge(...)
 
#define MkObjCreate_NULL(...)
 
#define MkObjCreate(...)
 
#define MkObjCreate_2(nat, lnk)
 
#define MkObjectDispose(x)
 
#define MkObjectDelete(x)
 
#define MkObjDup2_NULL(...)
 
#define MkObjDup2(...)
 
#define MkObjectDeleteCallbackCleanup_NULL(...)
 
#define MkObjectDeleteCallbackCleanup(...)
 
#define MkObjectDeleteCallbackSetup_NULL(...)
 
#define MkObjectDeleteCallbackSetup(...)
 
#define MkObjectDeleteCallbackSetup_E(...)
 
#define MkObjectDeleteCallbackSetup_C(...)
 

Detailed Description

MkObjectC - create and destroy a managed-object

Macro Definition Documentation

◆ MkObjCreate

#define MkObjCreate ( ...)
Value:
MK_OBJ MkObjCreate_RT(MK_RT mkrt, MK_TYP type, MK_PTR nat, MK_PTR lnk)
call the Constructor from the object
#define MK_RT_CALL

Definition at line 1796 of file kernel_overload_mk.h.

◆ MkObjCreate_2

#define MkObjCreate_2 ( nat,
lnk )
Value:
MkObjCreate(NULL,nat,lnk)
#define MkObjCreate(...)

Definition at line 1797 of file kernel_overload_mk.h.

◆ MkObjCreate_NULL

#define MkObjCreate_NULL ( ...)
Value:
#define MK_RT_CALL_NULL

Definition at line 1795 of file kernel_overload_mk.h.

◆ MkObjDup

#define MkObjDup ( ...)
Value:
MkObjDup_RT(MK_RT_CALL __VA_ARGS__)
MK_OBJ MkObjDup_RT(MK_RT mkrt, MK_OBJ const srcobj)
call the Dup-Constructor from the object

Definition at line 1790 of file kernel_overload_mk.h.

◆ MkObjDup2

#define MkObjDup2 ( ...)
Value:
MK_OBJ MkObjDup2_RT(MK_RT mkrt, MK_OBJ const srcmng, MK_STRN const ident)
call the Dup2-Constructor from the object

Definition at line 1807 of file kernel_overload_mk.h.

◆ MkObjDup2_NULL

#define MkObjDup2_NULL ( ...)
Value:

Definition at line 1806 of file kernel_overload_mk.h.

◆ MkObjDup_NULL

#define MkObjDup_NULL ( ...)
Value:

Definition at line 1789 of file kernel_overload_mk.h.

◆ MkObjectDelete

#define MkObjectDelete ( x)
Value:
#define MkObjectDeleteToNull(fct, NS, x)
void MkObjectDelete_RT(MK_RT mkrt, MK_OBJ obj)
Delete-Slot - delete an instance.

Definition at line 1803 of file kernel_overload_mk.h.

◆ MkObjectDelete_1X

#define MkObjectDelete_1X ( x)
Value:
#define MkObjectDeleteToNull_X(fct, NS, x)

Definition at line 4394 of file LibMkKernel_mk.h.

◆ MkObjectDelete_NULL

#define MkObjectDelete_NULL ( obj)
Value:

Definition at line 4392 of file LibMkKernel_mk.h.

◆ MkObjectDelete_NULL_X

#define MkObjectDelete_NULL_X ( x)
Value:

Definition at line 4393 of file LibMkKernel_mk.h.

◆ MkObjectDeleteCallbackCleanup

#define MkObjectDeleteCallbackCleanup ( ...)
Value:
void MkObjectDeleteCallbackCleanup_RT(MK_RT mkrt, MK_STRN ident)
cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup …

Definition at line 1811 of file kernel_overload_mk.h.

◆ MkObjectDeleteCallbackCleanup_NULL

#define MkObjectDeleteCallbackCleanup_NULL ( ...)
Value:

Definition at line 1810 of file kernel_overload_mk.h.

◆ MkObjectDeleteCallbackSetup

#define MkObjectDeleteCallbackSetup ( ...)
Value:
enum MkErrorE MkObjectDeleteCallbackSetup_RT(MK_RT mkrt, MK_STRN ident, MkObjectDeleteCallF fCall, MK_CBP callback, MkObjectDeleteFreeF fFree, MK_STRN filter)
Create/Delete the instance-delete-callback …

Definition at line 1813 of file kernel_overload_mk.h.

◆ MkObjectDeleteCallbackSetup_C

#define MkObjectDeleteCallbackSetup_C ( ...)
Value:
#define MkErrorCheckI(err)
#define MkObjectDeleteCallbackSetup(...)

Definition at line 1815 of file kernel_overload_mk.h.

◆ MkObjectDeleteCallbackSetup_E

#define MkObjectDeleteCallbackSetup_E ( ...)
Value:
#define MkErrorCheck(err)
check return-code and goto error on error …

Definition at line 1814 of file kernel_overload_mk.h.

◆ MkObjectDeleteCallbackSetup_NULL

#define MkObjectDeleteCallbackSetup_NULL ( ...)
Value:

Definition at line 1812 of file kernel_overload_mk.h.

◆ MkObjectDeleteCallF_ARGS

#define MkObjectDeleteCallF_ARGS
Value:
MK_RT_ARGS \
MK_OBJN const obj __parser__(internal), \
MK_STRN const typeName, \
MK_HDL const typeHdl, \
MK_HDL const objHdl, \
MK_CBP const __data__ \
#define __parser__(...)
parser: apply an attribute to an object in local scope …
const MK_STRB * MK_STRN
constant string pointer data-type
MK_PTRB * MK_CBP
generic pointer to call-back data
int32_t MK_HDL
4 byte int handle data-type

the MkObjectDeleteCallF arguments with default names

Definition at line 4431 of file LibMkKernel_mk.h.

4431#define MkObjectDeleteCallF_ARGS \
4432 MK_RT_ARGS \
4433 MK_OBJN const obj __parser__(internal), \
4434 MK_STRN const typeName, \
4435 MK_HDL const typeHdl, \
4436 MK_HDL const objHdl, \
4437 MK_CBP const __data__ \
4438

◆ MkObjectDeleteCallF_CALL

#define MkObjectDeleteCallF_CALL   MK_RT_CALL obj, __data__

Definition at line 4439 of file LibMkKernel_mk.h.

◆ MkObjectDeleteCallF_CHECK

#define MkObjectDeleteCallF_CHECK
Value:
do { \
assert (__data__ != NULL); \
} while (0)

validate call to MkObjectDeleteCallF

Definition at line 4425 of file LibMkKernel_mk.h.

4425#define MkObjectDeleteCallF_CHECK do { \
4426 assert (__data__ != NULL); \
4427} while (0)

◆ MkObjectDeleteFreeF_ARGS

#define MkObjectDeleteFreeF_ARGS   MK_RT_ARGS MK_CBP *dataP __parser__(inout)

the MkObjectDeleteFreeF arguments with default names

Definition at line 4489 of file LibMkKernel_mk.h.

◆ MkObjectDeleteToNull

#define MkObjectDeleteToNull ( fct,
NS,
x )
Value:
if (x) { fct (NS##_RT_CALL x); (x) = NULL ; }

Definition at line 4396 of file LibMkKernel_mk.h.

◆ MkObjectDeleteToNull_X

#define MkObjectDeleteToNull_X ( fct,
NS,
x )
Value:
if (x) { fct (NS##_RT_CALL MkOBJ(x)); (x) = NULL ; }
#define MkOBJ(x)
cast a known-object into an MkObjectS pointer

Definition at line 4397 of file LibMkKernel_mk.h.

◆ MkObjectDispose

#define MkObjectDispose ( x)
Value:
void MkObjectDispose_RT(MK_RT mkrt, MK_OBJ obj)
Dispose-Slot - untie the connection between the Native-Java-Instance and the jvmkkernel-Instance.

Definition at line 1800 of file kernel_overload_mk.h.

◆ MkObjectDispose_1X

#define MkObjectDispose_1X ( x)
Value:
#define MkObjectDispose(x)

Definition at line 4422 of file LibMkKernel_mk.h.

◆ MkObjectDispose_NULL

#define MkObjectDispose_NULL ( obj)
Value:

Definition at line 4420 of file LibMkKernel_mk.h.

◆ MkObjectDispose_NULL_X

#define MkObjectDispose_NULL_X ( x)
Value:

Definition at line 4421 of file LibMkKernel_mk.h.

◆ MkObjInit

#define MkObjInit ( rtmkV,
rtExtV,
cls,
refCountV,
isLocalV )
Value:
MkObjInit2(rtmkV,rtExtV,cls##_SIGNATURE,cls##_TT,refCountV,isLocalV)
#define MkObjInit2(rtmkV, rtExtV, sigV, typeV, refCountV, isLocalV)
Initialize an MkObjectS.

Definition at line 4284 of file LibMkKernel_mk.h.

4284#define MkObjInit(rtmkV,rtExtV,cls,refCountV,isLocalV) \
4285 MkObjInit2(rtmkV,rtExtV,cls##_SIGNATURE,cls##_TT,refCountV,isLocalV)

◆ MkObjInit2

#define MkObjInit2 ( rtmkV,
rtExtV,
sigV,
typeV,
refCountV,
isLocalV )
Value:
(struct MkObjectS) { \
.signature = sigV, \
.refCount = refCountV, \
.self = NULL, \
.type = typeV, \
.env = NULL, \
.selfCreated = false, \
.selfRefCount = 0, \
.objRt = rtmkV, \
.objRtExt = rtExtV, \
.obj_protect = { \
.isLocal = isLocalV, \
.prev = NULL, \
.next = NULL, \
}, \
}
object header …

Initialize an MkObjectS.

This is internal code used in the CTOR toinitialize the memory after the new object was created.

#define MkDumpObjInit MkObjInit(MkDump, 0, false)
...
Attention
with .obj_protect.isLocal=true the MkSelfDeleteForce_RT will NOT delete the memory

Definition at line 4247 of file LibMkKernel_mk.h.

4247 #define MkObjInit2(rtmkV,rtExtV,sigV,typeV,refCountV,isLocalV) \
4248 (struct MkObjectS) { \
4249 .signature = sigV, \
4250 .refCount = refCountV, \
4251 .self = NULL, \
4252 .type = typeV, \
4253 .env = NULL, \
4254 .selfCreated = false, \
4255 .selfRefCount = 0, \
4256 .objRt = rtmkV, \
4257 .objRtExt = rtExtV, \
4258 .obj_protect = { \
4259 .isLocal = isLocalV, \
4260 .prev = NULL, \
4261 .next = NULL, \
4262 }, \
4263 }

◆ MkObjInitFromInstance

#define MkObjInitFromInstance ( instV)
Value:
MkObjInit2(MK_RT_PTR, NULL, MkOBJ_R(instV).type->objsig, MkOBJ_R(instV).type, 0, false)
#define MkOBJ_R(x)
cast a known-object into an MkObjectS reference
#define MK_RT_PTR

Definition at line 4292 of file LibMkKernel_mk.h.

4292#define MkObjInitFromInstance(instV) \
4293 MkObjInit2(MK_RT_PTR, NULL, MkOBJ_R(instV).type->objsig, MkOBJ_R(instV).type, 0, false)

◆ MkObjInitFromType

#define MkObjInitFromType ( typeV,
isLocalV )
Value:
MkObjInit2(MK_RT_PTR, NULL, (*typeV).objsig, typeV, 0, isLocalV)

Definition at line 4288 of file LibMkKernel_mk.h.

4288#define MkObjInitFromType(typeV,isLocalV) \
4289 MkObjInit2(MK_RT_PTR, NULL, (*typeV).objsig, typeV, 0, isLocalV)

◆ MkObjMerge

#define MkObjMerge ( ...)
Value:
MK_OBJ MkObjMerge_RT(MK_RT mkrt, MK_OBJ const obj)
Constructor - create a new object as a merge from an existing object

Definition at line 1792 of file kernel_overload_mk.h.

◆ MkObjMerge_NULL

#define MkObjMerge_NULL ( ...)
Value:

Definition at line 1791 of file kernel_overload_mk.h.

Typedef Documentation

◆ MkObjectDeleteCallF

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

static callback to delete an obj

This callback is called when the obj is deleted. Setting up the callback is done using the MkObjectDeleteCallbackSetup function.

Introduction

Deleting an obj is not easy because there are generally two parts, the Target-Programming-Language (TPL) part and the Programming-Language-Micro-Kernel (PLMK) part.

Generally, two callbacks are involved:

  • The C-callback runs under the control of the PLMK
  • The TPL-callback runs under the control of the TPL. (non C language)
Definition
The obj is defined by the three callback arguments typeName, typeHdl and objHdl.
  • The objHdl is important because this is the export handle used as a reference to the internal object.
  • In Remote-Procedure-Call (RPC), this export handle is used to link the client object to the server object, and when the server object is deleted, the client object must also be deleted.
Workflow
This callback is called in MkRefDecrWithoutSelf and MkRefDecrWithUnlinkSelf, immediately before the PLMK-part is deleted and generally (not always) after the TPL-part is deleted.
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objthe theKernel part of the object, only use internal in the C-callback
[in]typeNamethe return from MkObjectToNameOfType
[in]typeHdlthe return from MkObjectHandleGetOfType
[in]objHdlthe return from MkObjectHandleGet
Exceptions
MkExceptionC→ The default-exception from the Programming-Language-Micro-Kernel (PLMK)
Attention

It is a design flaw to use obj in the TPL-callback because using obj or using the MkObjectHandleResolve function on objHdl will recreate the already deleted TPL-object and this generally breaks the TPL-runtime.

Just think of a Garbage-Collection (GC) deleting an object and that object is reborn in the GC deletion process.

Note
In the Target-Programming-Language (TPL) the TPL-callback is only called if the obj has a MkObjectS::self pointer.

Definition at line 4415 of file LibMkKernel_mk.h.

◆ MkObjectDeleteFreeF

typedef void( * MkObjectDeleteFreeF) (MkObjectDeleteFreeF_ARGS)

Definition at line 4492 of file LibMkKernel_mk.h.

Function Documentation

◆ MkObjCreate_RT()

MK_OBJ MkObjCreate_RT ( MK_RT mkrt,
MK_TYP type,
MK_PTR nat,
MK_PTR lnk )

call the Constructor from the object

Create a new object using type and an additional nat. This requie a MkTypeS::constructor be available

Attention
the type have to be resolved fist, already done in MkObjCreate->MkTypeResolve

◆ MkObjDup2_RT()

MK_OBJ MkObjDup2_RT ( MK_RT mkrt,
MK_OBJ const srcmng,
MK_STRN const ident )

call the Dup2-Constructor from the object

The Dup2-Constructor create a new object-shell, and copy all the internal data from the srcobj to the newobj. An additional ident is used to set e name ressource After the Dup2-Constructor the srcobj is unchanged.

Returns
the new object or null if no Dup2-Constructor fails
See also
MkObjMerge MkObjReset MkTypeDup2

◆ MkObjDup_RT()

MK_OBJ MkObjDup_RT ( MK_RT mkrt,
MK_OBJ const srcobj )

call the Dup-Constructor from the object

This is an Instance-Callback the real Dup function called depend on the MkObjectS::type.

The Dup-Constructor create a new object-shell, and copy all the internal data from the srcobj to the newobj. After the Dup-Constructor the srcobj is unchanged.

The new instance belongs to the caller and may have to be released if necessary. A manual release using ObjectDelete is always possible, but the instance can no longer be used afterwards.

Returns
The newly created MkObjectC instance, the instance is owned by the caller
See also
MkObjMerge_RT MkObjReset_RT

◆ MkObjectDelete_RT()

void MkObjectDelete_RT ( MK_RT mkrt,
MK_OBJ obj )

Delete-Slot - delete an instance.

There are two different ways to delete an instance:

ObjectDisposeto free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
  1. The internal memory will be freed and the object-pointer will be set to NULL. If the object-pointer is already NULL nothing will be done.
  2. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
  3. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
  4. After a SOFT-delete, the outher shell is still alive, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.
  5. On HARD-delete read more at MkSelfDeleteForce

◆ MkObjectDeleteCallbackCleanup_RT()

void MkObjectDeleteCallbackCleanup_RT ( MK_RT mkrt,
MK_STRN ident )

cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup

See also
MkObjectDeleteCallbackSetup

◆ MkObjectDeleteCallbackSetup_RT()

enum MkErrorE MkObjectDeleteCallbackSetup_RT ( MK_RT mkrt,
MK_STRN ident,
MkObjectDeleteCallF fCall,
MK_CBP callback,
MkObjectDeleteFreeF fFree,
MK_STRN filter )

Create/Delete the instance-delete-callback

The callback is called shortly before deleting an instance and is used to synchronize object management across the network.

The ident identifies the callback

  • before a new callback is created the existing-callback with name ident is deleted.
  • The ident is also required to delete the callback.
  • If the special ident ALL is used than all callbacks are deleted first.

The fCall (C-Only) or callback (Non-C) it is the callback called

  • If null than the callback with name ident is deleted if exists and no new callback is created.
  • If null then it is identical to MkObjectDeleteCallbackCleanup(ident).

The filter is a POSIX Extended Regular Expression to filter on type-names.

  • The filter is optional and is only used if not null and not "":
  • The filter is applied to MkTypeS::type_name like MkBufferC.
  • The POSIX Extended Regular Expression syntax is defined in man 7 regex.
  • If the filter is not used, the fCall is called on every instance deletion !
C-callback definition details:
Read more at MkObjectDeleteCallF
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]identIdentify the callback, have to ne non null and not "".
[in]fCall(C-Only) Internal required: the callback, if null than the callback is deleted.
[in]callbackOptional: the parameter for fcall, for cleanup use fFree.
[in]fFree(C-Only) Internal optional: cleanup callback data
[in]filterOptional: is an regular expression to filter for MkTypeS::type_name.
See also
MkObjectDeleteCallbackCleanup
MkObjectDeleteCallbackSetup : overload
public native static void DeleteCallbackSetup (String ident, MkObjectDeleteIF callback, String filter);
public static void DeleteCallbackSetup (String ident) {
DeleteCallbackSetup (ident, null, null);
}
MkObjectDeleteCallbackSetup : callback signature
Read more at: Callback signature
MkObjectDeleteCallbackSetup : callback example
Read more at: Callback example

◆ MkObjectDispose_RT()

void MkObjectDispose_RT ( MK_RT mkrt,
MK_OBJ obj )

Dispose-Slot - untie the connection between the Native-Java-Instance and the jvmkkernel-Instance.

There are two different ways to delete an instance:

ObjectDispose to free the internal data but keep the outher shell alive - this is called a SOFT-DELETE
ObjectDelete to delete the outher shell including the internal data - this is called a HARD-DELETE
Attention
1. For a programming language without HARD-Delete support, the "Delete" method is assigned to a SOFT-Delete.
2. For a programming language without garbage collection, a SOFT-delete without a HARD-delete causes a small memory loss (C++: ~32 bytes).
3. After a SOFT-delete, the outher shell is still active, but cannot be used. Any access to this shell generates an HDL-null-exception, but this exception can be caught. This is important for C++ as it prevents a core dump.

◆ MkObjMerge_RT()

MK_OBJ MkObjMerge_RT ( MK_RT mkrt,
MK_OBJ const obj )

Constructor - create a new object as a merge from an existing object

The Merge-Constructor create a new object-shell, and take-over all the internal data from the source-object. After the Merge-Constructor the source-object is empty as if a object-reset was called.

One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]objThe source-object of the merge.
Returns
The new object or null if no Merge-Constructor is available
Attention
The new object have to be deleted.
See also
MkObjDup_RT MkObjReset_RT MkObjectDelete