A library that adds an object layer with language bindings to the C language.
The libmkkernel package is the implementation of the Programming-Language-Micro-Kernel (PLMK) into the target-language C.
link: -Lpath -lmkkernel
or automake: LDADD = libmkkernel.la
The libmkkernel package is a composition of multiple classes defining the Programming-Language-Micro-Kernel (PLMK) :
object | description |
---|---|
Mk | the namespace with all libmkkernel specific definitions |
MkAttribute(…) | the interface to access the package specific attribute |
MkClassAttribute(…) | the interface to access the class specific attribute |
MkClassAttribute(Instance,…) | the interface to access the instance specific attribute |
To access all features without Mk prefix use:
#include "kernel_mk.h"
liblibmkkernel.so | A shared library or shared object is a computer file that contains executable code designed to be used by multiple computer programs or other libraries at runtime. |
liblibmkkernel.la | A .la file is a text file used by the GNU libtools package to describe the files that make up the corresponding library. |
LDADD = path/to/liblibmkkernel.la
mylib_la_LIBADD = path/to/liblibmkkernel.la
C-API: MK_C_API - The LibMkKernel API …
theKernel is an infrastructure that link an library-item with a Target-Programming-Language (TPL) using the Programming-Language-Micro-Kernel (PLMK) object-interface. The goal is a programming language independent interface between a C library and a target language.
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 (TPL) using a language that is supported by the Programming-Language-Micro-Kernel (PLMK).
Supported Languages are: (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO)
The library-item is connected to the Target-Programming-Language (TPL) using an api-layer generated by the token-stream-compiler of the Programming-Language-Micro-Kernel (PLMK).
The Programming-Language-Micro-Kernel (PLMK) is separted into three programming-layers:
C-API: MkKernel_C_API - MkKernel PACKAGE - The package is the toplevel structure of the Programming-Language-Micro-Kernel (PLMK) …
The libmkkernel package is loaded with:
link:
-Lpath -lmkkernel
or automake:LDADD = libmkkernel.la
and is a composition of one or more class-item.
The libmkkernel package add the following public classes into MkObjectC_C_API :
Object | C-Type | Description |
---|---|---|
MkObjectC | MK_OBJ | MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-Kernel (PLMK) class … |
MkBufferC | MK_BUF | MkBufferC - the abstract class known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. … |
MkBufferStreamC | MK_BUS | MkBufferStreamC - the abstract class known as bus or stream is a subclass of MkBufferC and is used for package-based-io … |
MkBufferListC | MK_BFL | MkBufferListC - the class known as bfl or buffer-list is used to create and manage a list of MkBufferC … |
MkLogFileC | MK_LFL | MkLogFileC - the class known as lfl or log-file is used to control the target of the logging-output … |
MkErrorC | MK_ERR | MkErrorC - the class known as err or error is used to create and manage an error message … |
MkRuntimeC | MK_RT | MkRuntimeC - The class known as mkrt or runtime is the main libmkkernel application environment … |
The libmkkernel package add the following public types into MkObjectC_C_API :
ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType) | |- ABSTRACT: MkSuperTypeSTT (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
C-API: MkObjectC_C_API - MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-Kernel (PLMK) class …
libmkkernel is also called as Programming-Language-Micro-Kernel (PLMK). libmkkernel is like a programming-language without syntax but using the Target-Programming-Language (in our case C) of the Micro-Kernel as runtime environment.
This integration is done using the managed-object-technology.
The managed object supports low level integration features descripted in MkObjectS :
In the implementation-layer of libmkkernel only the public-features of the MkObjectC are visible to the programmer.
C-API: MkKernel_PrimitiveType_C_API - MkKernel PACKAGE - 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 libmkkernel-API command with a focus on a specific type is using a type-postfix, for example MqReadSTR read a (STR=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 | T | native | comment |
---|---|---|---|
BOL | O | MK_BOL | 1 byte boolean value using MK_YES or MK_NO |
I8 | Y | MK_I8 | 1 byte signed character |
I16 | S | MK_I16 | 2 byte signed short |
I32 | I | MK_I32 | 4 byte signed integer |
I64 | W | MK_I64 | 8 byte signed long long integer |
FLT | F | MK_FLT | 4 byte float |
DBL | D | MK_DBL | 8 byte double |
BIN | B | MK_BINN | unsigned char array used for binary data |
STR | C | MK_STR | string data using a \0 at the end |
The following composee identifier's are available:
TT | T | native | comment |
---|---|---|---|
BUF | U | MK_BUF | buffer-item that can hold any single typed item from above |
BFL | L | MK_BFL | 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 C 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.
C-API: MkKernel_PointerType_C_API - MkKernel PACKAGE - 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 | T | type | const type | comment |
---|---|---|---|---|
BIN | B | MK_BIN | MK_BINN | byte-array pointer data-type with binary encoding (MK_BINN) |
STR | C | MK_STR | MK_STRN | string pointer data-type with UTF8 ecoding (MK_STR) |
C-API: MkKernel_Storage_C_API - MkKernel PACKAGE - Storage Management …
Storage management is used in libmkkernel to provide temporary storage. It is a common design pattern that libmkkernel 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 libmkkernel distinguishes three different storage sources:
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 C variable but with the following restriction:
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.c
→ "ReadBFL" overwrite previous "ReadBFL"
static enum MkErrorE Ot_BFL2 ( MQ_SERVICE_CALL_ARGS ) { MK_BFL tmp1 = MqReadBFL_e(mqctx); // "tmp1" is now a reference to the FLS storage of "ReadBFL" MK_BFL tmp2 = MqReadBFL_e(mqctx); // ERROR: the "tmp2" is using a SHARED reference with "tmp1" MqSend_E(mqctx, "R", "LL", tmp1, tmp2); // ERROR: "$tmp1" and "$tmp2" are the SAME values return MK_OK; error: return MqSendRETURN (mqctx); }
Example from server.c
→ "ReadBFL" overwrite previous "ReadBFL" even in an "Event-Loop"
static enum MkErrorE pBFL3 ( MQ_SERVICE_CALL_ARGS ) { __attribute__((unused)) MK_BFL tmp2 = MqReadBFL_e(mqctx); // ERROR: the "tmp2" is using a SHARED reference with "tmp1" return MK_OK; error: return MkErrorStack_1X(mqctx); } static enum MkErrorE Ot_BFL3 ( MQ_SERVICE_CALL_ARGS ) { MK_BFL tmp1 = MqReadBFL_e(mqctx); // "tmp1" is now a reference to the FLS storage of "ReadBFL" MqSend_E(mqctx, "C", pBFL3, "ECOL:[III]", 4, 5, 6); // ATTENTION: callback "pBFL3" using "ReadBFL" MqProcessEvent_E(mqctx,MQ_WAIT_OWN,MK_TIMEOUT_DEFAULT); // ERROR: enter event-loop, callback "pBFL3" is called MqSend_E(mqctx, "R", "L", tmp1); // ERROR: "tmp1" has now the value from "tmp2" return MK_OK; error: return MqSendRETURN (mqctx); }
Example from server.c
→ convert "ReadBFL" result into global storage using "Dup" and free later
static enum MkErrorE Ot_BFL4 ( MQ_SERVICE_CALL_ARGS ) { MK_BFL tmp1 = MqReadBFL_e(mqctx); // "tmp1" is now a reference to the FLS storage of "ReadBFL" MK_BFL glb1 = MkBufferListDup(tmp1); // OK: "glb1" is now a UNSHARED reference to the global memory MK_BFL tmp2 = MqReadBFL_e(mqctx); // "tmp2" is now a reference to the FLS storage of "ReadBFL" MqSend_E(mqctx, "R", "LL", glb1, tmp2); // OK: "glb1" (alias tmp1) and "tmp2" are separate references MkBufferListDelete(glb1); // ATTENTION: don't forget to free the global memory in C return MK_OK; error: return MqSendRETURN (mqctx); }
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 (TPL) supported by the Programming-Language-Micro-Kernel (PLMK).
The *CreateTLS
style function return a TLS that is a global storage. global mean unique per runtime and not unique per definition. The tlsid (0,1,2,3...) is used to distinguish the storage on the global level.
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.
*CreateTLS
style function with caution in a local (controlled) context. enum
Example from perfserver.c
→ performance test with TLS storage in a local (controlled) context
static enum MkErrorE Ot_BUST ( MQ_SERVICE_CALL_ARGS ) { MK_BUS bus = MkBufferStreamCreateTLS_1( "perfserver-BUST" ); while (MqReadItemExists(mqctx)) { MkBufferStreamWriteBUF(bus,MqReadBUF_e(mqctx)); } MkBufferStreamPosToStart(bus); MqSendSTART_E (mqctx); while (MkBufferStreamReadItemExists(bus)) { MqSendBUF_E (mqctx, MkBufferStreamReadBUF_e (bus)); } error: return MqSendRETURN (mqctx); }
Example from LibSq3LiteRpcClient.tcl
→ callback dealing the temporary TLS data
# Intro : Example from tcl-rpc-client of using a CreateTLS-like function (here for MkBufferListC) # to improve code speed and readability. # # Problem : This function is used to invoke a callback (myCb). The arguments come from the argument # list args *and* from a service call (ReadBFL). # The problem is that ReadBFL is called *twice* and the *second* call overwrites the value # of the *first* call because CreateTLS always returns *the same* MkBufferListC, just # replaced with a new set of values. # # Solution : The MkBufferListC instance returned by ReadBFL is copied into another MkBufferListC # instance returned by CreateTLS. # The "CreateTLS" instance is only created *once* and reused, *but* now we can create as # many MkBufferListC instances as we want, because "CreateTLS" distinguishes the returned # instances by the string identifier. # WITHOUT "CreateTLS" a copy would have to be created (Dup) which would then be destroyed # *after* the callback is called (Delete) proc Sq3LiteRpcClientExecV2CB {rpc myCb args} { set valL [MkBufferListC CreateTLS "Sq3LiteRpcClientExecV2CB→valL"] set colL [MkBufferListC CreateTLS "Sq3LiteRpcClientExecV2CB→colL"] $valL Copy [$rpc ReadBFL] $colL Copy [$rpc ReadBFL] $myCb {*}$args $valL $colL }
MkKernel SETUP | MkKernel PACKAGE - Setup und Cleanup the libmkkernel … | ||
MkKernel ENUM | |||
enum MkTypeE | basic data-types supported by Programming-Language-Micro-Kernel (PLMK) … | ||
enum MkTimeoutE | Predefined Timeout values … | ||
enum MkErrorE | collection for the different error-codes … | ||
MkKernel BINARY | |||
BinaryCreate | create a binary from data and size ... | ||
BinaryCreateSlice | create a binary slice ... | ||
BinaryDataGet | get data pointer from the binary ... | ||
BinaryDup | create a binary as duplicate from an already existsing MkBinaryR ... | ||
BinaryIsNull | check if binary is NULL ... | ||
BinaryLog | log the binary ... | ||
BinarySizeGet | get size from the binary ... | ||
MkKernel STRING | |||
StringCreate | create a str from ptr and len ... | ||
StringCreate_1 | create a str from ptr use MK_NULL as end-of-string ... | ||
StringDataGet | get ptr pointer from the string ... | ||
StringDup | create a string as duplicate from an already existsing MkBinaryR ... | ||
StringIsNULL | check if strR is MK_NULL_STR return true or false … | ||
StringLogI | log the string ... | ||
StringSizeGet | get len from the string ... | ||
StringSlice | create a slice of strR start at start with max len bytes … | ||
StringSplit | split a str into ptr and len … |
C-API: MkKernel_C_API - MkKernel PACKAGE - The package is the toplevel structure of the Programming-Language-Micro-Kernel (PLMK) …
The libmkkernel package is loaded with:
link:
-Lpath -lmkkernel
or automake:LDADD = libmkkernel.la
and is a composition of one or more class-item.
The libmkkernel package add the following public classes into MkObjectC_C_API :
Object | C-Type | Description |
---|---|---|
MkObjectC | MK_OBJ | MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-Kernel (PLMK) class … |
MkBufferC | MK_BUF | MkBufferC - the abstract class known as buf or buffer is used to create and manage dynamic, generic, mixed typed data. … |
MkBufferStreamC | MK_BUS | MkBufferStreamC - the abstract class known as bus or stream is a subclass of MkBufferC and is used for package-based-io … |
MkBufferListC | MK_BFL | MkBufferListC - the class known as bfl or buffer-list is used to create and manage a list of MkBufferC … |
MkLogFileC | MK_LFL | MkLogFileC - the class known as lfl or log-file is used to control the target of the logging-output … |
MkErrorC | MK_ERR | MkErrorC - the class known as err or error is used to create and manage an error message … |
MkRuntimeC | MK_RT | MkRuntimeC - The class known as mkrt or runtime is the main libmkkernel application environment … |
The libmkkernel package add the following public types into MkObjectC_C_API :
ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType) | |- ABSTRACT: MkSuperTypeSTT (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
Cleanup | cleanup libmkkernel internal memory … | ||
Setup | setup libmkkernel internal memory … |
C-API: MkKernel_Setup_libmkkernel_C_API - MkKernel PACKAGE - Setup und Cleanup the libmkkernel …
Initializing a libmkkernel library depends on the target language and the specific nature of the Programming-Language-Micro-Kernel (PLMK).
In general it is required to call a Setup style funtion as FIRST argument because of:
If more than one META library is called only the toplevel Setup is required:
A new libmkkernel 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 libmkkernel library startup functions
In the Programming-Language-Micro-Kernel (PLMK), a type is defined for each thread, which means that the new libmkkernel library must be known when the thread starts. This is not a problem as long as the external libmkkernel library is linked to the application. However, if dlopen
is used to load the libmkkernel library, the current restriction is that the new data type from the libmkkernel 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.
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 LcConfigServer
application from the example/cs
directory
LcConfigServer
application is that the libmkkernel and libmqmsgque libraries are loaded very early, at startup, and the liblcconfig very late, only on request.(static) void MkCleanup()
top cleanup libmkkernel internal memory … → API: MkCleanup
MkCleanup will only be recognized once and will be ignored if not called in the same thread as MkSetup. After a call to MkSetup the call to MkCleanup is possible again.
The public MkCleanup is just a placeholder, the internal MkCleanup is always called even if the public MkCleanup is not called.
- Attention
- during cleanup objects will be deleted too -> the language interpreter have to be active
(static) void MkSetup()
top setup libmkkernel internal memory … → API: MkSetup
MkSetup will only be recognized once, additional call's will be ignored until a MkCleanup is called.
A call to the public MkSetup is required if
dlopen
andthread
is used.
C-API: MkKernel_Enum_C_API - MkKernel PACKAGE - enum definition …
A enum in the Programming-Language-Micro-Kernel (PLMK) is a enum-data-type and 3 enum-access-attributes
ENUM_ToString
→ return the string-value from the enum-value ENUM_ToInt
→ return the integer-value from the enum-value 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).
top collection for the different error-codes … → API: MkErrorE
This is the default-error-indicator and the return-value from near all Programming-Language-Micro-Kernel (PLMK) functions.
(static) enum MkErrorE MkErrorE_FromInt(MK_I32 const value, enum MkErrorE *value_out)
top return the MkErrorE from integer … → API: MkErrorE_FromInt
(static) MK_I32 MkErrorE_ToInt(enum MkErrorE value)
top return the MkErrorE as integer … → API: MkErrorE_ToInt
(static) MK_STRN MkErrorE_ToString(enum MkErrorE value)
top return the MkErrorE as string … → API: MkErrorE_ToString
top Predefined Timeout values … → API: MkTimeoutE
The MkTimeoutE is used wherever a "timeout" is required. As a special feature, in addition to the defined values in MkTimeoutE, freely defined values as integers as seconds are also accepted.
(static) enum MkErrorE MkTimeoutE_FromInt(MK_I32 const value, enum MkTimeoutE *value_out)
top return the MkTimeoutE from integer … → API: MkTimeoutE_FromInt
(static) MK_I32 MkTimeoutE_ToInt(enum MkTimeoutE value)
top return the MkTimeoutE as integer … → API: MkTimeoutE_ToInt
(static) MK_STRN MkTimeoutE_ToString(enum MkTimeoutE value)
top return the MkTimeoutE as string … → API: MkTimeoutE_ToString
top basic data-types supported by Programming-Language-Micro-Kernel (PLMK) … → API: MkTypeE
(static) enum MkErrorE MkTypeE_FromInt(MK_I32 const value, enum MkTypeE *value_out)
top return the MkTypeE from integer … → API: MkTypeE_FromInt
(static) MK_I32 MkTypeE_ToInt(enum MkTypeE value)
top return the MkTypeE as integer … → API: MkTypeE_ToInt
(static) MK_STRN MkTypeE_ToString(enum MkTypeE value)
top return the MkTypeE as string … → API: MkTypeE_ToString
C-API: MkKernel_Binary_C_API - MkKernel PACKAGE - operate on a binary al struct of pointer and size …
(static,hide) MkBinaryR MkBinaryCreate(MK_SIZE size, MK_BINN data)
top create a binary from data and size ... → API: MkBinaryCreate
(static,hide) MkBinaryR MkBinaryCreateSlice(MkBinaryR const bin, MK_SIZE start, MK_SIZE wide)
top create a binary slice ... → API: MkBinaryCreateSlice
(static,hide) MK_BINN MkBinaryDataGet(MkBinaryR const bin)
top get data pointer from the binary ... → API: MkBinaryDataGet
(static,hide) MkBinaryR MkBinaryDup(MkBinaryR const bin)
top create a binary as duplicate from an already existsing MkBinaryR ... → API: MkBinaryDup
(static,hide) MK_BOOL MkBinaryIsNull(MkBinaryR const bin)
top check if binary is NULL ... → API: MkBinaryIsNull
(static,hide) void MkBinaryLog(MkBinaryR const bin)
top log the binary ... → API: MkBinaryLog
(static,hide) MK_SIZE MkBinarySizeGet(MkBinaryR const bin)
top get size from the binary ... → API: MkBinarySizeGet
C-API: MkKernel_String_C_API - MkKernel PACKAGE - operate on a string as struct of pointer and size …
(static,hide) MkStringR MkStringCreate(MK_NUM len, MK_STRN str)
top create a str from ptr and len ... → API: MkStringCreate
(static,hide) MkStringR MkStringCreate_1(MK_STRN str)
top create a str from ptr use MK_NULL
as end-of-string ... → API: MkStringCreate_1
(static,hide) MK_STRN MkStringDataGet(MkStringR const str)
top get ptr pointer from the string ... → API: MkStringDataGet
(static,hide) MkStringR MkStringDup(MkStringR const str)
top create a string as duplicate from an already existsing MkBinaryR ... → API: MkStringDup
(static,hide) MK_BOOL MkStringIsNULL(MkStringR const strR)
top check if strR is MK_NULL_STR return true
or false
… → API: MkStringIsNULL
[in] | strR | the string reference to test. |
boolean
value → true
if strR is a MK_NULL_STR. (static,hide) void MkStringLogI(MkStringR const str, MK_STRN func)
top log the string ... → API: MkStringLogI
(static,hide) MK_NUM MkStringSizeGet(MkStringR const str)
top get len from the string ... → API: MkStringSizeGet
(static,hide) MkStringR MkStringSlice(MkStringR strR, MK_NUM start, MK_NUM len)
top create a slice of strR start at start with max len bytes … → API: MkStringSlice
[in] | strR | the string reference to operate on |
[in] | start | the start-index, will be strR.ptr + start |
[in] | len | the size of the new slize, <0 will be to end of string |
MK_NULL
-> MkStringR is returned (static,hide) void MkStringSplit(MkStringR strR, MK_NUM *len_out, MK_STRN *str_out)
top split a str into ptr and len … → API: MkStringSplit
MkObjectC CLASS | |||
Define | MkObjectC - low level definition, access and cast … | ||
Export | MkObjectC - Export class functions … | ||
Introspection | MkObjectC - Introspection class functions … | ||
Misc | MkObjectC - Misc class functions … | ||
MkObjectC TOR | |||
ObjCreate | call the Constructor from the object | ||
DeleteCallbackCleanup | cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup … | ||
DeleteCallbackSetup | Create/Delete the instance-delete-callback … | ||
Delete | Delete-Slot - delete an instance. | ||
Dispose | Dispose-Slot - untie the connection between the Native-C-Instance and the libmkkernel-Instance. | ||
ObjDup | call the Dup-Constructor from the object | ||
ObjDup2 | call the Dup2-Constructor from the object | ||
ObjMerge | Constructor - create a new object as a merge from an existing object | ||
MkObjectC DBG | |||
DbgM | debug: write a static-marker to the MkLogFileC (default: stderr) … | ||
DbgDump | debug: Dump a instance to stderr with LNG and MQ internal data… | ||
DbgL | debug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix … | ||
DbgLogC | debug: write a short-obj-summary to MkLogFileC (default: stderr) … | ||
DbgO | debug: write the object-details to MkLogFileC (default: stderr) … | ||
DbgSTACK | debug: write the stack-trace to MkLogFileC (default: stderr) … | ||
MkObjectC LOG | |||
LogC | write a logging-message to MkLogFileC (default: stderr) using the internal format … | ||
LogHEX | log binaray data as HEX into the MkLogFileC (default: stderr) … | ||
LogV | write a printf style logging-message to MkLogFileC (default: stderr) using the internal format … | ||
LogVL | write a vprintf style logging-message to MkLogFileC using the internal format … | ||
Log | Log-Slot - log the entire object to the MkLogFileC (default: stderr) target … | ||
LogDetail | log the MkObjectS verbose into the MkLogFileC (default: stderr) … | ||
LogSimple | log the MkObjectS into the MkLogFileC (default: stderr) … | ||
MkObjectC OBJ | |||
RefCidN | return the reference-count-recursion-level | ||
RefDecr | decrement the reference-count | ||
RefIncr | increment the reference-count | ||
SelfCreate | create the MkObjectS::self value | ||
SelfDelete | delete the MkObjectS::self value | ||
SelfDeleteForce | force delete an instance, last step in instance-destructor | ||
SelfUnlink | Run the MkTypeS::selfUnlink slot from the instance... | ||
ObjCopy | call the copy from the object | ||
ObjReset | free the internal memory of an object and initialize the local variables to default values | ||
RefDecrWithoutSelf | ATOMIC operation -> unlink self with reference-count. | ||
RefIncrSelf | ATOMIC operation -> link self with reference-count. | ||
RefIsLocked | check if object is locked | ||
RefLock | lock the object | ||
SelfGet | get the MkObjectS::self value | ||
SelfNew | return the self pointer for a given obj … | ||
SelfSet | set the MkObjectS::self value | ||
MkObjectC MISC | |||
ErrorCatch | convert a programming-language-error into an libmkkernel error … | ||
HandleGetOfType | Export-Slot - returns typeHdl of the obj . | ||
IsNull | ckeck if the object is MK_NULL | ||
ToError | Error-Slot - return an error-object pre initialized with obj data. | ||
ToName | Info-Slot - returns brief information about the obj as a string | ||
ToNameOfClass | Class-Slot - returns the C-Class-Name of the obj as string | ||
ToNameOfType | Type-Slot - returns the LibMkKernel-Type-Name of the obj as a string | ||
ToString | String-Slot - returns the string representation of the inst … |
C-API: MkObjectC_C_API - MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-Kernel (PLMK) class …
libmkkernel is also called as Programming-Language-Micro-Kernel (PLMK). libmkkernel is like a programming-language without syntax but using the Target-Programming-Language (in our case C) of the Micro-Kernel as runtime environment.
This integration is done using the managed-object-technology.
The managed object supports low level integration features descripted in MkObjectS :
In the implementation-layer of libmkkernel only the public-features of the MkObjectC are visible to the programmer.
Obj | cast a unknown-object into an MkObjectS pointer or NULL if not possible | ||
ObjCheck | check MkObjectS -> MkObjectS::signature … | ||
ObjCheckO | check MkObjectS -> MkObjectS::signature … | ||
ObjN | (const) cast a unknown-object into an MkObjectS pointer or NULL if not possible |
HandleDeleteByNetHdl | Handle-Delete-Slot - delete a netHdl from handle-storage … | ||
HandleResolve | Handle-Resolve-Slot - return a MkObjectC from netHdl or MK_NULL if invalid… | ||
HandleDelete | Handle-Delete-Slot - delete a netObj from handle-storage … | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkObjectC useable for external storage |
Instances | get head-instance from linked-list of MkObjectS type … | ||
Next | get next instance from linked-list of MkObjectS type | ||
Prev | get previous instance from linked-list of MkObjectS type |
GetNull | Null-Slot - return a MkObjectC typed |
C-API: MkObjectC_Class_C_API - MkObjectC - define the class …
C-API: MkObjectC_Class_Define_C_API - MkObjectC - low level definition, access and cast …
(static,hide) MK_OBJ MkObj(MK_MNG mng)
top cast a unknown-object into an MkObjectS pointer or NULL if not possible → API: MkObj
(static,hide) MK_BOOL MkObjCheck(MK_MNGN mng)
top check MkObjectS -> MkObjectS::signature … → API: MkObjCheck
(static,hide) MK_BOOL MkObjCheckO(MK_OBJN obj)
top check MkObjectS -> MkObjectS::signature … → API: MkObjCheckO
(static,hide) MK_OBJN MkObjN(MK_MNGN mng)
top (const) cast a unknown-object into an MkObjectS pointer or NULL if not possible → API: MkObjN
MkObjectC - Export class functions …
(static,runtime) void MkObjectHandleDeleteByNetHdl(MK_HDL const netHdl)
top Handle-Delete-Slot - delete a netHdl from handle-storage … → API: MkObjectHandleDeleteByNetHdl_RT
(static,runtime) MK_OBJ MkObjectHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkObjectC from netHdl or MK_NULL
if invalid… → API: MkObjectHandleResolve_RT
The MkObjectHandleResolve undo the MkObjectHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkObjectHandleGet |
MK_NULL
if netHdl is invalid (runtime) void MkObjectHandleDelete(MK_OBJ const netObj)
top Handle-Delete-Slot - delete a netObj from handle-storage … → API: MkObjectHandleDelete_RT
(runtime) MK_HDL MkObjectHandleGet(MK_OBJ const obj)
top Handle-Get-Slot - returns a export-hdl to the MkObjectC useable for external storage → API: MkObjectHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkObjectHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
MkObjectC - Introspection class functions …
(static,runtime) MK_OBJ MkObjectInstances()
top get head-instance from linked-list of MkObjectS type … → API: MkObjectInstances_RT
The head-instance is the last instance created.
MK_OBJ MkObjectNext(MK_OBJ const obj)
top get next instance from linked-list of MkObjectS type → API: MkObjectNext
MK_OBJ MkObjectPrev(MK_OBJ const obj)
top get previous instance from linked-list of MkObjectS type → API: MkObjectPrev
MkObjectC - Misc class functions …
(static) MK_OBJ MkObjectGetNull()
top Null-Slot - return a MkObjectC typed NULL
instance … → API: MkObjectGetNull
C-API: MkObjectC_TOR_C_API - MkObjectC - create and destroy a managed-object …
(constructor,static,runtime,hide) MK_OBJ MkObjCreate(MK_PTR nat, MK_PTR lnk)
top call the Constructor from the object → API: MkObjCreate_RT
Create a new object using type and an additional nat. This requie a MkTypeS::constructor be available
(static,runtime) void MkObjectDeleteCallbackCleanup(MK_STRN ident)
top cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup … → API: MkObjectDeleteCallbackCleanup_RT
(static,runtime) enum MkErrorE MkObjectDeleteCallbackSetup(MK_STRN ident, MkObjectDeleteCallF fCall, MK_CBP callback, MK_STRN filter)
top Create/Delete the instance-delete-callback … → API: MkObjectDeleteCallbackSetup_RT
The callback is called shortly before deleting an instance and is used to synchronize object management across the network.
The ident identifies the callback
ALL
is used than all callbacks are deleted first.The fCall (C-Only) or callback (Non-C) it is the callback called
MK_NULL
than the callback with name ident is deleted if exists and no new callback is created. MK_NULL
then it is identical to MkObjectDeleteCallbackCleanup(ident).The filter is a POSIX Extended Regular Expression to filter on type-names.
MK_NULL
and not ""
: MkBufferC
. man 7 regex
. [in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | ident | Identify the callback, have to ne non MK_NULL and not "" . |
[in] | fCall | (C-Only) Internal required: the callback, if MK_NULL than the callback is deleted. |
[in] | callback | Optional: the parameter for fcall, for cleanup use fFree. |
[in] | fFree | (C-Only) Internal optional: cleanup callback data |
[in] | filter | Optional: is an regular expression to filter for MkTypeS::type_name. |
MkObjectDeleteCallbackSetup
: callback signatureMkObjectDeleteCallbackSetup
: callback example(destructor,runtime) void MkObjectDelete(MK_OBJ obj)
top Delete-Slot - delete an instance. → API: MkObjectDelete_RT
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 |
(destructor,runtime) void MkObjectDispose(MK_OBJ obj)
top Dispose-Slot - untie the connection between the Native-C-Instance and the libmkkernel-Instance. → API: MkObjectDispose_RT
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 |
(runtime,hide) MK_OBJ MkObjDup(MK_OBJ const srcobj)
top call the Dup-Constructor from the object → API: MkObjDup_RT
This is an Instance-Callback the real Dup function called depend on the MkObjectS::type.
The Dup-Constructor create a new object-shell, and copy all the internal data from the srcobj to the newobj. After the Dup-Constructor the srcobj is unchanged.
The new instance belongs to the caller and may have to be released if necessary. A manual release using ObjectDelete is always possible, but the instance can no longer be used afterwards.
(runtime,hide) MK_OBJ MkObjDup2(MK_OBJ const srcmng, MK_STRN const ident)
top call the Dup2-Constructor from the object → API: MkObjDup2_RT
The Dup2-Constructor create a new object-shell, and copy all the internal data from the srcobj to the newobj. An additional ident is used to set e name ressource After the Dup2-Constructor the srcobj is unchanged.
MK_NULL
if no Dup2-Constructor fails(runtime,hide) MK_OBJ MkObjMerge(MK_OBJ const obj)
top Constructor - create a new object as a merge from an existing object → API: MkObjMerge_RT
The Merge-Constructor create a new object-shell, and take-over all the internal data from the source-object. After the Merge-Constructor the source-object is empty as if a object-reset was called.
One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | The source-object of the merge. |
MK_NULL
if no Merge-Constructor is available C-API: MkObjectC_Dbg_C_API - MkObjectC - log a debugging-message to the MkLogFileC (default: stderr) …
This functions are "helpers" to support the programmer.
(static,runtime) void MkDbgM(MK_STRN const message, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top debug: write a static-marker to the MkLogFileC (default: stderr) … → API: MkDbgM_RT
(runtime) enum MkErrorE MkDbgDump(MK_OBJN const obj, MK_STRN const message, MK_STRN const callfunc)
top debug: Dump a instance to stderr with LNG and MQ internal data… → API: MkDbgDump_RT
(runtime) void MkDbgL(MK_OBJN fmtobj, MK_STRN const message, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top debug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix … → API: MkDbgL_RT
The marker is prefixed with object data from th fmtobj.
(runtime) void MkDbgLogC(MK_OBJN const obj, MK_STRN const callfunc)
top debug: write a short-obj-summary to MkLogFileC (default: stderr) … → API: MkDbgLogC_RT
(runtime) void MkDbgO(MK_OBJN const obj, MK_STRN const callfunc)
top debug: write the object-details to MkLogFileC (default: stderr) … → API: MkDbgO_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API (MK_NULL allowed) |
[in] | callfunc | a 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.
(runtime) void MkDbgSTACK(MK_OBJN const fmtobj, MK_I32 const skip, MK_I32 const num, MK_STRN const callfunc)
top debug: write the stack-trace to MkLogFileC (default: stderr) … → API: MkDbgSTACK_RT
C-API: MkObjectC_Log_C_API - MkObjectC - 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:
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
(runtime) void MkLogC(MK_OBJN fmtobj, MK_STRN const message, MK_DBG const debug, MK_STRN const callfunc)
top write a logging-message to MkLogFileC (default: stderr) using the internal format … → API: MkLogC_RT
The logging is only done if '
' and 'MqDebug
>= level
using the following format: MqIsSilent
== MK_NO
'
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | message | string to log |
(runtime) void MkLogHEX(MK_OBJN fmtobj, MK_STRN const callfunc, MkBinaryR const data)
top log binaray data as HEX into the MkLogFileC (default: stderr) … → API: MkLogHEX_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | data | the binary data to log |
(runtime,hide) void MkLogV(MK_OBJN fmtobj, MK_STRN const callfunc, MK_DBG debug, MK_FST const printfmt, ...)
top write a printf style logging-message to MkLogFileC (default: stderr) using the internal format … → API: MkLogV_RT
Use the format and the restrictions from LogC.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | printfmt | is a c-string used as printf like format string |
(runtime,hide) void MkLogVL(MK_OBJN fmtobj, MK_STRN const callfunc, MK_DBG debug, MK_FST const printfmt, va_list var_list)
top write a vprintf style logging-message to MkLogFileC using the internal format … → API: MkLogVL_RT
Use the format and the restrictions from LogC.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
(runtime) void MkObjectLog(MK_OBJN const obj, MK_OBJ fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top Log-Slot - log the entire object to the MkLogFileC (default: stderr) target … → API: MkObjectLog_RT
log_doku
slot_doku
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
(runtime) void MkObjectLogDetail(MK_OBJN const obj, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top log the MkObjectS verbose into the MkLogFileC (default: stderr) … → API: MkObjectLogDetail_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
(runtime) void MkObjectLog(MK_OBJN const obj, MK_OBJ fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
(runtime) void MkObjectLogSimple(MK_OBJN const obj, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top log the MkObjectS into the MkLogFileC (default: stderr) … → API: MkObjectLogSimple_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
C-API: MkObjectC_Obj_C_API - MkObjectC - managed-object details
Managed-Object-Technology (MOT) is a class system in C that is designed to integrate automatically into other software, which of course also includes other programming languages.
(static,runtime,hide) MK_NUM MkRefCidN()
top return the reference-count-recursion-level → API: MkRefCidN_RT
(static,runtime,hide) void MkRefDecr(MK_OBJ obj)
top decrement the reference-count → API: MkRefDecr_RT
MkObjectS::refCount <= 0
the destructor will be called. [in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(static,hide) void MkRefIncr(MK_OBJ obj)
top increment the reference-count → API: MkRefIncr
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(static,runtime,hide) MK_PTR MkSelfCreate(MK_OBJ const obj, MK_PTR const env)
top create the MkObjectS::self value → API: MkSelfCreate_RT
create the self from the object mng using MkTypeS::selfCreate
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | env | storage for an application specific environment pointer. (java: JNIEnv*) |
(static,runtime,hide) MK_BOOL MkSelfDelete(MK_OBJ const obj)
top delete the MkObjectS::self value → API: MkSelfDelete_RT
delete the self from obj using MkTypeS::selfDelete
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
self
and mq-obj was deleted and false if self is not available or self-delete does not delete the mq-obj (static,runtime,hide) MK_BOOL MkSelfDeleteForce(MK_OBJ obj)
top force delete an instance, last step in instance-destructor → API: MkSelfDeleteForce_RT
A instance has two parts an PLMK (Programming-Language-Micro-Kernel)-part and a TPL-part, the PLMK (Programming-Language-Micro-Kernel)-part have to be deleted but the deletion of the TPL-part depend on the TPL object-model-philosophy. Some TPL have a HARD-delete some TPL have only a SOFT-delete, read more at MkObjectDelete.
This function will do the following steps:
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
MK_YES
if instance is global or was already deleted and MK_NO
if local (static,runtime,hide) void MkSelfUnlink(MK_OBJ obj)
top Run the MkTypeS::selfUnlink slot from the instance... → API: MkSelfUnlink_RT
An instance has an MQ-part and an LNG-part, both are connected by MkObjectS::self and an LNG-specific proprietary connector. This low-level function will separate the MQpart from the LNG-part, leaving TWO independent objects.
The unlink has the following consequence:
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(runtime,hide) MK_OBJ MkObjCopy(MK_OBJ const tgtmng, MK_OBJN const srcmng)
top call the copy from the object → API: MkObjCopy_RT
MK_NULL
if no Merge-Constructor is available(runtime,hide) void MkObjReset(MK_OBJ const obj)
top free the internal memory of an object and initialize the local variables to default values → API: MkObjReset_RT
(runtime,hide) MK_OBJ MkRefDecrWithoutSelf(MK_OBJ const obj)
top ATOMIC operation -> unlink self with reference-count. → API: MkRefDecrWithoutSelf_RT
First the MkObjectS::self and MkObjectS::env will be set to NULL and than MkRefDecr is called.
This api-function is used to free libmkkernel ressources on an already destroyed Target-Programming-Language (TPL) instance.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(hide) void MkRefIncrSelf(MK_OBJ const obj, MK_PTR const self, MK_PTR const env)
top ATOMIC operation -> link self with reference-count. → API: MkRefIncrSelf
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | self | this is the self pointer of the object in the programming-language-shell used for libmkkernel pointer. |
[in] | env | storage for an application specific environment pointer. (java: JNIEnv*) |
(hide) MK_BOOL MkRefIsLocked(MK_OBJ const obj)
top check if object is locked → API: MkRefIsLocked
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(hide) MK_I32 MkRefLock(MK_OBJ const obj)
top lock the object → API: MkRefLock
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(hide) MK_PTR MkSelfGet(MK_OBJ const obj)
top get the MkObjectS::self value → API: MkSelfGet
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(runtime,hide) enum MkErrorE MkSelfNew(MK_OBJ obj, MK_PTR *self_out, MK_PTR const env)
top return the self pointer for a given obj … → API: MkSelfNew_RT
This is an important function because every return of a managed-object in a Target-Programming-Language (TPL) will call this function to check if the self is already set. If MK_YES
the self is returned and if MK_NO
a new self is created.
the following steps are done:
refCount > 0
return the self pointerrefCount <= 0
return an error [in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[out] | self_out | the new libmkkernel object as return |
[in] | env | storage for an application specific environment pointer. This pointer will be passed to MkTypeS::selfCreate. (example java: JNIEnv*) |
MK_OK
if self_out is new created MK_CONTINUE
if self_out was from MkOBJ_R(ctx)
.self MK_ERROR
on error (hide) void MkSelfSet(MK_OBJ const obj, MK_PTR const self, MK_PTR const env)
top set the MkObjectS::self value → API: MkSelfSet
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | self | the target-language-self-pointer usually self or this |
[in] | env | storage for an application specific environment pointer. (java: JNIEnv*) |
C-API: MkObjectC_Misc_C_API - MkObjectC - various functions related to the MkObjectS …
(runtime) MK_ERR MkObjectErrorCatch(MK_OBJN const obj, MK_EXP const exception, MK_STRN const callfunc)
top convert a programming-language-error into an libmkkernel error … → API: MkObjectErrorCatch_RT
This function is a placeholder and have to be overloaded by the Target-Programming-Language (TPL). The goal is to handel an error-catch condition and convert an programming-language-error into an libmkkernel-error.
This is the same as (example form c++):
Example from server.c
→ catch-send and reset an error
MQ_CTX const clmqctx = srvctx->cl[clid]; MqSendSTART_E (clmqctx); MqProxyItem_E (mqctx, clmqctx); if (MkErrorCheckI(MqSendEND_AND_WAIT(clmqctx, "ECOI", 5))) { MqContextErrorCopy (mqctx, clmqctx); MqSendI32_E (mqctx, MkErrorGetNum_0E()); MqSendSTR_E (mqctx, MkErrorGetText_0E()); MkErrorReset_1X(mqctx); }
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
[in] | exception | the exception object from C, if MK_NULL the global exception object is used |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
(runtime) enum MkErrorE MkErrorRaise(MK_ERRN const err)
(runtime) enum MkErrorE MkErrorReset(MK_ERR const err, MK_STRN const callfunc, MK_I32 const callline, MK_BOOL const force)
MK_I32 MkObjectHandleGetOfType(MK_OBJ const obj)
top Export-Slot - returns typeHdl of the obj . → API: MkObjectHandleGetOfType
A typeHdl identifies the type the obj belongs to. All instances of the same class share the same typeHdl.
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
MK_BOOL MkObjectIsNull(MK_OBJ const obj)
top ckeck if the object is MK_NULL
→ API: MkObjectIsNull
(runtime) MK_ERR MkObjectToError(MK_OBJ const obj)
top Error-Slot - return an error-object pre initialized with obj data. → API: MkObjectToError_RT
This slot is the same as ErrorDEFAULT with fmtobj set to this
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
MK_NULL
for a non-error result.(runtime) MK_STRN MkObjectToName(MK_OBJN const obj)
top Info-Slot - returns brief information about the obj as a string → API: MkObjectToName_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
MK_NULL
for a non-error result.(runtime) MK_STRN MkObjectToNameOfClass(MK_OBJ const obj)
top Class-Slot - returns the C-Class-Name of the obj as string → API: MkObjectToNameOfClass_RT
The Programming-Language-Micro-Kernel (PLMK) connect the C language with the libmkkernel runtime. Every class-object in C has an conterpart as libmkkernel type-object in the Programming-Language-Micro-Kernel (PLMK).
ObjectToNameOfType | returns the name of the libmkkernel type |
ObjectToNameOfClass | returns the name of the C class |
(runtime) MK_STRN MkObjectToNameOfType(MK_OBJN const obj)
top Type-Slot - returns the LibMkKernel-Type-Name of the obj as a string → API: MkObjectToNameOfType_RT
The Programming-Language-Micro-Kernel (PLMK) connect the C language with the libmkkernel runtime. Every class-object in C has an conterpart as libmkkernel type-object in the Programming-Language-Micro-Kernel (PLMK).
ObjectToNameOfType | returns the name of the libmsgque type |
ObjectToNameOfClass | returns the name of the C class |
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
(runtime) MK_STRN MkObjectToString(MK_OBJN const inst)
top String-Slot - returns the string representation of the inst … → API: MkObjectToString_RT
The string is a human-readable form of the data stored in the object.
ToString
function by default.[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | inst | - the instance to work on |
"MK_NULL"
on error MK_NULL
for a non-error result.MkBufferC CLASS | |||
Define | MkBufferC - low level definition, access and cast … | ||
Export | MkBufferC - Export class functions … | ||
Introspection | MkBufferC - Introspection class functions … | ||
Misc | MkBufferC - Misc class functions … | ||
MkBufferC TOR | |||
Create | Constructor - create a new MkBufferC with minimum size of internal storage … | ||
CreateTT | Constructor - create a new MkBufferC with an PRIMITIVE TYPE … | ||
CreateTLS | same as BufferCreate but require no cleanup | ||
CreateBUF | Constructor - create a new MkBufferC with an PRIMITIVE TYPE … | ||
Create64 | call the BufferCreate with default type MkBuffer64S (64 byte) … | ||
Create256 | call the BufferCreate with default type MkBuffer256S (256 byte) … | ||
Create1024 | call the BufferCreate with default type MkBuffer1024S (1024 byte) … | ||
CreateTLS_T | create an new MkBufferC object as T)hread L)ocal S)torage… | ||
CreateTLS_inout_T | Constructs a MkBufferC instance as T)hread L)ocal S)torage OR reuse inout if possible… | ||
CreateLOCAL_T | create an new MkBufferC object as L)ocal S)torage… | ||
Delete | Destructor - delete a MkBufferC instance … | ||
Dup | Dup-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 SET | |||
SetTT | Set the MkBufferC to the val … | ||
SetBinaryR | Set the MkBufferC to the val … | ||
SetBUF | Set the MkBufferC to the val … | ||
SetStringR | Set the MkBufferC to the val … | ||
SetV | set the MkBufferC using a ... value … | ||
SetVL | set the MkBufferC using a va_list value … | ||
MkBufferC GET | |||
GetTT | get a val_out from a MkBufferC … | ||
GetBFL | function to read an MkBufferListC from an MkBufferC object … | ||
GetBUF | get a val_out from a MkBufferC … | ||
GetStringR | get a val_out from a MkBufferC … | ||
MkBufferC ACCESS | |||
AppendSTR | append a single string to a MkBufferC object … | ||
AppendStringR | append a single string to a MkBufferC object … | ||
AppendV | append a single string with format and ... arguments to a MkBuffer64S … | ||
AppendVL | append a single string with format and var_list arguments to a MkBuffer64S … | ||
Pop | delete str from the MkBufferC … | ||
Push | add str to the MkBufferC … | ||
MkBufferC INFO | |||
GetType1 | return the type from a MkBufferC as single character value … | ||
GetType2 | return the MkTypeE from a MkBufferC … | ||
GetType3 | return the type from a MkBufferC as single character string … | ||
IsLocal | Check if the MkBufferC is local (temporary), not local mean global … | ||
Log | log the MkBufferC … | ||
LogS | log the short MkBufferC object data to the MkLogFileC (default: stderr) … | ||
MkBufferC MISC | |||
CastTo | change the type of an MkBufferC to type … | ||
Cmp | compare TWO MkBufferC objects like strcmp do it for strings … | ||
Copy | copy the MkBufferC from srce to dest … | ||
Reset | reset a MkBufferC to the length zero … | ||
ResetFull | reset a MkBufferC to the length zero and free allocated storage… | ||
SizeAdd | add size storage to the buf … | ||
SizeNew | alloc min size storage to the buf … | ||
Temp | create a temporary copy of the MkBufferC buf … | ||
ToString | String-Slot - returns the string representation of the inst … |
C-API: MkBufferC_C_API - MkBufferC - the abstract class 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 libmkkernel is working on data… libmkkernel is working on an MkBufferC object or on a list of MkBufferC objects called MkBufferListC.
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:
MkBufferSPtr->ils_data - MkBufferSPtr
.The ABSTRACT-CLASS MkBufferS is missing the ILS-storage, the FINAL-CLASSES are:
command | synonmym |
---|---|
(constructor,static,runtime) MK_BUF MkBufferCreate(MK_NUM const size) | no |
(destructor,runtime) void MkBufferDelete(MK_BUF const buf) | no |
Example from server.c
→ read a buffer-object and convert single-char-type-identifer to string.
static enum MkErrorE Ot_BUF2 ( MQ_SERVICE_CALL_ARGS ) { MK_BUF buf; int i; char str[2] = {'\0', '\0'}; MqSendSTART_E (mqctx); for (i=0; i<3; i++) { MqReadBUF_E (mqctx, &buf); str[0] = MkBufferGetType1(buf); MqSendSTR_E (mqctx, str); MqSendBUF_E (mqctx, buf); } return MqSendRETURN(mqctx); error: return MkErrorStack_1X(mqctx); }
Buf | cast a unknown-object into an MkBufferS pointer or NULL if not possible | ||
BufCheck | check MkBufferS -> MkObjectS::signature … | ||
BufCheckO | check MkBufferS -> MkObjectS::signature … | ||
BufN | (const) cast a unknown-object into an MkBufferS pointer or NULL if not possible |
HandleResolve | Handle-Resolve-Slot - return a MkBufferC from netHdl or MK_NULL if invalid… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkBufferC useable for external storage |
Instances | get head-instance from linked-list of MkBufferS type … | ||
Next | get next instance from linked-list of MkBufferS type | ||
Prev | get previous instance from linked-list of MkBufferS type |
GetNull | Null-Slot - return a MkBufferC typed |
C-API: MkBufferC_Class_C_API - MkBufferC - define the class …
C-API: MkBufferC_Class_Define_C_API - MkBufferC - low level definition, access and cast …
(static,hide) MK_BUF MkBuf(MK_MNG mng)
top cast a unknown-object into an MkBufferS pointer or NULL if not possible → API: MkBuf
(static,hide) MK_BOOL MkBufCheck(MK_MNGN mng)
top check MkBufferS -> MkObjectS::signature … → API: MkBufCheck
(static,hide) MK_BOOL MkBufCheckO(MK_OBJN obj)
top check MkBufferS -> MkObjectS::signature … → API: MkBufCheckO
(static,hide) MK_BUFN MkBufN(MK_MNGN mng)
top (const) cast a unknown-object into an MkBufferS pointer or NULL if not possible → API: MkBufN
MkBufferC - Export class functions …
(static,runtime) MK_BUF MkBufferHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkBufferC from netHdl or MK_NULL
if invalid… → API: MkBufferHandleResolve_RT
The MkBufferHandleResolve undo the MkBufferHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkBufferHandleGet |
MK_NULL
if netHdl is invalid (runtime) MK_HDL MkBufferHandleGet(MK_BUF const buf)
top Handle-Get-Slot - returns a export-hdl to the MkBufferC useable for external storage → API: MkBufferHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkBufferHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
MkBufferC - Introspection class functions …
(static,runtime) MK_BUF MkBufferInstances()
top get head-instance from linked-list of MkBufferS type … → API: MkBufferInstances_RT
The head-instance is the last instance created.
MK_BUF MkBufferNext(MK_BUF const buf)
top get next instance from linked-list of MkBufferS type → API: MkBufferNext
MK_BUF MkBufferPrev(MK_BUF const buf)
top get previous instance from linked-list of MkBufferS type → API: MkBufferPrev
MkBufferC - Misc class functions …
(static) MK_BUF MkBufferGetNull()
top Null-Slot - return a MkBufferC typed NULL
instance … → API: MkBufferGetNull
C-API: MkBufferC_TOR_C_API - MkBufferC - various functions to create, initialize and destroy a MkBufferC …
(constructor,static,runtime) MK_BUF MkBufferCreate(MK_NUM const size)
top Constructor - create a new MkBufferC with minimum size of internal storage … → API: MkBufferCreate_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | type | A type defined as MkTypeS with a TT postfix (default: MkBuffer64S, possible: MkBuffer64S, MkBuffer256S and MkBuffer1024S) |
[in] | size | The 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) |
(static,runtime) MK_BUF MkBufferCreateTLS(MK_STRN const tlsName, MK_BOOL const resetB)
top same as BufferCreate but require no cleanup → API: MkBufferCreateTLS_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | tlsName | An per-thread unique name (string) to identify the reuse-able instance-storage. if tlsName is MK_NULL or "" than a MK_NULL is returned |
[in] | resetB | should the new object be reset? |
(constructor,static,runtime) MK_BUF MkBufferCreateBUF(MK_BUFN const val)
top Constructor - create a new MkBufferC with an PRIMITIVE TYPE … → API: MkBufferCreateBUF_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | val | the PRIMITIVE TYPE object as data-source |
(constructor,static,runtime) MK_BUF MkBufferCreate64(MK_NUM const size)
top call the BufferCreate with default type MkBuffer64S (64 byte) … → API: MkBufferCreate64_RT
(constructor,static,runtime) MK_BUF MkBufferCreate256(MK_NUM const size)
top call the BufferCreate with default type MkBuffer256S (256 byte) … → API: MkBufferCreate256_RT
(constructor,static,runtime) MK_BUF MkBufferCreate1024(MK_NUM const size)
top call the BufferCreate with default type MkBuffer1024S (1024 byte) … → API: MkBufferCreate1024_RT
(constructor,static,hide,macro) void MkBufferCreateTLS_T(MK_MACRO_TYP cls, MK_MACRO_TYP name, MK_NUM const size)
top create an new MkBufferC object as T)hread L)ocal S)torage… → API: MkBufferCreateTLS_T
The cls argument is: MkBuffer64S 64 bytes, MkBuffer256S = 256 bytes, MkBuffer1024S = 1024 bytes,
[in] | cls | A subclass of MkBufferS with predefined ILS storage → MkBuffer64S, MkBuffer256S and MkBuffer1024S |
name | the name of the new MkBufferC | |
size | the initial size of the new MkBufferC |
(constructor,static,hide,macro) void MkBufferCreateTLS_inout_T(MK_MACRO_TYP cls, MK_MACRO_TYP name, MK_BUF inout)
top Constructs a MkBufferC instance as T)hread L)ocal S)torage OR reuse inout if possible… → API: MkBufferCreateTLS_inout_T
Same as MkBufferCreateTLS_T but try to reuse an already existsing inout. If inout is a MK_NULL
pointer than a pointer to a local-reference is returned.
(constructor,static,hide,macro) void MkBufferCreateLOCAL_T(MK_MACRO_TYP cls, MK_MACRO_TYP name, MK_NUM const size)
top create an new MkBufferC object as L)ocal S)torage… → API: MkBufferCreateLOCAL_T
The cls argument is: MkBuffer64S 64 bytes, MkBuffer256S = 256 bytes, MkBuffer1024S = 1024 bytes,
bufR.super.buf.storage.first.C
[in] | cls | A subclass of MkBufferS with predefined ILS storage → MkBuffer64S, MkBuffer256S and MkBuffer1024S |
name | the name of the new MkBufferC | |
size | the initial size of the new MkBufferC |
(destructor,runtime) void MkBufferDelete(MK_BUF const buf)
top Destructor - delete a MkBufferC instance … → API: MkBufferDelete_RT
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 |
(constructor,runtime) MK_BUF MkBufferDup(MK_BUFN const buf)
top Dup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance → API: MkBufferDup_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
(constructor,runtime) MK_BUF MkBufferMerge(MK_BUF const buf)
top Merge-Constructor - create a new MkBufferC as a merge from an existing object … → API: MkBufferMerge_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
MK_NULL
on error or if no Merge-Constructor is available ((constructor,static,runtime)) MK_BUF MkBufferCreateTT(MK_TT const val)
The BufferCreateTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
(constructor,static,runtime) | MK_BUF | MkBufferCreateI8(MK_I8 const val) | MkBufferCreateI8_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateI16(MK_I16 const val) | MkBufferCreateI16_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateI32(MK_I32 const val) | MkBufferCreateI32_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateI64(MK_I64 const val) | MkBufferCreateI64_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateSTR(MK_STRN const val) | MkBufferCreateSTR_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateBIN(MkBinaryR const val) | MkBufferCreateBIN_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateBOL(MK_BOL const val) | MkBufferCreateBOL_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateFLT(MK_FLT const val) | MkBufferCreateFLT_RT |
(constructor,static,runtime) | MK_BUF | MkBufferCreateDBL(MK_DBL const val) |
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | val | the PRIMITIVE TYPE object as data-source |
C-API: MkBufferC_Set_C_API - MkBufferC - various functions to set buffer-data …
(runtime) MK_BUF MkBufferSetBinaryR(MK_BUF const buf, MkBinaryR const val)
top Set the MkBufferC to the val … → API: MkBufferSetBinaryR_RT
The old value will be removed and the memory will be reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the value to set the buf to |
(runtime) MK_BUF MkBufferSetBUF(MK_BUF const buf, MK_BUFN const val)
top Set the MkBufferC to the val … → API: MkBufferSetBUF_RT
The old value will be removed and the memory will be reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the value to set the buf to |
(runtime) MK_BUF MkBufferSetStringR(MK_BUF const buf, MkStringR const val)
top Set the MkBufferC to the val … → API: MkBufferSetStringR_RT
The old value will be removed and the memory will be reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the value to set the buf to |
(runtime,hide) MK_BUF MkBufferSetV(MK_BUF const buf, MK_FST const val, ...)
top set the MkBufferC using a ... value … → API: MkBufferSetV_RT
The old value will be removed and the memory will be reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the value to set the buf to |
printf
like format string (runtime,hide) MK_BUF MkBufferSetVL(MK_BUF const buf, MK_FST const val, va_list var_list)
top set the MkBufferC using a va_list value … → API: MkBufferSetVL_RT
The old value will be removed and the memory will be reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the value to set the buf to |
[in] | var_list | a variable argument list object |
printf
like format string ((runtime)) MK_BUF MkBufferSetTT(MK_BUF const buf, MK_TT const val)
The BufferSetTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
(runtime) | MK_BUF | MkBufferSetI8(MK_BUF const buf, MK_I8 const val) | MkBufferSetI8_RT |
(runtime) | MK_BUF | MkBufferSetI16(MK_BUF const buf, MK_I16 const val) | MkBufferSetI16_RT |
(runtime) | MK_BUF | MkBufferSetI32(MK_BUF const buf, MK_I32 const val) | MkBufferSetI32_RT |
(runtime) | MK_BUF | MkBufferSetI64(MK_BUF const buf, MK_I64 const val) | MkBufferSetI64_RT |
(runtime) | MK_BUF | MkBufferSetSTR(MK_BUF const buf, MK_STRN const val) | MkBufferSetSTR_RT |
(runtime) | MK_BUF | MkBufferSetBIN(MK_BUF const buf, MkBinaryR const val) | MkBufferSetBIN_RT |
(runtime) | MK_BUF | MkBufferSetBOL(MK_BUF const buf, MK_BOL const val) | MkBufferSetBOL_RT |
(runtime) | MK_BUF | MkBufferSetFLT(MK_BUF const buf, MK_FLT const val) | MkBufferSetFLT_RT |
(runtime) | MK_BUF | MkBufferSetDBL(MK_BUF const buf, MK_DBL const val) |
Set the MkBufferC to the val …
The old value will be removed and the memory will be reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the value to set the buf to |
C-API: MkBufferC_Get_C_API - MkBufferC - various functions to get buffer-data …
(runtime) enum MkErrorE MkBufferGetBFL(MK_BUFN const buf, MK_BFL val_inout)
top function to read an MkBufferListC from an MkBufferC object … → API: MkBufferGetBFL_RT
This function read a buffer-item created with MqSendL_START and MqSendL_END into a temporary MkBufferListC.
MK_NULL
than the val_inout is populated with the result. MK_NULL
than a TLS alocated MkBufferListC is returned owned by Programming-Language-Micro-Kernel (PLMK)[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[out] | val_inout | the pointer to an MkBufferListC object or MULL at error |
MK_NULL
than this function return TLS memory.MK_NULL
for a non-error result.(runtime) enum MkErrorE MkBufferGetBUF(MK_BUF const buf, MK_BUF *const val_out)
top get a val_out from a MkBufferC … → API: MkBufferGetBUF_RT
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).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) - (nonnull) |
[in] | buf | the MkBufferS instance to work on - (nonnull) |
[out] | val_out | the value to return - (nonnull) |
(runtime) enum MkErrorE MkBufferGetStringR(MK_BUFN const buf, MkStringR *const val_out)
top get a val_out from a MkBufferC … → API: MkBufferGetStringR_RT
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).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) - (nonnull) |
[in] | buf | the MkBufferS instance to work on - (nonnull) |
[out] | val_out | the value to return - (nonnull) |
((runtime)) enum MkErrorE MkBufferGetTT(MK_BUFN const buf, MK_TT *const val_out)
The BufferGetTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
(runtime) | enum MkErrorE | MkBufferGetI8(MK_BUFN const buf, MK_I8 *const val_out) | MkBufferGetI8_RT |
(runtime) | enum MkErrorE | MkBufferGetI16(MK_BUFN const buf, MK_I16 *const val_out) | MkBufferGetI16_RT |
(runtime) | enum MkErrorE | MkBufferGetI32(MK_BUFN const buf, MK_I32 *const val_out) | MkBufferGetI32_RT |
(runtime) | enum MkErrorE | MkBufferGetI64(MK_BUFN const buf, MK_I64 *const val_out) | MkBufferGetI64_RT |
(runtime) | enum MkErrorE | MkBufferGetSTR(MK_BUFN const buf, MK_STRN *const val_out) | MkBufferGetSTR_RT |
(runtime) | enum MkErrorE | MkBufferGetBIN(MK_BUFN const buf, MkBinaryR *const val_out) | MkBufferGetBIN_RT |
(runtime) | enum MkErrorE | MkBufferGetBOL(MK_BUFN const buf, MK_BOL *const val_out) | MkBufferGetBOL_RT |
(runtime) | enum MkErrorE | MkBufferGetFLT(MK_BUFN const buf, MK_FLT *const val_out) | MkBufferGetFLT_RT |
(runtime) | enum MkErrorE | MkBufferGetDBL(MK_BUFN const buf, MK_DBL *const val_out) |
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).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) - (nonnull) |
[in] | buf | the MkBufferS instance to work on - (nonnull) |
[out] | val_out | the value to return - (nonnull) |
C-API: MkBufferC_Access_C_API - MkBufferC - various functions to access buffer-data …
(runtime) MK_BUF MkBufferAppendSTR(MK_BUF const buf, MK_STRN const val)
top append a single string to a MkBufferC object … → API: MkBufferAppendSTR_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the text to append to buf |
Example from server.c
→ read and update a MkBufferC
// START - ReadBUF - Example, read a buffer-object and append a string MK_BUF buf; MqReadBUF_E (mqctx,&buf); MkBufferAppendSTR(buf,"- a really log text to overwrite the already allocated space"); MqSendBUF_E (mqctx,buf); MqReadI32_E (mqctx,&i); MqSendI32_E (mqctx,i+1); // END - ReadBUF - Example
(runtime) MK_BUF MkBufferAppendStringR(MK_BUF const buf, MkStringR const val)
top append a single string to a MkBufferC object … → API: MkBufferAppendStringR_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | val | the text to append to buf |
Example from server.c
→ read and update a MkBufferC
// START - ReadBUF - Example, read a buffer-object and append a string MK_BUF buf; MqReadBUF_E (mqctx,&buf); MkBufferAppendSTR(buf,"- a really log text to overwrite the already allocated space"); MqSendBUF_E (mqctx,buf); MqReadI32_E (mqctx,&i); MqSendI32_E (mqctx,i+1); // END - ReadBUF - Example
(runtime,hide) MK_I32 MkBufferAppendV(MK_BUF const buf, MK_FST const printfmt, ...)
top append a single string with format and ... arguments to a MkBuffer64S … → API: MkBufferAppendV_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | printfmt | is a c-string used as printf like format string |
(runtime,hide) MK_I32 MkBufferAppendVL(MK_BUF const buf, MK_FST const printfmt, va_list var_list)
top append a single string with format and var_list arguments to a MkBuffer64S … → API: MkBufferAppendVL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
(runtime) MK_NUM MkBufferPop(MK_BUF const buf, MK_STRN const val)
top delete str from the MkBufferC … → API: MkBufferPop_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
val | the text (string) to remove from buf |
(runtime) MK_NUM MkBufferPush(MK_BUF const buf, MK_STRN const val)
top add str to the MkBufferC … → API: MkBufferPush_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
val | the text (string) to append to buf |
C-API: MkBufferC_Info_C_API - MkBufferC - various functions to get information out of buffer-data …
(runtime) MK_STRB MkBufferGetType1(MK_BUFN const buf)
top return the type from a MkBufferC as single character value … → API: MkBufferGetType1_RT
(runtime) enum MkTypeE MkBufferGetType2(MK_BUFN const buf)
top return the MkTypeE from a MkBufferC … → API: MkBufferGetType2_RT
(runtime) MK_STRN MkBufferGetType3(MK_BUFN const buf)
top return the type from a MkBufferC as single character string … → API: MkBufferGetType3_RT
(runtime) MK_BOOL MkBufferIsLocal(MK_BUFN const buf)
top Check if the MkBufferC is local (temporary), not local mean global … → API: MkBufferIsLocal_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
(runtime) void MkBufferLog(MK_BUFN const buf, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top log the MkBufferC … → API: MkBufferLog_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
(runtime) void MkBufferLogS(MK_BUFN const buf, MK_STRN const varname, MK_OBJN fmtobj, MK_STRN const callfunc)
top log the short MkBufferC object data to the MkLogFileC (default: stderr) … → API: MkBufferLogS_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | varname | The name of the argument to report |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
C-API: MkBufferC_Misc_C_API - MkBufferC - various functions to work on buffer-data …
(runtime) enum MkErrorE MkBufferCastTo(MK_BUF const buf, enum MkTypeE const typ)
top change the type of an MkBufferC to type … → API: MkBufferCastTo_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | typ | cast buf to typ |
(runtime) MK_I32 MkBufferCmp(MK_BUFN const buf1, MK_BUFN const buf2)
top compare TWO MkBufferC objects like strcmp
do it for strings … → API: MkBufferCmp_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf1 | the FIRST MkBufferC object to compare |
[in] | buf2 | the SECOND MkBufferC object to compare |
(runtime) MK_BUF MkBufferCopy(MK_BUF const buf, MK_BUFN const srce)
top copy the MkBufferC from srce to dest … → API: MkBufferCopy_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
srce | source of the copy |
(runtime) void MkBufferReset(MK_BUF const buf)
top reset a MkBufferC to the length zero … → API: MkBufferReset_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
(runtime) void MkBufferResetFull(MK_BUF const buf)
top reset a MkBufferC to the length zero and free allocated storage… → API: MkBufferResetFull_RT
In addition to (runtime) void MkBufferReset(MK_BUF const buf)
the allocated storage is freed and reset to ILS
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
(runtime) MK_BUF MkBufferSizeAdd(MK_BUF const buf, MK_NUM const size)
top add size storage to the buf … → API: MkBufferSizeAdd_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | size | The 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) |
(runtime) MK_BUF MkBufferSizeNew(MK_BUF const buf, MK_NUM const size)
top alloc min size storage to the buf … → API: MkBufferSizeNew_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | buf | the MkBufferS instance to work on |
[in] | size | The 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) |
(runtime) MK_BUF MkBufferTemp(MK_BUFN const buf)
top create a temporary copy of the MkBufferC buf … → API: MkBufferTemp_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
buf | - the source of the copy |
MK_NULL
for a non-error result.(runtime) MK_STRN MkBufferToString(MK_BUFN const inst)
top String-Slot - returns the string representation of the inst … → API: MkBufferToString_RT
The string is a human-readable form of the data stored in the object.
ToString
function by default.[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | inst | - the instance to work on |
"MK_NULL"
on error MK_NULL
for a non-error result.MkBufferStreamC CLASS | |||
Define | MkBufferStreamC - low level definition, access and cast … | ||
Export | MkBufferStreamC - Export class functions … | ||
Introspection | MkBufferStreamC - Introspection class functions … | ||
Misc | MkBufferStreamC - Misc class functions … | ||
MkBufferStreamC TOR | |||
Create | create and initialize an MkBufferStreamC instance … | ||
Create64 | call the BufferStreamCreate with default type MkBufferStream64S (64 byte) … | ||
Create256 | call the BufferStreamCreate with default type MkBufferStream256S (256 byte) … | ||
Create1024 | call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) … | ||
Create16384 | call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) … | ||
CreateLOCAL_T | Constructs a MkBufferStreamC instance as L)ocal S)torage … | ||
CreateSTATIC_T | Constructs a MkBufferStreamC instance as S)tatic S)torage … | ||
CreateTLS | same as BufferStreamCreate but require no cleanup … | ||
CreateTLS_T | Constructs a MkBufferStreamC instance as T)hread L)ocal S)torage … | ||
Delete | Destructor - delete a MkBufferStreamC instance … | ||
Dup | Dup-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 READ | |||
ReadTT | read a val_out from the MkBufferStreamC … | ||
ReadALL | get a temporary MkBufferListC from all data in the MkBufferStreamC … | ||
ReadBFL | read a MkBufferListC from the MkBufferStreamC … | ||
ReadBUF | read a val_out from the MkBufferStreamC … | ||
ReadGetNextType | get the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available | ||
ReadGetNumItems | get the number of items left in the MkBufferStreamC … | ||
ReadItemExists | check if an item exists in the read-data-package … | ||
ReadL_END | END read a list-item-type from the MkBufferStreamC … | ||
ReadL_START | START read a list-item-type from the MkBufferStreamC … | ||
ReadLONG | read the long native object from the MkBufferStreamC … | ||
ReadUndo | undo the last MkBufferStreamC READ function call … | ||
MkBufferStreamC WRITE | |||
WriteTT | write a PRIMITIVE TYPE into the MkBufferStreamC … | ||
WriteBFL | write a MkBufferListC into the MkBufferStreamC … | ||
WriteBUF | write a PRIMITIVE TYPE into the MkBufferStreamC … | ||
WriteBUS_FLAT | write a MkBufferStreamC into the MkBufferStreamC … | ||
WriteHDL | write the handle into the MkBufferStreamC … | ||
WriteL_END | END write a list-item-type into the MkBufferStreamC … | ||
WriteL_FLAT | write a MkBufferListC FLAT into the MkBufferStreamC … | ||
WriteL_START | START write a list-item-type into the MkBufferStreamC … | ||
WriteLONG | write the long native object into the MkBufferStreamC … | ||
WriteV | write format-string into the MkBufferStreamC … | ||
WriteVL | write format-string into the MkBufferStreamC … | ||
MkBufferStreamC MISC | |||
Copy | copy the MkBufferStreamC from src to bus … | ||
Log | log the MkBufferStreamC … | ||
PosToStart | set the current-access-position to the start of MkBufferStreamC … | ||
Reset | reset a MkBufferStreamC to the length zero … | ||
ResetFull | reset a MkBufferStreamC to the length zero and free allocated storage… | ||
ToBFL | convert the bus into a MkBufferListC … | ||
ToString | String-Slot - returns the string representation of the inst … |
C-API: MkBufferStreamC_C_API - MkBufferStreamC - the abstract class known as bus or stream is a subclass of MkBufferC and is 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.
In addition to the binary-array the MkBufferStreamS also include features like:
The MkBufferStreamS inherits the following features from MkBufferS:
The ABSTRACT-CLASS MkBufferStreamS is missing the ILS-storage, the FINAL-CLASSES are:
MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S
Bus | cast a unknown-object into an MkBufferStreamS pointer or NULL if not possible | ||
BusCheck | check MkBufferStreamS -> MkObjectS::signature … | ||
BusCheckO | check MkBufferStreamS -> MkObjectS::signature … | ||
BusN | (const) cast a unknown-object into an MkBufferStreamS pointer or NULL if not possible |
HandleResolve | Handle-Resolve-Slot - return a MkBufferStreamC from netHdl or MK_NULL if invalid… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkBufferStreamC useable for external storage |
MkBufferStreamC CLASS INTROSPECTION
Instances | get head-instance from linked-list of MkBufferStreamS type … | ||
Next | get next instance from linked-list of MkBufferStreamS type | ||
Prev | get previous instance from linked-list of MkBufferStreamS type |
GetNull | Null-Slot - return a MkBufferStreamC typed |
C-API: MkBufferStreamC_Class_C_API - MkBufferStreamC - define the class …
C-API: MkBufferStreamC_Class_Define_C_API - MkBufferStreamC - low level definition, access and cast …
(static,hide) MK_BUS MkBus(MK_MNG mng)
top cast a unknown-object into an MkBufferStreamS pointer or NULL if not possible → API: MkBus
(static,hide) MK_BOOL MkBusCheck(MK_MNGN mng)
top check MkBufferStreamS -> MkObjectS::signature … → API: MkBusCheck
(static,hide) MK_BOOL MkBusCheckO(MK_OBJN obj)
top check MkBufferStreamS -> MkObjectS::signature … → API: MkBusCheckO
(static,hide) MK_BUSN MkBusN(MK_MNGN mng)
top (const) cast a unknown-object into an MkBufferStreamS pointer or NULL if not possible → API: MkBusN
MkBufferStreamC - Export class functions …
(static,runtime) MK_BUS MkBufferStreamHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkBufferStreamC from netHdl or MK_NULL
if invalid… → API: MkBufferStreamHandleResolve_RT
The MkBufferStreamHandleResolve undo the MkBufferStreamHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkBufferStreamHandleGet |
MK_NULL
if netHdl is invalid (runtime) MK_HDL MkBufferStreamHandleGet(MK_BUS const bus)
top Handle-Get-Slot - returns a export-hdl to the MkBufferStreamC useable for external storage → API: MkBufferStreamHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkBufferStreamHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
MkBufferStreamC - Introspection class functions …
(static,runtime) MK_BUS MkBufferStreamInstances()
top get head-instance from linked-list of MkBufferStreamS type … → API: MkBufferStreamInstances_RT
The head-instance is the last instance created.
MK_BUS MkBufferStreamNext(MK_BUS const bus)
top get next instance from linked-list of MkBufferStreamS type → API: MkBufferStreamNext
MK_BUS MkBufferStreamPrev(MK_BUS const bus)
top get previous instance from linked-list of MkBufferStreamS type → API: MkBufferStreamPrev
MkBufferStreamC - Misc class functions …
(static) MK_BUS MkBufferStreamGetNull()
top Null-Slot - return a MkBufferStreamC typed NULL
instance … → API: MkBufferStreamGetNull
C-API: MkBufferStreamC_TOR_C_API - MkBufferStreamC - various functions to create and destroy a MkBufferStreamC …
(constructor,static,runtime) MK_BUS MkBufferStreamCreate(MK_NUM const size)
top create and initialize an MkBufferStreamC instance … → API: MkBufferStreamCreate_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | type | A type defined as MkTypeS with a TT postfix (default: MkBufferStream1024S, possible: MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S) |
[in] | size | The 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) |
(constructor,static,runtime) MK_BUS MkBufferStreamCreate64(MK_NUM const size)
top call the BufferStreamCreate with default type MkBufferStream64S (64 byte) … → API: MkBufferStreamCreate64_RT
(constructor,static,runtime) MK_BUS MkBufferStreamCreate256(MK_NUM const size)
top call the BufferStreamCreate with default type MkBufferStream256S (256 byte) … → API: MkBufferStreamCreate256_RT
(constructor,static,runtime) MK_BUS MkBufferStreamCreate1024(MK_NUM const size)
top call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) … → API: MkBufferStreamCreate1024_RT
(constructor,static,runtime) MK_BUS MkBufferStreamCreate16384(MK_NUM const size)
top call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) … → API: MkBufferStreamCreate16384_RT
(constructor,static,hide,macro) void MkBufferStreamCreateLOCAL_T(MK_MACRO_TYP cls, MK_MACRO_TYP name, MK_NUM const size)
top Constructs a MkBufferStreamC instance as L)ocal S)torage … → API: MkBufferStreamCreateLOCAL_T
[in] | cls | A subclass of MkBufferStreamS with predefined ILS storage → MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S |
name | the name of the new MkBufferStreamS instance | |
size | the minimum ILS storage to provide, if size exceed the predefined-storage from cls than heap-storage will be use. |
(constructor,static,hide,macro) void MkBufferStreamCreateSTATIC_T(MK_MACRO_TYP cls, MK_MACRO_TYP name)
top Constructs a MkBufferStreamC instance as S)tatic S)torage … → API: MkBufferStreamCreateSTATIC_T
[in] | cls | A subclass of MkBufferStreamS with predefined ILS storage → MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S |
name | the name of the new MkBufferStreamS instance |
(static,runtime) MK_BUS MkBufferStreamCreateTLS(MK_STRN const tlsName, MK_BOOL const resetB)
top same as BufferStreamCreate but require no cleanup … → API: MkBufferStreamCreateTLS_RT
Example from perfserver.c
→ performance test with TLS storage
static enum MkErrorE Ot_BUST ( MQ_SERVICE_CALL_ARGS ) { MK_BUS bus = MkBufferStreamCreateTLS_1( "perfserver-BUST" ); while (MqReadItemExists(mqctx)) { MkBufferStreamWriteBUF(bus,MqReadBUF_e(mqctx)); } MkBufferStreamPosToStart(bus); MqSendSTART_E (mqctx); while (MkBufferStreamReadItemExists(bus)) { MqSendBUF_E (mqctx, MkBufferStreamReadBUF_e (bus)); } error: return MqSendRETURN (mqctx); }
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | tlsName | An per-thread unique name (string) to identify the reuse-able instance-storage. if tlsName is MK_NULL or "" than a MK_NULL is returned |
[in] | resetB | should the new object be reset? |
(constructor,static,hide,macro) void MkBufferStreamCreateTLS_T(MK_MACRO_TYP cls, MK_MACRO_TYP name)
top Constructs a MkBufferStreamC instance as T)hread L)ocal S)torage … → API: MkBufferStreamCreateTLS_T
[in] | cls | A subclass of MkBufferStreamS with predefined ILS storage → MkBufferStream16384S, MkBufferStream256S, MkBufferStream64S and MkBufferStream1024S |
name | the name of the new MkBufferStreamS instance |
(destructor,runtime) void MkBufferStreamDelete(MK_BUS const bus)
top Destructor - delete a MkBufferStreamC instance … → API: MkBufferStreamDelete_RT
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 |
(constructor,runtime) MK_BUS MkBufferStreamDup(MK_BUSN const src)
top Dup-Constructor - create a new MkBufferStreamC instance as copy from an existing MkBufferStreamC instance … → API: MkBufferStreamDup_RT
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.
(constructor,runtime) MK_BUS MkBufferStreamMerge(MK_BUS const bus)
top Merge-Constructor - create a new MkBufferStreamC as a merge from an existing object … → API: MkBufferStreamMerge_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on - (nonnull) |
MK_NULL
on error or if no Merge-Constructor is available C-API: MkBufferStreamC_Read_C_API - MkBufferStreamC - various functions to 'read' data from a MkBufferStreamS …
Read is done at the position of MkBufferStreamS::storage->cur. After read the cur is incemented with read-sizeof characters.
(runtime) enum MkErrorE MkBufferStreamReadALL(MK_BUS const bus, MK_BFL const val_inout)
top get a temporary MkBufferListC from all data in the MkBufferStreamC … → API: MkBufferStreamReadALL_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in,out] | val_inout | the MkBufferListC - the storage of the input is reused |
MK_NULL
for a non-error result.(runtime) enum MkErrorE MkBufferStreamReadBFL(MK_BUS const bus, MK_BFL *const val_out)
top read a MkBufferListC from the MkBufferStreamC … → API: MkBufferStreamReadBFL_RT
The MkBufferListC represent a list-item-type (MK_LSTT from the MkBufferStreamC. A list-item-type is created with (runtime) enum MkErrorE MkBufferStreamWriteL_START(MK_BUS const bus)
and (runtime) enum MkErrorE MkBufferStreamWriteL_END(MK_BUS const bus)
and collect multiple items into one item, the list-item-type.
A list-item-type can have an other list-item-type as item, this create a tree-like structure of items.
If the next item in the read-data-package is not a list-item-type than an error is raised. To get all data in the read-data-package as one single MkBufferListC use the MqReadALL.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[out] | val_out | the MkBufferListC as return-value |
MK_NULL
for a non-error result.(runtime) enum MkErrorE MkBufferStreamReadBUF(MK_BUS const bus, MK_BUF *const val_out)
top read a val_out from the MkBufferStreamC … → API: MkBufferStreamReadBUF_RT
The MkBufferStreamReadTT
style of functions always return a val_out or a MkErrorC.
(runtime) void MkBufferStreamPosToStart(MK_BUS const bus)
.[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[out] | val_out | the new value |
(runtime) enum MkTypeE MkBufferStreamReadGetNextType(MK_BUSN const bus)
top get the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available → API: MkBufferStreamReadGetNextType_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
(runtime) MK_NUM MkBufferStreamReadGetNumItems(MK_BUSN const bus)
top get the number of items left in the MkBufferStreamC … → API: MkBufferStreamReadGetNumItems_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
(runtime) MK_BOOL MkBufferStreamReadItemExists(MK_BUSN const bus)
top check if an item exists in the read-data-package … → API: MkBufferStreamReadItemExists_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
MK_YES
or MK_NO
(runtime) enum MkErrorE MkBufferStreamReadL_END(MK_BUS const bus)
top END read a list-item-type from the MkBufferStreamC … → API: MkBufferStreamReadL_END_RT
(runtime) enum MkErrorE MkBufferStreamReadL_START(MK_BUS const bus, MK_BUF buf)
top START read a list-item-type from the MkBufferStreamC … → API: MkBufferStreamReadL_START_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | buf | MK_NULL or a MkBufferC with a list-item-type or an error is raised. |
(runtime) enum MkErrorE MkBufferStreamReadLONG(MK_BUS const bus, MK_LONG *const val_out)
top read the long native object from the MkBufferStreamC … → API: MkBufferStreamReadLONG_RT
on 64bit use a BufferStreamReadI32 and on 32bit use a BufferStreamReadI64
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[out] | val_out | the native long object to read |
(runtime) enum MkErrorE MkBufferStreamReadUndo(MK_BUS const bus)
top undo the last MkBufferStreamC READ function call … → API: MkBufferStreamReadUndo_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
((runtime)) enum MkErrorE MkBufferStreamReadTT(MK_BUS const bus, MK_TT *const val_out)
The BufferStreamReadTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
(runtime) | enum MkErrorE | MkBufferStreamReadI8(MK_BUS const bus, MK_I8 *const val_out) | MkBufferStreamReadI8_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadI32(MK_BUS const bus, MK_I32 *const val_out) | MkBufferStreamReadI32_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadI64(MK_BUS const bus, MK_I64 *const val_out) | MkBufferStreamReadI64_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadSTR(MK_BUS const bus, MK_STRN *const val_out) | MkBufferStreamReadSTR_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadBIN(MK_BUS const bus, MkBinaryR *const val_out) | MkBufferStreamReadBIN_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadBOL(MK_BUS const bus, MK_BOL *const val_out) | MkBufferStreamReadBOL_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadFLT(MK_BUS const bus, MK_FLT *const val_out) | MkBufferStreamReadFLT_RT |
(runtime) | enum MkErrorE | MkBufferStreamReadDBL(MK_BUS const bus, MK_DBL *const val_out) |
read a val_out from the MkBufferStreamC …
The MkBufferStreamReadTT
style of functions always return a val_out or a MkErrorC.
(runtime) void MkBufferStreamPosToStart(MK_BUS const bus)
.[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[out] | val_out | the new value |
C-API: MkBufferStreamC_Write_C_API - MkBufferStreamC - various functions to write into a MkBufferStreamS …
Write is done at the position of MkBufferStreamS::storage->cur. After write the cur is incemented with write-sizeof characters.
(runtime) enum MkErrorE MkBufferStreamWriteBFL(MK_BUS const bus, MK_BFLN const bfl)
top write a MkBufferListC into the MkBufferStreamC … → API: MkBufferStreamWriteBFL_RT
The MkBufferListC represent a list-item-type (MK_LSTT from the MkBufferStreamC. A list-item-type is created with (runtime) enum MkErrorE MkBufferStreamWriteL_START(MK_BUS const bus)
and (runtime) enum MkErrorE MkBufferStreamWriteL_END(MK_BUS const bus)
and collect multiple items into one item, the list-item-type.
A list-item-type can have an other list-item-type as item, this create a tree-like structure of items.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | bfl | the MkBufferListC to insert |
(runtime) enum MkErrorE MkBufferStreamWriteBUF(MK_BUS const bus, MK_BUFN const val)
top write a PRIMITIVE TYPE into the MkBufferStreamC … → API: MkBufferStreamWriteBUF_RT
After every write the current-access-position is incremented by one, use (runtime) void MkBufferStreamReset(MK_BUS const bus)
to reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | val | the new PRIMITIVE TYPE |
(runtime) enum MkErrorE MkBufferStreamWriteBUS_FLAT(MK_BUS const bus, MK_BUSN const add)
top write a MkBufferStreamC into the MkBufferStreamC … → API: MkBufferStreamWriteBUS_FLAT_RT
The add is appended to bus
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | add | the MkBufferStreamC to append |
(runtime) enum MkErrorE MkBufferStreamWriteHDL(MK_BUS const bus, MK_I32 const val)
top write the handle into the MkBufferStreamC … → API: MkBufferStreamWriteHDL_RT
The handle is a special type to represent an object as numeric-type able to be stored into an external-software.
The handle support the following API:
(runtime) enum MkErrorE MkBufferStreamWriteL_END(MK_BUS const bus)
top END write a list-item-type into the MkBufferStreamC … → API: MkBufferStreamWriteL_END_RT
(runtime) enum MkErrorE MkBufferStreamWriteL_FLAT(MK_BUS const bus, MK_BFL const bfl)
top write a MkBufferListC FLAT into the MkBufferStreamC … → API: MkBufferStreamWriteL_FLAT_RT
A MkBufferListC can be written into a MkBufferStreamC using:
command | description | example |
---|---|---|
BufferStreamWriteBFL | 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 .
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | bfl | the MkBufferListC to insert |
(runtime) enum MkErrorE MkBufferStreamWriteL_START(MK_BUS const bus)
top START write a list-item-type into the MkBufferStreamC … → API: MkBufferStreamWriteL_START_RT
(runtime) enum MkErrorE MkBufferStreamWriteLONG(MK_BUS const bus, MK_LONG const val)
top write the long native object into the MkBufferStreamC … → API: MkBufferStreamWriteLONG_RT
on 64bit use a MkBufferStreamWriteI64 and on 32bit use a MkBufferStreamWriteI32
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | val | the native long object to write |
(runtime,hide) enum MkErrorE MkBufferStreamWriteV(MK_BUS const bus, MK_STRN const fmt, ...)
top write format-string into the MkBufferStreamC … → API: MkBufferStreamWriteV_RT
(runtime,hide) enum MkErrorE MkBufferStreamWriteVL(MK_BUS const bus, MK_STRN const fmt, va_list ap)
top write format-string into the MkBufferStreamC … → API: MkBufferStreamWriteVL_RT
((runtime)) enum MkErrorE MkBufferStreamWriteTT(MK_BUS const bus, MK_TT const val)
The BufferStreamWriteTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
(runtime) | enum MkErrorE | MkBufferStreamWriteI8(MK_BUS const bus, MK_I8 const val) | MkBufferStreamWriteI8_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteI32(MK_BUS const bus, MK_I32 const val) | MkBufferStreamWriteI32_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteI64(MK_BUS const bus, MK_I64 const val) | MkBufferStreamWriteI64_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteSTR(MK_BUS const bus, MK_STRN const val, MK_NUM const len) | MkBufferStreamWriteSTR_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteBIN(MK_BUS const bus, MkBinaryR const val) | MkBufferStreamWriteBIN_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteBOL(MK_BUS const bus, MK_BOL const val) | MkBufferStreamWriteBOL_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteFLT(MK_BUS const bus, MK_FLT const val) | MkBufferStreamWriteFLT_RT |
(runtime) | enum MkErrorE | MkBufferStreamWriteDBL(MK_BUS const bus, MK_DBL const val) |
write a PRIMITIVE TYPE into the MkBufferStreamC …
After every write the current-access-position is incremented by one, use (runtime) void MkBufferStreamReset(MK_BUS const bus)
to reset.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | val | the new PRIMITIVE TYPE |
C-API: MkBufferStreamC_Misc_C_API - MkBufferStreamC - various functions to create and destroy a MkBufferStreamS …
(runtime) MK_BUS MkBufferStreamCopy(MK_BUS const bus, MK_BUSN const src)
top copy the MkBufferStreamC from src to bus … → API: MkBufferStreamCopy_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
src | source of the copy |
(runtime) void MkBufferStreamLog(MK_BUS const bus, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top log the MkBufferStreamC … → API: MkBufferStreamLog_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
(runtime) void MkBufferStreamPosToStart(MK_BUS const bus)
top set the current-access-position to the start of MkBufferStreamC … → API: MkBufferStreamPosToStart_RT
(runtime) void MkBufferStreamReset(MK_BUS const bus)
top reset a MkBufferStreamC to the length zero … → API: MkBufferStreamReset_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
(runtime) void MkBufferStreamResetFull(MK_BUS const bus)
top reset a MkBufferStreamC to the length zero and free allocated storage… → API: MkBufferStreamResetFull_RT
In addition to (runtime) void MkBufferStreamReset(MK_BUS const bus)
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
(runtime) MK_BFL MkBufferStreamToBFL(MK_BUSN const bus)
top convert the bus into a MkBufferListC … → API: MkBufferStreamToBFL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bus | the MkBufferStreamS instance to work on |
MK_NULL
for a non-error result.(runtime) MK_STRN MkBufferStreamToString(MK_BUSN const inst)
top String-Slot - returns the string representation of the inst … → API: MkBufferStreamToString_RT
The string is a human-readable form of the data stored in the object.
ToString
function by default.[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | inst | - the instance to work on |
"MK_NULL"
on error MK_NULL
for a non-error result.MkBufferListC CLASS | |||
Define | MkBufferListC - low level definition, access and cast … | ||
Export | MkBufferListC - Export class functions … | ||
Introspection | MkBufferListC - Introspection class functions … | ||
Misc | MkBufferListC - Misc class functions … | ||
MkBufferListC TOR | |||
Create | Constructs a MkBufferC instance with size storage… | ||
CreateLA | Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON C) | ||
CreateLOCAL_T | create a MkBufferListC instance on local-memory and return an pointer as instance … | ||
CreateSTATIC_T | create a MkBufferListC instance on static-storage … | ||
CreateTLS | same as BufferListCreate but require no cleanup … | ||
CreateTLS_inout_T | create a MkBufferListC instance as thread-local-torage OR reuse inout if possible… | ||
CreateTLS_T | create a MkBufferListC instance as thread-local-torage … | ||
CreateVA | Constructs a MkBufferListC instance with a varargs argument that ends with MK_NULL … | ||
CreateVAL | Constructs a MkBufferListC instance with a va_list argument … | ||
CreateVC | Constructs a MkBufferListC instance with a argc/argv data from a list of strings … | ||
Delete | Destructor - delete a MkBufferListC instance … | ||
Dup | Dup-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 APPEND | |||
AppendTT | append a native PRIMITIVE TYPE object to a MkBufferListC … | ||
AppendBUF | append a native PRIMITIVE TYPE object to a MkBufferListC … | ||
AppendG | append a native PRIMITIVE TYPE object to a MkBufferListC … | ||
AppendLA | append a variable number of MkBufferC object's to an MkBufferListC object using an other MkBufferListC OR a list of arguments (only in NON C) | ||
AppendLP | copy a MkBufferListS list into an MkBufferListS object on position … | ||
AppendStringR | append a native PRIMITIVE TYPE object to a MkBufferListC … | ||
AppendUP | append a MkBufferC item into an MkBufferListC object on position … | ||
AppendV | append an printf like format object to the end of an MkBufferListS object … | ||
AppendVA | append a variable number of strings to an MkBufferListS object … | ||
AppendVAL | append a variable number of strings to an MkBufferListS object … | ||
AppendVC | append a argc/argv list of strings to an MkBufferListS object … | ||
AppendVL | append an printf like format object to the end of an MkBufferListS object … | ||
MkBufferListC CHECK | |||
CheckOptionTT | search for opt in MkBufferListS list and fill var with opt_argument or the defval value … | ||
CheckOption | search for boolean option in MkBufferListS list and return MK_BOL value … | ||
CheckOptionBUF | search for opt in MkBufferListS list and fill var with opt_argument or the defval value … | ||
MkBufferListC INDEX | |||
IndexDelete | delete the index'th list item from the MkBufferListS object … | ||
IndexGet | get (read only) the index object from bfl … | ||
IndexGetBUF | get the index element from MkBufferListC ... if not available… create it. … | ||
IndexGetSTR | get the index element from MkBufferListC ... as string. … | ||
IndexSet | set the index object from bfl … | ||
IndexSetBUF | set the index element from MkBufferListC ... if not available… createspace … | ||
IndexSetSTR | set the index element from MkBufferListC ... to string… if not available… create space … | ||
IndexExtract | extract (read & delete) the index object from bfl … | ||
MkBufferListC LOG | |||
Log | write the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) … | ||
LogS | write the short-summary of the MkBufferListC to MkLogFileC (default: stderr) … | ||
LogSS | write 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 | |||
FileGlob | create a new MkBufferListC using the result from a filesystem glob operation … | ||
Move | move all internal data from from to the end of to … | ||
Copy | copy all internal data from src to tgt … | ||
PositionMerge | merge a MkBufferListS list into an MkBufferListS object on position … | ||
Cmp | compare two buffer-list … | ||
Reserve | reserve num items in a MkBufferListC object … | ||
Reset | reset a MkBufferListC object … | ||
SearchC | search MK_STR item from a MkBufferListS object starting at startindex … | ||
Size | get the number-of-items in the bfl … | ||
Sort | sort a MkBufferListC … | ||
ToBuffer | Export a bfl into an MkBufferC using an MkBufferStreamC … |
C-API: MkBufferListC_C_API - MkBufferListC - the class 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.
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.
command | alias |
---|---|
(constructor,static,runtime) MK_BFL MkBufferListCreate(MK_NUM const size) | no |
(destructor,runtime) void MkBufferListDelete(MK_BFL bfl) | no |
Bfl | cast a unknown-object into an MkBufferListS pointer or NULL if not possible | ||
BflCheck | check MkBufferListS -> MkObjectS::signature … | ||
BflCheckO | check MkBufferListS -> MkObjectS::signature … | ||
BflN | (const) cast a unknown-object into an MkBufferListS pointer or NULL if not possible |
HandleResolve | Handle-Resolve-Slot - return a MkBufferListC from netHdl or MK_NULL if invalid… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkBufferListC useable for external storage |
MkBufferListC CLASS INTROSPECTION
Instances | get head-instance from linked-list of MkBufferListS type … | ||
Next | get next instance from linked-list of MkBufferListS type | ||
Prev | get previous instance from linked-list of MkBufferListS type |
GetNull | Null-Slot - return a MkBufferListC typed |
C-API: MkBufferListC_Class_C_API - MkBufferListC - define the class …
C-API: MkBufferListC_Class_Define_C_API - MkBufferListC - low level definition, access and cast …
(static,hide) MK_BFL MkBfl(MK_MNG mng)
top cast a unknown-object into an MkBufferListS pointer or NULL if not possible → API: MkBfl
(static,hide) MK_BOOL MkBflCheck(MK_MNGN mng)
top check MkBufferListS -> MkObjectS::signature … → API: MkBflCheck
(static,hide) MK_BOOL MkBflCheckO(MK_OBJN obj)
top check MkBufferListS -> MkObjectS::signature … → API: MkBflCheckO
(static,hide) MK_BFLN MkBflN(MK_MNGN mng)
top (const) cast a unknown-object into an MkBufferListS pointer or NULL if not possible → API: MkBflN
MkBufferListC - Export class functions …
(static,runtime) MK_BFL MkBufferListHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkBufferListC from netHdl or MK_NULL
if invalid… → API: MkBufferListHandleResolve_RT
The MkBufferListHandleResolve undo the MkBufferListHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkBufferListHandleGet |
MK_NULL
if netHdl is invalid (runtime) MK_HDL MkBufferListHandleGet(MK_BFL const bfl)
top Handle-Get-Slot - returns a export-hdl to the MkBufferListC useable for external storage → API: MkBufferListHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkBufferListHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
MkBufferListC - Introspection class functions …
(static,runtime) MK_BFL MkBufferListInstances()
top get head-instance from linked-list of MkBufferListS type … → API: MkBufferListInstances_RT
The head-instance is the last instance created.
MK_BFL MkBufferListNext(MK_BFL const bfl)
top get next instance from linked-list of MkBufferListS type → API: MkBufferListNext
MK_BFL MkBufferListPrev(MK_BFL const bfl)
top get previous instance from linked-list of MkBufferListS type → API: MkBufferListPrev
MkBufferListC - Misc class functions …
(static) MK_BFL MkBufferListGetNull()
top Null-Slot - return a MkBufferListC typed NULL
instance … → API: MkBufferListGetNull
C-API: MkBufferListC_TOR_C_API - MkBufferListC - various functions to create and destroy a MkBufferListS …
(constructor,static,runtime) MK_BFL MkBufferListCreate(MK_NUM const size)
top Constructs a MkBufferC instance with size storage… → API: MkBufferListCreate_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | size | The 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) |
(constructor,static,runtime) MK_BFL MkBufferListCreateLA(MK_BAC const args)
top Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON C) → API: MkBufferListCreateLA_RT
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.
(constructor,static,hide,macro) void MkBufferListCreateLOCAL_T(MK_MACRO_TYP name, MK_NUM const num)
top create a MkBufferListC instance on local-memory and return an pointer as instance … → API: MkBufferListCreateLOCAL_T
name | is the instance-pointer and nameR is the instance-reference. |
num | is the minimal-size of the initial buffer-list, size will be inflated if necessary. |
(constructor,static,hide,macro) void MkBufferListCreateSTATIC_T(MK_MACRO_TYP name, MK_NUM const num)
top create a MkBufferListC instance on static-storage … → API: MkBufferListCreateSTATIC_T
name | is the instance-pointer and nameR is the instance-reference. |
num | is the minimal-size of the initial buffer-list, size will be inflated if necessary. |
(static,runtime) MK_BFL MkBufferListCreateTLS(MK_STRN const tlsName, MK_BOOL const resetB)
top same as BufferListCreate but require no cleanup … → API: MkBufferListCreateTLS_RT
Example from perfserver.c
→ performance test with TLS storage
Example from LibSq3LiteRpcClient.tcl
→ callback dealing the temporary TLS data
# Intro : Example from tcl-rpc-client of using a CreateTLS-like function (here for MkBufferListC) # to improve code speed and readability. # # Problem : This function is used to invoke a callback (myCb). The arguments come from the argument # list args *and* from a service call (ReadBFL). # The problem is that ReadBFL is called *twice* and the *second* call overwrites the value # of the *first* call because CreateTLS always returns *the same* MkBufferListC, just # replaced with a new set of values. # # Solution : The MkBufferListC instance returned by ReadBFL is copied into another MkBufferListC # instance returned by CreateTLS. # The "CreateTLS" instance is only created *once* and reused, *but* now we can create as # many MkBufferListC instances as we want, because "CreateTLS" distinguishes the returned # instances by the string identifier. # WITHOUT "CreateTLS" a copy would have to be created (Dup) which would then be destroyed # *after* the callback is called (Delete) proc Sq3LiteRpcClientExecV2CB {rpc myCb args} { set valL [MkBufferListC CreateTLS "Sq3LiteRpcClientExecV2CB→valL"] set colL [MkBufferListC CreateTLS "Sq3LiteRpcClientExecV2CB→colL"] $valL Copy [$rpc ReadBFL] $colL Copy [$rpc ReadBFL] $myCb {*}$args $valL $colL }
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | tlsName | An per-thread unique name (string) to identify the reuse-able instance-storage. if tlsName is MK_NULL or "" than a MK_NULL is returned |
[in] | resetB | should the new object be reset? |
(constructor,static,hide,macro) void MkBufferListCreateTLS_inout_T(MK_MACRO_TYP name, MK_NUM const num, MK_BFL inout)
top create a MkBufferListC instance as thread-local-torage OR reuse inout if possible… → API: MkBufferListCreateTLS_inout_T
The inout is an external-storage or MK_NULL
- the external storage will be reused or if MK_NULL
the internal thread-local-storage is used.
name | is the instance-pointer and nameR is the instance-reference. |
num | is the minimal-size of the initial buffer-list, size will be inflated if necessary. |
inout | is the preferred-storage, if MK_NULL the thread-local-storage is used. |
(constructor,static,hide,macro) void MkBufferListCreateTLS_T(MK_MACRO_TYP name, MK_NUM const num)
top create a MkBufferListC instance as thread-local-torage … → API: MkBufferListCreateTLS_T
name | is the instance-pointer and nameR is the instance-reference. |
num | is the minimal-size of the initial buffer-list, size will be inflated if necessary. |
(constructor,static,runtime,hide) MK_BFL MkBufferListCreateVA(MK_STRN const arg0, ...)
top Constructs a MkBufferListC instance with a varargs argument that ends with MK_NULL
… → API: MkBufferListCreateVA_RT
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.
(constructor,static,runtime,hide) MK_BFL MkBufferListCreateVAL(MK_STRN const arg0, va_list var_list)
top Constructs a MkBufferListC instance with a va_list argument … → API: MkBufferListCreateVAL_RT
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.
(constructor,static,runtime,hide) MK_BFL MkBufferListCreateVC(MK_I32 argv_num, MK_STRN *argv)
top Constructs a MkBufferListC instance with a argc/argv data from a list of strings … → API: MkBufferListCreateVC_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
argc | the argc from the initial main function | |
argv | the arguments from the initial main function |
argc = 0
(destructor,runtime) void MkBufferListDelete(MK_BFL bfl)
top Destructor - delete a MkBufferListC instance … → API: MkBufferListDelete_RT
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 |
(constructor,runtime) MK_BFL MkBufferListDup(MK_BFLN const bfl)
top Dup-Constructor - create a new MkBufferListC instance as copy from an existing MkBufferListC instance … → API: MkBufferListDup_RT
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.
(constructor,runtime) MK_BFL MkBufferListMerge(MK_BFL const bfl)
top Merge-Constructor - constructs a MkBufferListC instance as a merge from an existing MkBufferListC instance … → API: MkBufferListMerge_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
MK_NULL
on error or if no Merge-Constructor is available C-API: MkBufferListC_Append_C_API - MkBufferListC - various functions to 'append' to a MkBufferListS …
(runtime) void MkBufferListAppendBUF(MK_BFL const bfl, MK_BUF const val)
top append a native PRIMITIVE TYPE object to a MkBufferListC … → API: MkBufferListAppendBUF_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | val | the PRIMITIVE TYPE object data to append |
(runtime) void MkBufferListAppendG(MK_BFL const bfl, MK_LONG const val)
top append a native PRIMITIVE TYPE object to a MkBufferListC … → API: MkBufferListAppendG_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | val | the PRIMITIVE TYPE object data to append |
(runtime) MK_BFL MkBufferListAppendLA(MK_BFL const bfl, MK_BAC const args)
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 C) → API: MkBufferListAppendLA_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | args | the MkBufferListC object |
(runtime) MK_BFL MkBufferListAppendLP(MK_BFL const bfl, MK_BFL const addBufL, MK_NUM position)
top copy a MkBufferListS list into an MkBufferListS object on position … → API: MkBufferListAppendLP_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | addBufL | the MkBufferListS object to append |
[in] | position | insert in at position, shift all following arguments one up |
(runtime) void MkBufferListAppendStringR(MK_BFL const bfl, MkStringR const val)
top append a native PRIMITIVE TYPE object to a MkBufferListC … → API: MkBufferListAppendStringR_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | val | the PRIMITIVE TYPE object data to append |
(runtime) void MkBufferListAppendUP(MK_BFL const bfl, MK_BUF const addBuf, MK_NUM position)
top append a MkBufferC item into an MkBufferListC object on position … → API: MkBufferListAppendUP_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | addBuf | the MkBufferC object to append |
[in] | position | insert in at position, shift all following arguments one up |
(runtime,hide) void MkBufferListAppendV(MK_BFL const bfl, MK_FST const printfmt, ...)
top append an printf like format object to the end of an MkBufferListS object … → API: MkBufferListAppendV_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | printfmt | is a c-string used as printf like format string |
(runtime,hide) MK_BFL MkBufferListAppendVA(MK_BFL const bfl, MK_STRN arg0, ...)
top append a variable number of strings to an MkBufferListS object … → API: MkBufferListAppendVA_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | arg0 | anchor element for ... |
MK_NULL
item on end to signal… end-of-list. (runtime,hide) MK_BFL MkBufferListAppendVAL(MK_BFL const bfl, MK_STRN arg0, va_list var_list)
top append a variable number of strings to an MkBufferListS object … → API: MkBufferListAppendVAL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | arg0 | anchor element for ... |
[in] | var_list | a variable argument list object |
MK_NULL
item on end to signal… end-of-list. (runtime,hide) MK_BFL MkBufferListAppendVC(MK_BFL const bfl, MK_I32 argv_num, MK_STRN *argv)
top append a argc/argv list of strings to an MkBufferListS object … → API: MkBufferListAppendVC_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | argc | the number of arguments in argv, if <0 than check for MK_NULL in argv |
[in] | argv | the array of strings to append |
(runtime,hide) void MkBufferListAppendVL(MK_BFL const bfl, MK_FST const printfmt, va_list var_list)
top append an printf like format object to the end of an MkBufferListS object … → API: MkBufferListAppendVL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
((runtime)) void MkBufferListAppendTT(MK_BFL const bfl, MK_TT const val)
The BufferListAppendTT provide a single function for every PRIMITIVE TYPE
append a native PRIMITIVE TYPE object to a MkBufferListC …
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | val | the PRIMITIVE TYPE object data to append |
C-API: MkBufferListC_Check_C_API - MkBufferListC - various functions to 'check' a MkBufferListS …
This functions are used for parsing command-line-arguments.
(runtime) MK_BOOL MkBufferListCheckOption(MK_BFL const bfl, MK_STRN const opt, MK_BOOL const onlyFirst)
top search for boolean option in MkBufferListS list and return MK_BOL value … → API: MkBufferListCheckOption_RT
-
or a --
the opt is treated as true +
or a ++
the opt is treated as false -
or a +
than the opt is treated as true [in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on or MK_NULL |
[in] | opt | Find opt string in the MkBufferListC |
[in] | onlyFirst | Stop after first item was found |
(runtime) enum MkErrorE MkBufferListCheckOptionBUF(MK_BFL const bfl, MK_STRN const opt, MK_BUF const defval, MK_BOOL const onlyFirst, MK_BUF *const val_out)
top search for opt in MkBufferListS list and fill var with opt_argument or the defval value … → API: MkBufferListCheckOptionBUF_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on or MK_NULL |
[in] | opt | Find opt string in the MkBufferListC |
[in] | defval | The value used if opt was not found |
[in] | onlyFirst | If more than one opt is available, return only the first (true [DEFAULT]) or the last (false) |
[out] | val_out | If opt is found, return the argument from opt otherwise defval |
MK_NULL
an error is returned. MK_NULL
than an empty MkBufferC is returned. MK_NULL
for a non-error result.((runtime)) enum MkErrorE MkBufferListCheckOptionTT(MK_BFL const bfl, MK_STRN const opt, MK_TT const defval, MK_BOOL const onlyFirst, MK_TT *const val_out)
The BufferListCheckOptionTT provide a single function for every PRIMITIVE TYPE
search for opt in MkBufferListS list and fill var with opt_argument or the defval value …
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on or MK_NULL |
[in] | opt | Find opt string in the MkBufferListC |
[in] | defval | The value used if opt was not found |
[in] | onlyFirst | If more than one opt is available, return only the first (true [DEFAULT]) or the last (false) |
[out] | val_out | If opt is found, return the argument from opt otherwise defval |
MK_NULL
an error is returned. C-API: MkBufferListC_Index_C_API - MkBufferListC - various functions to access a MkBufferListS by index …
(runtime) enum MkErrorE MkBufferListIndexDelete(MK_BFL const bfl, MK_NUM const index, MK_NUM const numitems, MK_BOOL const doDelete)
top delete the index'th list item from the MkBufferListS object … → API: MkBufferListIndexDelete_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
numitems | delete number of items | |
doDelete | if doDelete == true delete the MkBufferC object, associated with the index, too |
(runtime) enum MkErrorE MkBufferListIndexGet(MK_BFLN const bfl, MK_NUM const index, MK_BUF *const val_out)
top get (read only) the index object from bfl … → API: MkBufferListIndexGet_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
[out] | val_out | the MkBufferC to return |
MK_NULL
first.(runtime) MK_BUF MkBufferListIndexGetBUF(MK_BFL const bfl, MK_NUM index)
top get the index element from MkBufferListC ... if not available… create it. … → API: MkBufferListIndexGetBUF_RT
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 |
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
(runtime) MK_STRN MkBufferListIndexGetSTR(MK_BFL const bfl, MK_NUM const index)
top get the index element from MkBufferListC ... as string. … → API: MkBufferListIndexGetSTR_RT
for details please refer to BufferListIndexGetBUF.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
(runtime) enum MkErrorE MkBufferListIndexSet(MK_BFL const bfl, MK_NUM const index, MK_BUF const buf)
top set the index object from bfl … → API: MkBufferListIndexSet_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
[in] | buf | the MkBufferS instance to work on |
(runtime) void MkBufferListIndexSetBUF(MK_BFL const bfl, MK_NUM const index, MK_BUF const buf)
top set the index element from MkBufferListC ... if not available… createspace … → API: MkBufferListIndexSetBUF_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
[in] | buf | the MkBufferS instance to work on |
(runtime) void MkBufferListIndexSetSTR(MK_BFL const bfl, MK_NUM const index, MK_STRN const str)
top set the index element from MkBufferListC ... to string… if not available… create space … → API: MkBufferListIndexSetSTR_RT
for details please refer to BufferListIndexGetBUF
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
[in] | str | the string to set |
(runtime) enum MkErrorE MkBufferListIndexExtract(MK_BFL const bfl, MK_NUM const index, MK_BUF *const val_out)
top extract (read & delete) the index object from bfl … → API: MkBufferListIndexExtract_RT
If the index is not available, this is an error
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | index | an integer index to access an object in an array by position, start=0, end=-1 |
[out] | val_out | the MkBuffer64S object to return |
MK_NULL
first.C-API: MkBufferListC_Log_C_API - MkBufferListC - various functions to 'log' a MkBufferListS …
(runtime) void MkBufferListLog(MK_BFLN bfl, MK_OBJN const fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top write the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLog_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
(runtime) void MkBufferListLogS(MK_BFLN const bfl, MK_STRN const varname, MK_OBJN fmtobj, MK_STRN const callfunc)
top write the short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLogS_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
varname | prefix to identify the variable name | |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
(runtime) void MkBufferListLogSS(MK_BFLN const bfl, MK_STRN const varname, MK_OBJN fmtobj, MK_STRN const callfunc)
top write the very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLogSS_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
varname | prefix to identify the variable name | |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
(runtime) void MkBufferListLogSSS(MK_BFLN const bfl, MK_STRN const varname, MK_OBJN fmtobj, MK_STRN const callfunc)
top write the very-very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: MkBufferListLogSSS_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | varname | The name of the argument to report |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
C-API: MkBufferListC_Misc_C_API - MkBufferListC - various functions to work on a MkBufferListS …
(constructor,static,runtime) MK_BFL MkBufferListFileGlob(MK_STRN const pattern_match)
top create a new MkBufferListC using the result from a filesystem glob operation … → API: MkBufferListFileGlob_RT
(runtime) void MkBufferListMove(MK_BFL const to, MK_BFL const from)
top move all internal data from from to the end of to … → API: MkBufferListMove_RT
after the move… the from is empty and only the shell exists
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | to | the target of the move |
[in] | from | the source of the move |
(runtime) void MkBufferListCopy(MK_BFL const bfl, MK_BFLN const src)
top copy all internal data from src to tgt … → API: MkBufferListCopy_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | src | the source of the copy |
(runtime) MK_BFL MkBufferListPositionMerge(MK_BFL const bfl, MK_BFL const source, MK_NUM position)
top merge a MkBufferListS list into an MkBufferListS object on position … → API: MkBufferListPositionMerge_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | source | the object to be merged into bfl, afterwords the source is empty and can be deleted |
[in] | position | insert 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 |
(runtime) MK_I32 MkBufferListCmp(MK_BFLN const bfl, MK_BFLN const bfl2)
top compare two buffer-list … → API: MkBufferListCmp_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
[in] | bfl2 | buffer-list to compare |
(runtime) void MkBufferListReserve(MK_BFL const bfl, MK_NUM const num)
top reserve num items in a MkBufferListC object … → API: MkBufferListReserve_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
bfl | the MkBufferListC object to reserve memory | |
num | reserve the number of items for later use. |
(runtime) MK_BFL MkBufferListReset(MK_BFL bfl)
top reset a MkBufferListC object … → API: MkBufferListReset_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
(runtime) MK_NUM MkBufferListSearchC(MK_BFLN const bfl, MK_STRN const str, MK_NUM const len, MK_NUM const startindex)
top search MK_STR item from a MkBufferListS object starting at startindex … → API: MkBufferListSearchC_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
str | the string to search for | |
len | the length of str or -1 to calulate the length with strlen | |
startindex | start searching in buf from index startindex |
a typical usage for this code is parsing an MkBufferListS object for multiple occurrences of a string
(runtime) MK_NUM MkBufferListSize(MK_BFLN const bfl)
top get the number-of-items in the bfl … → API: MkBufferListSize_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
(runtime) MK_BFL MkBufferListSort(MK_BFL const bfl)
top sort a MkBufferListC … → API: MkBufferListSort_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
(runtime) MK_BUF MkBufferListToBuffer(MK_BFLN const bfl)
top Export a bfl into an MkBufferC using an MkBufferStreamC … → API: MkBufferListToBuffer_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | bfl | the MkBufferListS instance to work on |
MK_NULL
on errorMK_NULL
for a non-error result.MkErrorC CLASS | |||
Define | MkErrorC - low level definition, access and cast … | ||
Export | MkErrorC - Export class functions … | ||
Introspection | MkErrorC - Introspection class functions … | ||
Misc | MkErrorC - Misc class functions … | ||
MkErrorC TOR | |||
Delete | Destructor - delete a MkErrorS object … | ||
Dup | Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance … | ||
MkErrorC GET | |||
GetCode | get the value of MkErrorS::code … | ||
GetNum | get the MkErrorS::num. The number can be used as exit-code … | ||
GetSize | get the error-message-size from the exception-object … | ||
GetText | get the MkErrorS::text … | ||
MkErrorC RAISE | |||
PanicC | do a panic with string as argument … | ||
PanicV | do a panic with a vararg as argument … | ||
PanicVL | do a panic with a vararg-list as argument … | ||
AppendC | append the message to the MkErrorS::text … | ||
AppendV | append a vararg string to the MkErrorC … | ||
AppendVL | append a va_list string to the MkErrorC … | ||
NoRaise | ignore the next return of MK_ERROR and do not raise an target-language-exception … | ||
Raise | convert an libmkkernel error into an programming-language-error and raise afterwards. … | ||
SetC | 'set' and 'raise' the MkErrorC using a string-message and a errnum-number … | ||
SetE | set the MkErrorC from a MkErrorC copy and raise an error … | ||
SetV | set the MkErrorS object using a format string argument list and raise an error … | ||
SetVL | 'set' and 'raise' the MkErrorC using a vararg-list message … | ||
MkErrorC SIGNAL | |||
IsABORT | check on ABORT signal … | ||
IsEXIT | check on APPLICATION-EXIT error … | ||
IsSOCKET | check on SOCKET-DOWN error … | ||
IsTIMEOUT | check on TIMEOUT error … | ||
SetABORT | send the ABORT signal to the calling stack… | ||
SetCode | set the MkErrorS::code value … | ||
SetCONTINUE | signal end of processing in an MqIEvent callback … | ||
SetEXIT | finish the current callback, return to toplevel and MqExit the application … | ||
SetSOCKET | create SOCKET-DOWN error … | ||
MkErrorC SYSTEM | |||
DEFAULT | default-system-error - default-error … | ||
FORMAT | system-error-format - format and return the default-error … | ||
IGNORE | ignore-system-error - ignore the next error … | ||
PANIC | panic-system-error - panic on next error … | ||
ignore-system-error - print the next error into MkLogFileC … | |||
MkErrorC MISC | |||
Catch | convert a programming-language-error into an libmkkernel error … | ||
Log | log the error to MkLogFileC (default: stderr) … | ||
Println | print the default-error to the MkLogFileC (default: stderr) and clear the error afterwards … | ||
Reset | This function clears the err and resets to MK_OK … | ||
Stack | check 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 … |
C-API: MkErrorC_C_API - MkErrorC - the class 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 libmkkernel into the error-handling-code of the target C.
Example from Filter6.c
→ use MqContextErrorCatch to convert a C error into a libmkkernel error
int main ( const int argc, MK_STRN argv[] ) { MqRtSetup_NULL; // define the new type Filter6TT = MkTypeDup2(MqContextC_TT,"Filter6"); Filter6TT->objsize = sizeof(struct FilterCtxS); Filter6T->fHelp = FilterHelp; // create the factory MQ_FCT mqfct = MqFactoryAdd(MK_ERROR_PANIC, Filter6Factory, NULL,NULL,NULL,NULL,NULL,NULL,NULL,"Filter6"); MQ_CTX mqctx = NULL; #ifdef BUG1 // for BUG testing in 'trans2-2-T1aE-...' MqFactoryInitial(mqfct); #endif // parse the command-line MK_BFL args = MkBufferListCreateVC (argc, argv); // search for option "--retryCnt" MkBufferListCheckOptionI32_E (args, "--retryCnt", 3, true, &retryCnt); // create the filter MqFactoryNew_E (mqfct, NULL, &mqctx); // create the link MqLinkCreate_E (mqctx, args); // start event-loop and wait forever MqProcessEvent_E (mqctx, MQ_WAIT_FOREVER, MK_TIMEOUT_USER); // finish and exit error: MkBufferListDelete(args); MqExit_1 (mqctx); }
MkExceptionC - The default-exception of the Programming-Language-Micro-Kernel (PLMK) …
The Programming-Language-Micro-Kernel (PLMK) 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 (TPL) add their own error-handling and the purpose of MkExceptionC is to integrate the MkErrorC into the Target-Programming-Language (TPL).
The default-exception MkExceptionC is used to connect the MkErrorC with the Target-Programming-Language (TPL) error-object.
The implementation of an exception depends heavily on the Target-Programming-Language (TPL), starting with no exception at all, for example. C
, an exception as a class object, or as an exception as a global attribute.
Checks if Exception is of type MkExceptionC and returns MK_YES
or MK_NO
…
Example: test case to check KILL and RECOVER feature, check on MkExceptionC
MK_BUF VAL = MqReadBUF_e(mqctx); clmqctx = MqContextCreate (ClientTT, NULL); MqConfigSetPrefix(clmqctx,"cl"); MqConfigSetPostfix(clmqctx,"-1"); MkErrorCheck (ClientCreateParent2( MK_RT_CALL mqctx, clmqctx)); MK_I32 PID=0; MqSend_E(clmqctx, "W", "GPID@I", &PID); MkSysKill_E(MkOBJ(mqctx),PID,9); MK_I32 RET=0; for (int i=1; i<=3; i++) { if (MkErrorCheckI(MqSend(clmqctx, "W", "ECOI:U@I", VAL, &RET))) { if (MkErrorIsSOCKET_0E()) { MkErrorReset_1X(clmqctx); MqLinkConnect(clmqctx); continue; } else { goto error; } } break; } MqSendSTART_E(mqctx); MqSendI32_E (mqctx, RET);
MK_YES
or MK_NO
[in] | exception | the exception object from C, if MK_NULL the global exception object is used |
Err | cast a unknown-object into an MkErrorS pointer or NULL if not possible | ||
ErrCheck | check MkErrorS -> MkObjectS::signature … | ||
ErrCheckO | check MkErrorS -> MkObjectS::signature … | ||
ErrN | (const) cast a unknown-object into an MkErrorS pointer or NULL if not possible |
HandleResolve | Handle-Resolve-Slot - return a MkErrorC from netHdl or MK_NULL if invalid… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkErrorC useable for external storage |
Instances | get head-instance from linked-list of MkErrorS type … | ||
Next | get next instance from linked-list of MkErrorS type | ||
Prev | get previous instance from linked-list of MkErrorS type |
GetNull | Null-Slot - return a MkErrorC typed |
C-API: MkErrorC_Class_C_API - MkErrorC - define the class …
C-API: MkErrorC_Class_Define_C_API - MkErrorC - low level definition, access and cast …
(static,hide) MK_ERR MkErr(MK_MNG mng)
top cast a unknown-object into an MkErrorS pointer or NULL if not possible → API: MkErr
(static,hide) MK_BOOL MkErrCheck(MK_MNGN mng)
top check MkErrorS -> MkObjectS::signature … → API: MkErrCheck
(static,hide) MK_BOOL MkErrCheckO(MK_OBJN obj)
top check MkErrorS -> MkObjectS::signature … → API: MkErrCheckO
(static,hide) MK_ERRN MkErrN(MK_MNGN mng)
top (const) cast a unknown-object into an MkErrorS pointer or NULL if not possible → API: MkErrN
MkErrorC - Export class functions …
(static,runtime) MK_ERR MkErrorHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkErrorC from netHdl or MK_NULL
if invalid… → API: MkErrorHandleResolve_RT
The MkErrorHandleResolve undo the MkErrorHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkErrorHandleGet |
MK_NULL
if netHdl is invalid (runtime) MK_HDL MkErrorHandleGet(MK_ERR const err)
top Handle-Get-Slot - returns a export-hdl to the MkErrorC useable for external storage → API: MkErrorHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkErrorHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
MkErrorC - Introspection class functions …
(static,runtime) MK_ERR MkErrorInstances()
top get head-instance from linked-list of MkErrorS type … → API: MkErrorInstances_RT
The head-instance is the last instance created.
MK_ERR MkErrorNext(MK_ERR const err)
top get next instance from linked-list of MkErrorS type → API: MkErrorNext
MK_ERR MkErrorPrev(MK_ERR const err)
top get previous instance from linked-list of MkErrorS type → API: MkErrorPrev
MkErrorC - Misc class functions …
(static) MK_ERR MkErrorGetNull()
top Null-Slot - return a MkErrorC typed NULL
instance … → API: MkErrorGetNull
C-API: MkErrorC_TOR_C_API - MkErrorC - various functions to 'create' and 'delete' a MkErrorS …
(destructor,runtime) void MkErrorDelete(MK_ERR err)
top Destructor - delete a MkErrorS object … → API: MkErrorDelete_RT
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 |
(constructor,runtime) MK_ERR MkErrorDup(MK_ERRN const srce)
top Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance … → API: MkErrorDup_RT
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.
C-API: MkErrorC_Get_C_API - MkErrorC - various functions to 'get' data out of a MkErrorS …
enum MkErrorE MkErrorGetCode(MK_ERRN const err)
top get the value of MkErrorS::code … → API: MkErrorGetCode
MK_I32 MkErrorGetNum(MK_ERRN const err)
top get the MkErrorS::num. The number can be used as exit-code … → API: MkErrorGetNum
MK_SIZE MkErrorGetSize(MK_ERRN const err)
top get the error-message-size from the exception-object … → API: MkErrorGetSize
MK_STRN MkErrorGetText(MK_ERRN const err)
top get the MkErrorS::text … → API: MkErrorGetText
C-API: MkErrorC_Raise_C_API - MkErrorC - various functions to 'raise' a MkErrorS …
An error is "raised" by naming the MkErrorS::text and changing the MkErrorS::code to MK_ERROR.
(static,runtime) void MkPanicC(MK_OBJN const errobj, MK_STRN const callfunc, MK_I32 const errnum, MK_STRN const message)
top do a panic with string as argument … → API: MkPanicC_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errobj | a managed object used to identify and format the error-message |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | errnum | the error number used as exit-code as well |
message | the string to be displayed |
(static,runtime,hide) void MkPanicV(MK_OBJN const errobj, MK_STRN const callfunc, MK_I32 const errnum, MK_FST const printfmt, ...)
top do a panic with a vararg as argument … → API: MkPanicV_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errobj | a managed object used to identify and format the error-message |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | errnum | the error number used as exit-code as well |
[in] | printfmt | is a c-string used as printf like format string |
(static,runtime,hide) void MkPanicVL(MK_OBJN const errobj, MK_STRN const callfunc, MK_I32 const errnum, MK_FST const printfmt, va_list var_list)
top do a panic with a vararg-list as argument … → API: MkPanicVL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errobj | a managed object used to identify and format the error-message |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | errnum | the error number used as exit-code as well |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
(runtime) void MkErrorAppendC(MK_ERR const err, MK_STRN const message)
top append the message to the MkErrorS::text … → API: MkErrorAppendC_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | message | the string to be displayed as message (append) |
(runtime,hide) void MkErrorAppendV(MK_ERR const err, MK_FST const printfmt, ...)
top append a vararg string to the MkErrorC … → API: MkErrorAppendV_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | printfmt | is a c-string used as printf like format string |
(runtime,hide) void MkErrorAppendVL(MK_ERR const err, MK_FST const printfmt, va_list var_list)
top append a va_list string to the MkErrorC … → API: MkErrorAppendVL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
(runtime) MK_ERR MkErrorNoRaise(MK_ERR const err)
top ignore the next return of MK_ERROR and do not raise an target-language-exception … → API: MkErrorNoRaise_RT
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:
Example from server.c
→ create and send an background-error message
static enum MkErrorE BgError ( MQ_SERVICE_CALL_ARGS ) { MQ_CTX master = MqSlaveGetMaster(mqctx); if (master) { MK_ERR err = MkErrorNoRaise(MkErrorFORMAT_1M(master)); // MkErrorGetTextI and MkErrorSetC using the !! SAME !! memory // → need a temporary buffer "ctxbuf.buf" MkBufferSetSTR(MkBUF(&master->ctxbuf), MkErrorGetText(err)); MkErrorSetC(err, MkBUF_R(&master->ctxbuf).storage.first.C, "BGERROR", MkErrorGetNum(err)); MqSendERROR (master); } return MkErrorStack_1M_Check(mqctx); }
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
(runtime) enum MkErrorE MkErrorRaise(MK_ERRN const err)
top convert an libmkkernel error into an programming-language-error and raise afterwards. … → API: MkErrorRaise_RT
If ther is no libmkkernel-error (MkErrorS::code "= #MK_ERROR) than nothing happen. @param [in] err the \ref MkErrorS "MkErrorS" instance to work on - the \e default-error is automatically created on startup. (NULL allowed) \sa \ref doc_mk_c_ErrorCatch "ErrorCatch" \ref doc_mk_c_ErrorReset "ErrorReset"
(runtime) enum MkErrorE MkErrorSetC(MK_ERR err, MK_STRN const message, MK_STRN const callfunc, MK_I32 const errnum)
top 'set' and 'raise' the MkErrorC using a string-message and a errnum-number … → API: MkErrorSetC_RT
The message will be formatted into a libmkkernel error-message.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) - err==NULL allowed |
[in] | message | the string to be displayed as message |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | errnum | the error number used as exit-code as well |
(runtime,hide) enum MkErrorE MkErrorSetE(MK_ERR const err, MK_ERR const newerr)
top set the MkErrorC from a MkErrorC copy and raise an error … → API: MkErrorSetE_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | newerr | the MkErrorC to be the new default-error |
(runtime,hide) enum MkErrorE MkErrorSetV(MK_ERR err, MK_STRN const callfunc, MK_I32 const errnum, MK_FST const printfmt, ...)
top set the MkErrorS object using a format string argument list and raise an error … → API: MkErrorSetV_RT
The string argument list will be formatted into a libmkkernel error-message.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | errnum | the error number used as exit-code as well |
[in] | printfmt | is a c-string used as printf like format string |
(runtime,hide) enum MkErrorE MkErrorSetVL(MK_ERR err, MK_STRN const callfunc, MK_I32 const errnum, MK_FST const printfmt, va_list var_list)
top 'set' and 'raise' the MkErrorC using a vararg-list message … → API: MkErrorSetVL_RT
The var_list will be formatted into a libmkkernel error-message.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | errnum | the error number used as exit-code as well |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
C-API: MkErrorC_Signal_C_API - MkErrorC - various functions to set and check a 'signal' on a MkErrorS …
MK_BOOL MkErrorIsABORT(MK_ERRN const err)
top check on ABORT signal … → API: MkErrorIsABORT
MK_BOOL MkErrorIsEXIT(MK_ERR const err)
top check on APPLICATION-EXIT error … → API: MkErrorIsEXIT
The exit-error-object is made for two resons:
The link-target-abnormal-exit can only occur for functions that perform a network-request, such as:
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.
example/c/Filter4.c
exampleExample "C"
: catch and ignore an EXIT return-code
MK_BOOL MkErrorIsSOCKET(MK_ERRN const err)
top check on SOCKET-DOWN error … → API: MkErrorIsSOCKET
MK_BOOL MkErrorIsTIMEOUT(MK_ERRN const err)
top check on TIMEOUT error … → API: MkErrorIsTIMEOUT
(runtime) enum MkErrorE MkErrorSetABORT(MK_ERR const err, MK_STRN const detail, MK_STRN const callfunc)
top send the ABORT signal to the calling stack… → API: MkErrorSetABORT_RT
The ABORT-signal is used to disrupt the current execution like an error and unwind the calling stack. The MkErrorIsABORT is used to detect the ABORT-signal and MkErrorReset is used to clear the ABORT-signal
(runtime) void MkErrorSetCode(MK_ERR const err, enum MkErrorE code)
top set the MkErrorS::code value … → API: MkErrorSetCode_RT
(runtime) void MkErrorSetCONTINUE(MK_ERR const err)
top signal end of processing in an MqIEvent callback … → API: MkErrorSetCONTINUE_RT
(runtime) enum MkErrorE MkErrorSetEXIT(MK_ERR const err, MK_STRN const callfunc)
top finish the current callback, return to toplevel and MqExit the application … → API: MkErrorSetEXIT_RT
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:
(runtime) enum MkErrorE MkErrorSetSOCKET(MK_ERR const err, MK_STRN const detail, MK_STRN const callfunc)
top create SOCKET-DOWN error … → API: MkErrorSetSOCKET_RT
C-API: MkErrorC_System_C_API - MkErrorC - various functions to raise a 'System' messagen on MkErrorS …
(static,runtime) MK_ERR MkErrorDEFAULT()
top default-system-error - default-error … → API: MkErrorDEFAULT_RT
The default-error is defined once per runtime and is used as only-valid-source of an MkErrorC in a thread or process.
(static) MK_ERR MkErrorFORMAT(MK_OBJN const fmtobj)
top system-error-format - format and return the default-error … → API: MkErrorFORMAT
Set the MkErrorS::format_of_error attribute to fmtobj or MK_NULL
. The next error-message 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
.
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
(static,runtime) MK_ERR MkErrorIGNORE()
top ignore-system-error - ignore the next error … → API: MkErrorIGNORE_RT
The next error will be ignored, no formatting will be performed and the the default-error will not be modified.
There are two functions to suppress an error: MkErrorIGNORE and MkErrorNoRaise.
(static,runtime,hide) MK_ERR MkErrorPANIC()
top panic-system-error - panic on next error … → API: MkErrorPANIC_RT
If the panic-system-error is used as the format-obj of an error-message, the text is formated as usual, but the default-error is not set, instead a MkPanicVL is called and the application terminates.
Set the MkErrorS::format_of_error attribute to PANIC. The next error-message will be formated as usual and than be reported using MkPanicVL. With MkPanicVL the error will be printed to MkLogFileC (default: stderr) and the application will abort.
(static,runtime) MK_ERR MkErrorPRINT()
top ignore-system-error - print the next error into MkLogFileC … → API: MkErrorPRINT_RT
The next error-message will be formated as usual and than be reported using MkLogVL. The default-error will not be modified.
Set the MkErrorS::format_of_error attribute to PRINT.
C-API: MkErrorC_Misc_C_API - MkErrorC - various functions to 'work' on a MkErrorS …
(runtime) MK_ERR MkErrorCatch(MK_ERR const err, MK_EXP const exception, MK_STRN const callfunc)
top convert a programming-language-error into an libmkkernel error … → API: MkErrorCatch_RT
Same as MkObjectErrorCatch but skip the Error-Prefix in final Target-Programming-Language (TPL).
Example from Bug3.c
→ catch an error using (runtime) MK_ERR MkErrorCatch(MK_ERR const err, MK_EXP const exception, MK_STRN const callfunc)
// "C" does not support the "Catch" function because there is ONLY the "LibMqMsgque" error and nothing else.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | exception | the exception object from C, if MK_NULL the global exception object is used |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
(runtime) void MkErrorLog(MK_ERRN const err, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top log the error to MkLogFileC (default: stderr) … → API: MkErrorLog_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
(runtime) void MkErrorLog(MK_ERRN const err, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
(runtime) void MkErrorPrintln(MK_ERR const err)
top print the default-error to the MkLogFileC (default: stderr) and clear the error afterwards … → API: MkErrorPrintln_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
(runtime) enum MkErrorE MkErrorReset(MK_ERR const err, MK_STRN const callfunc, MK_I32 const callline, MK_BOOL const force)
top This function clears the err and resets to MK_OK … → API: MkErrorReset_RT
It is recommended that you use this feature only after the error has been processed.
(runtime) enum MkErrorE MkErrorStack(MK_ERR const err, MK_STRN const callfunc, MK_STRN const callfile, MK_I32 const callline)
top check on error and if yes append an ErrorStackFormat to the error-message … → API: MkErrorStack_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) → MK_NULL allowed |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | callfile | the name of the file the call take place (e.g. FILE) |
[in] | callline | the number of the line the call take place (e.g. LINE) |
(runtime) void MkErrorStackFormat(MK_ERR const err, MK_STRN callfunc, MK_STRN callfile, MK_I32 const callline)
top append an ensemble of func, file and line to the error-message … → API: MkErrorStackFormat_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | err | the MkErrorS instance to work on - the default-error is automatically created on startup. (NULL allowed) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | callfile | the name of the file the call take place (e.g. FILE) |
[in] | callline | the number of the line the call take place (e.g. LINE) |
MkLogFileC CLASS | |||
Define | MkLogFileC - low level definition, access and cast … | ||
Export | MkLogFileC - Export class functions … | ||
Introspection | MkLogFileC - Introspection class functions … | ||
Misc | MkLogFileC - Misc class functions … | ||
MkLogFileC TOR | |||
Open | open the log-file in append mode … | ||
Close | Destructor - delete a MkLogFileC instance … | ||
MkLogFileC WRITE | |||
GetFile | get the log-file … | ||
WriteC | write to log-file … | ||
WriteV | write to log-file … | ||
WriteVL | write to log-file … |
C-API: MkLogFileC_C_API - MkLogFileC - the class 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) |
Lfl | cast a unknown-object into an MkLogFileS pointer or NULL if not possible | ||
LflCheck | check MkLogFileS -> MkObjectS::signature … | ||
LflCheckO | check MkLogFileS -> MkObjectS::signature … | ||
LflN | (const) cast a unknown-object into an MkLogFileS pointer or NULL if not possible |
HandleResolve | Handle-Resolve-Slot - return a MkLogFileC from netHdl or MK_NULL if invalid… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkLogFileC useable for external storage |
MkLogFileC CLASS INTROSPECTION
Instances | get head-instance from linked-list of MkLogFileS type … | ||
Next | get next instance from linked-list of MkLogFileS type | ||
Prev | get previous instance from linked-list of MkLogFileS type |
GetNull | Null-Slot - return a MkLogFileC typed |
C-API: MkLogFileC_Class_C_API - MkLogFileC - define the class …
C-API: MkLogFileC_Class_Define_C_API - MkLogFileC - low level definition, access and cast …
(static,hide) MK_LFL MkLfl(MK_MNG mng)
top cast a unknown-object into an MkLogFileS pointer or NULL if not possible → API: MkLfl
(static,hide) MK_BOOL MkLflCheck(MK_MNGN mng)
top check MkLogFileS -> MkObjectS::signature … → API: MkLflCheck
(static,hide) MK_BOOL MkLflCheckO(MK_OBJN obj)
top check MkLogFileS -> MkObjectS::signature … → API: MkLflCheckO
(static,hide) MK_LFLN MkLflN(MK_MNGN mng)
top (const) cast a unknown-object into an MkLogFileS pointer or NULL if not possible → API: MkLflN
MkLogFileC - Export class functions …
(static,runtime) MK_LFL MkLogFileHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkLogFileC from netHdl or MK_NULL
if invalid… → API: MkLogFileHandleResolve_RT
The MkLogFileHandleResolve undo the MkLogFileHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkLogFileHandleGet |
MK_NULL
if netHdl is invalid (runtime) MK_HDL MkLogFileHandleGet(MK_LFL const lfl)
top Handle-Get-Slot - returns a export-hdl to the MkLogFileC useable for external storage → API: MkLogFileHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkLogFileHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | lfl | the MkLogFileS instance to work on |
MkLogFileC - Introspection class functions …
(static,runtime) MK_LFL MkLogFileInstances()
top get head-instance from linked-list of MkLogFileS type … → API: MkLogFileInstances_RT
The head-instance is the last instance created.
MK_LFL MkLogFileNext(MK_LFL const lfl)
top get next instance from linked-list of MkLogFileS type → API: MkLogFileNext
MK_LFL MkLogFilePrev(MK_LFL const lfl)
top get previous instance from linked-list of MkLogFileS type → API: MkLogFilePrev
MkLogFileC - Misc class functions …
(static) MK_LFL MkLogFileGetNull()
top Null-Slot - return a MkLogFileC typed NULL
instance … → API: MkLogFileGetNull
C-API: MkLogFileC_TOR_C_API - MkLogFileC - various functions to 'create and delete' a MkLogFileS …
(constructor,static,runtime) enum MkErrorE MkLogFileOpen(MK_OBJ errobj, MK_STRN const file, MK_LFL *lfh_out)
top open the log-file in append mode … → API: MkLogFileOpen_RT
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.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errobj | a managed object used to identify and format the error-message |
[in] | file | the filename to open |
[out] | lfh_out | returns |
MK_NULL
(destructor,runtime) void MkLogFileClose(MK_LFL lfh)
top Destructor - delete a MkLogFileC instance … → API: MkLogFileClose_RT
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 |
C-API: MkLogFileC_Write_C_API - MkLogFileC - various functions to 'write' into a MkLogFileS …
(runtime) enum MkErrorE MkLogFileGetFile(MK_LFLN lfl, MK_STRN *file_out)
top get the log-file … → API: MkLogFileGetFile_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | lfl | the MkLogFileS instance to work on |
[out] | file_out | the log-file to return |
(runtime) enum MkErrorE MkLogFileWriteC(MK_LFLN lfl, MK_STRN text)
top write to log-file … → API: MkLogFileWriteC_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | lfl | the MkLogFileS instance to work on |
[in] | text | the text to write |
(runtime,hide) enum MkErrorE MkLogFileWriteV(MK_LFLN lfl, MK_FST printfmt, ...)
top write to log-file … → API: MkLogFileWriteV_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | lfl | the MkLogFileS instance to work on |
[in] | printfmt | is a c-string used as printf like format string |
(runtime,hide) enum MkErrorE MkLogFileWriteVL(MK_LFLN lfl, MK_FST printfmt, va_list var_list)
top write to log-file … → API: MkLogFileWriteVL_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | lfl | the MkLogFileS instance to work on |
[in] | printfmt | is a c-string used as printf like format string |
[in] | var_list | a variable argument list object |
MkRuntimeC CLASS | |||
Define | MkRuntimeC - low level definition, access and cast … | ||
Export | MkRuntimeC - Export class functions … | ||
Introspection | MkRuntimeC - Introspection class functions … | ||
Misc | MkRuntimeC - Misc class functions … | ||
MkRuntimeC CONFIG | |||
GetDebug | get the MkRuntimeS::debug value … | ||
GetIsSilent | get the MkRuntimeS::isSilent value … | ||
GetLogfile | get the MkRuntimeS::logfile value … | ||
SetCID | CID == context-in-duty. | ||
SetDebug | set the MkRuntimeS::debug value … | ||
SetIsSilent | set the MkRuntimeS::isSilent value … | ||
SetLogfile | set the MkRuntimeS::logfile value and cleanup old value … | ||
MkRuntimeC INFO | |||
Log | log the MkRuntimeC … |
C-API: MkRuntimeC_C_API - MkRuntimeC - The class known as mkrt or runtime is the main libmkkernel 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 of the thread has a link to the runtime it was created in:
MkOBJ_R(instance)
.objRt = MkObjectS::objRt--enable-thread
configure option of Nhi1Config
The goal of the runtime-interface is to provide the best performance for thread and non-thread.
configure --enable-threads ...
. configure --disable-threads ...
. MK_RT_*
, MkRt*
or MkRT*
macros. MkThreadLocal struct MkRuntimeS MkRuntimeRLS = {0};
. (&MkRuntimeRLS)
__thread
with thread-support and otherwise to empty
. MkRtSetup_xxx
call after the thread-creation.Always use the
MK_RT_xxx
andMkRtSetup_xxx
macros to get best performane to access the MkRuntimeRLS. Summary: Internal access to the MkRuntimeRLS
threaded storage resolve access MkRtSetup_xxx
speed yes thread-local-storage run-time cache via mkrt fast enough but slower than non-thread no application-global-storage compile-time direct via MkRT fast
The local-cache is only required for a threaded-environment and is defined internal as mkrt variable initialized with a pointer to the MkRuntimeRLS.
do NOT use the mkrt direct because your code will NOT compile in a non-thread environment.
In a runtime-aware function the local-cache is always as first argument in the function.
In a non-runtime-aware method the local-cache is created using the instance-argument:
In a non-runtime-aware static-function the local-cache is created using TLS direct:
In a non-runtime-aware static-function with instance-argument the local-cache is created using instArg:
Summary: In a non-runtime-aware function use the instance to setup the cache-access otherwise MkRtSetup_NULL:
source | local-cache is created with | example | speed |
---|---|---|---|
instance | MkRtSetup_O , MkRtSetup_X | MkRtSetup_X(instance) | fast |
runtime | MkRtSetup_NULL | MkRtSetup_NULL | slow in non-static |
access as | macro | threaded | nothreaded | example | speed |
---|---|---|---|---|---|
reference | MK_RT_REF | (*mkrt) | MkRuntimeRLS | MK_RT_REF.debug | fast if static |
pointer | MK_RT_PTR | mkrt | (&MkRuntimeRLS) | MK_RT_PTR->debug | slow |
args | function definition | function parser extension | function call |
---|---|---|---|
multiple args | MK_RT_ARGS | MK_RT_PARSER | MK_RT_CALL |
no args | MK_RT_ARGS_ONLY | MK_RT_PARSER_ONLY | MK_RT_CALL_ONLY |
MK_RT_ARGS
... and MK_RT_CALL
... and the first argument is no comma.libmkkernel
is mk
,Mk,MK libmqmsgque
is mq
,Mq,MQ liblcconfig
is lc
,Lc,LC libsq3lite
is sq3
,Sq3,SQ3 Rt | cast a unknown-object into an MkRuntimeS pointer or NULL if not possible | ||
RtCheck | check MkRuntimeS -> MkObjectS::signature … | ||
RtCheckO | check MkRuntimeS -> MkObjectS::signature … | ||
RtN | (const) cast a unknown-object into an MkRuntimeS pointer or NULL if not possible |
HandleResolve | Handle-Resolve-Slot - return a MkRuntimeC from netHdl or MK_NULL if invalid… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkRuntimeC useable for external storage |
MkRuntimeC CLASS INTROSPECTION
Instances | get head-instance from linked-list of MkRuntimeS type … | ||
Next | get next instance from linked-list of MkRuntimeS type | ||
Prev | get previous instance from linked-list of MkRuntimeS type |
GetNull | Null-Slot - return a MkRuntimeC typed |
C-API: MkRuntimeC_Class_C_API - MkRuntimeC - define the class …
C-API: MkRuntimeC_Class_Define_C_API - MkRuntimeC - low level definition, access and cast …
(static,hide) MK_RT MkRt(MK_MNG mng)
top cast a unknown-object into an MkRuntimeS pointer or NULL if not possible → API: MkRt
(static,hide) MK_BOOL MkRtCheck(MK_MNGN mng)
top check MkRuntimeS -> MkObjectS::signature … → API: MkRtCheck
(static,hide) MK_BOOL MkRtCheckO(MK_OBJN obj)
top check MkRuntimeS -> MkObjectS::signature … → API: MkRtCheckO
(static,hide) MK_RTN MkRtN(MK_MNGN mng)
top (const) cast a unknown-object into an MkRuntimeS pointer or NULL if not possible → API: MkRtN
MkRuntimeC - Export class functions …
(static,runtime) MK_RT MkRuntimeHandleResolve(MK_HDL const netHdl)
top Handle-Resolve-Slot - return a MkRuntimeC from netHdl or MK_NULL
if invalid… → API: MkRuntimeHandleResolve_RT
The MkRuntimeHandleResolve undo the MkRuntimeHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | netHdl | handle former exported with MkRuntimeHandleGet |
MK_NULL
if netHdl is invalid (runtime) MK_HDL MkRuntimeHandleGet(MK_RT const rt)
top Handle-Get-Slot - returns a export-hdl to the MkRuntimeC useable for external storage → API: MkRuntimeHandleGet_RT
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkRuntimeHandleResolve.
The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.
example: The export-hdl is used in rpc to identify an object across the network.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | rt | the MkRuntimeS instance to work on - the mk-runtime argument, used by MK_RT_CALL (C-only) |
MkRuntimeC - Introspection class functions …
(static,runtime) MK_RT MkRuntimeInstances()
top get head-instance from linked-list of MkRuntimeS type … → API: MkRuntimeInstances_RT
The head-instance is the last instance created.
MK_RT MkRuntimeNext(MK_RT const rt)
top get next instance from linked-list of MkRuntimeS type → API: MkRuntimeNext
MK_RT MkRuntimePrev(MK_RT const rt)
top get previous instance from linked-list of MkRuntimeS type → API: MkRuntimePrev
MkRuntimeC - Misc class functions …
(static) MK_RT MkRuntimeGetNull()
top Null-Slot - return a MkRuntimeC typed NULL
instance … → API: MkRuntimeGetNull
C-API: MkRuntimeC_Config_C_API - MkRuntimeC - various functions to configure the MkRuntimeRLS (only C) …
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) MK_I32 MkRuntimeGetDebug()
top get the MkRuntimeS::debug value … → API: MkRuntimeGetDebug
(static) MK_BOOL MkRuntimeGetIsSilent()
top get the MkRuntimeS::isSilent value … → API: MkRuntimeGetIsSilent
(static) MK_STRN MkRuntimeGetLogfile()
top get the MkRuntimeS::logfile value … → API: MkRuntimeGetLogfile
(static,hide) void MkRuntimeSetCID(MK_OBJ const cid)
top CID == context-in-duty. → API: MkRuntimeSetCID
(static) void MkRuntimeSetDebug(MK_I32 dbg)
top set the MkRuntimeS::debug value … → API: MkRuntimeSetDebug
(static) void MkRuntimeSetIsSilent(MK_BOOL silent)
top set the MkRuntimeS::isSilent value … → API: MkRuntimeSetIsSilent
(static,runtime) enum MkErrorE MkRuntimeSetLogfile(MK_STRN logfile)
top set the MkRuntimeS::logfile value and cleanup old value … → API: MkRuntimeSetLogfile_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | logfile | filename, "stdout" or "stderr", default = "stderr" for MK_NULL or "" |
C-API: MkRuntimeC_Info_C_API - MkRuntimeC - various functions to print information about the rt …
(runtime) void MkRuntimeLog(MK_RTN const rt, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
top log the MkRuntimeC … → API: MkRuntimeLog_RT
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | rt | The runtime to log, (default=MK_NULL → use the doc_mk_c_runtime-default) |
[in] | fmtobj | managed object used to format the log-message (default=MK_NULL → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
No special binary-object is used. All binary-data is available as C MK_BINN.
Example from server.c
→ read a buffer-object and convert single-char-type-identifer to string.
static enum MkErrorE Ot_BUF2 ( MQ_SERVICE_CALL_ARGS ) { MK_BUF buf; int i; char str[2] = {'\0', '\0'}; MqSendSTART_E (mqctx); for (i=0; i<3; i++) { MqReadBUF_E (mqctx, &buf); str[0] = MkBufferGetType1(buf); MqSendSTR_E (mqctx, str); MqSendBUF_E (mqctx, buf); } return MqSendRETURN(mqctx); error: return MkErrorStack_1X(mqctx); }
libmkkernel, ccmkkernel, csmkkernel, javamkkernel, gomkkernel, pymkkernel, rbmkkernel, tclmkkernel, perlmkkernel, phpmkkernel
C, unix, socket, message, msgque