A library that adds an object layer with language bindings to the C language.
The tclmkkernel package is the implementation of the Programming-Language-Micro-Kernel (PLMK) into the target-language Tcl.
package require tclmkkernel
The tclmkkernel package is a composition of multiple classes defining the Programming-Language-Micro-Kernel (PLMK) :
object | description |
---|---|
tclmkkernel | the namespace with all tclmkkernel specific definitions |
tclmkkernel Attribute | the interface to access the package specific attribute |
tclmkkernel::MkClassC Attribute | the interface to access the class specific attribute |
$Instance Attribute | the interface to access the instance specific attribute |
To access all features without tclmkkernel prefix use:
namespace import tclmkkernel::*
libtclmkkernel.so
libtclmkkernel.la
To access the tclmkkernel package the environment variable TCLLIBPATH
have to include the directory.
TCLLIBPATH If set, then it must contain a valid Tcl list giving directories to search during auto-load operations. Directories must be specified in Tcl format, using “/” as the path separator, regardless of platform. This variable is only used when initializing the auto_path variable.
::pkg::create is a utility procedure that is part of the standard Tcl library. It is used to create an appropriate `package ifneeded` command for a given package specification. It can be used to construct a `pkgIndex.tcl` file for use with the package mechanism.
pkgIndex.tcl
file is simplepackage ifneeded NAME 9.0 [list load [file join $dir libNAME.so]]
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 the Target-Programming-Language (TPL).
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 tclmkkernel package is loaded with:
package require tclmkkernel
and is a composition of one or more class-item.
The tclmkkernel 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 tclmkkernel application environment … |
The tclmkkernel 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 …
tclmkkernel is also called as Programming-Language-Micro-Kernel (PLMK). tclmkkernel is like a programming-language without syntax but using the Target-Programming-Language (in our case Tcl) 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 tclmkkernel 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 tclmkkernel-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 | bool | 1 byte boolean value using true or false |
I8 | Y | int8 | 1 byte signed character |
I16 | S | int16 | 2 byte signed short |
I32 | I | int32 | 4 byte signed integer |
I64 | W | int64 | 8 byte signed long long integer |
FLT | F | float | 4 byte float |
DBL | D | double | 8 byte double |
BIN | B | binary | unsigned char array used for binary data |
STR | C | string | string data using a \0 at the end |
The following composee identifier's are available:
TT | T | native | comment |
---|---|---|---|
BUF | U | MkBufferC | buffer-item that can hold any single typed item from above |
BFL | L | MkBufferListC | buffer-list that can hold many buffer-item from above |
Every native-data-type is encapsualted into a MkBufferC. A MkBufferC is type safe, this mean that every read to a MkBufferC have to match the data-type of the previous write. One exception is available, the cast from and to the 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 (binary) |
STR | C | MK_STR | MK_STRN | string pointer data-type with UTF8 ecoding (string) |
C-API: MkKernel_Storage_C_API - MkKernel PACKAGE - Storage Management …
Storage management is used in tclmkkernel to provide temporary storage. It is a common design pattern that tclmkkernel 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 tclmkkernel 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 Tcl 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.tcl
→ ReadBFL overwrite previous ReadBFL
method Ot_BFL2 {} { set tmp1 [my ReadBFL] ; # "tmp1" is now a reference to the FLS storage of "ReadBFL" set tmp2 [my ReadBFL] ; # ERROR: the "tmp2" is using a SHARED reference with "tmp1" my Send "R" "LL" $tmp1 $tmp2 ; # ERROR: "$tmp1" and "$tmp2" are the SAME values }
Example from server.tcl
→ ReadBFL overwrite previous ReadBFL even in an Event-Loop
method pBFL3 {} { set tmp2 [my ReadBFL] ; # ERROR: the "tmp2" is using a SHARED reference with "tmp1" } method Ot_BFL3 {} { set tmp1 [my ReadBFL] ; # "tmp1" is now a reference to the FLS storage of "ReadBFL" my Send "C" pBFL3 {ECOL:[III]} 4 5 6 ; # ATTENTION: callback "pBFL3" using "ReadBFL" my ProcessEvent MQ_WAIT_OWN ; # ERROR: enter event-loop, callback "pBFL3" is called my Send "R" "L" $tmp1 ; # ERROR: "$tmp1" has now the value from "$tmp2" }
Example from server.tcl
→ convert ReadBFL result into global storage using Dup and free later
method Ot_BFL4 {} { set tmp1 [my ReadBFL] ; # "tmp1" is now a reference to the FLS storage of "ReadBFL" set glb1 [$tmp1 Dup] ; # OK: "glb1" is now a UNSHARED reference to the global memory set tmp2 [my ReadBFL] ; # "tmp2" is now a reference to the FLS storage of "ReadBFL" my Send "R" "LL" $glb1 $tmp2 ; # OK: "glb1" (alias tmp1) and "tmp2" are separate references $glb1 Delete ; # without "garbage-collection" the global memory must be released }
*CreateTLS
style of functionsIn 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 string tlsid 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.tcl
→ performance test with TLS storage in a local (controlled) context
method Ot_BUST {} { set bus [MkBufferStreamC CreateTLS "perfserver-BUST" ] while {[my ReadItemExists]} { $bus WriteBUF [my ReadBUF] } $bus PosToStart my SendSTART while {[$bus ReadItemExists]} { my SendBUF [$bus ReadBUF] } my SendRETURN }
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 tclmkkernel … | ||
MkKernel ENUM | |||
enum MkTypeE | basic data-types supported by Programming-Language-Micro-Kernel (PLMK) … | ||
enum MkTimeoutE | Predefined Timeout values … | ||
enum MkIdSE | signal type of the MkIdS data val … | ||
enum MkErrorE | collection for the different error-codes … |
C-API: MkKernel_C_API - MkKernel PACKAGE - The package is the toplevel structure of the Programming-Language-Micro-Kernel (PLMK) …
The tclmkkernel package is loaded with:
package require tclmkkernel
and is a composition of one or more class-item.
The tclmkkernel 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 tclmkkernel application environment … |
The tclmkkernel 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 tclmkkernel internal memory … | ||
Setup | setup tclmkkernel internal memory … |
C-API: MkKernel_Setup_libmkkernel_C_API - MkKernel PACKAGE - Setup und Cleanup the tclmkkernel …
Initializing a tclmkkernel library depends on the Target-Programming-Language (TPL) and the specific nature of the Programming-Language-Micro-Kernel (PLMK).
In general it is required to call a Setup style funtion as FIRST command because of:
If more than one META library is called only the toplevel Setup is required:
A new tclmkkernel 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 tclmkkernel library startup functions
In the Programming-Language-Micro-Kernel (PLMK), a type is defined for each thread, which means that the new tclmkkernel library must be known when the thread starts. This is not a problem as long as the external tclmkkernel library is linked to the application. However, if dlopen
is used to load the tclmkkernel library, the current restriction is that the new data type from the tclmkkernel 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) MkKernel Cleanup
top cleanup tclmkkernel internal memory … → API: tclmkkernel_MkKernel_Cleanup
MkCleanup will only be recognized once and will be ignored if not called in the same thread as MkSetup. After a call to MkSetup the call to MkCleanup is possible again.
The public MkCleanup is just a placeholder, the internal MkCleanup is always called even if the public MkCleanup is not called.
- Attention
- during cleanup objects will be deleted too -> the language interpreter have to be active
(static) MkKernel Setup
top setup tclmkkernel internal memory … → API: tclmkkernel_MkKernel_Setup
MkSetup will only be recognized once, additional call's will be ignored until a MkCleanup is called.
A call to the public MkSetup is required if
dlopen
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: tclmkkernel_Get_MkErrorE_FromObj
This is the default-error-indicator and the return-value from near all Programming-Language-Micro-Kernel (PLMK) functions.
(static) MkErrorE [MkKernel ErrorE_FromInt value:int32]
top return the MkErrorE from integer … → API: tclmkkernel_MkKernel_ErrorE_FromInt
(static) int32 [MkKernel ErrorE_ToInt value:MkErrorE]
top return the MkErrorE as integer … → API: tclmkkernel_MkKernel_ErrorE_ToInt
(static) string [MkKernel ErrorE_ToString value:MkErrorE]
top return the MkErrorE as string … → API: tclmkkernel_MkKernel_ErrorE_ToString
top signal type of the MkIdS data val … → API: tclmkkernel_Get_MkIdSE_FromObj
(static) MkIdSE [MkKernel IdSE_FromInt value:int32]
top return the MkIdSE from integer … → API: tclmkkernel_MkKernel_IdSE_FromInt
(static) int32 [MkKernel IdSE_ToInt value:MkIdSE]
top return the MkIdSE as integer … → API: tclmkkernel_MkKernel_IdSE_ToInt
(static) string [MkKernel IdSE_ToString value:MkIdSE]
top return the MkIdSE as string … → API: tclmkkernel_MkKernel_IdSE_ToString
top Predefined Timeout values … → API: tclmkkernel_Get_MkTimeoutE_FromObj
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) MkTimeoutE [MkKernel TimeoutE_FromInt value:int32]
top return the MkTimeoutE from integer … → API: tclmkkernel_MkKernel_TimeoutE_FromInt
(static) int32 [MkKernel TimeoutE_ToInt value:MkTimeoutE]
top return the MkTimeoutE as integer … → API: tclmkkernel_MkKernel_TimeoutE_ToInt
(static) string [MkKernel TimeoutE_ToString value:MkTimeoutE]
top return the MkTimeoutE as string … → API: tclmkkernel_MkKernel_TimeoutE_ToString
top basic data-types supported by Programming-Language-Micro-Kernel (PLMK) … → API: tclmkkernel_Get_MkTypeE_FromObj
(static) MkTypeE [MkKernel TypeE_FromInt value:int32]
top return the MkTypeE from integer … → API: tclmkkernel_MkKernel_TypeE_FromInt
(static) int32 [MkKernel TypeE_ToInt value:MkTypeE]
top return the MkTypeE as integer … → API: tclmkkernel_MkKernel_TypeE_ToInt
(static) string [MkKernel TypeE_ToString value:MkTypeE]
top return the MkTypeE as string … → API: tclmkkernel_MkKernel_TypeE_ToString
MkObjectC CLASS | |||
Export | MkObjectC - Export class functions … | ||
Introspection | MkObjectC - Introspection class functions … | ||
Misc | MkObjectC - Misc class functions … | ||
MkObjectC TOR | |||
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-Tcl-Instance and the tclmkkernel-Instance. | ||
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) … | ||
Log | Log-Slot - log a summary of an 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 MISC | |||
ErrorCatch | convert a programming-language-error into an tclmkkernel error … | ||
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 Tcl-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 …
tclmkkernel is also called as Programming-Language-Micro-Kernel (PLMK). tclmkkernel is like a programming-language without syntax but using the Target-Programming-Language (in our case Tcl) 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 tclmkkernel only the public-features of the MkObjectC are visible to the programmer.
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 … | ||
HandleExists | check if obj has already a handle defined… | ||
HandleGet | Handle-Get-Slot - returns a export-hdl to the MkObjectC useable for external storage | ||
HandleGetOfType | Export-Slot - returns typeHdl of the obj . | ||
HandleGetOr0 | return export-hdl or 0 in not created… |
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 …
MkObjectC - Export class functions …
(static) MkObjectC HandleDeleteByNetHdl netHdl:MK_HDL
top Handle-Delete-Slot - delete a netHdl from handle-storage … → API: tclmkkernel_MkObjectC_HandleDeleteByNetHdl
(static) MkObjectC [MkObjectC HandleResolve netHdl:MK_HDL]
top Handle-Resolve-Slot - return a MkObjectC from netHdl or "MK_NULL"
if invalid… → API: tclmkkernel_MkObjectC_HandleResolve
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 $netObj HandleDelete
top Handle-Delete-Slot - delete a netObj from handle-storage … → API: tclmkkernel_MkObjectC_HandleDelete
bool [$obj HandleExists]
top check if obj has already a handle defined… → API: tclmkkernel_MkObjectC_HandleExists
[in] | obj | the MkObjectS instance to work on - a MANAGED OBJECT after type-check and able to be supported by the MkObjectS API |
true
or false
MK_HDL [$obj HandleGet]
top Handle-Get-Slot - returns a export-hdl to the MkObjectC useable for external storage → API: tclmkkernel_MkObjectC_HandleGet
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkObjectHandleResolve.
By default, the export-hdl is initialized to "0", which is equivalent to does not exist. This function returns a non-zero and unique export-hdl that is recreated if necessary.
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 |
MK_HDL [$obj HandleGetOfType]
top Export-Slot - returns typeHdl of the obj . → API: tclmkkernel_MkObjectC_HandleGetOfType
A typeHdl identifies the type the obj belongs to. All instances of the same type 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_HDL [$obj HandleGetOr0]
top return export-hdl or 0 in not created… → API: tclmkkernel_MkObjectC_HandleGetOr0
Same as MkObjectHandleGet, but no new export-hdl is created if it has not already been created and the initial value 0
is returned instead.
[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) MkObjectC [MkObjectC Instances]
top get head-instance from linked-list of MkObjectS type … → API: tclmkkernel_MkObjectC_Instances
The head-instance is the last instance created.
MkObjectC [$obj Next]
top get next instance from linked-list of MkObjectS type → API: tclmkkernel_MkObjectC_Next
MkObjectC [$obj Prev]
top get previous instance from linked-list of MkObjectS type → API: tclmkkernel_MkObjectC_Prev
MkObjectC - Misc class functions …
(static) MkObjectC [MkObjectC GetNull]
top Null-Slot - return a MkObjectC typed NULL
instance … → API: tclmkkernel_MkObjectC_GetNull
C-API: MkObjectC_TOR_C_API - MkObjectC - create and destroy a managed-object …
(static) MkObjectC DeleteCallbackCleanup ident:string
top cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup … → API: tclmkkernel_MkObjectC_DeleteCallbackCleanup
(static) MkObjectC DeleteCallbackSetup ident:string ?callback:callable="MK_NULL"? ?filter:string="MK_NULL"?
top Create/Delete the instance-delete-callback … → API: tclmkkernel_MkObjectC_DeleteCallbackSetup
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) $obj Delete
top Delete-Slot - delete an instance. → API: tclmkkernel_MkObjectC_Delete
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) $obj Dispose
top Dispose-Slot - untie the connection between the Native-Tcl-Instance and the tclmkkernel-Instance. → API: tclmkkernel_MkObjectC_Dispose
There are two different ways to delete an instance:
ObjectDispose | to free the internal data but keep the outher shell alive - this is called a SOFT-DELETE |
ObjectDelete | to delete the outher shell including the internal data - this is called a HARD-DELETE |
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) MkObjectC DbgM message:string ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top debug: write a static-marker to the MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_DbgM
$obj DbgDump ?message:string="var"? ?callfunc:string="MK_NULL"?
top debug: Dump a instance to stderr with LNG and MQ internal data… → API: tclmkkernel_MkObjectC_DbgDump
$fmtobj DbgL message:string ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top debug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix … → API: tclmkkernel_MkObjectC_DbgL
The marker is prefixed with object data from th fmtobj.
$obj DbgLogC ?callfunc:string="MK_NULL"?
top debug: write a short-obj-summary to MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_DbgLogC
$obj DbgO ?callfunc:string="MK_NULL"?
top debug: write the object-details to MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_DbgO
[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.
$fmtobj DbgSTACK ?skip:int32=0? ?num:int32=-1? ?callfunc:string="MK_NULL"?
top debug: write the stack-trace to MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_DbgSTACK
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 ) |
$fmtobj LogC message:string ?debug:int32=0? ?callfunc:string="MK_NULL"?
top write a logging-message to MkLogFileC (default: stderr) using the internal format … → API: tclmkkernel_MkObjectC_LogC
The logging is only done if '
' and 'MqDebug
>= level
using the following format: MqIsSilent
== false
'
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 |
$fmtobj LogHEX callfunc:string data:binary
top log binaray data as HEX into the MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_LogHEX
[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 |
$obj Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top Log-Slot - log a summary of an object to the MkLogFileC (default: stderr) target … → API: tclmkkernel_MkObjectC_Log
The Log slot is used to write a summary of an object to the logging-device defined by MkLogFileOpen and default to stderr.
The Log slot is calling the Log slot of the obj which is defined at object-setup (example: MkBufferC)
The log-format depending on the obeject to log. A common-prefix and a object-specific-postfix is usually available
require "rbmkkernel" include MkKernel buf = MkBufferC.CreateSTR("Hallo World") buf.Log() ---------------------------------------------------- X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: BUFFER [0x1ccd500] { cursize=11 } | | | | | | | | | | | | | | | | | | | | | ^ specific: START of the MkBufferC-log | | | | | | | | | ^ calling function | | | | | | | | ^ MqContextC: pointer | | | | | | | ^ ref-count | | | | | | ^ MqContextC: context-id | | | | | ^ debug-level | | | | ^ MqContextC: S)tring, B)inary, X)none | | | ^ thread-id | | ^ process-id | ^ class-name or MqContextC: object-name ^ MqContextC: S)erver, C)hild or X)none X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | OBJECT [0x1ccd500] { check=Y, netHdl=0, refCnt=1, isLocal=Y, sig=59b30440, objRt=0x1cc9ef0 } ^ common : START of the MkObjectC-log X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | SELF { self=0x7fd7690d82a0, selfCreated=Y, selfRef=0 } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | TYPE [MkBuffer64C] { noSelf=N, delCbCnt=0, typsize=320 } ^ common: start of the type-log X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | OBJECT { type=MkTypeC, ptr=0x1ccaad0, self=(nil), refCnt=1000005, isLocal=N } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | obj { sig=0x59b30440, mask=0xffffffc0, size=184 } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | constrF=N, destrF=Y, dupF=Y, dup2F=Y, mergeF=Y, resetF=Y, logF=Y X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | selfCrF=Y, selfDeF=Y, selfUlF=Y, allocF=Y, freeF=Y X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | BASE [MkBufferC] { noSelf=N, delCbCnt=0, typsize=320 } ^ common: start of the base-type-log (multiple times until 'MkSuperTypeC' X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | OBJECT { type=MkTypeC, ptr=0x1cca990, self=(nil), refCnt=1000009, isLocal=N } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | obj { sig=0x59b30400, mask=0xfffffc00, size=120 } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | constrF=N, destrF=Y, dupF=Y, dup2F=Y, mergeF=Y, resetF=Y, logF=Y X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | selfCrF=Y, selfDeF=Y, selfUlF=Y, allocF=N, freeF=N X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | BASE [MkObjectC] { noSelf=N, delCbCnt=0, typsize=320 } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | OBJECT { type=MkTypeC, ptr=0x1cca850, self=(nil), refCnt=1000008, isLocal=N } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | obj { sig=0x59b30000, mask=0xffff0000, size=88 } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | constrF=N, destrF=Y, dupF=N, dup2F=Y, mergeF=N, resetF=N, logF=Y X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | selfCrF=Y, selfDeF=Y, selfUlF=Y, allocF=N, freeF=N X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | BASE [MkSuperTypeC] { check=Y, ptr=0x1ccc3d0, refCnt=1000000, self=(nil) } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | storage { first=0x1ccd578(ILS=Y), size=63, doFree=N } ^ specific : START of the MkBufferC-data-log X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | ils { size=64, offset=120 } X> {MkBuffer64C :pid(53689):tid(0x7fd7844b4740):X:dlv(0):ctxId( 0):rc(1):ctx(0x1ccd500 ):<main> }: | STRT : 11 : Hallo World ----------------------------------------------------
[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 ) |
$obj LogDetail ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top log the MkObjectS verbose into the MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_LogDetail
[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 ) |
$obj Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
$obj LogSimple ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top log the MkObjectS into the MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_LogSimple
[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_Misc_C_API - MkObjectC - various functions related to the MkObjectS …
MkErrorC [$obj ErrorCatch ?exception:errorCode="MK_NULL"? ?callfunc:string="MK_NULL"?]
top convert a programming-language-error into an tclmkkernel error … → API: tclmkkernel_MkObjectC_ErrorCatch
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 tclmkkernel-error.
This is the same as (example form c++):
Example from server.tcl
→ catch-send and reset an error
$cl SendSTART try { my ProxyItem $cl $cl SendEND_AND_WAIT "ECOI" 5 } on error {} { set err [$cl ErrorCatch] my SendI32 [$err GetNum] my SendSTR [$err GetText] $err Reset }
[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 Tcl, 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 ) |
bool [$obj IsNull]
top ckeck if the object is "MK_NULL"
→ API: tclmkkernel_MkObjectC_IsNull
MkErrorC [$obj ToError]
top Error-Slot - return an error-object pre initialized with obj data. → API: tclmkkernel_MkObjectC_ToError
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. string [$obj ToName]
top Info-Slot - returns brief information about the obj as a string → API: tclmkkernel_MkObjectC_ToName
[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. string [$obj ToNameOfClass]
top Class-Slot - returns the Tcl-Class-Name of the obj as string → API: tclmkkernel_MkObjectC_ToNameOfClass
The Programming-Language-Micro-Kernel (PLMK) connect the Tcl language with the tclmkkernel runtime. Every class-object in Tcl has an conterpart as tclmkkernel type-object in the Programming-Language-Micro-Kernel (PLMK).
ObjectToNameOfType | returns the name of the tclmkkernel type |
ObjectToNameOfClass | returns the name of the Tcl class |
string [$obj ToNameOfType]
top Type-Slot - returns the LibMkKernel-Type-Name of the obj as a string → API: tclmkkernel_MkObjectC_ToNameOfType
The Programming-Language-Micro-Kernel (PLMK) connect the Tcl language with the tclmkkernel runtime. Every class-object in Tcl has an conterpart as tclmkkernel type-object in the Programming-Language-Micro-Kernel (PLMK).
ObjectToNameOfType | returns the name of the libmsgque type |
ObjectToNameOfClass | returns the name of the Tcl 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 |
string [$inst ToString]
top String-Slot - returns the string representation of the inst … → API: tclmkkernel_MkObjectC_ToString
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 | |||
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) … | ||
new | Constructor - create a new MkBufferC with minimum size of internal storage … | ||
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 … | ||
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 … | ||
Pop | delete str from the MkBufferC … | ||
Push | add str to the MkBufferC … | ||
ToObject | return the native language object from a 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 tclmkkernel is working on data… tclmkkernel 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) MkBufferC [MkBufferC Create ?size:int32=0?] | tclmkkernel::MkBufferC new ?size:W=0? |
(destructor) $buf Delete | rename $buf "" |
Example from server.tcl
→ read a buffer-object and convert single-char-type-identifer to string.
method Ot_BUF2 {} { my SendSTART foreach i {1 2 3} { set buf [my ReadBUF] my SendSTR [$buf GetType1] my SendBUF $buf $buf Delete } my SendRETURN }
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 …
MkBufferC - Export class functions …
(static) MkBufferC [MkBufferC HandleResolve netHdl:MK_HDL]
top Handle-Resolve-Slot - return a MkBufferC from netHdl or "MK_NULL"
if invalid… → API: tclmkkernel_MkBufferC_HandleResolve
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 MK_HDL [$buf HandleGet]
top Handle-Get-Slot - returns a export-hdl to the MkBufferC useable for external storage → API: tclmkkernel_MkObjectC_HandleGet
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkBufferHandleResolve.
By default, the export-hdl is initialized to "0", which is equivalent to does not exist. This function returns a non-zero and unique export-hdl that is recreated if necessary.
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) MkBufferC [MkBufferC Instances]
top get head-instance from linked-list of MkBufferS type … → API: tclmkkernel_MkBufferC_Instances
The head-instance is the last instance created.
MkBufferC [$buf Next]
top get next instance from linked-list of MkBufferS type → API: tclmkkernel_MkBufferC_Next
MkBufferC [$buf Prev]
top get previous instance from linked-list of MkBufferS type → API: tclmkkernel_MkBufferC_Prev
MkBufferC - Misc class functions …
(static) MkBufferC [MkBufferC GetNull]
top Null-Slot - return a MkBufferC typed NULL
instance … → API: tclmkkernel_MkBufferC_GetNull
C-API: MkBufferC_TOR_C_API - MkBufferC - various functions to create, initialize and destroy a MkBufferC …
(constructor,static) MkBufferC [MkBufferC Create ?size:int32=0?]
top Constructor - create a new MkBufferC with minimum size of internal storage … → API: tclmkkernel_MkBufferC_Create
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferDelete is always possible, but the instance can no longer be used afterwards.
There is a MkBufferCreateTT function for every PRIMITIVE TYPE.
[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) MkBufferC [MkBufferC CreateTLS tlsName:string ?resetB:bool=true?]
top same as BufferCreate but require no cleanup → API: tclmkkernel_MkBufferC_CreateTLS
[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) MkBufferC [MkBufferC CreateBUF val:MkBufferC]
top Constructor - create a new MkBufferC with an PRIMITIVE TYPE … → API: tclmkkernel_MkBufferC_CreateBUF
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) MkBufferC [MkBufferC Create64 ?size:int32=0?]
top call the BufferCreate with default type MkBuffer64S (64 byte) … → API: tclmkkernel_MkBufferC_Create64
(constructor,static) MkBufferC [MkBufferC Create256 ?size:int32=0?]
top call the BufferCreate with default type MkBuffer256S (256 byte) … → API: tclmkkernel_MkBufferC_Create256
(constructor,static) MkBufferC [MkBufferC Create1024 ?size:int32=0?]
top call the BufferCreate with default type MkBuffer1024S (1024 byte) … → API: tclmkkernel_MkBufferC_Create1024
(constructor,static) MkBufferC [MkBufferC new ?size:int32=0?]
top Constructor - create a new MkBufferC with minimum size of internal storage … → API: tclmkkernel_MkBufferC_new
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferDelete is always possible, but the instance can no longer be used afterwards.
There is a MkBufferCreateTT function for every PRIMITIVE TYPE.
[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) |
(destructor) $buf Delete
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) MkBufferC [$buf Dup]
top Dup-Constructor - create a new MkBufferC instance as copy from an existing MkBufferC instance → API: tclmkkernel_MkBufferC_Dup
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferDelete is always possible, but the instance can no longer be used afterwards.
[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) MkBufferC [$buf Merge]
top Merge-Constructor - create a new MkBufferC as a merge from an existing object … → API: tclmkkernel_MkBufferC_Merge
The Merge-Constructor create a new instance and merge all internal data from the src into the new instance. After the Merge-Constructor the BufferResetFull is called for the merge-source bus.
One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.
[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) [MkBufferC CreateTT val:int8]
The BufferCreateTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
(constructor,static) | MkBufferC | [MkBufferC CreateI8 val:int8] | MkBufferCreateI8_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateI16 val:int16] | MkBufferCreateI16_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateI32 val:int32] | MkBufferCreateI32_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateI64 val:int64] | MkBufferCreateI64_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateSTR val:string] | MkBufferCreateSTR_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateBIN val:binary] | MkBufferCreateBIN_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateBOL val:bool] | MkBufferCreateBOL_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateFLT val:float] | MkBufferCreateFLT_RT |
(constructor,static) | MkBufferC | [MkBufferC CreateDBL val:double] |
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 …
MkBufferC [$buf SetBinaryR val:binary]
top Set the MkBufferC to the val … → API: tclmkkernel_MkBufferC_SetBinaryR
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 |
MkBufferC [$buf SetBUF val:MkBufferC]
top Set the MkBufferC to the val … → API: tclmkkernel_MkBufferC_SetBUF
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 |
MkBufferC [$buf SetStringR val:string]
top Set the MkBufferC to the val … → API: tclmkkernel_MkBufferC_SetStringR
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 |
[$buf SetTT val:int8]
The BufferSetTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
MkBufferC | [$buf SetI8 val:int8] | MkBufferSetI8_RT | |
MkBufferC | [$buf SetI16 val:int16] | MkBufferSetI16_RT | |
MkBufferC | [$buf SetI32 val:int32] | MkBufferSetI32_RT | |
MkBufferC | [$buf SetI64 val:int64] | MkBufferSetI64_RT | |
MkBufferC | [$buf SetSTR val:string] | MkBufferSetSTR_RT | |
MkBufferC | [$buf SetBIN val:binary] | MkBufferSetBIN_RT | |
MkBufferC | [$buf SetBOL val:bool] | MkBufferSetBOL_RT | |
MkBufferC | [$buf SetFLT val:float] | MkBufferSetFLT_RT | |
MkBufferC | [$buf SetDBL val:double] |
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 …
MkBufferListC [$buf GetBFL ?val_inout:MkBufferListC="MK_NULL"?]
top function to read an MkBufferListC from an MkBufferC object … → API: tclmkkernel_MkBufferC_GetBFL
This function read a buffer-item created with MqSendL_START and MqSendL_END into a temporary MkBufferListC.
[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,out] | val_inout | the reference object or "MK_NULL" at error |
"MK_NULL"
."MK_NULL"
object than the reference object is populated with the result."MK_NULL"
object than :"MK_NULL"
for a non-error result.MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
MkBufferC [$buf GetBUF]
top get a val_out from a MkBufferC … → API: tclmkkernel_MkBufferC_GetBUF
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).
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
[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) |
string [$buf GetStringR]
top get a val_out from a MkBufferC … → API: tclmkkernel_MkBufferC_GetStringR
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).
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
[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) |
[$buf GetTT]
The BufferGetTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
int8 | [$buf GetI8] | MkBufferGetI8_RT | |
int16 | [$buf GetI16] | MkBufferGetI16_RT | |
int32 | [$buf GetI32] | MkBufferGetI32_RT | |
int64 | [$buf GetI64] | MkBufferGetI64_RT | |
string | [$buf GetSTR] | MkBufferGetSTR_RT | |
binary | [$buf GetBIN] | MkBufferGetBIN_RT | |
bool | [$buf GetBOL] | MkBufferGetBOL_RT | |
float | [$buf GetFLT] | MkBufferGetFLT_RT | |
double | [$buf GetDBL] |
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).
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
[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 …
MkBufferC [$buf AppendSTR val:string]
top append a single string to a MkBufferC object … → API: tclmkkernel_MkBufferC_AppendSTR
[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.tcl
→ read and update a MkBufferC
# START - ReadBUF - Example, read a buffer-object and append a string set buf [my ReadBUF] $buf AppendSTR "- a really log text to overwrite the already allocated space" my SendBUF $buf set i [my ReadI32] my SendI32 [expr {$i+1}] rename $buf ""
MkBufferC [$buf AppendStringR val:string]
top append a single string to a MkBufferC object … → API: tclmkkernel_MkBufferC_AppendStringR
[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.tcl
→ read and update a MkBufferC
# START - ReadBUF - Example, read a buffer-object and append a string set buf [my ReadBUF] $buf AppendSTR "- a really log text to overwrite the already allocated space" my SendBUF $buf set i [my ReadI32] my SendI32 [expr {$i+1}] rename $buf ""
int32 [$buf Pop val:string]
top delete str from the MkBufferC … → API: tclmkkernel_MkBufferC_Pop
[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 |
int32 [$buf Push val:string]
top add str to the MkBufferC … → API: tclmkkernel_MkBufferC_Push
[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 |
obj [$buf ToObject]
top return the native language object from a MkBufferC … → API: MkBufferToObject_RT
C-API: MkBufferC_Info_C_API - MkBufferC - various functions to get information out of buffer-data …
string[1] [$buf GetType1]
top return the type from a MkBufferC as single character value … → API: tclmkkernel_MkBufferC_GetType1
MkTypeE [$buf GetType2]
top return the MkTypeE from a MkBufferC … → API: tclmkkernel_MkBufferC_GetType2
string [$buf GetType3]
top return the type from a MkBufferC as single character string … → API: tclmkkernel_MkBufferC_GetType3
bool [$buf IsLocal]
top Check if the MkBufferC is local (temporary), not local mean global … → API: tclmkkernel_MkBufferC_IsLocal
[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 |
$buf Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top log the MkBufferC … → API: tclmkkernel_MkObjectC_Log
[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 ) |
$buf LogS ?varname:string="buf"? ?fmtobj:MkObjectC="MK_NULL"? ?callfunc:string="MK_NULL"?
top log the short MkBufferC object data to the MkLogFileC (default: stderr) … → API: tclmkkernel_MkBufferC_LogS
[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 …
$buf CastTo typ:MkTypeE
top change the type of an MkBufferC to type … → API: tclmkkernel_MkBufferC_CastTo
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
int32 [$buf1 Cmp buf2:MkBufferC]
top compare TWO MkBufferC objects like strcmp
do it for strings … → API: tclmkkernel_MkBufferC_Cmp
[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 |
MkBufferC [$buf Copy srce:MkBufferC]
top copy the MkBufferC from srce to dest … → API: tclmkkernel_MkBufferC_Copy
[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 |
MkBufferC [$buf Reset]
top reset a MkBufferC to the length zero … → API: tclmkkernel_MkBufferC_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 |
$buf ResetFull
$buf ResetFull
top reset a MkBufferC to the length zero and free allocated storage… → API: tclmkkernel_MkBufferC_ResetFull
In addition to MkBufferC [$buf Reset]
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 |
MkBufferC [$buf Reset]
MkBufferC [$buf SizeAdd size:int32]
top add size storage to the buf … → API: tclmkkernel_MkBufferC_SizeAdd
[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) |
MkBufferC [$buf SizeNew size:int32]
top alloc min size storage to the buf … → API: tclmkkernel_MkBufferC_SizeNew
[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) |
MkBufferC [$buf Temp]
top create a temporary copy of the MkBufferC buf … → API: tclmkkernel_MkBufferC_Temp
This function always return the same global memory from the per-thread-runtime-storage initialized with buf. This storage must not be freed and should only be used for temporary-short-time usage. In theory every function-call in the same thread could overwrite this memory.
[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. string [$inst ToString]
top String-Slot - returns the string representation of the inst … → API: tclmkkernel_MkObjectC_ToString
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 | |||
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) … | ||
CreateTLS | same as BufferStreamCreate but require no cleanup … | ||
new | create and initialize an MkBufferStreamC instance … | ||
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 … | ||
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
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 …
MkBufferStreamC - Export class functions …
(static) MkBufferStreamC [MkBufferStreamC HandleResolve netHdl:MK_HDL]
top Handle-Resolve-Slot - return a MkBufferStreamC from netHdl or "MK_NULL"
if invalid… → API: tclmkkernel_MkBufferStreamC_HandleResolve
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 MK_HDL [$bus HandleGet]
top Handle-Get-Slot - returns a export-hdl to the MkBufferStreamC useable for external storage → API: tclmkkernel_MkObjectC_HandleGet
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkBufferStreamHandleResolve.
By default, the export-hdl is initialized to "0", which is equivalent to does not exist. This function returns a non-zero and unique export-hdl that is recreated if necessary.
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) MkBufferStreamC [MkBufferStreamC Instances]
top get head-instance from linked-list of MkBufferStreamS type … → API: tclmkkernel_MkBufferStreamC_Instances
The head-instance is the last instance created.
MkBufferStreamC [$bus Next]
top get next instance from linked-list of MkBufferStreamS type → API: tclmkkernel_MkBufferStreamC_Next
MkBufferStreamC [$bus Prev]
top get previous instance from linked-list of MkBufferStreamS type → API: tclmkkernel_MkBufferStreamC_Prev
MkBufferStreamC - Misc class functions …
(static) MkBufferStreamC [MkBufferStreamC GetNull]
top Null-Slot - return a MkBufferStreamC typed NULL
instance … → API: tclmkkernel_MkBufferStreamC_GetNull
C-API: MkBufferStreamC_TOR_C_API - MkBufferStreamC - various functions to create and destroy a MkBufferStreamC …
(constructor,static) MkBufferStreamC [MkBufferStreamC Create ?size:int32=0?]
top create and initialize an MkBufferStreamC instance … → API: tclmkkernel_MkBufferStreamC_Create
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferStreamDelete is always possible, but the instance can no longer be used afterwards.
[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) MkBufferStreamC [MkBufferStreamC Create64 ?size:int32=0?]
top call the BufferStreamCreate with default type MkBufferStream64S (64 byte) … → API: tclmkkernel_MkBufferStreamC_Create64
(constructor,static) MkBufferStreamC [MkBufferStreamC Create256 ?size:int32=0?]
top call the BufferStreamCreate with default type MkBufferStream256S (256 byte) … → API: tclmkkernel_MkBufferStreamC_Create256
(constructor,static) MkBufferStreamC [MkBufferStreamC Create1024 ?size:int32=0?]
top call the BufferStreamCreate with default type MkBufferStream1024S (1024 byte) … → API: tclmkkernel_MkBufferStreamC_Create1024
(constructor,static) MkBufferStreamC [MkBufferStreamC Create16384 ?size:int32=0?]
top call the BufferStreamCreate with default type MkBufferStream16384S (16384 byte) … → API: tclmkkernel_MkBufferStreamC_Create16384
(static) MkBufferStreamC [MkBufferStreamC CreateTLS tlsName:string ?resetB:bool=true?]
top same as BufferStreamCreate but require no cleanup … → API: tclmkkernel_MkBufferStreamC_CreateTLS
Example from perfserver.tcl
→ performance test with TLS storage
method Ot_BUST {} { set bus [MkBufferStreamC CreateTLS "perfserver-BUST" ] while {[my ReadItemExists]} { $bus WriteBUF [my ReadBUF] } $bus PosToStart my SendSTART while {[$bus ReadItemExists]} { my SendBUF [$bus ReadBUF] } my SendRETURN }
[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) MkBufferStreamC [MkBufferStreamC new ?size:int32=0?]
top create and initialize an MkBufferStreamC instance … → API: tclmkkernel_MkBufferStreamC_new
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferStreamDelete is always possible, but the instance can no longer be used afterwards.
[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) |
(destructor) $bus Delete
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) MkBufferStreamC [$src Dup]
top Dup-Constructor - create a new MkBufferStreamC instance as copy from an existing MkBufferStreamC instance … → API: tclmkkernel_MkBufferStreamC_Dup
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferStreamDelete is always possible, but the instance can no longer be used afterwards.
(constructor) MkBufferStreamC [$bus Merge]
top Merge-Constructor - create a new MkBufferStreamC as a merge from an existing object … → API: tclmkkernel_MkBufferStreamC_Merge
The Merge-Constructor create a new instance and merge all internal data from the src into the new instance. After the Merge-Constructor the BufferStreamResetFull is called for the merge-source bus.
One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.
[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.
MkBufferListC [$bus ReadALL ?val_inout:MkBufferListC="MK_NULL"?]
top get a temporary MkBufferListC from all data in the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadALL
[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 reference object or "MK_NULL" at error |
"MK_NULL"
."MK_NULL"
object than the reference object is populated with the result."MK_NULL"
object than :"MK_NULL"
for a non-error result.MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
MkBufferListC [$bus ReadBFL]
top read a MkBufferListC from the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadBFL
The MkBufferListC represent a list-item-type (MK_LSTT from the MkBufferStreamC. A list-item-type is created with $bus WriteL_START
and $bus WriteL_END
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
for a non-error result. MkBufferC [$bus ReadBUF]
top read a val_out from the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadBUF
The MkBufferStreamReadTT
style of functions always return a val_out or a MkErrorC.
$bus PosToStart
.MkExceptionC | → The default-exception from 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] | bus | the MkBufferStreamS instance to work on |
[out] | val_out | the new value |
MkTypeE [$bus ReadGetNextType]
top get the type (MkTypeE) of the next Item in the MkBufferStreamC or "0" if not available → API: tclmkkernel_MkBufferStreamC_ReadGetNextType
[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 |
int32 [$bus ReadGetNumItems]
top get the number of items left in the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadGetNumItems
[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 |
bool [$bus ReadItemExists]
top check if an item exists in the read-data-package … → API: tclmkkernel_MkBufferStreamC_ReadItemExists
[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 |
true
or false
$bus ReadL_END
top END read a list-item-type from the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadL_END
$bus ReadL_START ?buf:MkBufferC="MK_NULL"?
top START read a list-item-type from the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadL_START
[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. |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
long [$bus ReadLONG]
top read the long native object from the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_ReadLONG
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$bus WriteLONG val:long
$bus ReadUndo
top undo the last MkBufferStreamC READ function call … → API: tclmkkernel_MkBufferStreamC_ReadUndo
Decrement the current-access-position by one, to the start of the last read body-item. The next read function call will extract the same item again. Only one undo level is supported.
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
[$bus ReadTT]
The BufferStreamReadTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
int8 | [$bus ReadI8] | MkBufferStreamReadI8_RT | |
int32 | [$bus ReadI32] | MkBufferStreamReadI32_RT | |
int64 | [$bus ReadI64] | MkBufferStreamReadI64_RT | |
string | [$bus ReadSTR] | MkBufferStreamReadSTR_RT | |
binary | [$bus ReadBIN] | MkBufferStreamReadBIN_RT | |
bool | [$bus ReadBOL] | MkBufferStreamReadBOL_RT | |
float | [$bus ReadFLT] | MkBufferStreamReadFLT_RT | |
double | [$bus ReadDBL] |
read a val_out from the MkBufferStreamC …
The MkBufferStreamReadTT
style of functions always return a val_out or a MkErrorC.
$bus PosToStart
.MkExceptionC | → The default-exception from 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] | 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.
$bus WriteBFL bfl:MkBufferListC
top write a MkBufferListC into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteBFL
The MkBufferListC represent a list-item-type (MK_LSTT from the MkBufferStreamC. A list-item-type is created with $bus WriteL_START
and $bus WriteL_END
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$bus WriteBUF val:MkBufferC
top write a PRIMITIVE TYPE into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteBUF
After every write the current-access-position is incremented by one, use MkBufferStreamC [$bus Reset]
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$bus WriteBUS_FLAT add:MkBufferStreamC
top write a MkBufferStreamC into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteBUS_FLAT
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$bus WriteHDL val:int32
top write the handle into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteHDL
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:
$bus WriteL_END
top END write a list-item-type into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteL_END
$bus WriteL_FLAT bfl:MkBufferListC
top write a MkBufferListC FLAT into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteL_FLAT
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$bus WriteL_START
top START write a list-item-type into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteL_START
$bus WriteLONG val:long
top write the long native object into the MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_WriteLONG
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
long [$bus ReadLONG]
$bus WriteTT val:int8
The BufferStreamWriteTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
$bus WriteI8 val:int8 | MkBufferStreamWriteI8_RT | ||
$bus WriteI32 val:int32 | MkBufferStreamWriteI32_RT | ||
$bus WriteI64 val:int64 | MkBufferStreamWriteI64_RT | ||
$bus WriteSTR val:string ?len:int32=-1? | MkBufferStreamWriteSTR_RT | ||
$bus WriteBIN val:binary | MkBufferStreamWriteBIN_RT | ||
$bus WriteBOL val:bool | MkBufferStreamWriteBOL_RT | ||
$bus WriteFLT val:float | MkBufferStreamWriteFLT_RT | ||
$bus WriteDBL val:double |
write a PRIMITIVE TYPE into the MkBufferStreamC …
After every write the current-access-position is incremented by one, use MkBufferStreamC [$bus Reset]
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
C-API: MkBufferStreamC_Misc_C_API - MkBufferStreamC - various functions to create and destroy a MkBufferStreamS …
MkBufferStreamC [$bus Copy src:MkBufferStreamC]
top copy the MkBufferStreamC from src to bus … → API: tclmkkernel_MkBufferStreamC_Copy
[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 |
$bus Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top log the MkBufferStreamC … → API: tclmkkernel_MkObjectC_Log
[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 ) |
$bus PosToStart
top set the current-access-position to the start of MkBufferStreamC … → API: tclmkkernel_MkBufferStreamC_PosToStart
MkBufferStreamC [$bus Reset]
top reset a MkBufferStreamC to the length zero … → API: tclmkkernel_MkBufferStreamC_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 |
$bus ResetFull
$bus ResetFull
top reset a MkBufferStreamC to the length zero and free allocated storage… → API: tclmkkernel_MkBufferStreamC_ResetFull
In addition to MkBufferStreamC [$bus Reset]
the allocated storage is freed and reset to ILS. This is usefull if the internal storage was filled once with a huge amount of data.
[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 [$bus Reset]
MkBufferListC [$bus ToBFL]
top convert the bus into a MkBufferListC … → API: tclmkkernel_MkBufferStreamC_ToBFL
[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. string [$inst ToString]
top String-Slot - returns the string representation of the inst … → API: tclmkkernel_MkObjectC_ToString
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 | |||
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) | ||
CreateTLS | same as BufferListCreate but require no cleanup … | ||
new | Constructs a MkBufferC instance with size storage… | ||
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 … | ||
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 … | ||
ToList | get a target-language list representation of the bfl … | ||
ToString | get a string representation of the bfl |
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) MkBufferListC [MkBufferListC Create ?size:int32=0?] | tclmkkernel::MkBufferListC new ?num:I=0? |
(destructor) $bfl Delete | rename $bfl "" |
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 …
MkBufferListC - Export class functions …
(static) MkBufferListC [MkBufferListC HandleResolve netHdl:MK_HDL]
top Handle-Resolve-Slot - return a MkBufferListC from netHdl or "MK_NULL"
if invalid… → API: tclmkkernel_MkBufferListC_HandleResolve
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 MK_HDL [$bfl HandleGet]
top Handle-Get-Slot - returns a export-hdl to the MkBufferListC useable for external storage → API: tclmkkernel_MkObjectC_HandleGet
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkBufferListHandleResolve.
By default, the export-hdl is initialized to "0", which is equivalent to does not exist. This function returns a non-zero and unique export-hdl that is recreated if necessary.
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) MkBufferListC [MkBufferListC Instances]
top get head-instance from linked-list of MkBufferListS type … → API: tclmkkernel_MkBufferListC_Instances
The head-instance is the last instance created.
MkBufferListC [$bfl Next]
top get next instance from linked-list of MkBufferListS type → API: tclmkkernel_MkBufferListC_Next
MkBufferListC [$bfl Prev]
top get previous instance from linked-list of MkBufferListS type → API: tclmkkernel_MkBufferListC_Prev
MkBufferListC - Misc class functions …
(static) MkBufferListC [MkBufferListC GetNull]
top Null-Slot - return a MkBufferListC typed NULL
instance … → API: tclmkkernel_MkBufferListC_GetNull
C-API: MkBufferListC_TOR_C_API - MkBufferListC - various functions to create and destroy a MkBufferListS …
(constructor,static) MkBufferListC [MkBufferListC Create ?size:int32=0?]
top Constructs a MkBufferC instance with size storage… → API: tclmkkernel_MkBufferListC_Create
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.
[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) MkBufferListC [MkBufferListC CreateLA args:MkBufferListC...]
top Constructs a MkBufferListC instance with an other MkBufferListC OR a list of arguments (only in NON C) → API: tclmkkernel_MkBufferListC_CreateLA
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.
(static) MkBufferListC [MkBufferListC CreateTLS tlsName:string ?resetB:bool=true?]
top same as BufferListCreate but require no cleanup … → API: tclmkkernel_MkBufferListC_CreateTLS
Example from perfserver.tcl
→ 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) MkBufferListC [MkBufferListC new ?size:int32=0?]
top Constructs a MkBufferC instance with size storage… → API: tclmkkernel_MkBufferListC_new
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.
[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) |
(destructor) $bfl Delete
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) MkBufferListC [$bfl Dup]
top Dup-Constructor - create a new MkBufferListC instance as copy from an existing MkBufferListC instance … → API: tclmkkernel_MkBufferListC_Dup
The new instance belongs to the caller and may have to be released if necessary. A manual release using BufferListDelete is always possible, but the instance can no longer be used afterwards.
(constructor) MkBufferListC [$bfl Merge]
top Merge-Constructor - constructs a MkBufferListC instance as a merge from an existing MkBufferListC instance … → API: tclmkkernel_MkBufferListC_Merge
The Merge-Constructor create a new object-shell, and take-over all the internal data from the source-object. After the Merge-Constructor the source-object is empty as if a BufferListReset was called.
One usage of the Merge-Constructor is to get a lightweight-copy of a Thread-Local-Storage object for external usage.
[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 …
$bfl AppendBUF val:MkBufferC
top append a native PRIMITIVE TYPE object to a MkBufferListC … → API: tclmkkernel_MkBufferListC_AppendBUF
[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 |
$bfl AppendG val:long
top append a native PRIMITIVE TYPE object to a MkBufferListC … → API: tclmkkernel_MkBufferListC_AppendG
[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 |
MkBufferListC [$bfl AppendLA args:MkBufferListC...]
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: tclmkkernel_MkBufferListC_AppendLA
[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 |
MkBufferListC [$bfl AppendLP addBufL:MkBufferListC ?position:int32=-1?]
top copy a MkBufferListS list into an MkBufferListS object on position … → API: tclmkkernel_MkBufferListC_AppendLP
[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 |
$bfl AppendStringR val:string
top append a native PRIMITIVE TYPE object to a MkBufferListC … → API: tclmkkernel_MkBufferListC_AppendStringR
[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 |
$bfl AppendUP addBuf:MkBufferC ?position:int32=-1?
top append a MkBufferC item into an MkBufferListC object on position … → API: tclmkkernel_MkBufferListC_AppendUP
[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 |
$bfl AppendTT val:int8
The BufferListAppendTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
$bfl AppendI8 val:int8 | MkBufferListAppendI8_RT | ||
$bfl AppendI16 val:int16 | MkBufferListAppendI16_RT | ||
$bfl AppendI32 val:int32 | MkBufferListAppendI32_RT | ||
$bfl AppendI64 val:int64 | MkBufferListAppendI64_RT | ||
$bfl AppendSTR val:string | MkBufferListAppendSTR_RT | ||
$bfl AppendBIN val:binary | MkBufferListAppendBIN_RT | ||
$bfl AppendBOL val:bool | MkBufferListAppendBOL_RT | ||
$bfl AppendFLT val:float | MkBufferListAppendFLT_RT | ||
$bfl AppendDBL val:double |
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.
bool [$bfl CheckOption opt:string ?onlyFirst:bool=false?]
top search for boolean option in MkBufferListS list and return MK_BOL value … → API: tclmkkernel_MkBufferListC_CheckOption
-
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 |
MkBufferC [$bfl CheckOptionBUF opt:string ?defval:MkBufferC="MK_NULL"? ?onlyFirst:bool=true?]
top search for opt in MkBufferListS list and fill var with opt_argument or the defval value … → API: tclmkkernel_MkBufferListC_CheckOptionBUF
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
an error is returned. "MK_NULL"
than an empty MkBufferC is returned. "MK_NULL"
for a non-error result.[$bfl CheckOptionTT opt:string ?defval:int8=0? ?onlyFirst:bool=true?]
The BufferListCheckOptionTT provide a single function for every PRIMITIVE TYPE
attribute | return | command | C-API : |
---|---|---|---|
int8 | [$bfl CheckOptionI8 opt:string ?defval:int8=0? ?onlyFirst:bool=true?] | MkBufferListCheckOptionI8_RT | |
int16 | [$bfl CheckOptionI16 opt:string ?defval:int16=0? ?onlyFirst:bool=true?] | MkBufferListCheckOptionI16_RT | |
int32 | [$bfl CheckOptionI32 opt:string ?defval:int32=0? ?onlyFirst:bool=true?] | MkBufferListCheckOptionI32_RT | |
int64 | [$bfl CheckOptionI64 opt:string ?defval:int64=0? ?onlyFirst:bool=true?] | MkBufferListCheckOptionI64_RT | |
string | [$bfl CheckOptionSTR opt:string ?defval:string=""? ?onlyFirst:bool=true?] | MkBufferListCheckOptionSTR_RT | |
bool | [$bfl CheckOptionBOL opt:string ?defval:bool=false? ?onlyFirst:bool=true?] | MkBufferListCheckOptionBOL_RT | |
float | [$bfl CheckOptionFLT opt:string ?defval:float=0? ?onlyFirst:bool=true?] | MkBufferListCheckOptionFLT_RT | |
double | [$bfl CheckOptionDBL opt:string ?defval:double=0? ?onlyFirst:bool=true?] |
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
an error is returned. C-API: MkBufferListC_Index_C_API - MkBufferListC - various functions to access a MkBufferListS by index …
$bfl IndexDelete index:int32 ?numitems:int32=1? ?doDelete:bool=true?
top delete the index'th list item from the MkBufferListS object … → API: tclmkkernel_MkBufferListC_IndexDelete
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
MkBufferC [$bfl IndexGet index:int32]
top get (read only) the index object from bfl … → API: tclmkkernel_MkBufferListC_IndexGet
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
first. MkBufferC [$bfl IndexGetBUF index:int32]
top get the index element from MkBufferListC ... if not available… create it. … → API: tclmkkernel_MkBufferListC_IndexGetBUF
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 |
string [$bfl IndexGetSTR index:int32]
top get the index element from MkBufferListC ... as string. … → API: tclmkkernel_MkBufferListC_IndexGetSTR
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 |
$bfl IndexSet index:int32 buf:MkBufferC
top set the index object from bfl … → API: tclmkkernel_MkBufferListC_IndexSet
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$bfl IndexSetBUF index:int32 buf:MkBufferC
top set the index element from MkBufferListC ... if not available… createspace … → API: tclmkkernel_MkBufferListC_IndexSetBUF
[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 |
$bfl IndexSetSTR index:int32 str:string
top set the index element from MkBufferListC ... to string… if not available… create space … → API: tclmkkernel_MkBufferListC_IndexSetSTR
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 |
MkBufferC [$bfl IndexExtract ?index:int32=0?]
top extract (read & delete) the index object from bfl … → API: tclmkkernel_MkBufferListC_IndexExtract
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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
first.C-API: MkBufferListC_Log_C_API - MkBufferListC - various functions to 'log' a MkBufferListS …
$bfl Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top write the detail-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_Log
[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 ) |
$bfl LogS ?varname:string="bfl"? ?fmtobj:MkObjectC="MK_NULL"? ?callfunc:string="MK_NULL"?
top write the short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: tclmkkernel_MkBufferListC_LogS
[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 ) |
$bfl LogSS ?varname:string="bfl"? ?fmtobj:MkObjectC="MK_NULL"? ?callfunc:string="MK_NULL"?
top write the very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: tclmkkernel_MkBufferListC_LogSS
[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 ) |
$bfl LogSSS ?varname:string="bfl"? ?fmtobj:MkObjectC="MK_NULL"? ?callfunc:string="MK_NULL"?
top write the very-very-short-summary of the MkBufferListC to MkLogFileC (default: stderr) … → API: tclmkkernel_MkBufferListC_LogSSS
[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) MkBufferListC [MkBufferListC FileGlob pattern_match:string]
top create a new MkBufferListC using the result from a filesystem glob operation … → API: tclmkkernel_MkBufferListC_FileGlob
$to Move from:MkBufferListC
top move all internal data from from to the end of to … → API: tclmkkernel_MkBufferListC_Move
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 |
$bfl Copy src:MkBufferListC
top copy all internal data from src to tgt … → API: tclmkkernel_MkBufferListC_Copy
[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 |
MkBufferListC [$bfl PositionMerge source:MkBufferListC position:int32]
top merge a MkBufferListS list into an MkBufferListS object on position … → API: tclmkkernel_MkBufferListC_PositionMerge
[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 |
int32 [$bfl Cmp bfl2:MkBufferListC]
top compare two buffer-list … → API: tclmkkernel_MkBufferListC_Cmp
First the size is compared and if the size is equal every argument starting from 0 is compared with BufferCmp. The first BufferCmp with a result != 0 finish the comparison and this result is returned.
[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 |
$bfl Reserve num:int32
top reserve num items in a MkBufferListC object … → API: tclmkkernel_MkBufferListC_Reserve
[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. |
MkBufferListC [$bfl Reset]
top reset a MkBufferListC object … → API: tclmkkernel_MkBufferListC_Reset
[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 |
int32 [$bfl SearchC str:string ?len:int32=-1? ?startindex:int32=0?]
top search MK_STR item from a MkBufferListS object starting at startindex … → API: tclmkkernel_MkBufferListC_SearchC
[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
int32 [$bfl Size]
top get the number-of-items in the bfl … → API: tclmkkernel_MkBufferListC_Size
[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 [$bfl Sort]
top sort a MkBufferListC … → API: tclmkkernel_MkBufferListC_Sort
[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 |
MkBufferC [$bfl ToBuffer]
top Export a bfl into an MkBufferC using an MkBufferStreamC … → API: tclmkkernel_MkBufferListC_ToBuffer
An buffer is able to hold all primitive types and LIST of primitive types. An buffer-list is an Indexed-LIST representation of a LIST of buffer.
To add a buffer-list into an buffer the buffer-list have to be converted into a buffer-stream and the buffer-stream have to be exported as buffer. The buffer is finally apended to the buffer-list.
[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"MK_NULL"
for a non-error result. [list...] [$bfl ToList]
top get a target-language list representation of the bfl … → API: MkBufferListToList_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 |
string [$bfl ToString]
top get a string representation of the bfl → API: tclmkkernel_MkObjectC_ToString
[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 |
MkErrorC CLASS | |||
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 … | ||
AppendC | append the message to the MkErrorS::text … | ||
NoRaise | ignore the next return of MK_ERROR and do not raise an target-language-exception … | ||
Raise | convert an tclmkkernel error into an programming-language-error and raise afterwards. … | ||
SetC | 'set' and 'raise' the MkErrorC using a string-message and a errnum-number … | ||
MkErrorC SIGNAL | |||
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 MqMqEventIF 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 … | ||
ignore-system-error - print the next error into MkLogFileC … | |||
MkErrorC MISC | |||
Catch | convert a programming-language-error into an tclmkkernel 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 … | ||
ToString | String-Slot - returns the string representation of the inst … |
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 tclmkkernel into the error-handling-code of the target Tcl.
Example from Filter6.tcl
→ use MqContextErrorCatch to convert a Tcl error into a tclmkkernel error
tclmqmsgque::Main { set srv [[MqFactoryC Add Filter6] New] try { $srv LinkCreate {*}$argv $srv ProcessEvent MQ_WAIT_FOREVER } on error {} { $srv ErrorCatch } finally { $srv Exit } }
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 true
or false
…
Example: test case to check KILL and RECOVER feature, check on MkExceptionC
set VAL [my ReadBUF] set cl [Client new] $cl myLinkCreate [my ConfigGetStartAs] $cl Send "W" "GPID@I" PID my SysKill $PID 9 set RET 0 foreach num {1 2 3} { try { set RET [$cl Send "W" "ECOI:U@I" $VAL] } trap {MkExceptionC} "" { set err [$cl ErrorCatch] if {[$err IsSOCKET]} { $err Reset $cl LinkConnect continue } else { $err Raise } $err Delete } break } my SendSTART my SendI32 $RET
true
or false
[in] | exception | the exception object from Tcl, if "MK_NULL" the global exception object is used |
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 …
MkErrorC - Export class functions …
(static) MkErrorC [MkErrorC HandleResolve netHdl:MK_HDL]
top Handle-Resolve-Slot - return a MkErrorC from netHdl or "MK_NULL"
if invalid… → API: tclmkkernel_MkErrorC_HandleResolve
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 MK_HDL [$err HandleGet]
top Handle-Get-Slot - returns a export-hdl to the MkErrorC useable for external storage → API: tclmkkernel_MkObjectC_HandleGet
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkErrorHandleResolve.
By default, the export-hdl is initialized to "0", which is equivalent to does not exist. This function returns a non-zero and unique export-hdl that is recreated if necessary.
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) MkErrorC [MkErrorC Instances]
top get head-instance from linked-list of MkErrorS type … → API: tclmkkernel_MkErrorC_Instances
The head-instance is the last instance created.
MkErrorC [$err Next]
top get next instance from linked-list of MkErrorS type → API: tclmkkernel_MkErrorC_Next
MkErrorC [$err Prev]
top get previous instance from linked-list of MkErrorS type → API: tclmkkernel_MkErrorC_Prev
MkErrorC - Misc class functions …
(static) MkErrorC [MkErrorC GetNull]
top Null-Slot - return a MkErrorC typed NULL
instance … → API: tclmkkernel_MkErrorC_GetNull
C-API: MkErrorC_TOR_C_API - MkErrorC - various functions to 'create' and 'delete' a MkErrorS …
(destructor) $err Delete
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) MkErrorC [$srce Dup]
top Dup-Constructor - create a new MkErrorC instance as copy from an existing MkErrorC instance … → API: tclmkkernel_MkErrorC_Dup
The new instance belongs to the caller and may have to be released if necessary. A manual release using ErrorDelete is always possible, but the instance can no longer be used afterwards.
C-API: MkErrorC_Get_C_API - MkErrorC - various functions to 'get' data out of a MkErrorS …
MkErrorE [$err GetCode]
top get the value of MkErrorS::code … → API: tclmkkernel_MkErrorC_GetCode
int32 [$err GetNum]
top get the MkErrorS::num. The number can be used as exit-code … → API: tclmkkernel_MkErrorC_GetNum
long [$err GetSize]
top get the error-message-size from the exception-object … → API: tclmkkernel_MkErrorC_GetSize
string [$err GetText]
top get the MkErrorS::text … → API: tclmkkernel_MkErrorC_GetText
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) MkErrorC PanicC errfmt:MkObjectC callfunc:string errnum:int32 message:string
top do a panic with string as argument … → API: tclmkkernel_MkErrorC_PanicC
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errfmt | 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 |
$err AppendC message:string
top append the message to the MkErrorS::text … → API: tclmkkernel_MkErrorC_AppendC
[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) |
MkErrorC [$err NoRaise]
top ignore the next return of MK_ERROR and do not raise an target-language-exception … → API: tclmkkernel_MkErrorC_NoRaise
Many functions from the MkErrorXXX return an MkErrorE to signal that an MK_ERROR is set. The target-language react on this signal and raise an target-language-exception.
If this behaviour is not desired the ErrorNoRaise is used to suppress the next MK_ERROR return.
This feature is used to avoid the target-language-exception after ErrorSetC etc.
This is usefull if:
Example from server.tcl
→ create and send an background-error message
method bgError {} { set master [my SlaveGetMaster] if {$master ne ""} { set err [[$master ErrorFORMAT] NoRaise] $err SetC [$err GetText] "BGERROR" [$err GetNum] $master SendERROR } }
[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 Raise
top convert an tclmkkernel error into an programming-language-error and raise afterwards. … → API: tclmkkernel_MkErrorC_Raise
If ther is no tclmkkernel-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_tcl_ErrorCatch "ErrorCatch" \ref doc_mk_tcl_ErrorReset "ErrorReset"
$err SetC message:string ?callfunc:string="MK_NULL"? ?errnum:int32=-1?
top 'set' and 'raise' the MkErrorC using a string-message and a errnum-number … → API: tclmkkernel_MkErrorC_SetC
The message will be formatted into a tclmkkernel 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 |
C-API: MkErrorC_Signal_C_API - MkErrorC - various functions to set and check a 'signal' on a MkErrorS …
bool [$err IsABORT]
top check on ABORT signal … → API: tclmkkernel_MkErrorC_IsABORT
bool [$err IsEXIT]
top check on APPLICATION-EXIT error … → API: tclmkkernel_MkErrorC_IsEXIT
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/tcl/Filter4.tcl
exampleExample "C"
: catch and ignore an EXIT return-code
bool [$err IsSOCKET]
top check on SOCKET-DOWN error … → API: tclmkkernel_MkErrorC_IsSOCKET
bool [$err IsTIMEOUT]
top check on TIMEOUT error … → API: tclmkkernel_MkErrorC_IsTIMEOUT
$err SetABORT ?detail:string="UNKNOWN"? ?callfunc:string="MK_NULL"?
top send the ABORT signal to the calling stack… → API: tclmkkernel_MkErrorC_SetABORT
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
$err SetCode code:MkErrorE
top set the MkErrorS::code value … → API: tclmkkernel_MkErrorC_SetCode
$err SetCONTINUE
top signal end of processing in an MqMqEventIF callback … → API: tclmkkernel_MkErrorC_SetCONTINUE
$err SetEXIT ?callfunc:string="MK_NULL"?
top finish the current callback, return to toplevel and MqExit the application … → API: tclmkkernel_MkErrorC_SetEXIT
To exit a application in a callback is a difficult task because the code is in-duty. To achieve this goal a special exit-error-object is created and reported to the toplevel. If a transaction is ongoing the MqSendRETURN is not called and thus the transaction is not finished. The calling application is informed later by a socket-down event. This only works for a parent-context. An exit in a child-context is ignored.
Example: raise an EXIT-exception in an ruby-service:
$err SetSOCKET ?detail:string="UNKNOWN"? ?callfunc:string="MK_NULL"?
top create SOCKET-DOWN error … → API: tclmkkernel_MkErrorC_SetSOCKET
C-API: MkErrorC_System_C_API - MkErrorC - various functions to raise a 'System' messagen on MkErrorS …
(static) MkErrorC [MkErrorC DEFAULT]
top default-system-error - default-error … → API: tclmkkernel_MkErrorC_DEFAULT
The default-error is defined once per runtime and is used as only-valid-source of an MkErrorC in a thread or process.
(static) MkErrorC [MkErrorC FORMAT ?fmtobj:MkObjectC="MK_NULL"?]
top system-error-format - format and return the default-error … → API: tclmkkernel_MkErrorC_FORMAT
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) MkErrorC [MkErrorC IGNORE]
top ignore-system-error - ignore the next error … → API: tclmkkernel_MkErrorC_IGNORE
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) MkErrorC [MkErrorC PRINT]
top ignore-system-error - print the next error into MkLogFileC … → API: tclmkkernel_MkErrorC_PRINT
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 …
MkErrorC [$err Catch ?exception:errorCode="MK_NULL"? ?callfunc:string="MK_NULL"?]
top convert a programming-language-error into an tclmkkernel error … → API: tclmkkernel_MkErrorC_Catch
Same as MkObjectErrorCatch but skip the Error-Prefix in final Target-Programming-Language (TPL).
Example from Bug3.tcl
→ catch an error using MkErrorC [$err Catch ?exception:errorCode="MK_NULL"? ?callfunc:string="MK_NULL"?]
} on error {} { [ [MkErrorC DEFAULT] Catch ] Println }
[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 Tcl, 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 ) |
$err Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top log the error to MkLogFileC (default: stderr) … → API: tclmkkernel_MkObjectC_Log
[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 ) |
$err Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
$err Println
top print the default-error to the MkLogFileC (default: stderr) and clear the error afterwards … → API: tclmkkernel_MkErrorC_Println
[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 Reset ?callfunc:string="MK_NULL"? ?callline:int32=-1? ?force:bool=false?
top This function clears the err and resets to MK_OK … → API: tclmkkernel_MkErrorC_Reset
It is recommended that you use this feature only after the error has been processed.
MkErrorE [$err Stack ?callfunc:string="MK_NULL"? ?callfile:string="MK_NULL"? ?callline:int32=-1?]
top check on error and if yes append an ErrorStackFormat to the error-message … → API: tclmkkernel_MkErrorC_Stack
[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) |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$err StackFormat ?callfunc:string="MK_NULL"? ?callfile:string="MK_NULL"? ?callline:int32=-1?
top append an ensemble of func, file and line to the error-message … → API: tclmkkernel_MkErrorC_StackFormat
[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) |
string [$inst ToString]
top String-Slot - returns the string representation of the inst … → API: tclmkkernel_MkObjectC_ToString
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.MkLogFileC CLASS | |||
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 … | ||
new | 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 … |
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) |
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 …
MkLogFileC - Export class functions …
(static) MkLogFileC [MkLogFileC HandleResolve netHdl:MK_HDL]
top Handle-Resolve-Slot - return a MkLogFileC from netHdl or "MK_NULL"
if invalid… → API: tclmkkernel_MkLogFileC_HandleResolve
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 MK_HDL [$lfl HandleGet]
top Handle-Get-Slot - returns a export-hdl to the MkLogFileC useable for external storage → API: tclmkkernel_MkObjectC_HandleGet
The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the MkLogFileHandleResolve.
By default, the export-hdl is initialized to "0", which is equivalent to does not exist. This function returns a non-zero and unique export-hdl that is recreated if necessary.
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) MkLogFileC [MkLogFileC Instances]
top get head-instance from linked-list of MkLogFileS type … → API: tclmkkernel_MkLogFileC_Instances
The head-instance is the last instance created.
MkLogFileC [$lfl Next]
top get next instance from linked-list of MkLogFileS type → API: tclmkkernel_MkLogFileC_Next
MkLogFileC [$lfl Prev]
top get previous instance from linked-list of MkLogFileS type → API: tclmkkernel_MkLogFileC_Prev
MkLogFileC - Misc class functions …
(static) MkLogFileC [MkLogFileC GetNull]
top Null-Slot - return a MkLogFileC typed NULL
instance … → API: tclmkkernel_MkLogFileC_GetNull
C-API: MkLogFileC_TOR_C_API - MkLogFileC - various functions to 'create and delete' a MkLogFileS …
(constructor,static) MkLogFileC [MkLogFileC Open errfmt:MkObjectC file:string]
top open the log-file in append mode … → API: tclmkkernel_MkLogFileC_Open
The new instance belongs to the caller and may have to be released if necessary. A manual release using LogFileClose is always possible, but the instance can no longer be used afterwards.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errfmt | a managed object used to identify and format the error-message |
[in] | file | the filename to open |
[out] | lfh_out | returns |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
(constructor,static) MkLogFileC [MkLogFileC new errfmt:MkObjectC file:string]
top open the log-file in append mode … → API: tclmkkernel_MkLogFileC_new
The new instance belongs to the caller and may have to be released if necessary. A manual release using LogFileClose is always possible, but the instance can no longer be used afterwards.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | errfmt | a managed object used to identify and format the error-message |
[in] | file | the filename to open |
[out] | lfh_out | returns |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
"MK_NULL"
(destructor) $lfh Close
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 …
string [$lfl GetFile]
top get the log-file … → API: tclmkkernel_MkLogFileC_GetFile
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
$lfl WriteC text:string
top write to log-file … → API: tclmkkernel_MkLogFileC_WriteC
[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 |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
MkRuntimeC CONFIG | |||
GetDebug | get the MkRuntimeS::debug value … | ||
GetErrorCode | return MkErrorS::code from a given MkRuntimeC … | ||
GetIsSilent | get the MkRuntimeS::isSilent value … | ||
GetLogfile | get the MkRuntimeS::logfile value … | ||
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 tclmkkernel 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
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) int32 [MkRuntimeC GetDebug]
top get the MkRuntimeS::debug value … → API: tclmkkernel_MkRuntimeC_GetDebug
(static) MkErrorE [MkRuntimeC GetErrorCode]
top return MkErrorS::code from a given MkRuntimeC … → API: tclmkkernel_MkRuntimeC_GetErrorCode
(static) bool [MkRuntimeC GetIsSilent]
top get the MkRuntimeS::isSilent value … → API: tclmkkernel_MkRuntimeC_GetIsSilent
(static) string [MkRuntimeC GetLogfile]
top get the MkRuntimeS::logfile value … → API: tclmkkernel_MkRuntimeC_GetLogfile
(static) MkRuntimeC SetDebug dbg:int32
top set the MkRuntimeS::debug value … → API: tclmkkernel_MkRuntimeC_SetDebug
(static) MkRuntimeC SetIsSilent silent:bool
top set the MkRuntimeS::isSilent value … → API: tclmkkernel_MkRuntimeC_SetIsSilent
(static) MkRuntimeC SetLogfile logfile:string
top set the MkRuntimeS::logfile value and cleanup old value … → API: tclmkkernel_MkRuntimeC_SetLogfile
[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 …
$rt Log ?fmtobj:MkObjectC="MK_NULL"? ?debug:int32=0? ?callfunc:string="MK_NULL"? ?lvl:int32=0?
top log the MkRuntimeC … → API: tclmkkernel_MkObjectC_Log
[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_tcl_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 Tcl binary.
Example from server.tcl
→ read a buffer-object and convert single-char-type-identifer to string.
method Ot_BUF2 {} { my SendSTART foreach i {1 2 3} { set buf [my ReadBUF] my SendSTR [$buf GetType1] my SendBUF $buf $buf Delete } my SendRETURN }
libmkkernel, ccmkkernel, csmkkernel, javamkkernel, gomkkernel, pymkkernel, rbmkkernel, tclmkkernel, perlmkkernel, phpmkkernel
Tcl, unix, socket, message, msgque