Thanks for the helpful feedback.
Sorry for my late reply.
JavaScript and Python work (I am guessing PHP but I did not try).
(based on [Haxe 4.0.0-preview.3 - Haxe - The Cross-platform Toolkit](Haxe 4.0.0-preview.3 - Haxe - The Cross-platform Toolkit Deprecations )
When I try C++ or C# or Java the Haxe compiler finishes but the language compilers give various Errors.
I tried to make a little utility class to help anyone else that wants to have Comments survive. I tried using the @remove Haxe flag but no success.
I expect I am missing something about controlling the Haxe compiler here.
To Reproduce:
If you have your Main in a separate file then I expect you will find the same Errors I did.
/*
* Comments.hx This supports Comments in various Haxe target programming languages
*
* THIS ONLY SEEMS TO WORK FOR JAVASCRIPT AND PYTHON (maybe PHP, I did not test)
*
* OTHER target languages like: C++, C# and Java FAIL
* Haxe compiler finishes but language specific compiler haves various errors.
*/
// Here I use the same package name as where this code is used. Change to fit your needs.
package lg4;
/**
* @author Randy Maxwell
*/
@:remove
class Comments
{
// Helper to put Comments in output target languages
// This gets called during a Haxe compile
//
// public static var comment_call_count = 0;
// public static var comment_multiline_call_count = 0;
@:remove
public static inline function comment( multiline : Bool, message : String )
{
// var retVal = "UNKNOWN target Language. ";
// comment_call_count++;
// if ( multiline )
// comment_multiline_call_count++;
// To find number of single line comments use
// comment_call_count - comment_multiline_call_count
#if (haxe_ver >= 4.0)
#if cpp // C++
if ( multiline )
return untyped __cpp__("/* {0} */", message);
else
return untyped __cpp__("// {0}", message);
#elseif cs // C#
if ( multiline )
return untyped __cs__("/* {0} */", message);
else
return untyped __cs__("// {0}", message);
#elseif fl // SWF ? maybe commonly called flash ?
if ( multiline )
return fl.Syntax.code("/* {0} */", message);
else
return fl.Syntax.code("// {0}", message);
#elseif hl // HashLink NOT SURE if HashLink even HAS comments ?
if ( multiline )
return hl.Syntax.code("/* {0} */", message);
else
return hl.Syntax.code("// {0}", message);
#elseif java
if ( multiline )
return java.Syntax.code("/* {0} */", message);
else
return java.Syntax.code("// {0}", message);
#elseif js // JavaScript
if ( multiline )
return js.Syntax.code("/* {0} */", message);
else
return js.Syntax.code("// {0}", message);
#elseif lua
if ( multiline )
return lua.Syntax.code("/* {0} */", message);
else
return lua.Syntax.code("// {0}", message);
#elseif neko // NOT SURE if Neko even HAS comments ?
if ( multiline )
return neko.Syntax.code("/* {0} */", message);
else
return neko.Syntax.code("// {0}", message);
#elseif php
if ( multiline )
return php.Syntax.code("/* {0} */", message);
else
return php.Syntax.code("// {0}", message);
#elseif python
if ( multiline ) // uses 3 double Quote characters before and after
return python.Syntax.code("\"\"\" {0} \"\"\"", message);
else
return python.Syntax.code("# {0}", message);
#else
// return "UNKNOWN target Language. ";
#end
#end
#if (haxe_ver < 4.0)
// User older syntax from Haxe
#if cpp // C++
if ( multiline )
return untyped __cpp__("/* {0} */", message);
else
return untyped __cpp__("// {0}", message);
#elseif cs // C#
if ( multiline )
return untyped __cs__("/* {0} */", message);
else
return untyped __cs__("// {0}", message);
#elseif fl // SWF ? maybe commonly called flash ?
if ( multiline )
return untyped __fl__("/* {0} */", message);
else
return untyped __fl__("// {0}", message);
#elseif hl // HashLink NOT SURE if HashLink even HAS comments ?
if ( multiline )
return untyped __hl__("/* {0} */", message);
else
return untyped __hl__("// {0}", message);
#elseif java
if ( multiline )
return untyped __java__("/* {0} */", message);
else
return untyped __java__("// {0}", message);
#elseif js // JavaScript
if ( multiline )
return untyped __js__("/* {0} */", message);
else
return untyped __js__("// {0}", message);
#elseif lua
if ( multiline )
return untyped __js__("/* {0} */", message);
else
return untyped __js__("// {0}", message);
#elseif neko // NOT SURE if Neko even HAS comments ?
if ( multiline )
return untyped __neko__("/* {0} */", message);
else
return untyped __neko__("// {0}", message);
#elseif php
if ( multiline )
return untyped __php__("/* {0} */", message);
else
return untyped __php__("// {0}", message);
#elseif python
if ( multiline ) // uses 3 double Quote characters before and after
return untyped __python__("\"\"\" {0} \"\"\"", message);
else
return untyped __python__("# {0}", message);
#else
// return "UNKNOWN target Language. ";
#end
#end
// return retVal;
}
}
Thanks for you help!