gomkkernel 9.0
Loading...
Searching...
No Matches
gomkkernel

The Programming-Language-Micro-Kernel Project.

SYNOPSIS

The gomkkernel package is the implementation of the Programming-Language-Micro-Kernel into the target-language Go.

import "gomsgque/mkkernel"

The gomkkernel package is a composition of multiple classes defining the Programming-Language-Micro-Kernel:

object description
mkkernel the namespace with all gomkkernel specific definitions
mkkernel.Attribute the interface to access the package specific attribute
mkkernelMkClassC.Attribute the interface to access the class specific attribute
Instance.Attribute the interface to access the instance specific attribute

To access all features without mkkernel prefix use:

import alias "gomsgque/mkkernel"

Using the gomkkernel package …
To access the gomkkernel package/module read the following documentation

GO initialization hint

‍In general the GO language does NOT require the call of [static] Setup() or [static] Cleanup() because this language is static linked and all initialization is done in the init default function.

GU application build

‍To build a GO application is more difficult as to build an other language application if you use your own build tool like automake etc.

The GO build-system is entirly hidden by the end-user and using a cache for speedup but the entire build is very slow if C code is involved.
GO does not have the concept of a shared-library as a collection of precompiled-code, and also each GO build is a build of all source-code including the source-code of all required libraries.

‍A module/package in GO is more like a zip file, i.e. a collection of source-code.

To make a parallel-build it is important to update the GO-cache first. The cache is updated if first a pre-build of a single exetuable is done using the same options as all the following parallel builds.
To access the gomkkernel package/module read the following documentation

GO initialization hint

‍In general the GO language does NOT require the call of [static] Setup() or [static] Cleanup() because this language is static linked and all initialization is done in the init default function.

GU application build

‍To build a GO application is more difficult as to build an other language application if you use your own build tool like automake etc.

The GO build-system is entirly hidden by the end-user and using a cache for speedup but the entire build is very slow if C code is involved.
GO does not have the concept of a shared-library as a collection of precompiled-code, and also each GO build is a build of all source-code including the source-code of all required libraries.

‍A module/package in GO is more like a zip file, i.e. a collection of source-code.

To make a parallel-build it is important to update the GO-cache first. The cache is updated if first a pre-build of a single exetuable is done using the same options as all the following parallel builds.

INDEX

BASICS
Philosophy , Package , ManagedObject , PrimitiveTypes , StorageManagement ,
CLASS
MkKernel PACKAGE , MkObjectC , MkBufferC , MkBufferStreamC , MkBufferListC , MkLogFileC , MkErrorC , MkRuntimeC
MISC
BinaryObject, Examples

INTRODUCTION

C-API: MK_C_API - Namespace for the LibMkKernel API …

The LibMkKernel API …

PHILOSOPHY

The MkKernel project is an infrastructure that link an library-item with a Target-Programming-Language using the Programming-Language-Micro-Kernel object-interface. The goal is a programming language independent interface between a C library and a target language.

Philosophy
Write Once → Run Everywhere

The library-item is a c-api for a library available as c-header-file.
The library-item is mapped into a Target-Programming-Language using a language that is supported by the Programming-Language-Micro-Kernel.
Supported Languages are: (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)

Strategy
It takes 4 years to write a programming-language, but it only takes 4 weeks to insert a micro-kernel.

The library-item is connected to the Target-Programming-Language using an api-layer generated by the token-stream-compiler of the Programming-Language-Micro-Kernel.

Conclusion
The MkKernel-Project is used to manage a collection of library-items using an API that is available in all major programming-languages.

PROGRAMMING

The MkKernel is responsible for:

  • providing the startup and cleanup API
  • providing the memory and caching API
  • providing the logging, debugging and error API
  • providing basic objects like buffer, list, stream, logging, runtime and error

The LibMsgque is separted into three programming-layers:

  1. The foundation-layer, used by the MkKernel library programmer
  2. The kernel-layer, used by the Programming-Language-Micro-Kernel programmer
  3. The implementation-layer, used by the target-language programmer
foundation-layer
The foundation-layer implement the libmkkernel library and is also responsible for the quality-target of the entire project.
  • establishing and managing the library-items
  • memory-management and garbage-collection
  • error-handling
  • logging and debugging
  • written in plain C
kernel-layer
The kernel-layer implement the Programming-Language-Micro-Kernel and is also responsible to generate and maintain the target-language-API source-code.
  • implementation of the managed-object technology
  • implementation of the token-stream-compiler technology
  • written in plain C, TCL and the target-language-API
implementation-layer
The implementation-layer is the API used by the target-language-programmer.
  • written in plain target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)
Target
!! This documentation describe the implementation-layer and target the Go programmer. !!

PACKAGE

C-API: MkKernel_C_API - The package is the toplevel structure of the Programming-Language-Micro-Kernel

The gomkkernel package is loaded with:

import "gomsgque/mkkernel"

and is a composition of one or more class-item.

The gomkkernel package add the following public classes into MkObjectC_C_API :

Object C-Type Description
MkObjectC MK_OBJ The MkObjectC object known as obj or object is used as base-object type for a managed-object
MkBufferC MK_BUF The MkBufferC object known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. …
MkBufferStreamC MK_BUS The MkBufferStreamC object known as bus or stream is a subclass of MkBufferC used for package-based-io
MkBufferListC MK_BFL The MkBufferListC object known as bfl or buffer-list is used to create and manage a list of MkBufferC
MkLogFileC MK_LFL The MkLogFileC object known as lfl or log-file is used to control … the target of the logging-output.
MkErrorC MK_ERR The MkErrorC object known as err or error is used to create … and manage an error message …
MkRuntimeC MK_RT The MkRuntimeC class known as mkrt or runtime is the main gomkkernel application environment …

The gomkkernel package add the following public types into MkObjectC_C_API :

    ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType)
    |
    |- ABSTRACT: MkDefTypeSTT (TypeType = type of a Type)
       |
       |- MkObjectST, MkLogFileST, MkBufferListST,
       |- MkErrorPanicST, MkErrorIgnoreST, MkErrorPrintST, MkErrorDefaultST, MkErrorST
       |
       |- ABSTRACT: MkBufferST
          |- FINAL: MkBuffer64ST, MkBuffer256ST, MkBuffer1024ST
          |- ABSTRACT: MkBufferStreamST
             | FINAL: MkBufferStream64ST, MkBufferStream256ST, MkBufferStream1024ST, MkBufferStream16384ST

MANAGED OBJECT

C-API: MkObjectC_C_API - The MkObjectC object known as obj or object is used as base-object type for a managed-object

libmqmsgque is also called as Programming-Language-Micro-Kernel. libmqmsgque is like a programming-language without syntax but using the Target-Programming-Language (in our case Go) of the Micro-Kernel as runtime environment.

Integration
To operate as a Micro-Kernel a maximum integration into the Target-Programming-Language is available.

This integration is done using the managed-object-technology.

Managed-Object
A managed-object is a piece of C-Code able to act as a native datatype in all Target-Programming-Languages supported.

The managed object supports low level integration features descripted in MkObjectS :

  • object identification based on signatures
  • reference counting
  • management of the self object pointer for the target-language
  • object-type specific features provided with MkTypeS

In the implementation-layer of gomkkernel only the public-features of the MkObjectC are visible to the programmer.

MANAGED OBJECT TYPES

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 GoMkKernel …

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.

MANAGED OBJECT PROGRAMMING

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

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.

  • The managed-object supports one or more super-class using a union with struct MkObjectS obj as the first attribute in the union.
  • The union is required because the managed-object share the memory with the super-class.

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

  • "cast" from an unknown pointer: MK_BUF ret = MkBuf(ptr);
    • This "cast" is called an up-cast because you're upgrading the pointer (getting more information).
    • This "cast" checks the MkObjectS::signature to ensure that ptr is a valid object.
    • This "cast" is checked at runtime.
  • "cast" from a managed pointer: MK_BUF ret = MkBUF(ptr);
    • This "cast" is called a down-cast because you downgrading the pointer (lose some information).
    • This "cast" uses the super-union to just return a pointer that is already available.
    • This "cast" is checked at compile time.
  • To put it simply: MkBuf ≠ MkBUF

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

PRIMITIVE TYPE

C-API: MkKernel_PrimitiveType_C_API - a collection of all native-data-types supported by MkBufferC

The data send from one package-item to an other package-item is focused on speed and usability. By default the data is send as binary, only if the endian changes or a string representation is required an additional transformation is done.
The data send from one package-item to an other package-item is limited to a collection of specific types, based on native C data types.
An gomkkernel-API command with a focus on a specific type is using a type-postfix, for example MqReadC read a (C=string) data from the read-package.
In the documentation the type-item (TT) is a synonym for a (Y,O,S,I,W,F,D,B,C,L,U) type-item.

The following native-type identifier are available:

TT native comment
Y int8 1 byte signed character
O bool 1 byte boolean value using true or false
S int16 2 byte signed short
I int32 4 byte signed integer
W int64 8 byte signed long long integer
F float32 4 byte float
D float64 8 byte double
B []byte unsigned char array used for binary data
C string string data using a \0 at the end

The following compose-type identifier's are available:

TT native comment
U MkBufferCI buffer-item that can hold any single typed item from above
L MkBufferListCI buffer-list that can hold many buffer-item from above

Every native-data-type is encapsualted into a MkBufferC. A MkBufferC is type safe, this mean that every read to a MkBufferC have to match the data-type of the previous write. One exception is available, the cast from and to the string data-type (TYPE=C) is allowed.

Sending data mean sending one ore more MkBufferC from one package-item to an other package-item. The sender is using a MqSendTT command to put data as MkBufferC into an send-data-package and the reveiver is using a MqReadTT command to retrieve the data from the read-data-package.

CLASS TYPE

C-API: MkKernel_ClassType_C_API - a collection of types using the META class definition …

TODO

POINTER TYPE

C-API: MkKernel_PointerType_C_API - a collection of types allocates as array of data and supported by MkBufferC

For native type support read: MkKernel_PrimitiveType_C_API

The pointer-type is part of the native-type and usually support the size argument to propper allocate storage.

The following pointer-type identifier is available in MkBufferS:

TT type const type comment
B MK_BIN MK_BINN unsigned char array used for binary data ([]byte)
C MK_STR MK_STRN string data using a \0 at the end (string)

STORAGE MANAGEMENT

C-API: MkKernel_Storage_C_API - Storage Management …

Storage management is used in gomkkernel to provide temporary storage. It is a common design pattern that gomkkernel only returns a reference to the Internal-Temporary-Storage (ITS), so the Internal-Active-Storage (IAS) is not returned to the external end user. The ITS is a storage that is only used as a return value and nothing else. The temporary in ITS refers exclusively to the current state of the storage and not to the lifespan of the storage, the ITS is only allocated once at startup and then used again and again, similar to the static storage in C.

Internal gomkkernel distinguishes three different storage sources:

Context-Local-Storage (CLS)
CLS is tied to a specific MqContextC.
Example: the MqReadU returns a reference to an internal MkBufferC.
Funktion-Local-Storage (FLS)
FLS is used as the local temporary storage, usually as thread-local-storage, of a function-return-value.
Example: the MqReadL returns a MkBufferListC which is filled with multiple MkBufferC.
Runtime-Local-Storage (RLS)
RLS is used as global storage per RunTime instance.
Example: the MkErrorC only exists ONCE per runtime.

The CLS and FLS have the same visibility to the end user and are explained together as FLS.
The RLS is not mentioned in this documentation section because the RLS is more internal than CLS and FLS.

The end-user uses a FLS reference like a normal local GO variable but with the following restriction:

  1. The value of the variable is a reference to the FLS storage belonging to the method that returned the reference.
  2. A FLS storage only ever exists once in a thread, which means that the FLS storage of a reference is overwritten if the FLS storage is used a second time in the same context.
  3. A context is, for example, a coherent block of code such as in a "service callback". A coherent context is broken if the same method that returned the original FLS as a result is called a second time or if a method is called that uses the "event loop".
  4. FLS storage must NOT be released by the end user, the Programming-Language-Micro-Kernel always ensures that the storage management of gomkkernel and the target-language is synchronized.
  5. If a FLS reference is added to another reference and this reference is also managed by the Programming-Language-Micro-Kernel, the Programming-Language-Micro-Kernel automatically ensures that the storage management is coherent, which means that the end user does not have to do anything.
  6. The FLS reference can be updated. This means that the FLS storage is being updated because the reference owner (usually a local variable) temporarily owns the FLS storage.

The "Dup" (duplicate) function is used to convert a temporary FLS variable into a global storage. The global storage is managed by the end user and may have to be released depending on the target programming language.

Example from server.go "ReadL" overwrite previous "ReadL"

type BFL2 Server
  func (this *BFL2) Call() {
    tmp1 := this.ReadL()                          // "tmp1" is now a reference to the FLS storage of "ReadL"
    tmp2 := this.ReadL()                          // ERROR: the "tmp2" is using a SHARED reference with "tmp1"
    this.Send("R","LL",tmp1,tmp2)                 // ERROR: "tmp1" and "tmp2" are the SAME values
  }

Example from server.go "ReadL" overwrite previous "ReadL" even in an "Event-Loop"

type BFL3 Server
  func pBFL3(this *MqContextC) {
    /* tmp2 = */ this.ReadL()                     // ERROR: the "tmp2" is using a SHARED reference with "tmp1"
  }
  func (this *BFL3) Call() {
    tmp1 := this.ReadL()                          // "tmp1" is now a reference to the FLS storage of "ReadL"
    this.Send("C",pBFL3,"ECOL:[III]",4,5,6)  // ATTENTION: callback "pBFL3" using "ReadL"
    this.ProcessEvent_1(MQ_WAIT_OWN)              // ERROR: enter event-loop, callback "pBFL3" is called
    this.Send("R","L",tmp1)                       // ERROR: "tmp1" has now the value from "tmp2"
  }

Example from server.go convert "ReadL" result into global storage using "Dup" and free later

type BFL4 Server
  func (this *BFL4) Call() {
    tmp1 := this.ReadL()                          // "tmp1" is now a reference to the FLS storage of "ReadL"
    glb1 := tmp1.Dup()                            // OK: "glb1" is now a UNSHARED reference to the global memory
    tmp2 := this.ReadL()                          // ERROR: the "tmp2" is using a SHARED reference with "tmp1"
    this.Send("R","LL",glb1,tmp2)                 // ATTENTION: glb1 will be freed by GO
  }

TLS storage used by the *CreateTLS style of functions

In the C language the TLS (Thread-Local-Storage) is unique per definition and the name is used to distinguish the storage.

‍The Problem is to create a TLS interface useable in all target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) supported by the Programming-Language-Micro-Kernel.

The *CreateTLS style function return a TLS that is unique per runtime and not unique per definition. The tlsid (0,1,2,3...) is used to distinguish the storage.

Note
Every *CreateTLS style function with the same tlsid return the same memory in the same thread.

There is always a risk that the memory used by the *CreateTLS style of functions will also be used by another component of the software in the same thread.

Attention
Use the *CreateTLS style function with caution in a local (controlled) context.
It is a problem if the event-loop is called like for an event or an asynchronous-service-call and if an other component of the software uses the same *CreateTLS style function with the same tlsid .

Example from perfserver.go performance test with TLS storage in a local (controlled) context

type BUST PerfServer
  func (this *BUST) Call() {
    bus := MkBufferStreamCreateTLS(0)
    for this.ReadItemExists() {
      bus.WriteU(this.ReadU())
    }
    bus.PosToStart()
    this.SendSTART()
    for bus.ReadItemExists() {
      this.SendU(bus.ReadU())
    }
    this.SendRETURN()
  }

MkKernel PACKAGE

MkKernel ENUM

enum MkErrorEcollection for the different error-codes …
ErrorE_FromIntreturn the MkErrorE from integer …
ErrorE_ToIntreturn the MkErrorE as integer …
ErrorE_ToStringreturn the MkErrorE as string …
enum MkTimeoutEPredefined Timeout values …
TimeoutE_FromIntreturn the MkTimeoutE from integer …
TimeoutE_ToIntreturn the MkTimeoutE as integer …
TimeoutE_ToStringreturn the MkTimeoutE as string …
enum MkTypeEbasic data-types supported by Programming-Language-Micro-Kernel
TypeE_FromIntreturn the MkTypeE from integer …
TypeE_ToIntreturn the MkTypeE as integer …
TypeE_ToString

return the MkTypeE as string …

MkKernel SETUP

Cleanupcleanup gomkkernel internal memory …
Setup

setup gomkkernel internal memory …

MkKernel DETAIL

C-API: MkKernel_C_API - The package is the toplevel structure of the Programming-Language-Micro-Kernel

The gomkkernel package is loaded with:

import "gomsgque/mkkernel"

and is a composition of one or more class-item.

The gomkkernel package add the following public classes into MkObjectC_C_API :

Object C-Type Description
MkObjectC MK_OBJ The MkObjectC object known as obj or object is used as base-object type for a managed-object
MkBufferC MK_BUF The MkBufferC object known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. …
MkBufferStreamC MK_BUS The MkBufferStreamC object known as bus or stream is a subclass of MkBufferC used for package-based-io
MkBufferListC MK_BFL The MkBufferListC object known as bfl or buffer-list is used to create and manage a list of MkBufferC
MkLogFileC MK_LFL The MkLogFileC object known as lfl or log-file is used to control … the target of the logging-output.
MkErrorC MK_ERR The MkErrorC object known as err or error is used to create … and manage an error message …
MkRuntimeC MK_RT The MkRuntimeC class known as mkrt or runtime is the main gomkkernel application environment …

The gomkkernel package add the following public types into MkObjectC_C_API :

    ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType)
    |
    |- ABSTRACT: MkDefTypeSTT (TypeType = type of a Type)
       |
       |- MkObjectST, MkLogFileST, MkBufferListST,
       |- MkErrorPanicST, MkErrorIgnoreST, MkErrorPrintST, MkErrorDefaultST, MkErrorST
       |
       |- ABSTRACT: MkBufferST
          |- FINAL: MkBuffer64ST, MkBuffer256ST, MkBuffer1024ST
          |- ABSTRACT: MkBufferStreamST
             | FINAL: MkBufferStream64ST, MkBufferStream256ST, MkBufferStream1024ST, MkBufferStream16384ST

MkKernel ENUM

C-API: MkKernel_Enum_C_API - C-API: Internal - Enum definition - gomkkernel enum definition …

MkKernel_C_API

A enum in the Programming-Language-Micro-Kernel is a enum-data-type and 3 enum-access-attributes

  1. ENUM_ToString → return the string-value from the enum-value
  2. ENUM_ToInt → return the integer-value from the enum-value
  3. ENUM_FromInt → create an enum-value from an integer-value.

The enum-data-type and the 3 enum-access-attributes are defined in all target-languages (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).

enum MkErrorE

TOP

collection for the different error-codes … → API: MkErrorE

This is the default-error-indicator and return-value from near all Programming-Language-Micro-Kernel functions.

enum MkErrorE {
MK_OK = 0,
MK_ERROR = 2,
};
MkErrorE
collection for the different error-codes …
Definition kernel_mk.h:3111
@ MK_ERROR
exit upper code with an error (persistent)
Definition kernel_mk.h:3114
@ MK_CONTINUE
continue with upper code
Definition kernel_mk.h:3113
@ MK_OK
everything is OK, no error available (persistent)
Definition kernel_mk.h:3112

[static] ErrorE_FromInt(value int32) MkErrorE

TOP

return the MkErrorE from integer … → API: MkErrorE_FromInt

[static] ErrorE_ToInt(value MkErrorE) int32

TOP

return the MkErrorE as integer … → API: MkErrorE_ToInt

[static] ErrorE_ToString(value MkErrorE) string

TOP

return the MkErrorE as string … → API: MkErrorE_ToString


enum MkTimeoutE

TOP

Predefined Timeout values … → API: MkTimeoutE

The MkTimeoutE is used wherever a "timeout" is required. As a special feature, in addition to the defined values in MkTimeoutE, freely defined values as integers as seconds are also accepted.

__parser__(enum-accept-integer=long)
enum MkTimeoutE {
};
MkTimeoutE
Predefined Timeout values …
Definition kernel_mk.h:3155
@ MK_TIMEOUT_LONG
long timeout in sec (180 sec) …
Definition kernel_mk.h:3159
@ MK_TIMEOUT_VERYSHORT
very short timeout in sec (5 sec) …
Definition kernel_mk.h:3168
@ MK_TIMEOUT_INIT
maximum timeout in sec (900 sec) …
Definition kernel_mk.h:3157
@ MK_TIMEOUT_MAX
request the maximum possible (infinite) timeout value …
Definition kernel_mk.h:3174
@ MK_TIMEOUT_NORMAL
normal timeout in sec (90 sec) …
Definition kernel_mk.h:3161
@ MK_TIMEOUT_USER
request the user defined timeout value from the MqTimeout configuration value …
Definition kernel_mk.h:3172
@ MK_TIMEOUT_SOCKET
shorter timeout in sec (10 sec) … This TIMEOUT is used for socket connection with 'connect'
Definition kernel_mk.h:3166
@ MK_TIMEOUT_SHORT
short timeout in sec (20 sec) …
Definition kernel_mk.h:3163
@ MK_TIMEOUT_DEFAULT
request the default timeout value …
Definition kernel_mk.h:3170
#define META_TIMEOUT_REF
Definition kernel_mk.h:194

[static] TimeoutE_FromInt(value int32) MkTimeoutE

TOP

return the MkTimeoutE from integer … → API: MkTimeoutE_FromInt

[static] TimeoutE_ToInt(value MkTimeoutE) int32

TOP

return the MkTimeoutE as integer … → API: MkTimeoutE_ToInt

[static] TimeoutE_ToString(value MkTimeoutE) string

TOP

return the MkTimeoutE as string … → API: MkTimeoutE_ToString


enum MkTypeE

TOP

basic data-types supported by Programming-Language-Micro-Kernel … → API: MkTypeE

enum MkTypeE {
MK_BINT = ((8 << MK_TYPE_SHIFT) ),
MK_STRT = ((9 << MK_TYPE_SHIFT) ),
MK_LSTT = ((10 << MK_TYPE_SHIFT) ),
};
#define MK_TYPE_IS_8_BYTE
the type is native and has a size of 8 bytes …
Definition kernel_mk.h:3282
#define MK_TYPE_IS_4_BYTE
the type is native and has a size of 4 bytes …
Definition kernel_mk.h:3279
#define MK_TYPE_IS_1_BYTE
the type is native and has a size of 1 byte …
Definition kernel_mk.h:3273
#define MK_TYPE_SHIFT
FIXED: type is only 8bit -> 4 bit=15 for type and 4 bit for flag …
Definition kernel_mk.h:3289
#define MK_TYPE_IS_2_BYTE
the type is native and has a size of 2 bytes …
Definition kernel_mk.h:3276
@ MK_BYTT
Y: 1 byte 'byte' type.
Definition kernel_mk.h:3300
@ MK_WIDT
W: 8 byte 'long long int' type.
Definition kernel_mk.h:3305
@ MK_INTT
I: 4 byte 'int' type.
Definition kernel_mk.h:3303
@ MK_FLTT
F: 4 byte 'float' type.
Definition kernel_mk.h:3304
@ MK_BINT
B: X byte 'byte-array' type.
Definition kernel_mk.h:3307
@ MK_BOLT
O: 1 byte 'boolean' type.
Definition kernel_mk.h:3301
@ MK_DBLT
D: 8 byte 'double' type.
Definition kernel_mk.h:3306
@ MK_STRT
C: X byte 'string' type (e.g. with a \0 at the end)
Definition kernel_mk.h:3308
@ MK_LSTT
L: X byte 'list' type.
Definition kernel_mk.h:3309
@ MK_SRTT
S: 2 byte 'short' type.
Definition kernel_mk.h:3302
See also
TypeE_ToString, TypeE_ToInt, TypeE_FromInt, BufferGetType2, BufferCastTo, BufferStreamReadGetNextType

[static] TypeE_FromInt(value int32) MkTypeE

TOP

return the MkTypeE from integer … → API: MkTypeE_FromInt

[static] TypeE_ToInt(value MkTypeE) int32

TOP

return the MkTypeE as integer … → API: MkTypeE_ToInt

[static] TypeE_ToString(value MkTypeE) string

TOP

return the MkTypeE as string … → API: MkTypeE_ToString

MkKernel SETUP

C-API: MkKernel_Setup_C_API - Setup und Cleanup the gomkkernel

Initializing a gomkkernel library depends on the target language and the specific nature of the Programming-Language-Micro-Kernel.

In general it is required to call a Setup style funtion as FIRST argument because of:

  • In a static build the shared library constructor/destructor is NOT called
  • In a shared build the order of library loading is target-language-specific
  • Every executable who uses a meta-library (MkKernel, MqMsgque, LcConfig, ...) which provide a language-specific-type (always assume this) and also support static-build (no constructor is called like C, C++, ...) require a call to the meta-library-setup-function for type-initialization at startup.

If more than one META library is called only the toplevel Setup is required:

  • example: The MkKernelSetup is not required if MqMsgqueSetup or LcConfigSetup is already used.

shared library detail

A new gomkkernel library is initialized with Setup and released again with Cleanup. Both functions are automatically called upon loading and unloading of the shared library.

Example: Definition (C) of the gomkkernel library startup functions

MK_EXTERN void MK_DECL MkSetup (void) __attribute__ ((constructor(200)));
MK_EXTERN void MK_DECL MkCleanup (void) __attribute__ ((destructor(200)));
#define MK_DECL
Definition kernel_mk.h:2159
#define MK_EXTERN
static library
Definition kernel_mk.h:2557
MK_EXTERN void MkCleanup(void)
cleanup gomkkernel internal memory …
MK_EXTERN void MkSetup(void)
setup gomkkernel internal memory …

In the Programming-Language-Micro-Kernel, a type is defined for each thread, which means that the new gomkkernel library must be known when the thread starts. This is not a problem as long as the external gomkkernel library is linked to the application. However, if dlopen is used to load the gomkkernel library, the current restriction is that the new data type from the gomkkernel library has not been defined in all existing threads.

The point in time when a library is loaded depends heavily on the programming language used.

  • A linked language such as C or C++ usually has all libraries initialised at startup.
  • A compiled language such as Java and C# only load a library when a function of the library is used and
    not when the library is declared.
  • A scripting language such as Tcl normally loads the library as soon as the declaration (package require myLib) is made, which happens fairly close to the start of the program but is not guaranteed.

‍To avoid all the problems call the Setup directly at the start of the main program.

Example: Start of the ConfigServer application from the example/csharp directory

  • The problem with the ConfigServer application is that the libmkkernel and libmqmsgque libraries are loaded very early, at startup, and the liblcconfig very late, only on request.
static void Main(string[] argv) {
LcConfig.Setup();
var srv = MqFactoryCT<ConfigServer>.Add().New();
try {
srv.LinkCreate(argv);
srv.ProcessEvent(MqWaitOnEventE.FOREVER);
} catch (Exception e) {
srv.ErrorCatch(e);
}
srv.Exit();
}

[static] Cleanup()

TOP

cleanup gomkkernel internal memory … → API: MkCleanup

MkCleanup will only be recognized once and will be ignored if not called in the same thread as MkSetup. After a call to MkSetup the call to MkCleanup is possible again.

‍The public MkCleanup is just a placeholder, the internal MkCleanup is always called even if the public MkCleanup is not called.

Attention
during cleanup objects will be deleted too -> the language interpreter have to be active

[static] Setup()

TOP

setup gomkkernel internal memory … → API: MkSetup

MkSetup will only be recognized once, additional call's will be ignored until a MkCleanup is called.

‍A call to the public MkSetup is required if dlopen and thread is used.


MkObjectC

MkObjectC DBG

DbgMdebug: write a static-marker to the MkLogFileC (default: stderr) …
DbgDumpdebug: Dump a instance to stderr with LNG and MQ internal data…
DbgLdebug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix …
DbgLogCdebug: write a short-obj-summary to MkLogFileC (default: stderr) …
DbgOidebug: write the object-details to MkLogFileC (default: stderr) …
DbgSTACK

debug: write the stack-trace to MkLogFileC (default: stderr) …

MkObjectC INTROSPECTION

Instancesget head-instance from linked-list of MkObjectS type …
Nextget next instance from linked-list of MkObjectS type
Prev

get previous instance from linked-list of MkObjectS type

MkObjectC LOG

LogCwrite a logging-message to MkLogFileC (default: stderr) using the internal format …
LogHEXlog binaray data as HEX into the MkLogFileC (default: stderr) …
LogLog-Slot - log the entire object to the MkLogFileC (default: stderr) target …
LogDetaillog the MkObjectS verbose into the MkLogFileC (default: stderr) …
LogSimple

log the MkObjectS into the MkLogFileC (default: stderr) …

MkObjectC MISC

FromHandleImport-Slot - returns a obj from a former exported handle
ErrorCatchconvert a programming-language-error into an gomkkernel error …
ToErrorError-Slot - return an error-object pre initialized with obj data.
ToHandleExport-Slot - returns a reference to the obj useable for external storage
ToNameInfo-Slot - returns brief information about the obj as a string
ToNameOfClassClass-Slot - returns the GO-Class-Name of the obj as string
ToNameOfTypeType-Slot - returns the LibMkKernel-Type-Name of the obj as a string
ToString

String-Slot - returns the string representation of the obj

MkObjectC TOR

DeleteDelete-Slot - delete an instance.
Dispose

Dispose-Slot - untie the connection between the Native-GO-Instance and the LibMsgque-Instance.

MkObjectC DETAIL

C-API: MkObjectC_C_API - The MkObjectC object known as obj or object is used as base-object type for a managed-object

libmqmsgque is also called as Programming-Language-Micro-Kernel. libmqmsgque is like a programming-language without syntax but using the Target-Programming-Language (in our case Go) of the Micro-Kernel as runtime environment.

Integration
To operate as a Micro-Kernel a maximum integration into the Target-Programming-Language is available.

This integration is done using the managed-object-technology.

Managed-Object
A managed-object is a piece of C-Code able to act as a native datatype in all Target-Programming-Languages supported.

The managed object supports low level integration features descripted in MkObjectS :

  • object identification based on signatures
  • reference counting
  • management of the self object pointer for the target-language
  • object-type specific features provided with MkTypeS

In the implementation-layer of gomkkernel only the public-features of the MkObjectC are visible to the programmer.

MANAGED OBJECT TYPES

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
    }

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;
...
}

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

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.

MANAGED OBJECT PROGRAMMING

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; …
}

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.

  • The managed-object supports one or more super-class using a union with struct MkObjectS obj as the first attribute in the union.
  • The union is required because the managed-object share the memory with the super-class.

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

  • "cast" from an unknown pointer: MK_BUF ret = MkBuf(ptr);
    • This "cast" is called an up-cast because you're upgrading the pointer (getting more information).
    • This "cast" checks the MkObjectS::signature to ensure that ptr is a valid object.
    • This "cast" is checked at runtime.
  • "cast" from a managed pointer: MK_BUF ret = MkBUF(ptr);
    • This "cast" is called a down-cast because you downgrading the pointer (lose some information).
    • This "cast" uses the super-union to just return a pointer that is already available.
    • This "cast" is checked at compile time.
  • To put it simply: MkBuf ≠ MkBUF

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

MkObjectC DBG

C-API: MkObjectC_Dbg_C_API - log a debugging-message to the MkLogFileC (default: stderr) …

This functions are "helpers" to support the programmer.

[static] MkDbgDbgM(message string, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

debug: write a static-marker to the MkLogFileC (default: stderr) … → API: MkDbgM

obj.DbgDump(?message string = "var"?, ?callfunc string = MkGetCallerProc()?)

TOP

debug: Dump a instance to stderr with LNG and MQ internal data… → API: MkDbgDump

Attention
this is only implemented by the Target-Programming-Language

fmtobj.DbgL(message string, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

debug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix … → API: MkDbgL

The marker is prefixed with object data from th fmtobj.

obj.DbgLogC(?callfunc string = MkGetCallerProc()?)

TOP

debug: write a short-obj-summary to MkLogFileC (default: stderr) … → API: MkDbgLogC

obj.DbgO(?callfunc string = MkGetCallerProc()?)

TOP

idebug: write the object-details to MkLogFileC (default: stderr) … → API: MkDbgO

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]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

This function can be overwritten in the target programming language.

fmtobj.DbgSTACK(?skip int32 = 0?, ?num int32 = -1?, ?callfunc string = MkGetCallerProc()?)

TOP

debug: write the stack-trace to MkLogFileC (default: stderr) … → API: MkDbgSTACK

MkObjectC INTROSPECTION

C-API: MkObjectC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferInstances() MkBufferCI)
    • return the last-instance created or nil if no instance was created.
  • The Next (example: buf.Next() MkBufferCI)
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: buf.Prev() MkBufferCI)
    • return the previous-instance for a given-instance or nil if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkObjectInstances() MkObjectCI

TOP

get head-instance from linked-list of MkObjectS type … → API: MkObjectInstances

The head-instance is the last instance created.

obj.Next() MkObjectCI

TOP

get next instance from linked-list of MkObjectS type → API: MkObjectNext

obj.Prev() MkObjectCI

TOP

get previous instance from linked-list of MkObjectS type → API: MkObjectPrev

MkObjectC LOG

C-API: MkObjectC_Log_C_API - log information to MkLogFileC (default: stderr) …

The logging-target is set direct by RuntimeSetLogfile or using the class MkLogFileC.

The target is stored at the MkRuntimeC using a FILE-stream and can be set individually for each thread. The default is stderr.

possible values are:

value decription OS man-page
stdout the standart output stdio(3)
stderr the standart error output stdio(3)
fileName an arbitary fileName fopen(3)

Many logging functions have common parameters:

Parameters
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)

fmtobj.LogC(message string, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?)

TOP

write a logging-message to MkLogFileC (default: stderr) using the internal format … → API: MkLogC

The logging is only done if 'MqDebug >= level' and 'MqIsSilent == false' using the following format:

C> (NAME:PID:THREADID) [YYYY-MM-DD:HH-MM-SS] [String|Binary-DEBUGLEVEL-CONTEXTID-REFCOUNT-CONTEXTPTR-prefix]: message

The message is build with snprintf and finally send with fputsn without newline '\n' character at the end. To add the newline or an other special-caracter use the '\xxx' syntax.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]messagestring to log

fmtobj.LogHEX(callfunc string, data []byte)

TOP

log binaray data as HEX into the MkLogFileC (default: stderr) … → API: MkLogHEX

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]datathe binary data to log

obj.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

Log-Slot - log the entire object to the MkLogFileC (default: stderr) target … → API: MkObjectLog

Todo:

log_doku

slot_doku

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]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
BufferLog, BufferListLog, BufferStreamLog, ?MkLogFileLog?, ErrorLog, RuntimeDebug, ObjectLogSimple

obj.LogDetail(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

log the MkObjectS verbose into the MkLogFileC (default: stderr) … → API: MkObjectLogDetail

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]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 obj.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

obj.LogSimple(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

log the MkObjectS into the MkLogFileC (default: stderr) … → API: MkObjectLogSimple

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]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

MkObjectC MISC

C-API: MkObjectC_Misc_C_API - Various functions related to the MkObjectC

[static] MkObjectFromHandle(exporthdl int) MkObjectCI

TOP

Import-Slot - returns a obj from a former exported handle → API: MkObjectFromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

obj.ErrorCatch(?exception interface{} = nil?, ?callfunc string = MkGetCallerProc()?) MkErrorCI

TOP

convert a programming-language-error into an gomkkernel error … → API: MkObjectErrorCatch

This function is a placeholder and have to be overloaded by the Target-Programming-Language. The goal is to handel an error-catch condition and convert an programming-language-error into an gomkkernel-error.

This is the same as (example form c++):

mngx->ErrorDEFAULT()->Catch(exception)

Example from server.go catch-send and reset an error

	defer func() {
	  if x := recover(); x != nil {
	    err := this.ErrorCatch_1(x)
	    this.SendI(err.GetNum())
	    this.SendC(err.GetText())
	    err.Reset_0()
	    this.SendRETURN()
	  }
	}()
	this.cl[id].SendSTART()
	this.ProxyItem(this.cl[id])
	this.cl[id].SendEND_AND_WAIT("ECOI", 5)
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]exceptionthe exception object from Go, if nil the global exception object is used
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
Returns
the ErrorDEFAULT initialized with exception value
See also
err.Raise() err.Reset(?callfunc string = MkGetCallerProc()?, ?callline int32 = MkGetCallerLine()?, ?force bool = false?)

obj.ToError() MkErrorCI

TOP

Error-Slot - return an error-object pre initialized with obj data. → API: MkObjectToError

This slot is the same as ErrorDEFAULT with fmtobj set to this

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
the error-object
Attention
The memory of the out-value belongs to the called GoMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

obj.ToHandle() int

TOP

Export-Slot - returns a reference to the obj useable for external storage → API: MkObjectToHandle

A handle is a reference for an instance. A handle can be converted back into an instance using the ?Class?FromHandle syntax like [static] MkBufferListFromHandle(exporthdl int) MkBufferListCI

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 required handle

obj.ToName() string

TOP

Info-Slot - returns brief information about the obj as a string → API: MkObjectToName

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
the identification of the object as string
Attention
The memory of the out-value belongs to the called GoMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

obj.ToNameOfClass() string

TOP

Class-Slot - returns the GO-Class-Name of the obj as string → API: MkObjectToNameOfClass

The Programming-Language-Micro-Kernel connect the GO language with the libmqmsgque runtime. Every class-object in GO has an conterpart as libmqmsgque type-object in the Programming-Language-Micro-Kernel.

ObjectToNameOfType returns the name of the libmqmsgque type
ObjectToNameOfClass returns the name of the GO class

obj.ToNameOfType() string

TOP

Type-Slot - returns the LibMkKernel-Type-Name of the obj as a string → API: MkObjectToNameOfType

The Programming-Language-Micro-Kernel connect the GO language with the LibMsgque runtime. Every class-object in GO has an conterpart as LibMsgque type-object in the Programming-Language-Micro-Kernel.

ObjectToNameOfType returns the name of the libmsgque type
ObjectToNameOfClass returns the name of the GO class
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
the name of the object-type as a string

obj.ToString() string

TOP

String-Slot - returns the string representation of the obj … → API: MkObjectToString

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
the required string
Attention
~ The memory of the out-value belongs to the called GoMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.
~ On error an empty string is returned.

MkObjectC TOR

C-API: MkObjectC_TOR_C_API - Create and Destroy a managed-object.

[destructor] obj.Delete()

TOP

Delete-Slot - delete an instance. → API: MkObjectDelete

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 SelfDeleteForce

[destructor] obj.Dispose()

TOP

Dispose-Slot - untie the connection between the Native-GO-Instance and the LibMsgque-Instance. → API: MkObjectDispose

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.

MkBufferC

MkBufferC ACCESS

AppendCappend a single string to a MkBufferC object …
Popdelete str from the MkBufferC
Pushadd str to the MkBufferC
ToObject

return the native language object from a MkBufferC

MkBufferC GET

GetTT

get a val_out from a MkBufferC

MkBufferC INFO

GetType1return the type from a MkBufferC as single character value …
GetType2return the MkTypeE from a MkBufferC
GetType3return the type from a MkBufferC as single character string …
IsLocalCheck if the MkBufferC is local (temporary), not local mean global
Loglog the MkBufferC
LogS

log the short MkBufferC object data to the MkLogFileC (default: stderr) …

MkBufferC INTROSPECTION

Instancesget head-instance from linked-list of MkBufferS type …
Nextget next instance from linked-list of MkBufferS type
Prev

get previous instance from linked-list of MkBufferS type

MkBufferC MISC

CastTochange the type of an MkBufferC to type
Cmpcompare TWO MkBufferC objects like strcmp do it for strings …
Copycopy the MkBufferC from srce to dest
Resetreset a MkBufferC to the length zero …
ResetFullreset a MkBufferC to the length zero and free allocated storage…
SizeAddadd size storage to the buf
SizeNewalloc min size storage to the buf
Tempcreate a temporary copy of the MkBufferC buf …
ToString

get the string representation of the buf

MkBufferC SET

SetTT

Set the MkBufferC to the val

MkBufferC TOR

CreateConstructor - create a new MkBufferC with minimum size of internal storage …
Create1024call the BufferCreate with default type MkBuffer1024S (1024 byte) …
Create256call the BufferCreate with default type MkBuffer256S (256 byte) …
Create64call the BufferCreate with default type MkBuffer64S (64 byte) …
CreateTLSsame as BufferCreate but require no cleanup
CreateTTConstructor - create a new MkBufferC with an PRIMITIVE TYPE
FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkBufferC instance …
DupDup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance
Merge

Merge-Constructor - create a new MkBufferC as a merge from an existing object …

MkBufferC DETAIL

C-API: MkBufferC_C_API - The MkBufferC object known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. …

The MkBufferC is used to store PRIMITIVE TYPE data. If gomkkernel is working on data… gomkkernel is working on an MkBufferC object or on a list of MkBufferC objects called MkBufferListC.

MkBufferCI CLASS

The ABSTRACT-CLASS used to store a native-type-data-item defined by PRIMITIVE TYPE

C-Kernel-Details

The ABSTRACT-CLASS MkBufferS is used to store MkTypeE data in an MkBufferS::storage

A new MkBufferS is always preallocated with the predefined ILS-storage (MkBufferS::ils_data), but can switch to a MALLOC-storage if the storage requirements of the user exceed the predefined MkBufferS::ilsS::size.

‍A MkBufferS never run out of storage.

The basic goal of the ILS-storage technology is to minimize the usage of MALLOC, this mean that the MkBufferS::ilsS::size should be large enought to be sufficient for the user needs.

The following conditions must always be met for the ILS memory:

The ABSTRACT-CLASS MkBufferS is missing the ILS-storage, the FINAL-CLASSES are:

MkBuffer64C, MkBuffer256C and MkBuffer1024C

See also
MkBufferListC, MkBufferStreamC

MkBufferCI CTOR / DTOR

command synonmym
[constructor] MkBufferCreate(?size int32 = 0?) mkkernel.MkBufferCreate(size int64)
[destructor] buf.Delete() buf.Dispose()

Example from server.go read a buffer-object and convert single-char-type-identifer to string.

type BUF2 Server
  func (this *BUF2) Call() {
    this.SendSTART()
    for i:=0; i<3; i++ {
      buf := this.ReadU()
      this.SendC(buf.GetType3())
      this.SendU(buf)
    }
    this.SendRETURN()
  }
See also
BufferGetType1 BufferGetType2 BufferGetType3

MkBufferC ACCESS

C-API: MkBufferC_Access_C_API - various functions to access buffer-data

buf.AppendC(val string) MkBufferCI

TOP

append a single string to a MkBufferC object … → API: MkBufferAppendC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]valthe text to append to buf
Returns
the MkBufferC object with the new value

Example from server.go read and update a MkBufferC

	// ReadU - Example, read a buffer-object and append a string
	buf := this.ReadU()
	buf.AppendC("- a really log text to overwrite the already allocated space")
	this.SendU(buf)
	this.SendI(this.ReadI()+1)

buf.Pop(val string) int32

TOP

delete str from the MkBufferC … → API: MkBufferPop

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
valthe text (string) to remove from buf
Returns
the size of the string removed from the MkBuffer64S object
Attention
MkBufferC have to be of type MK_STRT

buf.Push(val string) int32

TOP

add str to the MkBufferC … → API: MkBufferPush

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
valthe text (string) to append to buf
Returns
the size of the string appended to the MkBuffer64S object
Attention
MkBufferC have to be of type MK_STRT

buf.ToObject() interface{}

TOP

return the native language object from a MkBufferC … → API: MkBufferToObject_RT

MkBufferC GET

C-API: MkBufferC_Get_C_API - various functions to get buffer-data

buf.GetTT()

The BufferGetTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

buf.GetB() []byteMkBufferGetB_RT
buf.GetC() stringMkBufferGetC_RT
buf.GetD() float64MkBufferGetD_RT
buf.GetF() float32MkBufferGetF_RT
buf.GetI() int32MkBufferGetI_RT
buf.GetL(?val_inout MkBufferListCI = nil?) MkBufferListCIMkBufferGetL_RT
buf.GetO() boolMkBufferGetO_RT
buf.GetS() int16MkBufferGetS_RT
buf.GetU() MkBufferCIMkBufferGetU_RT
buf.GetW() int64MkBufferGetW_RT
buf.GetY() int8

MkBufferGetY_RT

get a val_out from a MkBufferC

The MkBufferGetTT style of functions always return a val_out or a MkErrorC.

The val_out can be a PRIMITIVE TYPE, a class-type or a pointer-type (binary, string etc).

Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) - (nonnull)
[in]bufthe MkBufferS instance to work on - (nonnull)
[out]val_outthe value to return - (nonnull)

MkBufferC INFO

C-API: MkBufferC_Info_C_API - various functions to get information out of buffer-data

buf.GetType1() byte

TOP

return the type from a MkBufferC as single character value … → API: MkBufferGetType1

MK_BUFN const buf
)
{
switch (buf->var.type) {
case MK_STRT: return 'C';
case MK_INTT: return 'I';
case MK_DBLT: return 'D';
case MK_WIDT: return 'W';
case MK_BINT: return 'B';
case MK_BYTT: return 'Y';
case MK_BOLT: return 'O';
case MK_SRTT: return 'S';
case MK_FLTT: return 'F';
case MK_LSTT: return 'L';
}
return '*';
}
MK_EXTERN MK_STRB MkBufferGetType1_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
return the type from a MkBufferC as single character value …
char MK_STRB
string type data-type
Definition kernel_mk.h:2703
#define MK_RT_ATTR_HDL_CHECK(x)
Definition kernel_mk.h:2421
#define MK_RT_ATTR_RUNTIME_CHECK_XN(x)
Definition kernel_mk.h:2424
#define MK_RT_ARGS
Definition kernel_mk.h:2365

buf.GetType2() MkTypeE

TOP

return the MkTypeE from a MkBufferC … → API: MkBufferGetType2

enum MkTypeE
MK_BUFN const buf
) {
return buf->var.type;
}
MK_EXTERN enum MkTypeE MkBufferGetType2_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
return the MkTypeE from a MkBufferC …

buf.GetType3() string

TOP

return the type from a MkBufferC as single character string … → API: MkBufferGetType3

MK_BUFN const buf
) {
switch (buf->var.type) {
case MK_STRT: return "C";
case MK_INTT: return "I";
case MK_DBLT: return "D";
case MK_WIDT: return "W";
case MK_BINT: return "B";
case MK_BYTT: return "Y";
case MK_BOLT: return "O";
case MK_SRTT: return "S";
case MK_FLTT: return "F";
case MK_LSTT: return "L";
}
return "*";
}
MK_EXTERN MK_STRN MkBufferGetType3_RT(MK_RT const mkrt, MK_BUFN const buf) MK_RT_ATTR_HDL
return the type from a MkBufferC as single character string …
const MK_STRB * MK_STRN
constant string pointer data-type
Definition kernel_mk.h:2745

buf.IsLocal() bool

TOP

Check if the MkBufferC is local (temporary), not local mean global … → API: MkBufferIsLocal

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
a boolean value… yes or no

buf.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

log the MkBufferC … → API: MkBufferLog

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS 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
MkBufferC

buf.LogS(?varname string = "buf"?, ?fmtobj MkObjectCI = nil?, ?callfunc string = MkGetCallerProc()?)

TOP

log the short MkBufferC object data to the MkLogFileC (default: stderr) … → API: MkBufferLogS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]varnameThe name of the argument to report
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

MkBufferC INTROSPECTION

C-API: MkBufferC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferInstances() MkBufferCI)
    • return the last-instance created or nil if no instance was created.
  • The Next (example: buf.Next() MkBufferCI)
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: buf.Prev() MkBufferCI)
    • return the previous-instance for a given-instance or nil if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkBufferInstances() MkBufferCI

TOP

get head-instance from linked-list of MkBufferS type … → API: MkBufferInstances

The head-instance is the last instance created.

buf.Next() MkBufferCI

TOP

get next instance from linked-list of MkBufferS type → API: MkBufferNext

buf.Prev() MkBufferCI

TOP

get previous instance from linked-list of MkBufferS type → API: MkBufferPrev

MkBufferC MISC

C-API: MkBufferC_Misc_C_API - various functions to work on buffer-data

buf.CastTo(typ MkTypeE)

TOP

change the type of an MkBufferC to type … → API: MkBufferCastTo

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]typcast buf to typ
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

buf1.Cmp(buf2 MkBufferCI) int32

TOP

compare TWO MkBufferC objects like strcmp do it for strings … → API: MkBufferCmp

-# if both types are equal than the native types are compared

  1. if both types are non-equal than the string representation of the types are compared
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]buf1the FIRST MkBufferC object to compare
[in]buf2the SECOND MkBufferC object to compare
Returns
Returns < 0 if buf1 is less than buf2; > 0 if buf1 is greater than buf2, and 0 if they are equal.

buf.Copy(srce MkBufferCI) MkBufferCI

TOP

copy the MkBufferC from srce to dest … → API: MkBufferCopy

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
srcesource of the copy
Returns
the dest object

buf.Reset()

TOP

reset a MkBufferC to the length zero … → API: MkBufferReset

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
See also
buf.ResetFull()

buf.ResetFull()

TOP

reset a MkBufferC to the length zero and free allocated storage… → API: MkBufferResetFull

In addition to buf.Reset() the allocated storage is freed and reset to ILS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
See also
buf.Reset()

buf.SizeAdd(size int32) MkBufferCI

TOP

add size storage to the buf … → API: MkBufferSizeAdd

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]sizeThe initial size of the instance-local-storage. The MkBufferC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
the input buf

buf.SizeNew(size int32) MkBufferCI

TOP

alloc min size storage to the buf … → API: MkBufferSizeNew

Returns
the input buf
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]sizeThe initial size of the instance-local-storage. The MkBufferC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)

buf.Temp() MkBufferCI

TOP

create a temporary copy of the MkBufferC buf … → API: MkBufferTemp

This function always return the same global memory from the per-thread-runtime-storage initialized with buf. This storage must not be freed and should only be used for temporary-short-time usage. In theory every function-call in the same thread could overwrite this memory.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
buf- the source of the copy
Returns
the temporary buffer-object
Attention
The memory of the out-value belongs to the called GoMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

buf.ToString() string

TOP

get the string representation of the buf … → API: MkBufferToString

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
the required string
Attention
~ The returned string is owned by self… do not free.
~ On error an empty string is returned.

MkBufferC SET

C-API: MkBufferC_Set_C_API - various functions to set buffer-data

buf.SetTT(val int8)

The BufferSetTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

buf.SetB(val []byte) MkBufferCIMkBufferSetB_RT
buf.SetC(val string) MkBufferCIMkBufferSetC_RT
buf.SetD(val float64) MkBufferCIMkBufferSetD_RT
buf.SetF(val float32) MkBufferCIMkBufferSetF_RT
buf.SetI(val int32) MkBufferCIMkBufferSetI_RT
buf.SetO(val bool) MkBufferCIMkBufferSetO_RT
buf.SetS(val int16) MkBufferCIMkBufferSetS_RT
buf.SetU(val MkBufferCI) MkBufferCIMkBufferSetU_RT
buf.SetW(val int64) MkBufferCIMkBufferSetW_RT
buf.SetY(val int8) MkBufferCI

MkBufferSetY_RT

Set the MkBufferC to the val

The old value will be removed and the memory will be reset.

Returns
the MkBufferS object
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
[in]valthe value to set the buf to

MkBufferC TOR

C-API: MkBufferC_TOR_C_API - various functions to create, initialize and destroy a MkBufferC

[constructor] MkBufferCreate(?size int32 = 0?)

TOP

Constructor - create a new MkBufferC with minimum size of internal storage … → API: MkBufferCreate

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

There is a MkBufferCreateTT function for every PRIMITIVE TYPE.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typeA type defined as MkTypeS with a TT postfix (default: MkBuffer64S, possible: MkBuffer64S, MkBuffer256S and MkBuffer1024S)
[in]sizeThe initial size of the instance-local-storage. The MkBufferC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
The newly created MkBufferC instance, the instance is owned by the caller
See also
BufferDelete BufferDup MqReadU

[constructor] MkBufferCreate1024(?size int32 = 0?)

TOP

call the BufferCreate with default type MkBuffer1024S (1024 byte) … → API: MkBufferCreate1024

[constructor] MkBufferCreate256(?size int32 = 0?)

TOP

call the BufferCreate with default type MkBuffer256S (256 byte) … → API: MkBufferCreate256

[constructor] MkBufferCreate64(?size int32 = 0?)

TOP

call the BufferCreate with default type MkBuffer64S (64 byte) … → API: MkBufferCreate64

[constructor] MkBufferCreateTLS(tlsid int32)

TOP

same as BufferCreate but require no cleanup → API: MkBufferCreateTLS

A TLS-instance only exists ONCE per thread and per TLS-function in memory. The memory will be reused and must not be freed.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tlsidAn per-thread unique name (integer > 0) to identify the reuse-able instance-storage. The tlsid have to be between: 0 <= tlsid < 32
Returns
the new MkBufferC instance, the instance belongs to the TLS-function and does not need to be deleted.
Note
This function is intended as a replacement for MkBufferCreateTLS_T for non-C programming languages.
Attention
for usage of the TLS-storage read more at StorageCreateTLS

[static] MkBufferFromHandle(exporthdl int) MkBufferCI

TOP

Import-Slot - returns a obj from a former exported handle → API: MkBufferFromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] buf.Delete()

TOP

Destructor - delete a MkBufferC instance … → API: MkBufferDelete_RT

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 SelfDeleteForce
See also
BufferCreate BufferDup MqReadU

[constructor] buf.Dup()

TOP

Dup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance → API: MkBufferDup

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

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bufthe MkBufferS instance to work on
Returns
The newly created MkBufferC instance, the instance is owned by the caller
See also
ObjDup BufferDelete

[constructor] buf.Merge()

TOP

Merge-Constructor - create a new MkBufferC as a merge from an existing object … → API: MkBufferMerge

The Merge-Constructor create a new instance and merge all internal data from the src into the new instance. After the Merge-Constructor the BufferResetFull is called for the merge-source bus.

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]bufthe MkBufferS instance to work on
Returns
The new instance or NULL on error or if no Merge-Constructor is available
Attention
The new instance have to be deleted with BufferDelete
See also
BufferDup BufferResetFull BufferDelete

[constructor] MkBufferCreateTT(val int8)

The BufferCreateTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

[constructor] MkBufferCreateB(val []byte)MkBufferCreateB_RT
[constructor] MkBufferCreateC(val string)MkBufferCreateC_RT
[constructor] MkBufferCreateD(val float64)MkBufferCreateD_RT
[constructor] MkBufferCreateF(val float32)MkBufferCreateF_RT
[constructor] MkBufferCreateI(val int32)MkBufferCreateI_RT
[constructor] MkBufferCreateO(val bool)MkBufferCreateO_RT
[constructor] MkBufferCreateS(val int16)MkBufferCreateS_RT
[constructor] MkBufferCreateU(val MkBufferCI)MkBufferCreateU_RT
[constructor] MkBufferCreateW(val int64)MkBufferCreateW_RT
[constructor] MkBufferCreateY(val int8)

MkBufferCreateY_RT

Constructor - create a new MkBufferC with an PRIMITIVE TYPE

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

Returns
The newly created MkBufferC instance, the instance is owned by the caller
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]valthe PRIMITIVE TYPE object as data-source

MkBufferStreamC

MkBufferStreamC INTROSPECTION

Instancesget head-instance from linked-list of MkBufferStreamS type …
Nextget next instance from linked-list of MkBufferStreamS type
Prev

get previous instance from linked-list of MkBufferStreamS type

MkBufferStreamC MISC

Copycopy the MkBufferStreamC from src to bus
Loglog the MkBufferStreamC
PosToStartset the current-access-position to the start of MkBufferStreamC
Resetreset a MkBufferStreamC to the length zero …
ResetFull

reset a MkBufferStreamC to the length zero and free allocated storage…

MkBufferStreamC READ

ReadALLget a temporary MkBufferListC from all data in the MkBufferStreamC
ReadGetNextTypeget the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available
ReadGetNumItemsget the number of items left in the MkBufferStreamC
ReadItemExistscheck if an item exists in the read-data-package
ReadLONGread the long native object from the MkBufferStreamC
ReadL_ENDEND read a list-item-type from the MkBufferStreamC
ReadL_STARTSTART read a list-item-type from the MkBufferStreamC
ReadUndoundo the last MkBufferStreamC READ function call …
ReadTT

read a val_out from the MkBufferStreamC

MkBufferStreamC TOR

Createcreate and initialize an MkBufferStreamC instance …
Create1024call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) …
Create16384call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) …
Create256call the BufferStreamCreate with default type MkBufferStream256S (256 byte) …
Create64call the BufferStreamCreate with default type MkBufferStream64S (64 byte) …
CreateTLSsame as BufferStreamCreate but require no cleanup …
FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkBufferStreamC instance …
DupDup-Constructor - create a new MkBufferStreamC instance as copy from an existing MkBufferStreamC instance …
Merge

Merge-Constructor - create a new MkBufferStreamC as a merge from an existing object …

MkBufferStreamC WRITE

WriteLONGwrite the long native object into the MkBufferStreamC
WriteL_ENDEND write a list-item-type into the MkBufferStreamC
WriteL_FLATwrite a MkBufferListC FLAT into the MkBufferStreamC
WriteL_STARTSTART write a list-item-type into the MkBufferStreamC
WriteTT

write a PRIMITIVE TYPE into the MkBufferStreamC

MkBufferStreamC DETAIL

C-API: MkBufferStreamC_C_API - The MkBufferStreamC object known as bus or stream is a subclass of MkBufferC used for package-based-io

The MkBufferStreamC is required to send data via a socket (pipe,tcp,uds,...). The data is organized as a continuous binary-array. Each item is preceded by type and, if applicable, size information.

‍See also: MkBufferC, MkBufferListC

C-Kernel-Details

The ABSTRACT-CLASS MkBufferStreamS has the private-parent-class MkBufferS and is used to store typed-data in a continuous binary-array at MkBufferS::storage.

private-parent-class mean:
MkBufferStreamS use the features of MkBufferS but does not expose the API

In addition to the binary-array the MkBufferStreamS also include features like:

  1. the encoding: MkBufferStreamS::endian_is_wrong
  2. the total number of items: MkBufferStreamS::numItems
  3. current position pointer: MkBufferStreamS::cur
  4. support for recursion: embedding a MkBufferStreamS into a MkBufferStreamS

The MkBufferStreamS inherits the following features from MkBufferS:

  1. the storage: MkBufferS::storage
  2. the type: MkBufferS::type
  3. the ILS: MkBufferS::ils

The ABSTRACT-CLASS MkBufferStreamS is missing the ILS-storage, the FINAL-CLASSES are:

MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S

See also
MkBufferC, MkBufferListC

MkBufferStreamC INTROSPECTION

C-API: MkBufferStreamC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferInstances() MkBufferCI)
    • return the last-instance created or nil if no instance was created.
  • The Next (example: buf.Next() MkBufferCI)
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: buf.Prev() MkBufferCI)
    • return the previous-instance for a given-instance or nil if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkBufferStreamInstances() MkBufferStreamCI

TOP

get head-instance from linked-list of MkBufferStreamS type … → API: MkBufferStreamInstances

The head-instance is the last instance created.

bus.Next() MkBufferStreamCI

TOP

get next instance from linked-list of MkBufferStreamS type → API: MkBufferStreamNext

bus.Prev() MkBufferStreamCI

TOP

get previous instance from linked-list of MkBufferStreamS type → API: MkBufferStreamPrev

MkBufferStreamC MISC

C-API: MkBufferStreamC_Misc_C_API - various functions to create and destroy a MkBufferStreamC

bus.Copy(src MkBufferStreamCI) MkBufferStreamCI

TOP

copy the MkBufferStreamC from src to bus … → API: MkBufferStreamCopy

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
srcsource of the copy
Returns
the bus instance

bus.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

log the MkBufferStreamC … → API: MkBufferStreamLog

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS 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)

bus.PosToStart()

TOP

set the current-access-position to the start of MkBufferStreamC … → API: MkBufferStreamPosToStart

bus.Reset()

TOP

reset a MkBufferStreamC to the length zero … → API: MkBufferStreamReset

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
See also
bus.ResetFull()

bus.ResetFull()

TOP

reset a MkBufferStreamC to the length zero and free allocated storage… → API: MkBufferStreamResetFull

In addition to bus.Reset() the allocated storage is freed and reset to ILS. This is usefull if the internal storage was filled once with a huge amount of data.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
See also
bus.Reset()

MkBufferStreamC READ

C-API: MkBufferStreamC_Read_C_API - various functions to 'read' data from a MkBufferStreamC

Read is done at the position of MkBufferStreamS::storage->cur. After read the cur is incemented with read-sizeof characters.

bus.ReadALL(?val_inout MkBufferListCI = nil?) MkBufferListCI

TOP

get a temporary MkBufferListC from all data in the MkBufferStreamC … → API: MkBufferStreamReadALL

If the val_inout is NULL than a temporary MkBufferListC is returned. If the val_inout is not NULL than the memory of the val_inout is reused.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in,out]val_inoutthe MkBufferListC - the storage of the input is reused
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
See also
BufferStreamReadL
Attention
The memory of the out-value belongs to the called GoMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

bus.ReadGetNextType() MkTypeE

TOP

get the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available → API: MkBufferStreamReadGetNextType

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
the type

bus.ReadGetNumItems() int32

TOP

get the number of items left in the MkBufferStreamC … → API: MkBufferStreamReadGetNumItems

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
the number of items as integer

bus.ReadItemExists() bool

TOP

check if an item exists in the read-data-package … → API: MkBufferStreamReadItemExists

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
boolean, true or false

bus.ReadLONG() int

TOP

read the long native object from the MkBufferStreamC … → API: MkBufferStreamReadLONG

on 64bit use a BufferStreamReadI and on 32bit use a BufferStreamReadW

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[out]val_outthe native long object to read
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
this api-function is NOT portable
See also
bus.WriteLONG(val int)

bus.ReadL_END()

TOP

END read a list-item-type from the MkBufferStreamC … → API: MkBufferStreamReadL_END

bus.ReadL_START(?buf MkBufferCI = nil?)

TOP

START read a list-item-type from the MkBufferStreamC … → API: MkBufferStreamReadL_START

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]bufNULL or a MkBufferC with a list-item-type or an error is raised.
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

bus.ReadUndo()

TOP

undo the last MkBufferStreamC READ function call … → API: MkBufferStreamReadUndo

Decrement the current-access-position by one, to the start of the last read body-item. The next read function call will extract the same item again. Only one undo level is supported.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

bus.ReadTT()

The BufferStreamReadTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bus.ReadB() []byteMkBufferStreamReadB_RT
bus.ReadC() stringMkBufferStreamReadC_RT
bus.ReadD() float64MkBufferStreamReadD_RT
bus.ReadF() float32MkBufferStreamReadF_RT
bus.ReadI() int32MkBufferStreamReadI_RT
bus.ReadL() MkBufferListCIMkBufferStreamReadL_RT
bus.ReadO() boolMkBufferStreamReadO_RT
bus.ReadU() MkBufferCIMkBufferStreamReadU_RT
bus.ReadW() int64MkBufferStreamReadW_RT
bus.ReadY() int8

MkBufferStreamReadY_RT

read a val_out from the MkBufferStreamC

The MkBufferStreamReadTT style of functions always return a val_out or a MkErrorC.

Precondition
The val_out can be a PRIMITIVE TYPE, a class-type or a pointer-type (binary, string etc).
After every read the current-access-position is incremented by one to get the next item for the next read.
To reset the current-access-position to the start use bus.PosToStart().
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[out]val_outthe new value

MkBufferStreamC TOR

C-API: MkBufferStreamC_TOR_C_API - various functions to create and destroy a MkBufferStreamC

[constructor] MkBufferStreamCreate(?size int32 = 0?)

TOP

create and initialize an MkBufferStreamC instance … → API: MkBufferStreamCreate

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

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]typeA type defined as MkTypeS with a TT postfix (default: MkBufferStream1024S, possible: MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S)
[in]sizeThe initial size of the instance-local-storage. The MkBufferStreamC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
The newly created MkBufferStreamC instance, the instance is owned by the caller

[constructor] MkBufferStreamCreate1024(?size int32 = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) … → API: MkBufferStreamCreate1024

[constructor] MkBufferStreamCreate16384(?size int32 = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) … → API: MkBufferStreamCreate16384

[constructor] MkBufferStreamCreate256(?size int32 = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream256S (256 byte) … → API: MkBufferStreamCreate256

[constructor] MkBufferStreamCreate64(?size int32 = 0?)

TOP

call the BufferStreamCreate with default type MkBufferStream64S (64 byte) … → API: MkBufferStreamCreate64

[constructor] MkBufferStreamCreateTLS(tlsid int32)

TOP

same as BufferStreamCreate but require no cleanup … → API: MkBufferStreamCreateTLS

A TLS-instance only exists ONCE per thread and per TLS-function in memory. The memory will be reused and must not be freed.

The new BufferStreamCreateTLS instance is ready to use and does NOT require a BufferStreamReset first and a BufferStreamDelete last.

By default the MkBufferStream64S type is used as an array of references (struct MkBufferStream64S and not struct MkBufferStream64S *). If the memory requirement exceed the predefined-storage of the MkBufferStream64S the memory is allocated on the heap.

Example from perfserver.go performance test with TLS storage

type BUST PerfServer
  func (this *BUST) Call() {
    bus := MkBufferStreamCreateTLS(0)
    for this.ReadItemExists() {
      bus.WriteU(this.ReadU())
    }
    bus.PosToStart()
    this.SendSTART()
    for bus.ReadItemExists() {
      this.SendU(bus.ReadU())
    }
    this.SendRETURN()
  }
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tlsidAn per-thread unique name (integer > 0) to identify the reuse-able instance-storage. The tlsid have to be between: 0 <= tlsid < 32
Returns
the new MkBufferStreamC instance, the instance belongs to the TLS-function and does not need to be deleted.
Attention
for usage of the TLS-storage read more at StorageCreateTLS

[static] MkBufferStreamFromHandle(exporthdl int) MkBufferStreamCI

TOP

Import-Slot - returns a obj from a former exported handle → API: MkBufferStreamFromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] bus.Delete()

TOP

Destructor - delete a MkBufferStreamC instance … → API: MkBufferStreamDelete_RT

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 SelfDeleteForce
See also
BufferStreamCreate BufferStreamDup

[constructor] src.Dup()

TOP

Dup-Constructor - create a new MkBufferStreamC instance as copy from an existing MkBufferStreamC instance … → API: MkBufferStreamDup

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

Returns
The newly created MkBufferStreamC instance, the instance is owned by the caller
See also
ObjDup BufferStreamDelete

[constructor] bus.Merge()

TOP

Merge-Constructor - create a new MkBufferStreamC as a merge from an existing object … → API: MkBufferStreamMerge

The Merge-Constructor create a new instance and merge all internal data from the src into the new instance. After the Merge-Constructor the BufferStreamResetFull is called for the merge-source bus.

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]busthe MkBufferStreamS instance to work on - (nonnull)
Returns
The new instance or NULL on error or if no Merge-Constructor is available
Attention
The new instance have to be deleted with BufferStreamDelete
See also
BufferStreamDup BufferStreamResetFull BufferStreamDelete

MkBufferStreamC WRITE

C-API: MkBufferStreamC_Write_C_API - various functions to write into a MkBufferStreamC

Write is done at the position of MkBufferStreamS::storage->cur. After write the cur is incemented with write-sizeof characters.

bus.WriteLONG(val int)

TOP

write the long native object into the MkBufferStreamC … → API: MkBufferStreamWriteLONG

on 64bit use a BufferStreamWriteW and on 32bit use a BufferStreamWriteI

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]valthe native long object to write
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
this api-function is NOT portable
See also
bus.ReadLONG() int

bus.WriteL_END()

TOP

END write a list-item-type into the MkBufferStreamC … → API: MkBufferStreamWriteL_END

bus.WriteL_FLAT(bfl MkBufferListCI)

TOP

write a MkBufferListC FLAT into the MkBufferStreamC … → API: MkBufferStreamWriteL_FLAT

A MkBufferListC can be written into a MkBufferStreamC using:

command description example
BufferStreamWriteL one item as list-item-type … [ itm1 itm2 itm3 itm4 ] …
BufferStreamWriteL_FLAT a sequence of single items … itm1 itm2 itm3 itm4 …

The second is called FLAT because the shell of the list-item-type is missing .

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]bflthe MkBufferListC to insert
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
See also
BufferStreamReadL BufferStreamReadL

bus.WriteL_START()

TOP

START write a list-item-type into the MkBufferStreamC … → API: MkBufferStreamWriteL_START

bus.WriteTT(val int8)

The BufferStreamWriteTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bus.WriteB(val []byte)MkBufferStreamWriteB_RT
bus.WriteC(val string)MkBufferStreamWriteC_RT
bus.WriteD(val float64)MkBufferStreamWriteD_RT
bus.WriteF(val float32)MkBufferStreamWriteF_RT
bus.WriteI(val int32)MkBufferStreamWriteI_RT
bus.WriteL(bfl MkBufferListCI)MkBufferStreamWriteL_RT
bus.WriteO(val bool)MkBufferStreamWriteO_RT
bus.WriteU(val MkBufferCI)MkBufferStreamWriteU_RT
bus.WriteW(val int64)MkBufferStreamWriteW_RT
bus.WriteY(val int8)

MkBufferStreamWriteY_RT

write a PRIMITIVE TYPE into the MkBufferStreamC

After every write the current-access-position is incremented by one, use bus.Reset() to reset.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]busthe MkBufferStreamS instance to work on
[in]valthe new PRIMITIVE TYPE
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

MkBufferListC

MkBufferListC APPEND

AppendGappend a native PRIMITIVE TYPE object to a MkBufferListC
AppendLAappend a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON string)
AppendLPcopy a MkBufferListS list into an MkBufferListS object on position
AppendUPappend a MkBufferC item into an MkBufferListC object on position
BufferListAppendVAappend a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON string)
BufferListAppendVCappend a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON string)
AppendTTappend a native PRIMITIVE TYPE object to a MkBufferListC
PositionMerge

merge a MkBufferListS list into an MkBufferListS object on position

MkBufferListC CHECK

CheckOptionsearch for boolean option in MkBufferListS list and return MK_BOL value …
CheckOptionTT

search for opt in MkBufferListS list and fill var with opt_argument or the defval value …

MkBufferListC INDEX

IndexDeletedelete the index'th list item from the MkBufferListS object …
IndexExtractextract (read & delete) the index object from bfl
IndexGetget (read only) the index object from bfl
IndexGetCget the index element from MkBufferListC ... as string. …
IndexGetUget the index element from MkBufferListC ... if not available… create it. …
IndexSetset the index object from bfl
IndexSetCset the index element from MkBufferListC ... to string… if not available… create space …
IndexSetUset the index element from MkBufferListC ... if not available… createspace …
Reservereserve num items in a MkBufferListC object …
Size

get the number-of-items in the bfl

MkBufferListC INTROSPECTION

Instancesget head-instance from linked-list of MkBufferListS type …
Nextget next instance from linked-list of MkBufferListS type
Prev

get previous instance from linked-list of MkBufferListS type

MkBufferListC LOG

Logwrite the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) …
LogSwrite the short-summary of the MkBufferListC to MkLogFileC (default: stderr) …
LogSSwrite the very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) …
LogSSS

write the very-very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) …

MkBufferListC MISC

Cmpcompare two buffer-list
Copycopy all internal data from src to tgt
Movemove all internal data from from to the end of to
Resetreset a MkBufferListC object …
SearchCsearch MK_STR item from a MkBufferListS object starting at startindex
Sortsort a MkBufferListC
ToBufferExport a bfl into an MkBufferC using an MkBufferStreamC
ToList

get a target-language list representation of the bfl

MkBufferListC TOR

CreateConstructs a MkBufferC instance with size storage…
CreateLAConstructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON string)
CreateTLSsame as BufferListCreate but require no cleanup …
BufferListCreateVAConstructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON string)
BufferListCreateVCConstructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON string)
FileGlobcreate a new MkBufferListC using the result from a filesystem glob operation …
FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkBufferListC instance …
DupDup-Constructor - create a new MkBufferListC instance as copy from an existing MkBufferListC instance …
Merge

Merge-Constructor - constructs a MkBufferListC instance as a merge from an existing MkBufferListC instance …

MkBufferListC DETAIL

C-API: MkBufferListC_C_API - The MkBufferListC object known as bfl or buffer-list is used to create and manage a list of MkBufferC

The MkBufferListC is used to store a list of MkBufferC data into an array. In contrast to the MkBufferStreamC, each individual item can be accessed directly with the MkBufferListC.

MkBufferListCI CLASS

The CLASS used to store a list of MkBufferS items into a flat array…

C-Kernel-Details

The CLASS MkBufferListS is used to store a list of MkBufferS into an MkBufferListS::data array. To access an MkBufferS item use:

‍0 <= index < MkBufferListS::cursize

A new MkBufferListS is always preallocated with the predefined ILS-storage (MkBufferListS::bls), but can switch to a MALLOC-storage if the storage requirements of the user exceed the predefined ILS-storage-size (MkBufferListS_bls_size).

‍A MkBufferListS never run out of storage.

See also
MkBufferC, MkBufferStreamC

MkBufferListCI CTOR / DTOR

command alias
[constructor] MkBufferListCreate(?size int32 = 0?) mkkernel.MkBufferListCreate(num int32)
[destructor] bfl.Delete() bfl.Dispose()

MkBufferListC APPEND

C-API: MkBufferListC_Append_C_API - various functions to 'append' on a MkBufferListC

bfl.AppendG(val int)

TOP

append a native PRIMITIVE TYPE object to a MkBufferListC … → API: MkBufferListAppendG

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]valthe PRIMITIVE TYPE object data to append

bfl.AppendLA(args MkBufferListCI) MkBufferListCI

TOP

append a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON string) → API: MkBufferListAppendLA

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]argsthe MkBufferListC object

bfl.AppendLP(addBufL MkBufferListCI, ?position int32 = -1?) MkBufferListCI

TOP

copy a MkBufferListS list into an MkBufferListS object on position … → API: MkBufferListAppendLP

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]addBufLthe MkBufferListS object to append
[in]positioninsert in at position, shift all following arguments one up
Attention
Set position to 0 to append to the beginning or set position to -1 to append to the end

bfl.AppendUP(addBuf MkBufferCI, ?position int32 = -1?)

TOP

append a MkBufferC item into an MkBufferListC object on position … → API: MkBufferListAppendUP

- set position to 0 to append to the beginning

  • set position to -1 to append to the end
  • after append the addBuf belongs to bfl
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]addBufthe MkBufferC object to append
[in]positioninsert in at position, shift all following arguments one up
Attention
After append the object addBuf will be owned by bfl.

bfl.AppendVA(args ...string) MkBufferListCI

TOP

append a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON string) → API: MkBufferListAppendLA

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]argsthe MkBufferListC object

bfl.AppendVC(args []string) MkBufferListCI

TOP

append a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON string) → API: MkBufferListAppendLA

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]argsthe MkBufferListC object

bfl.PositionMerge(source MkBufferListCI, position int32) MkBufferListCI

TOP

merge a MkBufferListS list into an MkBufferListS object on position … → API: MkBufferListPositionMerge

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]sourcethe object to be merged into bfl, afterwords the source is empty and can be deleted
[in]positioninsert in at position, shift all following arguments one up. Set position to 0 to append to the beginning or set position to -1 to append to the end

bfl.AppendTT(val int8)

The BufferListAppendTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bfl.AppendC(val string)MkBufferListAppendC_RT
bfl.AppendD(val float64)MkBufferListAppendD_RT
bfl.AppendF(val float32)MkBufferListAppendF_RT
bfl.AppendI(val int32)MkBufferListAppendI_RT
bfl.AppendO(val bool)MkBufferListAppendO_RT
bfl.AppendS(val int16)MkBufferListAppendS_RT
bfl.AppendU(val MkBufferCI)MkBufferListAppendU_RT
bfl.AppendW(val int64)MkBufferListAppendW_RT
bfl.AppendY(val int8)

MkBufferListAppendY_RT

append a native PRIMITIVE TYPE object to a MkBufferListC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]valthe PRIMITIVE TYPE object data to append

MkBufferListC CHECK

C-API: MkBufferListC_Check_C_API - various functions to 'check' a MkBufferListC

This functions are used for parsing command-line-arguments.

bfl.CheckOption(opt string, ?onlyFirst bool = false?) bool

TOP

search for boolean option in MkBufferListS list and return MK_BOL value … → API: MkBufferListCheckOption

-# If opt is found, the opt is deleted from the MkBufferListC.

  1. If opt starting with a - or a -- the opt is treated as true
  2. If opt starting with a + or a ++ the opt is treated as false
  3. If opt does not start with a - or a + than the opt is treated as true
  4. It multiple opt are available all opt are checked and deleted.
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on or NULL
[in]optFind opt string in the MkBufferListC
[in]onlyFirstStop after first item was found

bfl.CheckOptionTT(opt string, ?defval int8 = 0?, ?onlyFirst bool = true?)

The BufferListCheckOptionTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bfl.CheckOptionC(opt string, ?defval string = ""?, ?onlyFirst bool = true?) stringMkBufferListCheckOptionC_RT
bfl.CheckOptionD(opt string, ?defval float64 = 0?, ?onlyFirst bool = true?) float64MkBufferListCheckOptionD_RT
bfl.CheckOptionF(opt string, ?defval float32 = 0?, ?onlyFirst bool = true?) float32MkBufferListCheckOptionF_RT
bfl.CheckOptionI(opt string, ?defval int32 = 0?, ?onlyFirst bool = true?) int32MkBufferListCheckOptionI_RT
bfl.CheckOptionO(opt string, ?defval bool = false?, ?onlyFirst bool = true?) boolMkBufferListCheckOptionO_RT
bfl.CheckOptionS(opt string, ?defval int16 = 0?, ?onlyFirst bool = true?) int16MkBufferListCheckOptionS_RT
bfl.CheckOptionU(opt string, ?defval MkBufferCI = nil?, ?onlyFirst bool = true?) MkBufferCIMkBufferListCheckOptionU_RT
bfl.CheckOptionW(opt string, ?defval int64 = 0?, ?onlyFirst bool = true?) int64MkBufferListCheckOptionW_RT
bfl.CheckOptionY(opt string, ?defval int8 = 0?, ?onlyFirst bool = true?) int8

MkBufferListCheckOptionY_RT

search for opt in MkBufferListS list and fill var with opt_argument or the defval value …

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on or NULL
[in]optFind opt string in the MkBufferListC
[in]defvalThe value used if opt was not found
[in]onlyFirstIf more than one opt is available, return only the first (true [DEFAULT]) or the last (false)
[out]val_outIf opt is found, return the argument from opt otherwise defval
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
  • If val_out is NULL an error is returned.
  • If the opt is found but no opt_argument than a error is returned.
  • If the opt is found, the opt and the opt_argument are deleted from the MkBufferListC.
  • If the defval is returned only a copy of the defval is returned and not the original defval.

MkBufferListC INDEX

C-API: MkBufferListC_Index_C_API - various functions to access a MkBufferListC by 'index' …

bfl.IndexDelete(index int32, ?numitems int32 = 1?, ?doDelete bool = true?)

TOP

delete the index'th list item from the MkBufferListS object … → API: MkBufferListIndexDelete

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
numitemsdelete number of items
doDeleteif doDelete == true delete the MkBufferC object, associated with the index, too
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

bfl.IndexExtract(?index int32 = 0?) MkBufferCI

TOP

extract (read & delete) the index object from bfl … → API: MkBufferListIndexExtract

If the index is not available, this is an error

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[out]val_outthe MkBuffer64S object to return
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
1. val_out is owned by the caller and have to be freed.
2. val_out will allways be set to NULL first.
See also
BufferListDelete

bfl.IndexGet(index int32) MkBufferCI

TOP

get (read only) the index object from bfl … → API: MkBufferListIndexGet

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[out]val_outthe MkBufferC to return
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
1. val_out is owned by the MkBufferListC and must NOT be freed.
2. val_out will allways be set to NULL first.
3. it is an error if index is not available.
See also
BufferListIndexGetU

bfl.IndexGetC(index int32) string

TOP

get the index element from MkBufferListC ... as string. … → API: MkBufferListIndexGetC

for details please refer to BufferListIndexGetU.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
Returns
the string requested or an EMPTY-STRING on error

bfl.IndexGetU(index int32) MkBufferCI

TOP

get the index element from MkBufferListC ... if not available… create it. … → API: MkBufferListIndexGetU

The buffer returned is still owned by bfl.

index starting first next... mode
+0 < idx < (+)~ begin 0 1, 2, 3 ... access idx from begin
-1 < idx < (-)~ end -1 -2, -3, -4 ... append idx to the end
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
Returns
the MkBufferC requested
See also
BufferListIndexGet

bfl.IndexSet(index int32, buf MkBufferCI)

TOP

set the index object from bfl … → API: MkBufferListIndexSet

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[in]bufthe MkBufferS instance to work on
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
It is an error if index is not available.
See also
BufferListIndexSetU

bfl.IndexSetC(index int32, str string)

TOP

set the index element from MkBufferListC ... to string… if not available… create space … → API: MkBufferListIndexSetC

for details please refer to BufferListIndexGetU

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[in]strthe string to set

bfl.IndexSetU(index int32, buf MkBufferCI)

TOP

set the index element from MkBufferListC ... if not available… createspace … → API: MkBufferListIndexSetU

-# cursize will be >= index+1

  1. size will be >= index+1
  2. cursize <= X < index+1 -> the missing buffer will be created
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]indexan integer index to access an object in an array by position, start=0, end=-1
[in]bufthe MkBufferS instance to work on

bfl.Reserve(num int32)

TOP

reserve num items in a MkBufferListC object … → API: MkBufferListReserve

-# cursize will be num

  1. size will b >= num
  2. free: num <= X < cursize
  3. init: cursize <= X < num
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
bflthe MkBufferListC object to reserve memory
numreserve the number of items for later use.

bfl.Size() int32

TOP

get the number-of-items in the bfl … → API: MkBufferListSize

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
the number-of-items in the bfl

MkBufferListC INTROSPECTION

C-API: MkBufferListC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferInstances() MkBufferCI)
    • return the last-instance created or nil if no instance was created.
  • The Next (example: buf.Next() MkBufferCI)
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: buf.Prev() MkBufferCI)
    • return the previous-instance for a given-instance or nil if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkBufferListInstances() MkBufferListCI

TOP

get head-instance from linked-list of MkBufferListS type … → API: MkBufferListInstances

The head-instance is the last instance created.

bfl.Next() MkBufferListCI

TOP

get next instance from linked-list of MkBufferListS type → API: MkBufferListNext

bfl.Prev() MkBufferListCI

TOP

get previous instance from linked-list of MkBufferListS type → API: MkBufferListPrev

MkBufferListC LOG

C-API: MkBufferListC_Log_C_API - various functions to 'log' a MkBufferListC

bfl.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

write the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLog

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS 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
MkBufferListC

bfl.LogS(?varname string = "bfl"?, ?fmtobj MkObjectCI = nil?, ?callfunc string = MkGetCallerProc()?)

TOP

write the short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLogS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
varnameprefix to identify the variable name
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

bfl.LogSS(?varname string = "bfl"?, ?fmtobj MkObjectCI = nil?, ?callfunc string = MkGetCallerProc()?)

TOP

write the very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLogSS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
varnameprefix to identify the variable name
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

bfl.LogSSS(?varname string = "bfl"?, ?fmtobj MkObjectCI = nil?, ?callfunc string = MkGetCallerProc()?)

TOP

write the very-very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLogSSS

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]varnameThe name of the argument to report
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)

MkBufferListC MISC

C-API: MkBufferListC_Misc_C_API - various functions to work on a MkBufferListC

bfl.Cmp(bfl2 MkBufferListCI) int32

TOP

compare two buffer-list … → API: MkBufferListCmp

First the size is compared and if the size is equal every argument starting from 0 is compared with BufferCmp. The first BufferCmp with a result != 0 finish the comparison and this result is returned.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]bfl2buffer-list to compare
Returns
Returns < 0 if bfl is less than bfl2; > 0 if bfl is greater than bfl2, and 0 if they are equal

bfl.Copy(src MkBufferListCI)

TOP

copy all internal data from src to tgt … → API: MkBufferListCopy

-# existing data will be overwritten

  1. the cursize of src will be the cursize of tgt
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
[in]srcthe source of the copy

to.Move(from MkBufferListCI)

TOP

move all internal data from from to the end of to … → API: MkBufferListMove

after the move… the from ist empty and only the shell exists

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tothe target of the move
[in]fromthe source of the move

bfl.Reset()

TOP

reset a MkBufferListC object … → API: MkBufferListReset

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Attention
all MkBufferC objects will be freed

bfl.SearchC(str string, ?len int32 = -1?, ?startindex int32 = 0?) int32

TOP

search MK_STR item from a MkBufferListS object starting at startindex … → API: MkBufferListSearchC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
strthe string to search for
lenthe length of str or -1 to calulate the length with strlen
startindexstart searching in buf from index startindex
Returns
The index of the str found or -1 if not found. The return value can be used as startindex of following calls to BufferListSearchC

a typical usage for this code is parsing an MkBufferListS object for multiple occurrences of a string

while ((startindex = MkBufferListSearchC (buf, str, strlen(str), startindex)) != -1) {
...
}
#define MkBufferListSearchC(...)
Attention
The size of str have to be at least 4 bytes

bfl.Sort() MkBufferListCI

TOP

sort a MkBufferListC … → API: MkBufferListSort

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
Return the input bfl as sorted list

bfl.ToBuffer() MkBufferCI

TOP

Export a bfl into an MkBufferC using an MkBufferStreamC … → API: MkBufferListToBuffer

An buffer is able to hold all primitive types and LIST of primitive types. An buffer-list is an Indexed-LIST representation of a LIST of buffer.

To add a buffer-list into an buffer the buffer-list have to be converted into a buffer-stream and the buffer-stream have to be exported as buffer. The buffer is finally apended to the buffer-list.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
the required buffer or a NULL on error
Attention
The memory of the out-value belongs to the called GoMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

bfl.ToList() []interface{}

TOP

get a target-language list representation of the bfl … → API: MkBufferListToList_RT

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]bflthe MkBufferListS instance to work on
Returns
the required list
Attention
this is only implemented by the Target-Programming-Language

MkBufferListC TOR

C-API: MkBufferListC_TOR_C_API - various functions to create and destroy a MkBufferListC

[constructor] MkBufferListCreate(?size int32 = 0?)

TOP

Constructs a MkBufferC instance with size storage… → API: MkBufferListCreate

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

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sizeThe initial size of the instance-local-storage. The MkBufferListC has dynamic-memory-management, the size value is just a hint to provide enought memory for future tasks. The real size created is the maximum of type-ILS-size and size . (default: 0 = use the type-ILS-size)
Returns
The newly created MkBufferListC instance, the instance is owned by the caller

[constructor] MkBufferListCreateLA(args MkBufferListCI)

TOP

Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON string) → API: MkBufferListCreateLA

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

Returns
The newly created MkBufferListC instance, the instance is owned by the caller
See also
BufferListDup

[constructor] MkBufferListCreateTLS(tlsid int32)

TOP

same as BufferListCreate but require no cleanup … → API: MkBufferListCreateTLS

A TLS-instance only exists ONCE per thread and per TLS-function in memory. The memory will be reused and must not be freed.

The new BufferListCreateTLS instance is ready to use and does NOT require a BufferListReset first and a BufferListDelete last.

By default a MkBufferListS type is created because internal an array of references is used and no "malloc" etc is done. ONLY if the required size extend the MkBufferListS prealloc size the storage-manager switch internal to dynamic storage management.

Example from perfserver.go performance test with TLS storage

type BFLT PerfServer
func (this *BFLT) Call() {
bfl := MkBufferListCreateTLS(0)
for this.ReadItemExists() {
bfl.AppendU(this.ReadU())
}
this.SendSTART()
size := bfl.Size()
for i := int32(0); i < size; i++ {
this.SendU(bfl.IndexGet(i))
}
this.SendRETURN()
}
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]tlsidAn per-thread unique name (integer > 0) to identify the reuse-able instance-storage. The tlsid have to be between: 0 <= tlsid < 32
Returns
the new MkBufferListC instance, the instance belongs to the TLS-function and does not need to be deleted.
Attention
for usage of the TLS-storage read more at StorageCreateTLS

[constructor] MkBufferListCreateVA(args ...string)

TOP

Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON string) → API: MkBufferListCreateLA

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

Returns
The newly created MkBufferListC instance, the instance is owned by the caller
See also
BufferListDup

[constructor] MkBufferListCreateVC(args []string)

TOP

Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON string) → API: MkBufferListCreateLA

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

Returns
The newly created MkBufferListC instance, the instance is owned by the caller
See also
BufferListDup

[constructor] MkBufferListFileGlob(pattern_match string)

TOP

create a new MkBufferListC using the result from a filesystem glob operation … → API: MkBufferListFileGlob

[static] MkBufferListFromHandle(exporthdl int) MkBufferListCI

TOP

Import-Slot - returns a obj from a former exported handle → API: MkBufferListFromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] bfl.Delete()

TOP

Destructor - delete a MkBufferListC instance … → API: MkBufferListDelete_RT

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 SelfDeleteForce
See also
BufferListCreate BufferListDup MqReadL

[constructor] bfl.Dup()

TOP

Dup-Constructor - create a new MkBufferListC instance as copy from an existing MkBufferListC instance … → API: MkBufferListDup

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

Returns
The newly created MkBufferListC instance, the instance is owned by the caller
See also
ObjDup

[constructor] bfl.Merge()

TOP

Merge-Constructor - constructs a MkBufferListC instance as a merge from an existing MkBufferListC instance … → API: MkBufferListMerge

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 BufferListReset 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]bflthe MkBufferListS instance to work on
Returns
The new instance or NULL on error or if no Merge-Constructor is available
Attention
The new instance have to be deleted with BufferListDelete
See also
BufferListDup

MkErrorC

MkErrorC GET

GetCodeget the value of MkErrorS::code
GetNumget the MkErrorS::num. The number can be used as exit-code …
GetSizeget the error-message-size from the exception-object
GetText

get the MkErrorS::text

MkErrorC INTROSPECTION

Instancesget head-instance from linked-list of MkErrorS type …
Nextget next instance from linked-list of MkErrorS type
Prev

get previous instance from linked-list of MkErrorS type

MkErrorC MISC

Catchconvert a programming-language-error into an gomkkernel error …
Loglog the error to MkLogFileC (default: stderr) …
Printlnprint the default-error to the MkLogFileC (default: stderr) and clear the error afterwards …
ResetThis function clears the err and resets to MK_OK
Stackcheck on error and if yes append an ErrorStackFormat to the error-message
StackFormat

append an ensemble of func, file and line to the error-message

MkErrorC RAISE

PanicCdo a panic with string as argument …
AppendCappend the message to the MkErrorS::text
NoRaiseignore the next return of MK_ERROR and do not raise an target-language-exception
Raiseconvert an gomkkernel error into an programming-language-error and raise afterwards. …
SetC

'set' and 'raise' the MkErrorC using a string-message and a errnum-number

MkErrorC SIGNAL

IsEXITcheck on APPLICATION-EXIT error …
IsSOCKETcheck on SOCKET-DOWN error …
SetCONTINUEsignal end of processing in an MqIEvent callback …
SetCodeset the MkErrorS::code value …
SetEXITfinish the current callback, return to toplevel and MqExit the application …
SetSOCKET

create SOCKET-DOWN error …

MkErrorC SYSTEM

DEFAULTsystem-error - this is always the error in duty …
IGNOREsystem-error - do not store the error in an MkErrorC and ignore the error …
PRINT

system-error - print the error to the MkLogFileC

MkErrorC TOR

FromHandleImport-Slot - returns a obj from a former exported handle
DeleteDestructor - delete a MkErrorS object …
Dup

Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance …

MkErrorC DETAIL

C-API: MkErrorC_C_API - The MkErrorC object known as err or error is used to create … and manage an error message …

An error is a singleton object per thread created at startup and is located at MkRuntimeRLS using the datatype MkErrorC.

‍As error-indicator the enum MkErrorE is used.

The MkErrorC is used to collect all data needed to handle an error and provide global ressources required to process and report the error.

The MkErrorC is also used to integrate the error-handling from gomkkernel into the error-handling-code of the target Go.

Example from Filter6.go use MqContextErrorCatch to convert a Go error into a gomkkernel error

func main() {
  srv := MqFactoryAdd(Filter6_Factory, "Filter6").New()
  defer func() {
    if x := recover(); x != nil {
      srv.ErrorCatch_1(x)
    }
    srv.Exit_0()
  }()
  srv.ConfigSetIgnoreExit(true)
  srv.LinkCreateVC(os.Args)
  srv.ProcessEvent_1(MQ_WAIT_FOREVER)
}

MkExceptionC

Object used to connect the LibMsgqueError with the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) error …

The LibMsgque provide with MkErrorC a complete error-handling with focus to support the "C" Programming-Language. The support include catch, raise, signal and attributes. In addition every target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) add their own error-handling and the purpose of MkExceptionC is to integrate the MkErrorC into the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).

The implementation of an exception depends heavily on the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO), starting with no exception at all, for example. C, an exception as a class object, or as an exception as a global attribute.

Attention
  • All MkExceptionC code is implemented at the target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO) without support by the Programming-Language-Micro-Kernel compiler.
  • By default, MkExceptionC is only used internally, hidden by the class MkErrorC.

ExceptionCheck

Checks if Exception is of type MkExceptionC and returns true or false

Example: test case to check KILL and RECOVER feature, check on MkExceptionC

        var PID int32
        VAL := this.ReadU()
        mycl = Client_New()
        mycl.LinkCreate(this.ConfigGetStartAs())

        mycl.Send("W", "GPID@I", &PID)
        this.SysKill(PID,9)

        for i:=0; i<3; i++ {
          RET, err := mycl.CLDE_ECOI_ERR_2(VAL)
          if err != nil {
            if (err.IsSOCKET()) {
              err.Reset_0()
              mycl.LinkConnect()
              continue
            } else {
              err.Raise()
            }
          }
          this.SendSTART()
          this.SendI(RET)
          break
        }
Returns
the result of the check, true or false
Parameters
[in]exceptionthe exception object from Go, if nil the global exception object is used

MkErrorC GET

C-API: MkErrorC_Get_C_API - various functions to 'get' data out of MkErrorC

err.GetCode() MkErrorE

TOP

get the value of MkErrorS::code … → API: MkErrorGetCode

err.GetNum() int32

TOP

get the MkErrorS::num. The number can be used as exit-code … → API: MkErrorGetNum

err.GetSize() int

TOP

get the error-message-size from the exception-object … → API: MkErrorGetSize

err.GetText() string

TOP

get the MkErrorS::text … → API: MkErrorGetText

MkErrorC INTROSPECTION

C-API: MkErrorC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferInstances() MkBufferCI)
    • return the last-instance created or nil if no instance was created.
  • The Next (example: buf.Next() MkBufferCI)
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: buf.Prev() MkBufferCI)
    • return the previous-instance for a given-instance or nil if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkErrorInstances() MkErrorCI

TOP

get head-instance from linked-list of MkErrorS type … → API: MkErrorInstances

The head-instance is the last instance created.

err.Next() MkErrorCI

TOP

get next instance from linked-list of MkErrorS type → API: MkErrorNext

err.Prev() MkErrorCI

TOP

get previous instance from linked-list of MkErrorS type → API: MkErrorPrev

MkErrorC MISC

C-API: MkErrorC_Misc_C_API - various functions to 'work' on a MkErrorC

err.Catch(?exception interface{} = nil?, ?callfunc string = MkGetCallerProc()?) MkErrorCI

TOP

convert a programming-language-error into an gomkkernel error … → API: MkErrorCatch

Same as obj.ErrorCatch(?exception interface{} = nil?, ?callfunc string = MkGetCallerProc()?) MkErrorCI but skip the Error-Prefix in final target-programming-language (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).

Example from Bug3.go catch an error using [static] MkErrorDEFAULT(?fmtobj MkObjectCI = nil?) MkErrorCI

  defer func() {
    if x := recover(); x != nil {
      MkErrorDEFAULT_0().Catch_1(x).Println()
    }
  }()
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]exceptionthe exception object from Go, if nil the global exception object is used
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
Returns
the ErrorDEFAULT initialized with exception value
See also
err.Raise() err.Reset(?callfunc string = MkGetCallerProc()?, ?callline int32 = MkGetCallerLine()?, ?force bool = false?)

err.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

log the error to MkLogFileC (default: stderr) … → API: MkErrorLog

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[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
MkErrorC err.Log(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

err.Println()

TOP

print the default-error to the MkLogFileC (default: stderr) and clear the error afterwards … → API: MkErrorPrintln

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)

err.Reset(?callfunc string = MkGetCallerProc()?, ?callline int32 = MkGetCallerLine()?, ?force bool = false?)

TOP

This function clears the err and resets to MK_OK … → API: MkErrorReset

Attention
Use this function carfully, as misuse will result in the loss of the error-message.

It is recommended that you use this feature only after the error has been processed.

  • processed = The error was send to another server or printed to the user or to a file.
See also
ErrorRaise ErrorCatch

err.Stack(?callfunc string = MkGetCallerProc()?, ?callfile string = MkGetCallerFile()?, ?callline int32 = MkGetCallerLine()?) MkErrorE

TOP

check on error and if yes append an ErrorStackFormat to the error-message … → API: MkErrorStack

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) → NULL allowed
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]callfilethe name of the file the call take place (e.g. FILE)
[in]calllinethe number of the line the call take place (e.g. LINE)
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

err.StackFormat(?callfunc string = MkGetCallerProc()?, ?callfile string = MkGetCallerFile()?, ?callline int32 = MkGetCallerLine()?)

TOP

append an ensemble of func, file and line to the error-message … → API: MkErrorStackFormat

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]callfilethe name of the file the call take place (e.g. FILE)
[in]calllinethe number of the line the call take place (e.g. LINE)

MkErrorC RAISE

C-API: MkErrorC_Raise_C_API - various functions to 'raise' a MkErrorC

An error is "raised" by naming the MkErrorS::text and changing the MkErrorS::code to MK_ERROR.

[static] MkPanicPanicC(errobj MkObjectCI, callfunc string, errnum int32, message string)

TOP

do a panic with string as argument … → API: MkPanicC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errobja managed object used to identify and format the error-message
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]errnumthe error number used as exit-code as well
messagethe string to be displayed
Attention
this function will never return

err.AppendC(message string)

TOP

append the message to the MkErrorS::text … → API: MkErrorAppendC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
[in]messagethe string to be displayed as message (append)

err.NoRaise() MkErrorCI

TOP

ignore the next return of MK_ERROR and do not raise an target-language-exception … → API: MkErrorNoRaise

Many functions from the MkErrorXXX return an MkErrorE to signal that an MK_ERROR is set. The target-language react on this signal and raise an target-language-exception.
If this behaviour is not desired the ErrorNoRaise is used to suppress the next MK_ERROR return.

This feature is used to avoid the target-language-exception after ErrorSetC etc.

This is usefull if:

  1. an error should be send by MqSendERROR later
  2. an error will be extended by using multiple ErrorAppendC etc later and than raised with ErrorRaise

Example from server.go create and send an background-error message

func (this *Client) BgError() {
  master := this.SlaveGetMaster()
  if master != nil {
    err := MkErrorDEFAULT(master).NoRaise()
    err.SetC (err.GetText(), "BGERROR", err.GetNum())
    master.SendERROR()
  }
}
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed)
Returns
the input err with MkErrorS::noRaise flag set

err.Raise()

TOP

convert an gomkkernel error into an programming-language-error and raise afterwards. … → API: MkErrorRaise

If ther is no gomkkernel-error (MkErrorS::code "= #MK_ERROR) than nothing happen. @param [in] err the #MkErrorS instance to work on - the \e default-error is automatically created on startup. (NULL allowed) \sa \ref doc_mk_go_ErrorCatch "ErrorCatch" \ref doc_mk_go_ErrorReset "ErrorReset"

err.SetC(message string, ?callfunc string = MkGetCallerProc()?, ?errnum int32 = -1?)

TOP

'set' and 'raise' the MkErrorC using a string-message and a errnum-number … → API: MkErrorSetC

The message will be formatted into a gomkkernel error-message.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errthe MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) - err==NULL allowed
[in]messagethe string to be displayed as message
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]errnumthe error number used as exit-code as well
Attention
Use ErrorNoRaise to avoid raise an error.

MkErrorC SIGNAL

C-API: MkErrorC_Signal_C_API - various functions to set and check a 'signal' on a MkErrorC

err.IsEXIT() bool

TOP

check on APPLICATION-EXIT error … → API: MkErrorIsEXIT

The exit-error-object is made for two resons:

  1. The error is set by ErrorSetEXIT to signal end-of-application.
  2. The error is raised by a function to signal a fatal-error which require an application-exit.
    The only source of this kind of fatal-error is a link-target-abnormal-exit caused by a server/network crash.

The link-target-abnormal-exit can only occur for functions that perform a network-request, such as:

  • MqLinkCreate, MqLinkCreateChild, MqLinkConnect, MqSendEND, MqSendEND_AND_WAIT or MqProcessEvent

The aim of this function is to react to an exit-error-object and is used to ignore the error with an ErrorReset and then later to re-establish a connection with a MqLinkConnect.

  • Read more from the: example/go/Filter4.go example

Example "C": catch and ignore an EXIT return-code

if (MkErrorCheckI (MqSendEND_AND_WAIT (ctx, "TOKS", MK_TIMEOUT_USER))) {
}
#define MkErrorIsEXIT_0E()
#define MkErrorReset_1X(x)
#define MkErrorCheckI(err)

err.IsSOCKET() bool

TOP

check on SOCKET-DOWN error … → API: MkErrorIsSOCKET

err.SetCONTINUE()

TOP

signal end of processing in an MqIEvent callback … → API: MkErrorSetCONTINUE

err.SetCode(code MkErrorE)

TOP

set the MkErrorS::code value … → API: MkErrorSetCode

err.SetEXIT(?callfunc string = MkGetCallerProc()?)

TOP

finish the current callback, return to toplevel and MqExit the application … → API: MkErrorSetEXIT

To exit a application in a callback is a difficult task because the code is in-duty. To achieve this goal a special exit-error-object is created and reported to the toplevel. If a transaction is ongoing the MqSendRETURN is not called and thus the transaction is not finished. The calling application is informed later by a socket-down event. This only works for a parent-context. An exit in a child-context is ignored.

Example: raise an EXIT-exception in an ruby-service:

def EXIT
MkErrorC.DEFAULT().SetEXIT()
end

err.SetSOCKET(?detail string = "UNKNOWN"?, ?callfunc string = MkGetCallerProc()?)

TOP

create SOCKET-DOWN error … → API: MkErrorSetSOCKET

MkErrorC SYSTEM

C-API: MkErrorC_System_C_API - various functions to reaise 'System' messagen on MkErrorC

[static] MkErrorDEFAULT(?fmtobj MkObjectCI = nil?) MkErrorCI

TOP

system-error - this is always the error in duty … → API: MkErrorDEFAULT

Set the MkErrorS::format_of_error attribute to fmtobj or NULL. The next error-massage will be formated as usual and than be raised as error. The default-error will be modified.

The next error-message created with ErrorSetC etc is formatted with MkRuntimeS->cid ("context-in-duty") or simply as "DEFAULT" if cid == NULL.

Parameters
[in]fmtobjmanaged object used to format the log-message (default=NULL = use default format)
Returns
the default-error with MkErrorS::format_of_error attribute set
See also
ErrorDEFAULT, ErrorPRINT, ErrorIGNORE, ErrorPANIC

[static] MkErrorIGNORE() MkErrorCI

TOP

system-error - do not store the error in an MkErrorC and ignore the error … → API: MkErrorIGNORE

There are two functions to suppress an error: [static] MkErrorIGNORE() MkErrorCI and err.NoRaise() MkErrorCI.

The [static] MkErrorIGNORE() MkErrorCI set the MkErrorS::format_of_error attribute to IGNORE. The next error will be ignored, no formatting will be performed and the the default-error will not be modified.

The err.NoRaise() MkErrorCI set the MkErrorS::noRaise attribute to TRUE. The next error will be set as usual but not raised. This is usefull to set an error and later append additional information to the error. Final the error have to be raised with err.Raise().

Returns
the default-error with MkErrorS::format_of_error attribute set
See also
ErrorDEFAULT, ErrorPRINT, ErrorIGNORE, ErrorPANIC

[static] MkErrorPRINT() MkErrorCI

TOP

system-error - print the error to the MkLogFileC … → API: MkErrorPRINT

Set the MkErrorS::format_of_error attribute to PRINT. The next error-massage will be formated as usual and than be reported using LogVL. The default-error will not be modified.

Returns
the default-error with MkErrorS::format_of_error attribute set
See also
ErrorDEFAULT, ErrorPRINT, ErrorIGNORE, ErrorPANIC

MkErrorC TOR

C-API: MkErrorC_TOR_C_API - various functions to 'create' and 'delete' a MkErrorC

[static] MkErrorFromHandle(exporthdl int) MkErrorCI

TOP

Import-Slot - returns a obj from a former exported handle → API: MkErrorFromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[destructor] err.Delete()

TOP

Destructor - delete a MkErrorS object … → API: MkErrorDelete_RT

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 SelfDeleteForce
See also
BufferDup ObjectDelete

[constructor] srce.Dup()

TOP

Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance … → API: MkErrorDup

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

Returns
The newly created MkErrorC instance, the instance is owned by the caller
See also
ObjDup ErrorDelete

MkLogFileC

MkLogFileC INTROSPECTION

Instancesget head-instance from linked-list of MkLogFileS type …
Nextget next instance from linked-list of MkLogFileS type
Prev

get previous instance from linked-list of MkLogFileS type

MkLogFileC TOR

FromHandleImport-Slot - returns a obj from a former exported handle
Openopen the log-file in append mode …
Close

Destructor - delete a MkLogFileC instance …

MkLogFileC WRITE

GetFileget the log-file
WriteC

write to log-file

MkLogFileC DETAIL

C-API: MkLogFileC_C_API - The MkLogFileC object known as lfl or log-file is used to control … the target of the logging-output.

The logging-target is set direct by RuntimeSetLogfile or using the class MkLogFileC.

The target is stored at the MkRuntimeC using a FILE-stream and can be set individually for each thread. The default is stderr.

possible values are:

value decription OS man-page
stdout the standart output stdio(3)
stderr the standart error output stdio(3)
fileName an arbitary fileName fopen(3)

MkLogFileC INTROSPECTION

C-API: MkLogFileC_Introspection_C_API - Get information from the MkTypeS.

Get information about all instances created by class

Get information about all instances created by class

The Introspection API is used to get information about the details of the instance and type implementation. Only the connection between type and instance is currently implemented.

Three methods are used to create an iteration over all avaialable instances of a type.

  • Every class has a Linked-List of all instances created starting from last to first.
  • The Introspection support always 3 Functions per class: Instance (static), Next and Prev
  • The Instance (example: [static] MkBufferInstances() MkBufferCI)
    • return the last-instance created or nil if no instance was created.
  • The Next (example: buf.Next() MkBufferCI)
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: buf.Prev() MkBufferCI)
    • return the previous-instance for a given-instance or nil if the given-instance is the first-instance.

Example: a simple loop over all instances of class MkBufferC (language C++)

for (auto buf = MkBufferC::Instances(); buf != NULL; buf = buf->Next()) {
SendC(buf->ToString());
}

[static] MkLogFileInstances() MkLogFileCI

TOP

get head-instance from linked-list of MkLogFileS type … → API: MkLogFileInstances

The head-instance is the last instance created.

lfl.Next() MkLogFileCI

TOP

get next instance from linked-list of MkLogFileS type → API: MkLogFileNext

lfl.Prev() MkLogFileCI

TOP

get previous instance from linked-list of MkLogFileS type → API: MkLogFilePrev

MkLogFileC TOR

C-API: MkLogFileC_TOR_C_API - various functions to 'create and delete' a MkLogFileC

[static] MkLogFileFromHandle(exporthdl int) MkLogFileCI

TOP

Import-Slot - returns a obj from a former exported handle → API: MkLogFileFromHandle

Parameters
[in]exporthdlhandle former exported with ObjectToHandle
Returns
the required handle or NULL if handle is invalid

[constructor] MkLogFileOpen(errobj MkObjectCI, file string)

TOP

open the log-file in append mode … → API: MkLogFileOpen

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

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]errobja managed object used to identify and format the error-message
[in]filethe filename to open
[out]lfh_outreturns
Returns
The newly created MkLogFileC instance, the instance is owned by the caller
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR
Attention
on error the lfh_out is set to NULL

[destructor] lfh.Close()

TOP

Destructor - delete a MkLogFileC instance … → API: MkLogFileClose_RT

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 SelfDeleteForce
See also
LogFileOpen

MkLogFileC WRITE

C-API: MkLogFileC_Write_C_API - various functions to 'write' into a MkLogFileC

lfl.GetFile() string

TOP

get the log-file … → API: MkLogFileGetFile

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]lflthe MkLogFileS instance to work on
[out]file_outthe log-file to return
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

lfl.WriteC(text string)

TOP

write to log-file … → API: MkLogFileWriteC

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]lflthe MkLogFileS instance to work on
[in]textthe text to write
Returns
set the MkErrorC to the status MK_OK, MK_CONTINUE or MK_ERROR

MkRuntimeC

MkRuntimeC CONFIG

Debuglog the MkRuntimeC
GetDebugget the MkRuntimeS::debug value …
GetIsSilentget the MkRuntimeS::isSilent value …
GetLogfileget the MkRuntimeS::logfile value …
SetDebugset the MkRuntimeS::debug value …
SetIsSilentset the MkRuntimeS::isSilent value …
SetLogfile

set the MkRuntimeS::logfile value and cleanup old value …

MkRuntimeC DETAIL

C-API: MkRuntimeC_C_API - The MkRuntimeC class known as mkrt or runtime is the main gomkkernel application environment …

The runtime is automatically created as thread-local-storage at startup, so that each new thread receives a thread-specific runtime. Each instance on this thread has a link to the runtime it was created in:

The runtime provide the following features:

  • the default-error -> MkErrorC
  • the runtime local storage (RLS) for various internal features
  • application wide configuration data like debug logfile or silent

MkRuntimeC CONFIG

C-API: MkRuntimeC_Config_C_API - only C - various functions to configure the MkRuntimeC

The MkRuntimeRLS-configuration belongs to a single MkRuntimeRLS. In a threadable application, each thread has its own MkRuntimeRLS and therefore its own configuration.

A function ending in 'I' is the inline variant of the function without the 'I' and is preferred in C.

[static] MkRuntimeDebug(?fmtobj MkObjectCI = nil?, ?debug int32 = 0?, ?callfunc string = MkGetCallerProc()?, ?lvl int32 = 0?)

TOP

log the MkRuntimeC … → API: MkRuntimeDebug

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[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
MkRuntimeC

[static] MkRuntimeGetDebug() int32

TOP

get the MkRuntimeS::debug value … → API: MkRuntimeGetDebug

[static] MkRuntimeGetIsSilent() bool

TOP

get the MkRuntimeS::isSilent value … → API: MkRuntimeGetIsSilent

[static] MkRuntimeGetLogfile() string

TOP

get the MkRuntimeS::logfile value … → API: MkRuntimeGetLogfile

Attention
the string is owned by gomkkernel -> do not free !!

[static] MkRuntimeSetDebug(dbg int32)

TOP

set the MkRuntimeS::debug value … → API: MkRuntimeSetDebug

[static] MkRuntimeSetIsSilent(silent bool)

TOP

set the MkRuntimeS::isSilent value … → API: MkRuntimeSetIsSilent

[static] MkRuntimeSetLogfile(logfile string)

TOP

set the MkRuntimeS::logfile value and cleanup old value … → API: MkRuntimeSetLogfile

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]logfilefilename, "stdout" or "stderr", default = "stderr" for NULL or ""

BINARY OBJECT

No special binary-object is used. All binary-data is available as GO []byte.


EXAMPLES

Example from server.go read a buffer-object and convert single-char-type-identifer to string.

type BUF2 Server
  func (this *BUF2) Call() {
    this.SendSTART()
    for i:=0; i<3; i++ {
      buf := this.ReadU()
      this.SendC(buf.GetType3())
      this.SendU(buf)
    }
    this.SendRETURN()
  }

SEE ALSO

libmkkernel, ccmkkernel, csmkkernel, javamkkernel, gomkkernel, pymkkernel, rbmkkernel, tclmkkernel, perlmkkernel, phpmkkernel

KEYWORDS

Go, unix, socket, message, msgque