Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom freemarker templates are confusing. #105

Open
dlurton opened this issue Oct 15, 2021 · 1 comment
Open

Custom freemarker templates are confusing. #105

dlurton opened this issue Oct 15, 2021 · 1 comment

Comments

@dlurton
Copy link
Member

dlurton commented Oct 15, 2021

For example, the custom target exposes a boolean property CElement.isVariadic. But the name appears to only be accessible as variadic instead. I.e. ${element.isVariadic} does not work as expected, but ${element.variadic} does.

There's things at play which make accessing boolean properties prefixed with "is" very confusing.

Firstly, there is partly due to an idiom of Apache Freemarker. This behavior is not well described in their manual. The best part of their manual that I can find about it is here.

Basically, element.variadic calls element.isVariadic(). or element.getVariadic(), or element.variadic() depending on which is available.

Addtionally, some inconsistencies in the Java API exposed by Kotlin makes this even worse. Basically, the following Kotlin class:

class X(val foo: Int, val isBar: Boolean)

Kotlin generates a .class file with the following Java API:

public final class X {
   private final int foo;
   private final boolean isBar;

   public final int getFoo() {
      return this.foo;
   }

   public final boolean isBar() {
      return this.isBar;
   }

   public X(int foo, boolean isBar) {
      this.foo = foo;
      this.isBar = isBar;
   }
}

Note that, for foo, a getFoo() method is generated, but, for isBar, only an isBar method is generated.

@dlurton
Copy link
Member Author

dlurton commented Oct 19, 2021

One solution to this would be to define these classes using Java instead of Kotlin...

Another solution might be to see if we can turn off the name mangling feature of FreeMarker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant