////////////////////////////////////////////////////////////////////
string txt = q{ int x; cpp_quote("#ifndef WIN16") typedef struct tagSIZE { LONG cx; LONG cy; } SIZE, *PSIZE, *LPSIZE; cpp_quote("#else // WIN16") cpp_quote("typedef struct tagSIZE") cpp_quote("{") cpp_quote(" INT cx;") cpp_quote(" INT cy;") cpp_quote("} SIZE, *PSIZE, *LPSIZE;") cpp_quote("#endif // WIN16") }; version(remove_pp) string exptxt = q{ int x; struct tagSIZE { LONG cx; LONG cy; } alias tagSIZE SIZE; alias tagSIZE *PSIZE; alias tagSIZE *LPSIZE; } ~ q{ // WIN16 }; else // !remove_pp string exptxt = q{ int x; version(all) /* #ifndef WIN16 */ { struct tagSIZE { LONG cx; LONG cy; } alias tagSIZE SIZE; alias tagSIZE *PSIZE; alias tagSIZE *LPSIZE; } else { // #else // WIN16 struct tagSIZE { INT cx; INT cy; } alias tagSIZE SIZE; alias tagSIZE *PSIZE; alias tagSIZE *LPSIZE; } // #endif // WIN16 }; testConvert(txt, exptxt);
////////////////////////////////////////////////////////////////////
string txt = " int x; #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else // MIDL_PASS typedef union _LARGE_INTEGER { struct { }; #endif //MIDL_PASS LONGLONG QuadPart; } LARGE_INTEGER; "; string exptxt = " int x; union _LARGE_INTEGER { struct { }; LONGLONG QuadPart; } alias _LARGE_INTEGER LARGE_INTEGER; "; testConvert(txt, exptxt, "winnt");
////////////////////////////////////////////////////////////////////
string txt = " #define convert() \\ hello #define noconvert(n,m) \\ hallo1 |\\ hallo2 "; string exptxt = " int convert() { return " ~ " hello; } // #define noconvert(n,m) \\ // hallo1 |\\ // hallo2 "; version(macro2template) exptxt = replace(exptxt, "int", "auto"); testConvert(txt, exptxt);
////////////////////////////////////////////////////////////////////