libmkkernel 9.0
Loading...
Searching...
No Matches
Data Fields
MkTypeS Struct Reference

define a Type object … More...

#include <kernel_mk.h>

+ Collaboration diagram for MkTypeS:

Data Fields

union { 
 
   struct MkObjectS   obj 
 
super 
 
MK_STRB type_name [MkTypeS_name_size]
 public type name like "MkBufferC"
 
MK_SIG objsig
 public st signatur of the type-instance
 
MK_SIG objmask
 public object signatur-mask of the type-instance
 
bool noSelf
 do NOT use the self feature -> used by MqFactoryS
 
MK_TYP base
 base type
 
size_t objsize
 the size of the new object created with this type, used in malloc
 
size_t typsize
 the size of the this type self, used in TypeDup2
 
MK_INT type_id
 default "0" but "MkFactoryTypeAdd" need more
 
MkTypeInitF type_init
 initializer for new type
 
MkToStringF toString
 get the string representation
 
MkLogF log
 "log" object data to MkLogFileC (default: stderr)
 
MkConstructorF constructor
 create an object
 
MkDestructorF destructor
 delete an object
 
MkDupF dup
 "dup" constructor
 
MkDup2F dup2
 "dup" constructor with "ident" initialisation
 
MkMergeF merge
 "merge" constructor
 
MkCopyF copy
 "copy"
 
MkResetF reset
 "reset" the object to the "initial" state
 
MkSelfCreateF selfCreate
 "create" the "self" pointer
 
MkSelfDeleteF selfDelete
 "delete" the "self" pointer
 
MkSelfUnlinkF selfUnlink
 "unlink" the "self" pointer from MQ, example RUBY
 
MkLogFormatF fLogFormat
 format the log message of an object, used in "sLogVL_O"
 
struct MkAllocDefS objalloc
 define the storage-allocator function
 
MK_OBJ instances
 linked list of instances belong to type
 

Detailed Description

define a Type object …

In Programming-Language-Micro-Kernel everything is a struct, there are type-struct(s) and instance-struct(s):

  1. A type-struct is derived from MkTypeS and provide type-properties (static-properties) and type-methods (slots)
  2. A instance-struct is derived from MkObjectS and provide instance-properties and instance-methods

An instance is full defined by min 4 structs and optional base-structs :

  1. instance-struct -> base-struct(s) -> object-struct (MkObjectS)
  2. instance-type -> base-type(s) -> type-type (MkTypeS)

The following naming-convention exist for the C-API (example: MkBufferC)

name definition
MkBufferS instance-struct → This is the main-struct to define an instance
MkBufferST instance-type as specific-instance-type
MkBufferSTT instance-type as common-instance-type (cast from MkBufferST into MkTypeS) …
MkBufferC_T instance-type as specific-instance-type, useable in a class-macro as: class##_T
MkBufferC_TT instance-type as common-instance-type, useable in a class-macro as: class##_TT
MK_BUF class-shortcut for struct MkBufferS *, all shortcut using the XX_YYY syntax (only for public API) …
MK_BUFR reference-shortcut for struct MkBufferS, all shortcut using the XX_YYYR syntax (only for public API) …
MkBufferCR instance-struct-reference same as struct MkBufferS, useable in a class-macro as: class##R
MkBufferCT_X(instance) cast from an instance into the specific-instance-type
MkBufferCTT_X(instance) cast from an instance into the common-instance-type
MkBufferCT_TT(typ) cast from an common-instance-type into an specific-instance-type
MkBufferCTT instance-type as common-instance-type for MkBufferC in the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)
MkBufferCT instance-type as specific-instance-type for MkBufferC in the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)

the struct(s) are defined as:

  1. The instance-type is a type-struct able to create an instance.
  2. The type-type is a type-struct not able to create an instance but used as super-class for a instance-type and the base-type
  3. The base-type is a type-struct and used to initialize the type-properties and type-methods (called slots).
    An instance provide methods and slots. A slot is a method predefined in the type like constructor. A list of all slots are defined in MkTypeS.

    example MkBufferC : MkTypeS -> MkDefTypeS -> MkObjectST -> MkBufferST

  4. The instance is a link between the instance-struct, the base-struct the instance-type and the base-type.

    example MkBufferC : MkBufferST -> MkBufferS <- MkObjectS

  5. The base-struct is used to provide the base-instance-properties
    struct MyBaseStruct {
    union {
    struct MkObjectS obj
    } super;
    // MyBaseStruct-properties
    }
    struct MyInstanceStruct {
    union {
    struct MkObjectS obj
    struct MyBaseStruct bse
    } super;
    // MyInstanceStruct-properties
    }
    object header …
    Definition kernel_mk.h:4442

To use the specific-instance-type as argument to a function or as property in a struct the common-instance-type of type MkTypeS is used. To cast a specific-instance-type into a common-instance-type use:

  1. the path: type->super.typ
  2. the shortcut: MkTYP(type)->XYZ (pointer) or MkTYP_R(type).XYZ (reference)

To get the common-instance-type from the instance use:

  1. the path: instance->super.obj.type
  2. the shortcut: MkOBJ(instance)->type (pointer) or MkOBJ_R(instance).type (reference)

To get the base-type from the instance-type use:

  1. the path: instance->super.obj.type->base
  2. the shortcut: MkOBJ(instance)->type->base (pointer) or MkOBJ_R(instance).type->base (reference)

The predefined instance-type is an instance of the default-instance-type (MkDefTypeS) …

struct MkRuntimeS {
...
struct MkDefTypeS _MkBufferST;
...
}
BASE-TYPE all non specific types
Definition kernel_mk.h:4885
The MkRuntimeS provide a per-thread environment for LibMkKernel …

The properties and slots of the instance-type are predefined by the base-type and may be overwritten …

MkInstanceTypeInit ( MkBufferC, MkObjectC ) ;
#define MkBufferST
instance-type as specific-instance-type …
Definition kernel_mk.h:6255
MK_EXTERN void MkBufferLog_RT(MK_RT const mkrt, MK_BUFN const buf, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_INT const lvl)
log the MkBufferC …
MK_EXTERN void MkBufferReset_RT(MK_RT const mkrt, MK_BUF const buf) MK_RT_ATTR_HDL
reset a MkBufferC to the length zero …
MK_EXTERN MK_STRN MkBufferToString_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
get the string representation of the buf …
MK_EXTERN MK_BUF MkBufferCopy_RT(MK_RT const mkrt, MK_BUF const buf, MK_BUFN const srce) MK_RT_ATTR_HDL
copy the MkBufferC from srce to dest …
MK_EXTERN void MkBufferDelete_RT(MK_RT const mkrt, MK_BUF const buf) MK_RT_ATTR_HDL
Destructor - delete a MkBufferC instance …
MK_EXTERN MK_BUF MkBufferMerge_RT(MK_RT const mkrt, MK_BUF const buf) MK_RT_ATTR_HDL
Merge-Constructor - create a new MkBufferC as a merge from an existing object …
MK_EXTERN MK_BUF MkBufferDup_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
Dup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance
MK_OBJ(* MkMergeF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4603
MK_OBJ(* MkCopyF)(MK_RT const mkrt, MK_OBJ const obj, MK_OBJN const src)
Definition kernel_mk.h:4604
void(* MkLogF)(MK_RT const mkrt, MK_OBJN const obj, MK_OBJ fmt, MK_INT const debug, MK_STRN const prefix, MK_INT const lvl)
Definition kernel_mk.h:4612
MK_OBJ(* MkDupF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4601
void(* MkDestructorF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4600
MK_STRN(* MkToStringF)(MK_RT const mkrt, MK_OBJN const obj)
Definition kernel_mk.h:4614
#define MkTYP_R(x)
cast a known-managed-object into an MkTypeS reference
Definition kernel_mk.h:4879
void(* MkResetF)(MK_RT const mkrt, MK_OBJ const obj)
Definition kernel_mk.h:4605

The following relationship between the three different struct exists:

  1. The instance-type and the type-type have the super-class MkTypeS and the instance not.
  2. The type-type is a super-class of an instance-type.
  3. The instance-type has the 3 attributes MkTypeS::objsig, MkTypeS::objmask and MkTypeS::objsize defined, the type-type not.
  4. The instance has access to the instance-type using the cast (example MkBufferCT_X(instance))
  5. The instance-type has access to the base using MkTypeS::base and to the type using MkObjectS::type.

Definition at line 4745 of file kernel_mk.h.

Field Documentation

◆ base

MK_TYP MkTypeS::base

base type

Definition at line 4758 of file kernel_mk.h.

◆ constructor

MkConstructorF MkTypeS::constructor

create an object

Definition at line 4768 of file kernel_mk.h.

◆ copy

MkCopyF MkTypeS::copy

"copy"

Definition at line 4773 of file kernel_mk.h.

◆ destructor

MkDestructorF MkTypeS::destructor

delete an object

Definition at line 4769 of file kernel_mk.h.

◆ dup

MkDupF MkTypeS::dup

"dup" constructor

Definition at line 4770 of file kernel_mk.h.

◆ dup2

MkDup2F MkTypeS::dup2

"dup" constructor with "ident" initialisation

Definition at line 4771 of file kernel_mk.h.

◆ fLogFormat

MkLogFormatF MkTypeS::fLogFormat

format the log message of an object, used in "sLogVL_O"

Definition at line 4778 of file kernel_mk.h.

◆ instances

MK_OBJ MkTypeS::instances

linked list of instances belong to type

Definition at line 4781 of file kernel_mk.h.

◆ log

MkLogF MkTypeS::log

"log" object data to MkLogFileC (default: stderr)

Definition at line 4767 of file kernel_mk.h.

◆ merge

MkMergeF MkTypeS::merge

"merge" constructor

Definition at line 4772 of file kernel_mk.h.

◆ noSelf

bool MkTypeS::noSelf

do NOT use the self feature -> used by MqFactoryS

Definition at line 4757 of file kernel_mk.h.

◆ obj

struct MkObjectS MkTypeS::obj

Definition at line 4748 of file kernel_mk.h.

◆ objalloc

struct MkAllocDefS MkTypeS::objalloc

define the storage-allocator function

The alloc_data is used as storage for the allocator-data and is set at definition. The alloc_createF and alloc_deleteF function is a pointer, NULL or 0x1

  • pointer -> use this pointer as external memory allocator
  • NULL -> use default MkSysCalloc MkSysFree
  • 0x1 -> use the MkTypeAllocpAllocCreatepAllocMemGet to use predefined storage with input from alloc_data attribute
Attention
, The alloc_createF HAVE TO set the MkObjectS::obj_protectisLocal to the value true (default: false) if the memory is static and must not be freed.

Definition at line 4780 of file kernel_mk.h.

◆ objmask

MK_SIG MkTypeS::objmask

public object signatur-mask of the type-instance

Definition at line 4756 of file kernel_mk.h.

◆ objsig

MK_SIG MkTypeS::objsig

public st signatur of the type-instance

Definition at line 4755 of file kernel_mk.h.

◆ objsize

size_t MkTypeS::objsize

the size of the new object created with this type, used in malloc

Definition at line 4759 of file kernel_mk.h.

◆ reset

MkResetF MkTypeS::reset

"reset" the object to the "initial" state

Definition at line 4774 of file kernel_mk.h.

◆ selfCreate

MkSelfCreateF MkTypeS::selfCreate

"create" the "self" pointer

Definition at line 4775 of file kernel_mk.h.

◆ selfDelete

MkSelfDeleteF MkTypeS::selfDelete

"delete" the "self" pointer

Definition at line 4776 of file kernel_mk.h.

◆ selfUnlink

MkSelfUnlinkF MkTypeS::selfUnlink

"unlink" the "self" pointer from MQ, example RUBY

Definition at line 4777 of file kernel_mk.h.

◆ [union]

union { ... } MkTypeS::super

◆ toString

MkToStringF MkTypeS::toString

get the string representation

Definition at line 4766 of file kernel_mk.h.

◆ type_id

MK_INT MkTypeS::type_id

default "0" but "MkFactoryTypeAdd" need more

Definition at line 4762 of file kernel_mk.h.

◆ type_init

MkTypeInitF MkTypeS::type_init

initializer for new type

Definition at line 4763 of file kernel_mk.h.

◆ type_name

MK_STRB MkTypeS::type_name[MkTypeS_name_size]

public type name like "MkBufferC"

Definition at line 4754 of file kernel_mk.h.

◆ typsize

size_t MkTypeS::typsize

the size of the this type self, used in TypeDup2

Definition at line 4760 of file kernel_mk.h.


The documentation for this struct was generated from the following file: