Fork me on GitHub

Home Forums JSweet Discussion How to customize a JavaScript file.

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by Avatar Anonymous 1 year, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3376
    Avatar
    Anonymous

    Hi,
    Successfully generate javascript file from java class file. But need customization some particular class. Is it possible ? If more clear suppose i have a java enum like:

    DemoEnum.java
    package pack;
    public enum DemoEnum
    {
    zero,
    one,
    }

    After transpile it will be like.
    DemoEnum.js
    var pack;
    (function (pack) {
    var DemoEnum;
    (function (DemoEnum) {
    DemoEnum[DemoEnum[“zero”] = 0] = “zero”;
    DemoEnum[DemoEnum[“one”] = 1] = “one”;
    })(DemoEnum = pack.DemoEnum || (pack.DemoEnum = {}));
    })(pack || (pack = {}));

    I need customization like:
    DemoEnum.js
    var pack;
    (function (pack) {
    var DemoEnum;
    (function (DemoEnum) {
    DemoEnum[DemoEnum[“zero”] = “zero”;
    DemoEnum[DemoEnum[“one”] = “one”;
    })(DemoEnum = pack.DemoEnum || (pack.DemoEnum = {}));
    })(pack || (pack = {}));

    Is it possible, If Possible what will be its procedure to change this.
    Thank You.

    #3377
    Avatar
    Louis Grignon
    Keymaster

    Hello,
    I am not quite sure about what you want to do, but did you check this documentation?
    https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md#extending-the-transpiler

    #3378
    Avatar
    Anonymous

    Hi,
    I saw this documentation, i did’t found any solution for my problem. Let me clear again.
    I want to generate JavaScript code from java code. I am using maven and pom.xml to generate javascript code. I am
    successfully generate javascript code. But i need some customization in javascript code.
    For example:
    A java Enum is there

    public enum DemoEnum
    {
    zero,
    one,
    }

    JavaScript code of above enum

    var DemoEnum;
    (function (DemoEnum) {
    DemoEnum[DemoEnum[“zero”] = 0] = “zero”;
    DemoEnum[DemoEnum[“one”] = 1] = “one”;
    })(DemoEnum = pack.DemoEnum || (pack.DemoEnum = {}));

    I want customization like Both line like:

    DemoEnum[DemoEnum[“zero”] = “zero”;
    DemoEnum[DemoEnum[“one”] = “one”;

    i want to generate a javascript file with my required customization.
    – is there anything need to change in pom.xml.
    – or any annotation is there for customization.

    Thank You.

    #3379
    Avatar
    Anonymous

    hi,
    i am waiting for your Answer.

    Thank you.

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘JSweet Discussion’ is closed to new topics and replies.