I just added a compiler feature to support @debug comments. This causes the good.DEBUG bail-out to be added at the top of the method.
I tested and all uses are now removed. I don’t know how to add a compiler test for this, but we now have a universal way of declaring a method debug-only. The only issue I see is that we get this warning from the google compiler: WARNING - Parse error. illegal use of unknown JSDoc tag "debug"; ignoring it * @debug ^ Any suggestions on how to get rid of that warning? Harbs > On Sep 7, 2018, at 12:32 AM, Alex Harui <aha...@adobe.com.INVALID> wrote: > > Yeah, I think I saw that so I opted to try to use GOOG::DEBUG to eliminate > the trace in the method body. > > ROYALE::DISPLAYOBJECT is some other substitution that helps with code > clarity, although there is a chance it isn't needed anymore. > > -Alex > > On 9/6/18, 2:29 PM, "Harbs" <harbs.li...@gmail.com> wrote: > > In practice this is not quite happening because trace is output like this: > > org.apache.royale.utils.Language.trace = function(rest) { > rest = Array.prototype.slice.call(arguments, 0); > var /** @type {*} */ theConsole; > if (!goog.DEBUG) > return; > theConsole = goog.global["console"]; > if (theConsole === undefined) { > if (typeof(window) !== "undefined") { > theConsole = window.console; > } else if (typeof(console) !== "undefined") { > theConsole = console; > } > } > try { > if (theConsole && theConsole.log) { > theConsole.log.apply(theConsole, rest); > } > } catch (e) { > } > }; > > The first line does not get stripped out. If we could output that line > after the good.DEBUG check, it would get completely stripped out… > > org.apache.royale.utils.Language.trace = function(rest) { > if (!goog.DEBUG) > return; > rest = Array.prototype.slice.call(arguments, 0); > var /** @type {*} */ theConsole; > theConsole = goog.global["console"]; > if (theConsole === undefined) { > if (typeof(window) !== "undefined") { > theConsole = window.console; > } else if (typeof(console) !== "undefined") { > theConsole = console; > } > } > try { > if (theConsole && theConsole.log) { > theConsole.log.apply(theConsole, rest); > } > } catch (e) { > } > }; > > I wonder if we should add a @debug comment to methods which would cause > the compiler to automatically add if(!goog.DEBUG)return; to the first line of > the function… > > Harbs > > >> On Sep 7, 2018, at 12:20 AM, Harbs <harbs.li...@gmail.com> wrote: >> >> Language.trace has this at the beginning of the method: >> >> if (!goog.DEBUG) return; >> >> That should cause the google compiler to optimize out the entire function >> call. >> >>> On Sep 7, 2018, at 12:15 AM, Alex Harui <aha...@adobe.com.INVALID> wrote: >>> >>> How do trace statements get removed from function bodies in release mode? >>> >>> On 9/6/18, 2:13 PM, "Harbs" <harbs.li...@gmail.com> wrote: >>> >>> I see code like this in MXRoyale: >>> >>> if (GOOG::DEBUG) >>> trace("get_uid not implemented"); >>> >>> I’m not aware of a reason to use compiler definitions for this. >>> >>> trace statements get stripped out on release. Why do we need this? >>> >>> Harbs >>> >> > > >