soywiz-archive / jtransc

Bytecode to source converting Java & Kotlin code into JavaScript, C++, D, C#, PHP, AS3, Dart and Haxe and run it everywhere. Also use JVM code in your favourite language as a library.
https://jtransc.soywiz.com/
Apache License 2.0
632 stars 67 forks source link

Need improve using extra vars in code #190

Closed ghost closed 7 years ago

ghost commented 7 years ago

Fail this, always return false

    @HaxeMethodBody(
        "{% if extra.showFPS %} return {{ extra.showFPS }};" +
        "{% else %} return false; {% end %}"
    )
    private static boolean isShowFPS() {
        return false;
    }

But this works

    @HaxeMethodBody(
        "{% if extra.showFPS %} return {{ extra.showFPS }}; {% end %}" +
        "{% if !extra.showFPS %} return false; {% end %}"
    )

We can add else ?

soywiz commented 7 years ago

Else should work AFAIK: https://github.com/jtransc/jtransc/blob/31181f104c0e224c1d610915163ac1c036f2953e/jtransc-utils/test/com/jtransc/template/MinitemplateTest.kt#L31

ghost commented 7 years ago

I don't know, maybe it work in JT, but in backend in not working. I try write test after finish test performance. In backend replace with 2 if, it works right now.

soywiz commented 7 years ago

Example: https://github.com/jtransc/gdx-backend-jtransc/pull/65/files#diff-ed96fdbf95732b5454ae4dba94ae1d10R74

I have verified this, I have a test and I'm working on the fix. I'll create a PR soon.

ghost commented 7 years ago

@soywiz looks as not fixed for me What i doing wrong? I test master-master-master for 3 projects, on windows and new mac. But i have not fps. program.xml is fine <window fps="1000" unless="js" /> in haxe

@:unreflective static  public   function getFramesPerSecond__I/*getFramesPerSecond*/():Int {
    return 60;
}

@:unreflective static  public   function isShowFPS__Z/*isShowFPS*/():Bool {
        return false;
}
soywiz commented 7 years ago

I have bumped to 0.6.5. While other projects are still in 0.6.4. Maybe that's the problem?

soywiz commented 7 years ago

Master in all three projects: https://github.com/jtransc/jtransc/blob/ef1f1809fd402dca31b29a6557bbb5855139b6ed/gradle.properties#L1 0.6.5 https://github.com/jtransc/gdx-backend-jtransc/blob/c2c77abdd0573a13af23aa85cc945d407ba029a0/gradle.properties#L1 0.6.4 https://github.com/jtransc/jtransc-examples/blob/216c1bb29459626ff8c26ded9b34ee8ef8c8a256/spine-demo/gradle.properties#L1 0.6.4

I have tested in windows, but I think that bug doesn't have any platform-specific issues so I think it is unlikely to happen.

ghost commented 7 years ago

Oh my god =))) i really stupid today =))))

soywiz commented 7 years ago

No problem. I had problems related to versions always :) Maybe I should do the PR for bumping versions in those projects just after is available at maven central

ghost commented 7 years ago

i will do update version right now, need for make global pure test for https://github.com/jtransc/gdx-backend-jtransc/issues/59

ghost commented 7 years ago

confirmed fixed.