18using System.Runtime.InteropServices;
23 public partial class MkObjectC {
26 return System.Diagnostics.Process.GetCurrentProcess().Id;
30 return System.Threading.Thread.CurrentThread.ManagedThreadId;
34 return Environment.StackTrace;
38 var sf =
new System.Diagnostics.StackFrame(level);
39 return sf.GetMethod().Name;
43 var sf =
new System.Diagnostics.StackFrame(level);
44 return sf.GetFileLineNumber();
48 var sf =
new System.Diagnostics.StackFrame(level,
true);
49 return sf.GetFileName();
52 internal static void getCallerStack(ref
string func, ref
string file, ref
int line,
int level=2) {
53 if (func !=
null && file !=
null && line != -1)
return;
54 var sf =
new System.Diagnostics.StackFrame(level,
true);
55 if (func ==
null) {func = sf.GetMethod().Name;}
56 if (file ==
null) {file = sf.GetFileName();}
57 if (line == -1) {line = sf.GetFileLineNumber();}
61 public static void SF(
string msg,
string name =
null,
int framelvl=1) {
63 Console.Error.WriteLine(
"[pid=" +
getPId() +
",tid=" +
getTId() +
",caller={0,-25}] -> {1,-15} = " + msg,
66 public static void printVal(IntPtr ptr,
string name=
null,
int framelvl=1) {
68 if (ptr == IntPtr.Zero) {
69 SF(
"null", name, framelvl+1);
71 SF(
"0x" + ptr.ToString(
"x"), name, framelvl+1);
74 public static void printVal(
byte bol,
string name=
null,
int framelvl=1) {
76 SF(bol.ToString(), name, framelvl+1);
78 public static void printVal(
bool bol,
string name=
null,
int framelvl=1) {
80 SF(bol.ToString(), name, framelvl+1);
82 public static void printVal(
object id,
string name=
null,
int framelvl=1) {
85 SF(
"type=null " +
id.GetType().
ToString(), name, framelvl+1);
87 SF(
"type=" +
id.GetType().
ToString() +
", value=" +
id, name, framelvl+1);
90 public static void printVal(
string id,
string name=
null,
int framelvl=1) {
94 public static void printTyp(IntPtr
id,
string name=
null,
int framelvl=1) {
96 if (
id == IntPtr.Zero) {
97 SF(
"NULL", name, framelvl+1);
99 SF(MkObjectC.Name(IntPtr.Zero,
id), name, framelvl+1);
103 public static void printStack(
string name=
null,
int framelvl=1) {
105 System.Diagnostics.StackTrace st =
new System.Diagnostics.StackTrace(
true);
106 for(
int i =framelvl; i< st.FrameCount; i++ )
110 System.Diagnostics.StackFrame sf = st.GetFrame(i);
111 SF(String.Format(
"[{0}] {1}",i ,sf.GetMethod()), name, framelvl+1);
114 public static void printTyp(MkObjectC obj,
string name=
null,
int framelvl=1) {
115 printTyp(obj.hdl,name,framelvl+1);
117 public static void M0(
string name=
"M0") { SF(
"M0000000000000",name,2); }
118 public static void M1(
string name=
"M1") { SF(
"M1111111111111",name,2); }
119 public static void M2(
string name=
"M2") { SF(
"M2222222222222",name,2); }
120 public static void M3(
string name=
"M3") { SF(
"M3333333333333",name,2); }
121 public static void M4(
string name=
"M4") { SF(
"M4444444444444",name,2); }
122 public static void M5(
string name=
"M5") { SF(
"M5555555555555",name,2); }
123 public static void M6(
string name=
"M6") { SF(
"M6666666666666",name,2); }
124 public static void M7(
string name=
"M7") { SF(
"M7777777777777",name,2); }
125 public static void M8(
string name=
"M8") { SF(
"M8888888888888",name,2); }
126 public static void M9(
string name=
"M9") { SF(
"M9999999999999",name,2); }
127 public static void MA(
string name=
"MA") { SF(
"MAAAAAAAAAAAAA",name,2); }
128 public static void MB(
string name=
"MB") { SF(
"MBBBBBBBBBBBBB",name,2); }
129 public static void MC(
string name=
"MC") { SF(
"MCCCCCCCCCCCCC",name,2); }
130 public static void MD(
string name=
"MD") { SF(
"MDDDDDDDDDDDDD",name,2); }
131 public static void ME(
string name=
"ME") { SF(
"MEEEEEEEEEEEEE",name,2); }
143 private void SL(
string txt) {
144 IntPtr caller_cstr = Marshal.StringToHGlobalAnsi(
getCallerProc());
145 IntPtr message_cstr = Marshal.StringToHGlobalAnsi(
this +
":\n" + txt +
"\n");
146 Mk.MkLogC(IntPtr.Zero,
hdl,message_cstr,0,caller_cstr);
147 Marshal.FreeHGlobal(message_cstr);
148 Marshal.FreeHGlobal(caller_cstr);
151 public void L0() { SL(
"0000000000000"); }
152 public void L1() { SL(
"1111111111111"); }
153 public void L2() { SL(
"2222222222222"); }
154 public void L3() { SL(
"3333333333333"); }
155 public void L4() { SL(
"4444444444444"); }
156 public void L5() { SL(
"5555555555555"); }
157 public void L6() { SL(
"6666666666666"); }
158 public void L7() { SL(
"7777777777777"); }
159 public void L8() { SL(
"8888888888888"); }
160 public void L9() { SL(
"9999999999999"); }
161 public void LA() { SL(
"AAAAAAAAAAAAA"); }
162 public void LB() { SL(
"BBBBBBBBBBBBB"); }
163 public void LC() { SL(
"CCCCCCCCCCCCC"); }
164 public void LE() { SL(
"EEEEEEEEEEEEE"); }
166 public void printL(
string name, Object val ) { SL(
"["+name +
":" + val +
"]"); }
MkKernel PACKAGE - The package is the toplevel structure of the Programming-Language-Micro-Kernel (PL...
MkObjectC - class known as obj or object is used as base-class type for a Programming-Language-Micro-...
static int getCallerLine(int level=2)
static string getCallerProc(int level=2)
static string getStackTrace(int level=2)
static string getCallerFile(int level=2)
override string ToString()
C#: string inst.ToString() → C-API String-Slot - returns the string representation of the inst ...