2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-07-14 23:38:02 +01:00
< meta name = "generator" content = "ZealOS V0.08" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-03 05:07:57 +01:00
< a name = "l1" > < / a > < span class = cF2 > /*Demonstrates class meta data.< / span > < span class = cF0 >
< a name = "l2" > < / a > < / span > < span class = cF2 > Basically, we make use of the compiler's< / span > < span class = cF0 >
< a name = "l3" > < / a > < / span > < span class = cF2 > data about a class. We can add to the< / span > < span class = cF0 >
< a name = "l4" > < / a > < / span > < span class = cF2 > compilers data arbitrary items, either string or< / span > < span class = cF0 >
< a name = "l5" > < / a > < / span > < span class = cF2 > or int or F64 (if you typecast).< / span > < span class = cF0 >
< a name = "l6" > < / a >
< a name = "l7" > < / a > < / span > < span class = cF2 > This stuff is not high performance.< / span > < span class = cF0 >
< a name = "l8" > < / a > < / span > < span class = cF2 > Don't get carried away -- it might be slow.< / span > < span class = cF0 >
< a name = "l9" > < / a > < / span > < span class = cF2 > */< / span > < span class = cF0 >
< a name = "l10" > < / a >
< a name = "l11" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > RankOut(< / span > < span class = cF9 > I64< / span > < span class = cF0 > i)
< a name = "l12" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l13" > < / a > < / span > < span class = cF6 > " %z" < / span > < span class = cF0 > , i, < / span > < span class = cF6 > " Cadet\0Ensign\0Captain\0Admiral\0President\0" < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l14" > < / a > }
< a name = "l15" > < / a >
< a name = "l16" > < / a > < / span > < span class = cF1 > class< / span > < span class = cF0 > Test1Struct
< a name = "l17" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l18" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > age print_str < / span > < span class = cF6 > " %2d" < / span > < span class = cF0 > default_val < / span > < span class = cFE > 38< / span > < span class = cF0 > ;
< a name = "l19" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > color default_val < / span > < span class = cF3 > RED< / span > < span class = cF0 > ; < / span > < span class = cF2 > //Accepts expressions< / span > < span class = cF0 >
< a name = "l20" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > rank print_str < / span > < span class = cF6 > " %1d" < / span > < span class = cF0 > default_val < / span > < span class = cFE > 6< / span > < span class = cF0 > /< / span > < span class = cFE > 2< / span > < span class = cF0 > output_fun & RankOut;
2021-07-03 05:07:57 +01:00
< a name = "l21" > < / a > };
< a name = "l22" > < / a >
< a name = "l23" > < / a > < / span > < span class = cF1 > class< / span > < span class = cF0 > Test2Struct
< a name = "l24" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l25" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > age print_str < / span > < span class = cF6 > " %2d" < / span > < span class = cF0 > default_val < / span > < span class = cFE > 38< / span > < span class = cF0 > percentile < / span > < span class = cFE > 54< / span > < span class = cF0 > .< / span > < span class = cFE > 20< / span > < span class = cF0 > ;
< a name = "l26" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > rank print_str < / span > < span class = cF6 > " %1d" < / span > < span class = cF0 > default_val < / span > < span class = cFE > 5< / span > < span class = cF0 > ;
< a name = "l27" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > serial_num print_str < / span > < span class = cF6 > " %6d" < / span > < span class = cF0 > default_val < / span > < span class = cFE > 123456< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l28" > < / a > };
< a name = "l29" > < / a >
< a name = "l30" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > DumpStruct(< / span > < span class = cF1 > U8< / span > < span class = cF0 > *_d, < / span > < span class = cF1 > U8< / span > < span class = cF0 > *class_name=< / span > < span class = cF1 > lastclass< / span > < span class = cF0 > )
2021-07-05 01:57:09 +01:00
< a name = "l31" > < / a > {< / span > < span class = cF2 > //lastclass is keyword.< / span > < span class = cF0 > < / span > < span class = cF2 > See < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/LastClass.CC.html#l1" > < span class = cF4 > ::/Demo/LastClass.CC< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l32" > < / a > < / span > < span class = cF9 > CHashClass< / span > < span class = cF0 > *tmpc = < / span > < span class = cF5 > HashFind< / span > < span class = cF0 > (class_name, < / span > < span class = cF5 > Fs< / span > < span class = cF0 > -> hash_table, < / span > < span class = cF3 > HTT_CLASS< / span > < span class = cF0 > );
< a name = "l33" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *print_str;
< a name = "l34" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > *q, default_val;
< a name = "l35" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > (*fp_output_fun)(< / span > < span class = cF9 > I64< / span > < span class = cF0 > i);
< a name = "l36" > < / a > < / span > < span class = cF1 > F64< / span > < span class = cF0 > percentile;
< a name = "l37" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!tmpc)
< a name = "l38" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > ;
< a name = "l39" > < / a > < / span > < span class = cF9 > CMemberList< / span > < span class = cF0 > *ml;
2021-07-03 05:07:57 +01:00
< a name = "l40" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l41" > < / a > ml = tmpc-> member_list_and_root;
< a name = "l42" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (ml)
< a name = "l43" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l44" > < / a > < / span > < span class = cF6 > " %s:" < / span > < span class = cF0 > , ml-> str;
2021-07-03 05:07:57 +01:00
< a name = "l45" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l46" > < / a > < / span > < span class = cF2 > //All our items are I64's.< / span > < span class = cF0 > < / span > < span class = cF2 > If you want, you can check< / span > < span class = cF0 >
2021-07-05 01:57:09 +01:00
< a name = "l47" > < / a > < / span > < span class = cF2 > //the data type of the member var. See < / span > < a href = "https://tomawezome.github.io/ZealOS/System/Debug.CC.html#l216" > < span class = cF4 > ClassRep< / span > < / a > < span class = cF2 > ().< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l48" > < / a > q = _d + ml-> < / span > < span class = cF1 > offset< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l49" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l50" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (print_str = < / span > < span class = cF5 > MemberMetaData< / span > < span class = cF7 > (< / span > < span class = cF6 > " print_str" < / span > < span class = cF0 > , ml< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l51" > < / a > < / span > < span class = cF6 > " " < / span > < span class = cF0 > print_str, *q;
2021-07-03 05:07:57 +01:00
< a name = "l52" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l53" > < / a > < / span > < span class = cF2 > //This is slightly ambiguous -- if no meta is present it will return zero.< / span > < span class = cF0 >
< a name = "l54" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (default_val = < / span > < span class = cF5 > MemberMetaData< / span > < span class = cF7 > (< / span > < span class = cF6 > " default_val" < / span > < span class = cF0 > , ml< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l55" > < / a > < / span > < span class = cF6 > " default:%d" < / span > < span class = cF0 > , default_val;
2021-07-03 05:07:57 +01:00
< a name = "l56" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l57" > < / a > < / span > < span class = cF2 > //This corrects for the ambiguity, allowing zero percentile.< / span > < span class = cF0 >
< a name = "l58" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (< / span > < span class = cF5 > MemberMetaFind< / span > < span class = cF7 > (< / span > < span class = cF6 > " percentile" < / span > < span class = cF0 > , ml< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l59" > < / a > {< / span > < span class = cF2 > //check if it exists< / span > < span class = cF0 >
2021-07-11 22:47:19 +01:00
< a name = "l60" > < / a > < / span > < span class = cF2 > //We could use the < / span > < a href = "https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l928" > < span class = cF4 > CMemberListMeta< / span > < / a > < span class = cF2 > structure returned by< / span > < span class = cF0 >
2021-07-05 01:57:09 +01:00
< a name = "l61" > < / a > < / span > < span class = cF2 > //< / span > < a href = "https://tomawezome.github.io/ZealOS/Compiler/LexLib.CC.html#l64" > < span class = cF4 > MemberMetaFind< / span > < / a > < span class = cF2 > () and save a search.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l62" > < / a > percentile = < / span > < span class = cF5 > MemberMetaData< / span > < span class = cF0 > (< / span > < span class = cF6 > " percentile" < / span > < span class = cF0 > , ml)(< / span > < span class = cF1 > F64< / span > < span class = cF0 > );
< a name = "l63" > < / a > < / span > < span class = cF6 > " percentile: %5.2f" < / span > < span class = cF0 > , percentile;
< a name = "l64" > < / a > }
2021-07-03 05:07:57 +01:00
< a name = "l65" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l66" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (fp_output_fun = < / span > < span class = cF5 > MemberMetaData< / span > < span class = cF7 > (< / span > < span class = cF6 > " output_fun" < / span > < span class = cF0 > , ml< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l67" > < / a > (*fp_output_fun)(*q);
< a name = "l68" > < / a > < / span > < span class = cF6 > '\n'< / span > < span class = cF0 > ;
< a name = "l69" > < / a > ml = ml-> next;
< a name = "l70" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l71" > < / a > }
< a name = "l72" > < / a >
< a name = "l73" > < / a > Test1Struct t1;
< a name = "l74" > < / a > t1.age = < / span > < span class = cFE > 44< / span > < span class = cF0 > ;
< a name = "l75" > < / a > t1.rank = < / span > < span class = cFE > 3< / span > < span class = cF0 > ;
< a name = "l76" > < / a >
< a name = "l77" > < / a > DumpStruct(& t1);
< a name = "l78" > < / a >
< a name = "l79" > < / a > Test2Struct t2;
2021-07-04 23:11:34 +01:00
< a name = "l80" > < / a > t2.age = < / span > < span class = cFE > 22< / span > < span class = cF0 > ;
< a name = "l81" > < / a > t2.rank = < / span > < span class = cFE > 2< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l82" > < / a > t2.serial_num = < / span > < span class = cFE > 55555< / span > < span class = cF0 > ;
< a name = "l83" > < / a >
< a name = "l84" > < / a > DumpStruct(& t2);
< / span > < / pre > < / body >
< / html >