This is probably trivial or impossible Code Introspection...

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 19 12:52:54 PDT 2015


given some struct:

writeln("face.glyph.bitmap = ", face.glyph.bitmap);

which displays the following:

face.glyph.bitmap = FT_Bitmap(30, 25, 25, 4105948, 256, 2, 0, 
null)

Is there a way for D to display the variable names within the 
FT_Bitmap?

For instance, the following code snippet outputs:

foreach (i, member; face.glyph.bitmap.tupleof) {
     writefln("Member %s:", i);
     writefln("  type : %s", typeof(member).stringof);
     writefln("  value: %s", member);
}

Member 0:
   type : int
   value: 30
Member 1:
   type : int
   value: 25
// dot...dot...dot
Member 6:
   type : byte
   value: 0
Member 7:
   type : void*
   value: null

So I've got type and value of each member, but I want their 
actual names?

My first naive attempt was to try member.stringof but this just 
returns the string "member".    Thanks.



More information about the Digitalmars-d-learn mailing list