rbmkkernel 9.0
Loading...
Searching...
No Matches
rbmkkernel

The Programming-Language-Micro-Kernel Project.

SYNOPSIS

The rbmkkernel package is the implementation of the Programming-Language-Micro-Kernel into the target-language Ruby.

require 'rbmkkernel'

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

object description
RbMsgque.MkKernel the namespace with all rbmkkernel specific definitions
RbMsgque.MkKernel.Attribute the interface to access the package specific attribute
RbMsgque.MkKernel.MkClassC.Attribute the interface to access the class specific attribute
Instance.Attribute the interface to access the instance specific attribute

To access all features without RbMsgque.MkKernel prefix use:

include PhpMsgque::RbMsgque.MkKernel

Using the rbmkkernel package …
To access the rbmkkernel package the environment variable RUBYLIB have to include the directory.

> man ruby

RUBYLIB
      A colon-separated list of directories that are added to Ruby's library load path ("$:"). 
      Directories from this environment variable are searched before the standard load path is searched.

      e.g.:
        RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext"
To access the rbmkkernel package the environment variable RUBYLIB have to include the directory.

> man ruby

RUBYLIB
      A colon-separated list of directories that are added to Ruby's library load path ("$:"). 
      Directories from this environment variable are searched before the standard load path is searched.

      e.g.:
        RUBYLIB="$HOME/lib/ruby:$HOME/lib/rubyext"

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 Ruby programmer. !!

PACKAGE

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

The rbmkkernel package is loaded with:

require 'rbmkkernel'

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

The rbmkkernel 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 rbmkkernel application environment …

The rbmkkernel 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 Ruby) 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 rbmkkernel 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 RbMkKernel …

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 rbmkkernel-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 float 4 byte float
D double 8 byte double
B binary 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 MkBufferC buffer-item that can hold any single typed item from above
L MkBufferListC 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 (binary)
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 rbmkkernel to provide temporary storage. It is a common design pattern that rbmkkernel 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 rbmkkernel 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 RB 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 rbmkkernel 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.rb "ReadL" overwrite previous "ReadL"

  def BFL2()
    tmp1 = ReadL()                          ; # "tmp1" is now a reference to the FLS storage of "ReadL"
    tmp2 = ReadL()                          ; # ERROR: the "tmp2" is using a SHARED reference with "tmp1"
    Send("R","LL",tmp1,tmp2)                ; # ERROR: "$tmp1" and "$tmp2" are the SAME values
  end

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

  def pBFL3()
    tmp2 = ReadL()                          ; # ERROR: the "tmp2" is using a SHARED reference with "tmp1"
  end
  def BFL3()
    tmp1 = ReadL()                          ; # "tmp1" is now a reference to the FLS storage of "ReadL"
    Send("C",method(:pBFL3),"ECOL:[III]",4,5,6)      ; # ATTENTION: callback "pBFL3" using "ReadL"
    ProcessEvent(MqWaitOnEventE::OWN)       ; # ERROR: enter event-loop, callback "pBFL3" is called
    Send("R","L",tmp1)                      ; # ERROR: "$tmp1" has now the value from "$tmp2"
  end

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

  def BFL4()
    tmp1 = 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 = ReadL()                          ; # "tmp2" is now a reference to the FLS storage of "ReadL"
    Send("R","LL",glb1,tmp2)                ; # OK: "glb1" (alias tmp1) and "tmp2" are separate references
  end

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.rb performance test with TLS storage in a local (controlled) context

  def BUST
    bus = MkBufferStreamC.CreateTLS(0)
    while ReadItemExists()
      bus.WriteU(ReadU())
    end
    bus.PosToStart()
    SendSTART()
    while bus.ReadItemExists()
      SendU(bus.ReadU())
    end
    SendRETURN()
  end

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 rbmkkernel internal memory …
Setup

setup rbmkkernel internal memory …

MkKernel DETAIL

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

The rbmkkernel package is loaded with:

require 'rbmkkernel'

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

The rbmkkernel 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 rbmkkernel application environment …

The rbmkkernel 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 - rbmkkernel 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: rb_mkkernel_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) MkErrorE MkKernel.ErrorE_FromInt(value:int32)

TOP

return the MkErrorE from integer … → API: rb_mkkernel_MkKernel_ErrorE_FromInt

(static) int32 MkKernel.ErrorE_ToInt(value:MkErrorE)

TOP

return the MkErrorE as integer … → API: rb_mkkernel_MkKernel_ErrorE_ToInt

(static) string MkKernel.ErrorE_ToString(value:MkErrorE)

TOP

return the MkErrorE as string … → API: rb_mkkernel_MkKernel_ErrorE_ToString


enum MkTimeoutE

TOP

Predefined Timeout values … → API: rb_mkkernel_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) MkTimeoutE MkKernel.TimeoutE_FromInt(value:int32)

TOP

return the MkTimeoutE from integer … → API: rb_mkkernel_MkKernel_TimeoutE_FromInt

(static) int32 MkKernel.TimeoutE_ToInt(value:MkTimeoutE)

TOP

return the MkTimeoutE as integer … → API: rb_mkkernel_MkKernel_TimeoutE_ToInt

(static) string MkKernel.TimeoutE_ToString(value:MkTimeoutE)

TOP

return the MkTimeoutE as string … → API: rb_mkkernel_MkKernel_TimeoutE_ToString


enum MkTypeE

TOP

basic data-types supported by Programming-Language-Micro-Kernel … → API: rb_mkkernel_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) MkTypeE MkKernel.TypeE_FromInt(value:int32)

TOP

return the MkTypeE from integer … → API: rb_mkkernel_MkKernel_TypeE_FromInt

(static) int32 MkKernel.TypeE_ToInt(value:MkTypeE)

TOP

return the MkTypeE as integer … → API: rb_mkkernel_MkKernel_TypeE_ToInt

(static) string MkKernel.TypeE_ToString(value:MkTypeE)

TOP

return the MkTypeE as string … → API: rb_mkkernel_MkKernel_TypeE_ToString

MkKernel SETUP

C-API: MkKernel_Setup_C_API - Setup und Cleanup the rbmkkernel

Initializing a rbmkkernel 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 rbmkkernel 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 rbmkkernel 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 rbmkkernel internal memory …
MK_EXTERN void MkSetup(void)
setup rbmkkernel internal memory …

In the Programming-Language-Micro-Kernel, a type is defined for each thread, which means that the new rbmkkernel library must be known when the thread starts. This is not a problem as long as the external rbmkkernel library is linked to the application. However, if dlopen is used to load the rbmkkernel library, the current restriction is that the new data type from the rbmkkernel 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) MkKernel.Cleanup()

TOP

cleanup rbmkkernel internal memory … → API: rb_mkkernel_MkKernel_Cleanup

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) MkKernel.Setup()

TOP

setup rbmkkernel internal memory … → API: rb_mkkernel_MkKernel_Setup

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 rbmkkernel 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 RB-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-RB-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 Ruby) 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 rbmkkernel 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) MkObjectC.DbgM(message:string, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

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

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

TOP

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

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

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

TOP

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

The marker is prefixed with object data from th fmtobj.

obj.DbgLogC(?callfunc:string=""?)

TOP

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

obj.DbgO(?callfunc:string=""?)

TOP

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

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=""?)

TOP

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

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) MkBufferC MkBufferC.Instances())
    • return the last-instance created or nil if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • 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) MkObjectC MkObjectC.Instances()

TOP

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

The head-instance is the last instance created.

MkObjectC obj.Next()

TOP

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

MkObjectC obj.Prev()

TOP

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

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=""?)

TOP

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

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:binary)

TOP

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

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:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

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

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:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

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

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:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

obj.LogSimple(?fmtobj:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

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

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) MkObjectC MkObjectC.FromHandle(exporthdl:long)

TOP

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

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

MkErrorC obj.ErrorCatch(?exception:Exception=nil?, ?callfunc:string=""?)

TOP

convert a programming-language-error into an rbmkkernel error … → API: rb_mkkernel_MkObjectC_ErrorCatch

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 rbmkkernel-error.

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

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

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

        @cl[id].SendSTART()
        begin
          ProxyItem(@cl[id])
          @cl[id].SendEND_AND_WAIT("ECOI", 5)
        rescue Exception => ex
          err = ErrorCatch(ex)
          SendI(err.GetNum())
          SendC(err.GetText())
          err.Reset()
        end
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 Ruby, 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=""?, ?callline:int32=-1?, ?force:bool=false?)

MkErrorC obj.ToError()

TOP

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

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 RbMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

long obj.ToHandle()

TOP

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

A handle is a reference for an instance. A handle can be converted back into an instance using the ?Class?FromHandle syntax like (static) MkBufferListC MkBufferListC.FromHandle(exporthdl:long)

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

string obj.ToName()

TOP

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

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 RbMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

string obj.ToNameOfClass()

TOP

Class-Slot - returns the RB-Class-Name of the obj as string → API: rb_mkkernel_MkObjectC_ToNameOfClass

The Programming-Language-Micro-Kernel connect the RB language with the libmqmsgque runtime. Every class-object in RB 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 RB class

string obj.ToNameOfType()

TOP

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

The Programming-Language-Micro-Kernel connect the RB language with the LibMsgque runtime. Every class-object in RB 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 RB 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

string obj.ToString()

TOP

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

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 RbMkKernel 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: rb_mkkernel_MkObjectC_Delete

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-RB-Instance and the LibMsgque-Instance. → API: rb_mkkernel_MkObjectC_Dispose

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
newConstructor - create a new MkBufferC with minimum size of internal storage …
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 rbmkkernel is working on data… rbmkkernel is working on an MkBufferC object or on a list of MkBufferC objects called MkBufferListC.

MkBufferC 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

MkBufferC CTOR / DTOR

command synonmym
(constructor) MkBufferC.Create(?size:int32=0?) RbMsgque.MkKernel.MkBufferC(?size:long=0?)
(destructor) buf.Delete() buf = nil

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

  def BUF2
    SendSTART()
    for i in 1..3 do
      buf = ReadU()
      SendC(buf.GetType1())
      SendU(buf)
    end
    SendRETURN()
  end
See also
BufferGetType1 BufferGetType2 BufferGetType3

MkBufferC ACCESS

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

MkBufferC buf.AppendC(val:string)

TOP

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

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.rb read and update a MkBufferC

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

int32 buf.Pop(val:string)

TOP

delete str from the MkBufferC … → API: rb_mkkernel_MkBufferC_Pop

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

int32 buf.Push(val:string)

TOP

add str to the MkBufferC … → API: rb_mkkernel_MkBufferC_Push

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

obj buf.ToObject()

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 :

binary buf.GetB()MkBufferGetB_RT
string buf.GetC()MkBufferGetC_RT
double buf.GetD()MkBufferGetD_RT
float buf.GetF()MkBufferGetF_RT
int32 buf.GetI()MkBufferGetI_RT
MkBufferListC buf.GetL(?val_inout:MkBufferListC=nil?)MkBufferGetL_RT
bool buf.GetO()MkBufferGetO_RT
int16 buf.GetS()MkBufferGetS_RT
MkBufferC buf.GetU()MkBufferGetU_RT
int64 buf.GetW()MkBufferGetW_RT
int8 buf.GetY()

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

string[1] buf.GetType1()

TOP

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

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

MkTypeE buf.GetType2()

TOP

return the MkTypeE from a MkBufferC … → API: rb_mkkernel_MkBufferC_GetType2

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 …

string buf.GetType3()

TOP

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

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

bool buf.IsLocal()

TOP

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

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:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

log the MkBufferC … → API: rb_mkkernel_MkBufferC_Log

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:MkObjectC=nil?, ?callfunc:string=""?)

TOP

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

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) MkBufferC MkBufferC.Instances())
    • return the last-instance created or nil if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • 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) MkBufferC MkBufferC.Instances()

TOP

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

The head-instance is the last instance created.

MkBufferC buf.Next()

TOP

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

MkBufferC buf.Prev()

TOP

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

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: rb_mkkernel_MkBufferC_CastTo

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

int32 buf1.Cmp(buf2:MkBufferC)

TOP

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

-# 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.

MkBufferC buf.Copy(srce:MkBufferC)

TOP

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

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: rb_mkkernel_MkBufferC_Reset

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: rb_mkkernel_MkBufferC_ResetFull

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()

MkBufferC buf.SizeAdd(size:int32)

TOP

add size storage to the buf … → API: rb_mkkernel_MkBufferC_SizeAdd

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

MkBufferC buf.SizeNew(size:int32)

TOP

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

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)

MkBufferC buf.Temp()

TOP

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

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 RbMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

string buf.ToString()

TOP

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

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 :

MkBufferC buf.SetB(val:binary)MkBufferSetB_RT
MkBufferC buf.SetC(val:string)MkBufferSetC_RT
MkBufferC buf.SetD(val:double)MkBufferSetD_RT
MkBufferC buf.SetF(val:float)MkBufferSetF_RT
MkBufferC buf.SetI(val:int32)MkBufferSetI_RT
MkBufferC buf.SetO(val:bool)MkBufferSetO_RT
MkBufferC buf.SetS(val:int16)MkBufferSetS_RT
MkBufferC buf.SetU(val:MkBufferC)MkBufferSetU_RT
MkBufferC buf.SetW(val:int64)MkBufferSetW_RT
MkBufferC buf.SetY(val:int8)

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) MkBufferC.Create(?size:int32=0?)

TOP

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

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) MkBufferC.Create1024(?size:int32=0?)

TOP

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

(constructor) MkBufferC.Create256(?size:int32=0?)

TOP

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

(constructor) MkBufferC.Create64(?size:int32=0?)

TOP

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

(constructor) MkBufferC.CreateTLS(tlsid:int32)

TOP

same as BufferCreate but require no cleanup → API: rb_mkkernel_MkBufferC_CreateTLS

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) MkBufferC MkBufferC.FromHandle(exporthdl:long)

TOP

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

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

(constructor) MkBufferC.new(?size:int32=0?)

TOP

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

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

(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: rb_mkkernel_MkBufferC_Dup

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: rb_mkkernel_MkBufferC_Merge

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) MkBufferC.CreateTT(val:int8)

The BufferCreateTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

(constructor) MkBufferC.CreateB(val:binary)MkBufferCreateB_RT
(constructor) MkBufferC.CreateC(val:string)MkBufferCreateC_RT
(constructor) MkBufferC.CreateD(val:double)MkBufferCreateD_RT
(constructor) MkBufferC.CreateF(val:float)MkBufferCreateF_RT
(constructor) MkBufferC.CreateI(val:int32)MkBufferCreateI_RT
(constructor) MkBufferC.CreateO(val:bool)MkBufferCreateO_RT
(constructor) MkBufferC.CreateS(val:int16)MkBufferCreateS_RT
(constructor) MkBufferC.CreateU(val:MkBufferC)MkBufferCreateU_RT
(constructor) MkBufferC.CreateW(val:int64)MkBufferCreateW_RT
(constructor) MkBufferC.CreateY(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
newcreate and initialize an MkBufferStreamC instance …
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) MkBufferC MkBufferC.Instances())
    • return the last-instance created or nil if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • 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) MkBufferStreamC MkBufferStreamC.Instances()

TOP

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

The head-instance is the last instance created.

MkBufferStreamC bus.Next()

TOP

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

MkBufferStreamC bus.Prev()

TOP

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

MkBufferStreamC MISC

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

MkBufferStreamC bus.Copy(src:MkBufferStreamC)

TOP

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

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:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

log the MkBufferStreamC … → API: rb_mkkernel_MkBufferStreamC_Log

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: rb_mkkernel_MkBufferStreamC_PosToStart

bus.Reset()

TOP

reset a MkBufferStreamC to the length zero … → API: rb_mkkernel_MkBufferStreamC_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
See also
bus.ResetFull()

bus.ResetFull()

TOP

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

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.

MkBufferListC bus.ReadALL(?val_inout:MkBufferListC=nil?)

TOP

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

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 RbMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

MkTypeE bus.ReadGetNextType()

TOP

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

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

int32 bus.ReadGetNumItems()

TOP

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

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

bool bus.ReadItemExists()

TOP

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

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

long bus.ReadLONG()

TOP

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

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:long)

bus.ReadL_END()

TOP

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

bus.ReadL_START(?buf:MkBufferC=nil?)

TOP

START read a list-item-type from the MkBufferStreamC … → API: rb_mkkernel_MkBufferStreamC_ReadL_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: rb_mkkernel_MkBufferStreamC_ReadUndo

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 :

binary bus.ReadB()MkBufferStreamReadB_RT
string bus.ReadC()MkBufferStreamReadC_RT
double bus.ReadD()MkBufferStreamReadD_RT
float bus.ReadF()MkBufferStreamReadF_RT
int32 bus.ReadI()MkBufferStreamReadI_RT
MkBufferListC bus.ReadL()MkBufferStreamReadL_RT
bool bus.ReadO()MkBufferStreamReadO_RT
MkBufferC bus.ReadU()MkBufferStreamReadU_RT
int64 bus.ReadW()MkBufferStreamReadW_RT
int8 bus.ReadY()

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) MkBufferStreamC.Create(?size:int32=0?)

TOP

create and initialize an MkBufferStreamC instance … → API: rb_mkkernel_MkBufferStreamC_Create

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) MkBufferStreamC.Create1024(?size:int32=0?)

TOP

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

(constructor) MkBufferStreamC.Create16384(?size:int32=0?)

TOP

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

(constructor) MkBufferStreamC.Create256(?size:int32=0?)

TOP

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

(constructor) MkBufferStreamC.Create64(?size:int32=0?)

TOP

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

(constructor) MkBufferStreamC.CreateTLS(tlsid:int32)

TOP

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

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.rb performance test with TLS storage

  def BUST
    bus = MkBufferStreamC.CreateTLS(0)
    while ReadItemExists()
      bus.WriteU(ReadU())
    end
    bus.PosToStart()
    SendSTART()
    while bus.ReadItemExists()
      SendU(bus.ReadU())
    end
    SendRETURN()
  end
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) MkBufferStreamC MkBufferStreamC.FromHandle(exporthdl:long)

TOP

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

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

(constructor) MkBufferStreamC.new(?size:int32=0?)

TOP

create and initialize an MkBufferStreamC instance … → API: rb_mkkernel_MkBufferStreamC_new

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

(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: rb_mkkernel_MkBufferStreamC_Dup

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: rb_mkkernel_MkBufferStreamC_Merge

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:long)

TOP

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

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
long bus.ReadLONG()

bus.WriteL_END()

TOP

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

bus.WriteL_FLAT(bfl:MkBufferListC)

TOP

write a MkBufferListC FLAT into the MkBufferStreamC … → API: rb_mkkernel_MkBufferStreamC_WriteL_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: rb_mkkernel_MkBufferStreamC_WriteL_START

bus.WriteTT(val:int8)

The BufferStreamWriteTT provide a single function for every PRIMITIVE TYPE

returncommand

C-API :

bus.WriteB(val:binary)MkBufferStreamWriteB_RT
bus.WriteC(val:string)MkBufferStreamWriteC_RT
bus.WriteD(val:double)MkBufferStreamWriteD_RT
bus.WriteF(val:float)MkBufferStreamWriteF_RT
bus.WriteI(val:int32)MkBufferStreamWriteI_RT
bus.WriteL(bfl:MkBufferListC)MkBufferStreamWriteL_RT
bus.WriteO(val:bool)MkBufferStreamWriteO_RT
bus.WriteU(val:MkBufferC)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
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 …
FileGlobcreate a new MkBufferListC using the result from a filesystem glob operation …
FromHandleImport-Slot - returns a obj from a former exported handle
newConstructs a MkBufferC instance with size storage…
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.

MkBufferListC 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

MkBufferListC CTOR / DTOR

command alias
(constructor) MkBufferListC.Create(?size:int32=0?) RbMsgque.MkKernel.MkBufferListC(?num:int=0?)
(destructor) bfl.Delete() bfl = nil

MkBufferListC APPEND

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

bfl.AppendG(val:long)

TOP

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

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 bfl.AppendLA(args:MK_BAC)

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: rb_mkkernel_MkBufferListC_AppendLA

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

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

TOP

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

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:MkBufferC, ?position:int32=-1?)

TOP

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

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

MkBufferListC bfl.PositionMerge(source:MkBufferListC, position:int32)

TOP

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

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:double)MkBufferListAppendD_RT
bfl.AppendF(val:float)MkBufferListAppendF_RT
bfl.AppendI(val:int32)MkBufferListAppendI_RT
bfl.AppendO(val:bool)MkBufferListAppendO_RT
bfl.AppendS(val:int16)MkBufferListAppendS_RT
bfl.AppendU(val:MkBufferC)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.

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

TOP

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

-# 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 :

string bfl.CheckOptionC(opt:string, ?defval:string=""?, ?onlyFirst:bool=true?)MkBufferListCheckOptionC_RT
double bfl.CheckOptionD(opt:string, ?defval:double=0?, ?onlyFirst:bool=true?)MkBufferListCheckOptionD_RT
float bfl.CheckOptionF(opt:string, ?defval:float=0?, ?onlyFirst:bool=true?)MkBufferListCheckOptionF_RT
int32 bfl.CheckOptionI(opt:string, ?defval:int32=0?, ?onlyFirst:bool=true?)MkBufferListCheckOptionI_RT
bool bfl.CheckOptionO(opt:string, ?defval:bool=false?, ?onlyFirst:bool=true?)MkBufferListCheckOptionO_RT
int16 bfl.CheckOptionS(opt:string, ?defval:int16=0?, ?onlyFirst:bool=true?)MkBufferListCheckOptionS_RT
MkBufferC bfl.CheckOptionU(opt:string, ?defval:MkBufferC=nil?, ?onlyFirst:bool=true?)MkBufferListCheckOptionU_RT
int64 bfl.CheckOptionW(opt:string, ?defval:int64=0?, ?onlyFirst:bool=true?)MkBufferListCheckOptionW_RT
int8 bfl.CheckOptionY(opt:string, ?defval:int8=0?, ?onlyFirst:bool=true?)

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: rb_mkkernel_MkBufferListC_IndexDelete

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

MkBufferC bfl.IndexExtract(?index:int32=0?)

TOP

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

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

MkBufferC bfl.IndexGet(index:int32)

TOP

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

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

string bfl.IndexGetC(index:int32)

TOP

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

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

MkBufferC bfl.IndexGetU(index:int32)

TOP

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

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:MkBufferC)

TOP

set the index object from bfl … → API: rb_mkkernel_MkBufferListC_IndexSet

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: rb_mkkernel_MkBufferListC_IndexSetC

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:MkBufferC)

TOP

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

-# 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: rb_mkkernel_MkBufferListC_Reserve

-# 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.

int32 bfl.Size()

TOP

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

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) MkBufferC MkBufferC.Instances())
    • return the last-instance created or nil if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • 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) MkBufferListC MkBufferListC.Instances()

TOP

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

The head-instance is the last instance created.

MkBufferListC bfl.Next()

TOP

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

MkBufferListC bfl.Prev()

TOP

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

MkBufferListC LOG

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

bfl.Log(?fmtobj:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

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

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:MkObjectC=nil?, ?callfunc:string=""?)

TOP

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

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:MkObjectC=nil?, ?callfunc:string=""?)

TOP

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

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:MkObjectC=nil?, ?callfunc:string=""?)

TOP

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

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

int32 bfl.Cmp(bfl2:MkBufferListC)

TOP

compare two buffer-list … → API: rb_mkkernel_MkBufferListC_Cmp

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:MkBufferListC)

TOP

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

-# 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:MkBufferListC)

TOP

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

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: rb_mkkernel_MkBufferListC_Reset

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

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

TOP

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

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) {
...
}
Attention
The size of str have to be at least 4 bytes

MkBufferListC bfl.Sort()

TOP

sort a MkBufferListC … → API: rb_mkkernel_MkBufferListC_Sort

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

MkBufferC bfl.ToBuffer()

TOP

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

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 RbMkKernel function and therefore never becomes nil. For details on the out-value, see: MkKernel_Storage_C_API.

[list...] bfl.ToList()

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) MkBufferListC.Create(?size:int32=0?)

TOP

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

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) MkBufferListC.CreateLA(args:MK_BAC)

TOP

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

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) MkBufferListC.CreateTLS(tlsid:int32)

TOP

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

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.rb performance test with TLS storage

def BFLT
bfl = MkBufferListC.CreateTLS(0)
while ReadItemExists()
bfl.AppendU(ReadU())
end
SendSTART()
for i in 0...bfl.Size()
SendU(bfl.IndexGet(i))
end
SendRETURN()
end
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) MkBufferListC.FileGlob(pattern_match:string)

TOP

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

(static) MkBufferListC MkBufferListC.FromHandle(exporthdl:long)

TOP

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

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

(constructor) MkBufferListC.new(?size:int32=0?)

TOP

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

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

(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: rb_mkkernel_MkBufferListC_Dup

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: rb_mkkernel_MkBufferListC_Merge

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 rbmkkernel 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 rbmkkernel 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 rbmkkernel into the error-handling-code of the target Ruby.

Example from Filter6.rb use MqContextErrorCatch to convert a Ruby error into a rbmkkernel error

srv = MqFactoryC.Add(Filter6).New()
begin
  srv.LinkCreate(ARGV)
  srv.ProcessEvent(MqWaitOnEventE::FOREVER)
rescue Exception => ex
  srv.ErrorCatch(ex)
ensure
  srv.Exit()
end

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

        val = ReadU()
        cl = Client.new
        cl.LinkCreate(ConfigGetStartAs())
        pid = cl.Send("W", "GPID@I")
        SysKill(pid, 9)
        for i in 1..3
          begin
            ret = cl.Send("W", "ECOI:U@I", val)
          rescue MkExceptionC => ex
            err = ErrorCatch(ex)
            if err.IsSOCKET()
              err.Reset()
              cl.LinkConnect()
              next
            else
              err.Raise()
            end
          end
          break
        end
        SendSTART()
        SendI(ret)
Returns
the result of the check, true or false
Parameters
[in]exceptionthe exception object from Ruby, if nil the global exception object is used

MkErrorC GET

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

MkErrorE err.GetCode()

TOP

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

int32 err.GetNum()

TOP

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

long err.GetSize()

TOP

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

string err.GetText()

TOP

get the MkErrorS::text … → API: rb_mkkernel_MkErrorC_GetText

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) MkBufferC MkBufferC.Instances())
    • return the last-instance created or nil if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • 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) MkErrorC MkErrorC.Instances()

TOP

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

The head-instance is the last instance created.

MkErrorC err.Next()

TOP

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

MkErrorC err.Prev()

TOP

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

MkErrorC MISC

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

MkErrorC err.Catch(?exception:Exception=nil?, ?callfunc:string=""?)

TOP

convert a programming-language-error into an rbmkkernel error … → API: rb_mkkernel_MkErrorC_Catch

Same as MkErrorC obj.ErrorCatch(?exception:Exception=nil?, ?callfunc:string=""?) 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.rb catch an error using (static) MkErrorC MkErrorC.DEFAULT(?fmtobj:MkObjectC=nil?)

rescue Exception => ex
  MkErrorC::DEFAULT().Catch(ex).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 Ruby, 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=""?, ?callline:int32=-1?, ?force:bool=false?)

err.Log(?fmtobj:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

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

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:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

err.Println()

TOP

print the default-error to the MkLogFileC (default: stderr) and clear the error afterwards … → API: rb_mkkernel_MkErrorC_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)

err.Reset(?callfunc:string=""?, ?callline:int32=-1?, ?force:bool=false?)

TOP

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

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

MkErrorE err.Stack(?callfunc:string=""?, ?callfile:string=""?, ?callline:int32=-1?)

TOP

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

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=""?, ?callfile:string=""?, ?callline:int32=-1?)

TOP

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

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) MkErrorC.PanicC(errobj:MkObjectC, callfunc:string, errnum:int32, message:string)

TOP

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

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: rb_mkkernel_MkErrorC_AppendC

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)

MkErrorC err.NoRaise()

TOP

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

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.rb create and send an background-error message

  def BgError
    master = SlaveGetMaster()
    if master != nil
      err = master.ErrorDEFAULT().NoRaise()
      err.SetC(err.GetText(), "BGERROR", err.GetNum())
      master.SendERROR()
    end
  end
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 rbmkkernel error into an programming-language-error and raise afterwards. … → API: rb_mkkernel_MkErrorC_Raise

If ther is no rbmkkernel-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_rb_ErrorCatch "ErrorCatch" \ref doc_mk_rb_ErrorReset "ErrorReset"

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

TOP

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

The message will be formatted into a rbmkkernel 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

bool err.IsEXIT()

TOP

check on APPLICATION-EXIT error … → API: rb_mkkernel_MkErrorC_IsEXIT

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/ruby/Filter4.rb example

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

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

bool err.IsSOCKET()

TOP

check on SOCKET-DOWN error … → API: rb_mkkernel_MkErrorC_IsSOCKET

err.SetCONTINUE()

TOP

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

err.SetCode(code:MkErrorE)

TOP

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

err.SetEXIT(?callfunc:string=""?)

TOP

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

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=""?)

TOP

create SOCKET-DOWN error … → API: rb_mkkernel_MkErrorC_SetSOCKET

MkErrorC SYSTEM

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

(static) MkErrorC MkErrorC.DEFAULT(?fmtobj:MkObjectC=nil?)

TOP

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

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) MkErrorC MkErrorC.IGNORE()

TOP

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

There are two functions to suppress an error: (static) MkErrorC MkErrorC.IGNORE() and MkErrorC err.NoRaise().

The (static) MkErrorC MkErrorC.IGNORE() 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 MkErrorC err.NoRaise() 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) MkErrorC MkErrorC.PRINT()

TOP

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

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) MkErrorC MkErrorC.FromHandle(exporthdl:long)

TOP

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

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: rb_mkkernel_MkErrorC_Dup

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 …
newopen 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) MkBufferC MkBufferC.Instances())
    • return the last-instance created or nil if no instance was created.
  • The Next (example: MkBufferC buf.Next())
    • return the next-instance for a given-instance or nil if the given-instance is the last-instance.
  • The Prev (example: MkBufferC buf.Prev())
    • 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) MkLogFileC MkLogFileC.Instances()

TOP

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

The head-instance is the last instance created.

MkLogFileC lfl.Next()

TOP

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

MkLogFileC lfl.Prev()

TOP

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

MkLogFileC TOR

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

(static) MkLogFileC MkLogFileC.FromHandle(exporthdl:long)

TOP

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

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

(constructor) MkLogFileC.Open(errobj:MkObjectC, file:string)

TOP

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

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

(constructor) MkLogFileC.new(errobj:MkObjectC, file:string)

TOP

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

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

string lfl.GetFile()

TOP

get the log-file … → API: rb_mkkernel_MkLogFileC_GetFile

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: rb_mkkernel_MkLogFileC_WriteC

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 rbmkkernel 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) MkRuntimeC.Debug(?fmtobj:MkObjectC=nil?, ?debug:int32=0?, ?callfunc:string=""?, ?lvl:int32=0?)

TOP

log the MkRuntimeC … → API: rb_mkkernel_MkRuntimeC_Debug

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) int32 MkRuntimeC.GetDebug()

TOP

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

(static) bool MkRuntimeC.GetIsSilent()

TOP

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

(static) string MkRuntimeC.GetLogfile()

TOP

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

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

(static) MkRuntimeC.SetDebug(dbg:int32)

TOP

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

(static) MkRuntimeC.SetIsSilent(silent:bool)

TOP

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

(static) MkRuntimeC.SetLogfile(logfile:string)

TOP

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

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 RB binary.


EXAMPLES

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

  def BUF2
    SendSTART()
    for i in 1..3 do
      buf = ReadU()
      SendC(buf.GetType1())
      SendU(buf)
    end
    SendRETURN()
  end

SEE ALSO

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

KEYWORDS

Ruby, unix, socket, message, msgque