www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Any way to print compile-time generated code?

reply "Chris Williams" <yoreanon-chrisw yahoo.co.jp> writes:
I'm toying with the dproto library and have encountered an issue 
where I can't remove items from a "repeated" list of items. I'd 
like to see what the mixins are producing in terms of actual D 
code, so that I can figure out how I can correctly try to delete 
an entry or find the code that's generating the array and add 
whatever corrections are necessary to expose this ability.

Is there any way to push a mixin into a string, instead of into 
the code, or otherwise to view the output of the "preprocessor"?
Mar 10 2014
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
Change the mixin(x) line to pragma(msg, x);. It will then print 
out the generated string at compile time instead of mixing it in 
so you can take a look at it.
Mar 10 2014
parent "Chris Williams" <yoreanon-chrisw yahoo.co.jp> writes:
On Monday, 10 March 2014 at 18:25:10 UTC, Adam D. Ruppe wrote:
 Change the mixin(x) line to pragma(msg, x);. It will then print 
 out the generated string at compile time instead of mixing it 
 in so you can take a look at it.
That just gives me an error: source/app.d(29): Error: Cannot interpret ProtocolBufferFromString!"\x0a message Person {\x0a required string name = 1;\x0a required int32 id = 2;\x0a optional string email = 3;\x0a\x0a enum PhoneType {\x0a MOBILE = 0;\x0a HOME = 1;\x0a WORK = 2;\x0a }\x0a\x0a message PhoneNumber {\x0a required string number = 1;\x0a optional PhoneType type = 2 [default = HOME];\x0a }\x0a\x0a repeated PhoneNumber phone = 4;\x0a }\x0a" at compile time
Mar 10 2014