cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 160 forks source link

Issue with "candies/babylonjs--babylon/2.2.2-SNAPSHOT" #32

Closed ssatguru closed 8 years ago

ssatguru commented 8 years ago

"babylon.d.ts" has a

class Mesh

with method

clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): Mesh;

JSweet coompiles this to

Clone(....)

that is clone with capital C

See https://jsweet.org/apidocs/snapshots/org/jsweet/candies/babylonjs--babylon/2.2.2-SNAPSHOT/def/babylonjs/babylon/Mesh.html#Clone-java.lang.String-

The TS compiler fails with this error

ERROR: Property 'Clone' does not exist on type 'Mesh'. at org\ssatguru\babylonjs\TestIt.ts(73)

Here's a small program to Test

import def.babylonjs.babylon.Mesh;

public class Test {

    public static void main(String args[]){
        Mesh mesh = new Mesh();
        Mesh mesh2 = mesh.Clone("cloned mesh"); 
    }

}
renaudpawlak commented 8 years ago

Thanks for reporting this bug. I am on it.

renaudpawlak commented 8 years ago

Status update. I have improved the algorithm to detect clashes with Object methods so that clone does not need to be capitalized anymore (it is actually not clashing with the Object's clone method). So if you update your Babylonjs candy and rename Clone to clone, it should work. However, I am still working on it because I found some other problems. For example the Mesh empty constructor is not valid (there are other constructors that are actually valid and you should call new Mesh("name", null) for instance). I am trying to understand why this empty constructor is generated and fix it (amongst other details in the API generator).

You can use it right now but be aware that I am working on small details, so the APIs may slightly evolve to make it safer... nothing too impacting for sure anyway (most probably you will not even see it for your use cases).

ssatguru commented 8 years ago

Nice. I got around the clone issue by using .$get() method and casting that to jsweet Function class I missed the Mesh empty contructor issue :)

renaudpawlak commented 8 years ago

Really cool workaround hack. Well done ;)

renaudpawlak commented 8 years ago

Most issues are now solved. The empty constructor should now be protected (not visible). Thanks.

ssatguru commented 8 years ago

Great, Thanks