theKernel 10.0
Loading...
Searching...
No Matches
csmkkernel.MkObjectC Class Reference

MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-Kernel (PLMK) class … More...

+ Inheritance diagram for csmkkernel.MkObjectC:

Classes

struct  MkCall
 

Public Member Functions

delegate void MkObjectDeleteSCB (string typeName, int typeHdl, int objHdl)
 implements the csmkkernel API object: public version from MkObjectDeleteSCB as method
 
void ErrorCheck (MkErrorE err)
 
bool Check ()
 
string ToNameOfClass ()
  C#: string obj.ToNameOfClass() C-API
Class-Slot - returns the C#-Class-Name of the obj as string
 
void HandleDelete ()
  C#: netObj.HandleDelete() C-API
Handle-Delete-Slot - delete a netObj from handle-storage …
 
bool HandleExists ()
  C#: bool obj.HandleExists() C-API
check if obj has already a handle defined…
 
Int32 HandleGet ()
  C#: Int32 obj.HandleGet() C-API
Handle-Get-Slot - returns a export-hdl to the MkObjectC useable for external storage
 
Int32 HandleGetOfType ()
  C#: Int32 obj.HandleGetOfType() C-API
Export-Slot - returns typeHdl of the obj .
 
Int32 HandleGetOr0 ()
  C#: Int32 obj.HandleGetOr0() C-API
return export-hdl or 0 in not created…
 
MkObjectC Next ()
  C#: MkObjectC obj.Next() C-API
get next instance from linked-list of MkObjectS type
 
MkObjectC Prev ()
  C#: MkObjectC obj.Prev() C-API
get previous instance from linked-list of MkObjectS type
 
void DbgDump (string message="var", [CallerMemberName]string callfunc=null)
  C#: obj.DbgDump(string message = "var", [CallerMemberName]string callfunc = null) C-API
debug: Dump a instance to stderr with LNG and MQ internal data…
 
void DbgL (string message, int debug=0, [CallerMemberName]string callfunc=null, int lvl=0)
  C#: fmtobj.DbgL(string message, int debug = 0, [CallerMemberName]string callfunc = null, int lvl = 0) C-API
debug: write a instance-marker to the MkLogFileC (default: stderr) using the fmtobj as prefix …
 
void DbgLogC ([CallerMemberName]string callfunc=null)
  C#: obj.DbgLogC([CallerMemberName]string callfunc = null) C-API
debug: write a short-obj-summary to MkLogFileC (default: stderr) …
 
void DbgO ([CallerMemberName]string callfunc=null)
  C#: obj.DbgO([CallerMemberName]string callfunc = null) C-API
debug: write the object-details to MkLogFileC (default: stderr) …
 
void DbgSTACK (int skip=0, int num=-1, [CallerMemberName]string callfunc=null)
  C#: fmtobj.DbgSTACK(int skip = 0, int num = -1, [CallerMemberName]string callfunc = null) C-API
debug: write the stack-trace to MkLogFileC (default: stderr) …
 
void LogC (string message, int debug=0, [CallerMemberName]string callfunc=null)
  C#: fmtobj.LogC(string message, int debug = 0, [CallerMemberName]string callfunc = null) C-API
write a logging-message to MkLogFileC (default: stderr) using the internal format …
 
void LogHEX (string callfunc, byte[] data)
  C#: fmtobj.LogHEX(string callfunc, byte[] data) C-API
log binaray data as HEX into the MkLogFileC (default: stderr) …
 
void Log (MkObjectC fmtobj=null, int debug=0, [CallerMemberName]string callfunc=null, int lvl=0)
  C#: obj.Log(MkObjectC fmtobj = null, int debug = 0, [CallerMemberName]string callfunc = null, int lvl = 0) C-API
Log-Slot - log a summary of an object to the MkLogFileC (default: stderr) target …
 
void LogLong (MkObjectC fmtobj=null, int debug=0, [CallerMemberName]string callfunc=null, int lvl=0)
  C#: obj.LogLong(MkObjectC fmtobj = null, int debug = 0, [CallerMemberName]string callfunc = null, int lvl = 0) C-API
log the MkObjectS verbose into the MkLogFileC (default: stderr) …
 
void LogShort (MkObjectC fmtobj=null, int debug=0, [CallerMemberName]string callfunc=null, int lvl=0)
  C#: obj.LogShort(MkObjectC fmtobj = null, int debug = 0, [CallerMemberName]string callfunc = null, int lvl = 0) C-API
log the MkObjectS into the MkLogFileC (default: stderr) …
 
void LogType (MkObjectC fmtobj=null, int debug=0, [CallerMemberName]string callfunc=null, int lvl=0)
  C#: obj.LogType(MkObjectC fmtobj = null, int debug = 0, [CallerMemberName]string callfunc = null, int lvl = 0) C-API
log the tyoe of the MkObjectS into the MkLogFileC (default: stderr) …
 
MkErrorC ErrorCatch (Exception exception=null, [CallerMemberName]string callfunc=null)
  C#: MkErrorC obj.ErrorCatch(Exception exception = null, [CallerMemberName]string callfunc = null) C-API
convert a programming-language-error into an csmkkernel error …
 
MkErrorC ToError ()
  C#: MkErrorC obj.ToError() C-API
Error-Slot - return an error-object pre initialized with obj data.
 
bool IsNull ()
  C#: bool obj.IsNull() C-API
ckeck if the object is null
 
string ToName ()
  C#: string obj.ToName() C-API
Info-Slot - returns brief information about the obj as a string
 
string ToNameOfType ()
  C#: string obj.ToNameOfType() C-API
Type-Slot - returns the LibMkKernel-Type-Name of the obj as a string
 
override string ToString ()
  C#: string inst.ToString() C-API
String-Slot - returns the string representation of the inst
 
int RefGet ()
 MkRefGetP
 
void SysKill (int pid, int signal)
 MkSysKill
 
int SysGetPid ()
 MkSysGetPid
 
void Dispose ()
  C#: [destructor] obj.Dispose() C-API
Dispose-Slot - untie the connection between the Native-C#-Instance and the csmkkernel-Instance.
 
void Delete ()
  C#: [destructor] obj.Delete() C-API
Delete-Slot - delete an instance.
 

Static Public Member Functions

static MkObjectC MkObjectC_ObjNew (IntPtr hdl)
 
static IntPtr getOBJ (string cls, MkObjectC obj)
 
static IntPtr getOBJ_null_allow (MkObjectC obj)
 
static MkObjectC HandleResolve (Int32 netHdl)
  C#: [static] MkObjectC MkObjectC.HandleResolve(Int32 netHdl) C-API
Handle-Resolve-Slot - return a MkObjectC from netHdl or null if invalid…
 
static void HandleDeleteByNetHdl (Int32 netHdl)
  C#: [static] MkObjectC.HandleDeleteByNetHdl(Int32 netHdl) C-API
Handle-Delete-Slot - delete a netHdl from handle-storage …
 
static MkObjectC Instances ()
  C#: [static] MkObjectC MkObjectC.Instances() C-API
get head-instance from linked-list of MkObjectS type …
 
static MkObjectC GetNull ()
  C#: [static] MkObjectC MkObjectC.GetNull() C-API
Null-Slot - return a MkObjectC typed NULL instance …
 
static void DbgM (string message, int debug=0, [CallerMemberName]string callfunc=null, int lvl=0)
  C#: [static] MkObjectC.DbgM(string message, int debug = 0, [CallerMemberName]string callfunc = null, int lvl = 0) C-API
debug: write a static-marker to the MkLogFileC (default: stderr) …
 
static int SysHashI32 (string key, int length=-1)
 MkSysHashI32
 
static string SysHashSTR (string key, int length=-1)
 MkSysHashSTR
 
static void DeleteCallbackCleanup (string ident)
  C#: [static] MkObjectC.DeleteCallbackCleanup(string ident) C-API
cleanup the DeleteCallback installed with MkObjectDeleteCallbackSetup
 
static void DeleteCallbackSetup (string ident, MkObjectDeleteSCB callback=null, string filter=null)
  C#: [static] MkObjectC.DeleteCallbackSetup(string ident, MkObjectDeleteSCB callback = null, string filter = null) C-API
Create/Delete the instance-delete-callback
 
static int getPId ()
 
static int getTId ()
 
static string getStackTrace (int level=2)
 
static string getCallerProc (int level=2)
 
static int getCallerLine (int level=2)
 
static string getCallerFile (int level=2)
 

Protected Member Functions

 MkObjectC (IntPtr obj)
 
 MkObjectC ()
 
virtual void Dispose (bool disposing)
 Support IDisposable.
 

Static Protected Member Functions

static object atomObjNew (Type type, ConstructorInfo ctor, IntPtr obj)
 
static object atomObjCreate (Type type, ConstructorInfo ctor, IntPtr obj)
 
static IntPtr atomSelfCreate (ConstructorInfo ctor, IntPtr obj, IntPtr env)
 
static object atomSelfNull (ConstructorInfo ctor)
 
static void atomSelfUnlink (IntPtr self, IntPtr env)
 
static ConstructorInfo getCtor (Type type)
 
static string Name (IntPtr mkrt, IntPtr obj)
  C#: string obj.ToName() C-API
Info-Slot - returns brief information about the obj as a string
 

Protected Attributes

IntPtr pmkrt = IntPtr.Zero
 

Properties

IntPtr hdl [get, set]
 
IntPtr hdl_null_allow [get, set]
 
IntPtr mkrt [get, set]
 

Detailed Description

MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-Kernel (PLMK) class …

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

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

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

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

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

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

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

See also
For the full documentation read: Managed-Object

Definition at line 135 of file MkObjectLog.cs.

Constructor & Destructor Documentation

◆ MkObjectC() [1/2]

csmkkernel.MkObjectC.MkObjectC ( IntPtr obj)
inlineprotected

Definition at line 121 of file MkObjectC.cs.

121 {
122 atomCreate(obj);
123 }

◆ MkObjectC() [2/2]

csmkkernel.MkObjectC.MkObjectC ( )
inlineprotected

Definition at line 125 of file MkObjectC.cs.

125{}

Member Function Documentation

◆ atomObjCreate()

static object csmkkernel.MkObjectC.atomObjCreate ( Type type,
ConstructorInfo ctor,
IntPtr obj )
inlinestaticprotected

Definition at line 202 of file MkObjectC.cs.

202 {
203//printTyp(obj, getCallerProc(3) + "-" + type.Name);
204 return ctor.Invoke(new Object[] {obj});
205 }

◆ atomObjNew()

static object csmkkernel.MkObjectC.atomObjNew ( Type type,
ConstructorInfo ctor,
IntPtr obj )
inlinestaticprotected

Definition at line 189 of file MkObjectC.cs.

189 {
190 IntPtr self = Mk.CsGetSelfPtr(obj);
191 if (self != IntPtr.Zero) {
192#if META_STRONG_REF
193 return GCHandle.FromIntPtr(self).Target;
194#else
195 object ret = GCHandle.FromIntPtr(self).Target;
196 if (ret != null) return ret;
197#endif
198 }
199 return ctor.Invoke(new Object[] {obj});
200 }
csmkkernel.MkKernel Mk
+ Here is the caller graph for this function:

◆ atomSelfCreate()

static IntPtr csmkkernel.MkObjectC.atomSelfCreate ( ConstructorInfo ctor,
IntPtr obj,
IntPtr env )
inlinestaticprotected

Definition at line 207 of file MkObjectC.cs.

207 {
208//printTyp(obj, getCallerProc(3) + "-" + type.Name);
209 if (obj == IntPtr.Zero) {
210 return IntPtr.Zero;
211 } else {
212 ctor.Invoke(new Object[] {obj});
213 return Mk.CsGetSelfPtr(obj);
214 }
215 }

◆ atomSelfNull()

static object csmkkernel.MkObjectC.atomSelfNull ( ConstructorInfo ctor)
inlinestaticprotected

Definition at line 217 of file MkObjectC.cs.

217 {
218//printTyp(obj, getCallerProc(3) + "-" + type.Name);
219 return ctor.Invoke(new Object[] {IntPtr.Zero});
220 }

◆ atomSelfUnlink()

static void csmkkernel.MkObjectC.atomSelfUnlink ( IntPtr self,
IntPtr env )
inlinestaticprotected

Definition at line 222 of file MkObjectC.cs.

222 {
223 var obj = (MkObjectC) GCHandle.FromIntPtr(self).Target;
224#if META_STRONG_REF
225 obj.hdl = IntPtr.Zero;
226#else
227 if (obj != null) obj.hdl = IntPtr.Zero;
228#endif
229 }

◆ Check()

bool csmkkernel.MkObjectC.Check ( )
inline

Definition at line 299 of file MkObjectC.cs.

299 {
300 return phdl != IntPtr.Zero;
301 }
+ Here is the caller graph for this function:

◆ Dispose()

virtual void csmkkernel.MkObjectC.Dispose ( bool disposing)
inlineprotectedvirtual

Support IDisposable.

Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed.

Definition at line 271 of file MkObjectC.cs.

272 {
273//printStack("Dispose");
274
275 // Check to see if Dispose has already been called.
276 if(phdl != IntPtr.Zero)
277 //if(hdl != IntPtr.Zero)
278 {
279 // If disposing equals true, dispose all managed
280 // and unmanaged resources.
281 if(disposing)
282 {
283 // Dispose managed resources. (not used here)
284 }
285
286 // Call the appropriate methods to clean up
287 // unmanaged resources here.
288 // If disposing is false,
289 // only the following code is executed.
290
291 // Note disposing has been done.
292 // hint: MkRefDecr->FactoryDelete->Dispose => double-invoke
293 atomDeleteSoft();
294 }
295 }

◆ getCallerFile()

static string csmkkernel.MkObjectC.getCallerFile ( int level = 2)
inlinestatic

Definition at line 47 of file MkObjectLog.cs.

47 {
48 var sf = new System.Diagnostics.StackFrame(level,true);
49 return sf.GetFileName();
50 }

◆ getCallerLine()

static int csmkkernel.MkObjectC.getCallerLine ( int level = 2)
inlinestatic

Definition at line 42 of file MkObjectLog.cs.

42 {
43 var sf = new System.Diagnostics.StackFrame(level);
44 return sf.GetFileLineNumber();
45 }

◆ getCallerProc()

static string csmkkernel.MkObjectC.getCallerProc ( int level = 2)
inlinestatic

Definition at line 37 of file MkObjectLog.cs.

37 {
38 var sf = new System.Diagnostics.StackFrame(level);
39 return sf.GetMethod().Name;
40 }

◆ getCtor()

static ConstructorInfo csmkkernel.MkObjectC.getCtor ( Type type)
inlinestaticprotected

Definition at line 244 of file MkObjectC.cs.

244 {
245 Type[] types = new Type[1];
246 types[0] = typeof(IntPtr);
247 ConstructorInfo constr = type.GetConstructor(
248 BindingFlags.Instance | BindingFlags.NonPublic, null, CallingConventions.HasThis, types, null
249 );
250 if (constr == null) {
251 throw new Exception("internal constructor '" + type.Name + " (IntPtr)' not found.");
252 }
253 return constr;
254 }

◆ getOBJ()

static IntPtr csmkkernel.MkObjectC.getOBJ ( string cls,
MkObjectC obj )
inlinestatic

Definition at line 109 of file MkObjectC.cs.

109 {
110 if (obj == null || obj.phdl == IntPtr.Zero) {
111 throw new NullReferenceException($"'{obj != null ? obj.GetType().Name : cls}' hdl is NULL");
112 }
113 return obj.phdl;
114 }
+ Here is the caller graph for this function:

◆ getOBJ_null_allow()

static IntPtr csmkkernel.MkObjectC.getOBJ_null_allow ( MkObjectC obj)
inlinestatic

Definition at line 116 of file MkObjectC.cs.

116 {
117 if (obj == null) return IntPtr.Zero;
118 return obj.phdl;
119 }
+ Here is the caller graph for this function:

◆ getPId()

static int csmkkernel.MkObjectC.getPId ( )
inlinestatic

Definition at line 25 of file MkObjectLog.cs.

25 {
26 return System.Diagnostics.Process.GetCurrentProcess().Id;
27 }

◆ getStackTrace()

static string csmkkernel.MkObjectC.getStackTrace ( int level = 2)
inlinestatic

Definition at line 33 of file MkObjectLog.cs.

33 {
34 return Environment.StackTrace;
35 }

◆ getTId()

static int csmkkernel.MkObjectC.getTId ( )
inlinestatic

Definition at line 29 of file MkObjectLog.cs.

29 {
30 return System.Threading.Thread.CurrentThread.ManagedThreadId;
31 }

◆ MkObjectC_ObjNew()

static MkObjectC csmkkernel.MkObjectC.MkObjectC_ObjNew ( IntPtr hdl)
inlinestatic

Definition at line 38 of file MkObjectC.cs.

38 {
39 return hdl != IntPtr.Zero ? (MkObjectC) atomObjNew(typeof(MkObjectC), ctor, hdl) : MK_NULL.Value;
40 }
static object atomObjNew(Type type, ConstructorInfo ctor, IntPtr obj)
Definition MkObjectC.cs:189
+ Here is the caller graph for this function:

◆ MkObjectDeleteSCB()

delegate void csmkkernel.MkObjectC.MkObjectDeleteSCB ( string typeName,
int typeHdl,
int objHdl )

implements the csmkkernel API object: public version from MkObjectDeleteSCB as method

◆ Name()

static string csmkkernel.MkObjectC.Name ( IntPtr mkrt,
IntPtr obj )
inlinestaticprotected

C#: string obj.ToName() C-API
Info-Slot - returns brief information about the obj as a string

Definition at line 257 of file MkObjectC.cs.

257 {
258 return Marshal.PtrToStringAnsi(Mk.MkObjectToName(mkrt,obj));
259 }

Member Data Documentation

◆ pmkrt

IntPtr csmkkernel.MkObjectC.pmkrt = IntPtr.Zero
protected

Definition at line 70 of file MkObjectC.cs.

Property Documentation

◆ hdl

IntPtr csmkkernel.MkObjectC.hdl
getset

Definition at line 76 of file MkObjectC.cs.

76 {
77 get {
78 if (phdl == IntPtr.Zero) throw new NullReferenceException($"'{this.GetType().Name}' hdl is NULL");
79 return phdl;
80 }
81 set {
82 phdl = value;
83 }
84 }

◆ hdl_null_allow

IntPtr csmkkernel.MkObjectC.hdl_null_allow
getset

Definition at line 86 of file MkObjectC.cs.

86 {
87 get {
88 return phdl;
89 }
90 set {
91 phdl = value;
92 }
93 }

◆ mkrt

IntPtr csmkkernel.MkObjectC.mkrt
getsetprotected

Definition at line 95 of file MkObjectC.cs.

95 {
96 get {
97/*
98 if (pmkrt != Mk.MkRuntimeGet()) {
99 Console.Error.WriteLine($"runtime invalid: {pmkrt} != {Mk.MkRuntimeGet()}");
100 }
101*/
102 return pmkrt;
103 }
104 set {
105 pmkrt = value;
106 }
107 }

The documentation for this class was generated from the following files: