Closed sadevelopment closed 8 years ago
Could you please be more specific with the error/context? Having several constants in the same interface is totally fine with JSweet AFAIK, and I have just added a test to make sure it works (it passes).
Hi,
We are using the gradle-jsweet-plugin version 1.1.0-SNAPSHOT. We have an interface called TextTraits.java defined below:
public interface TextTraits {
int KB_DEFAULT = 0x01;
int KB_ASCIICAPABLE = 0x02;
int KB_NUMBERSANDPUNC = 0x03;
int KB_URL = 0x04;
int KB_NUMBERPAD = 0x05;
int KB_PHONEPAD = 0x06;
int KB_NAMEPHONEPAD = 0x07;
int KB_EMAIL = 0x08;
int KB_DECIMALPAD = 0x09;
int KB_TWITTER = 0x10;
int KB_WEBSERACH = 0x11;
int TEXT_DEFAULT = 1;
int TEXT_AUTO_CAP_TYPE_NONE = 1 << 2;
int TEXT_AUTO_CAP_TYPE_WORDS = 1 << 3;
int TEXT_AUTO_CAP_TYPE_SENTENCES = 1 << 4;
int TEXT_AUTO_CAP_TYPE_ALL = 1 << 5;
int TEXT_AUTO_COMPLETE_YES = 1 << 6;
int TEXT_AUTO_COMPLETE_NO = 1 << 7;
int TEXT_AUTO_CHECKING_YES = 1 << 8;
int TEXT_AUTO_CHECKING_NO = 1 << 9;
int TEXT_PASSWORD = 1 << 10;
/**
* Passing in a trait will test to see if this field has it.
*
* @param trait
* @return whether the trait is supported for this field
*/
boolean hasTextTrait(int trait);
int getKeyboardType();
}
When we run the script via gradle the following output is seen:
cannot adjust line for: class com.sun.tools.javac.tree.JCTree$JCMethodInvocation at line 86 cannot adjust line for: class com.sun.tools.javac.tree.JCTree$JCIdent at line 86 cannot adjust line for: class com.sun.tools.javac.tree.JCTree$JCIdent at line 86 cannot adjust line for: class com.sun.tools.javac.tree.JCTree$JCNewClass at line 86 cannot adjust line for: class com.sun.tools.javac.tree.JCTree$JCIdent at line 86 ',' expected at com/hambroperks/presenter/item/TextTraits.ts(49) ',' expected at com/hambroperks/presenter/item/TextTraits.ts(49) ',' expected at com/hambroperks/presenter/item/TextTraits.ts(49)
"Generated from Java with JSweet 1.1.0-SNAPSHOT - http://www.jsweet.org"; namespace com.hambroperks.presenter.item {
/**
/**
getKeyboardType() : number; } export namespace TextTraits { export var KB_DEFAULT : number = 1 export var KB_ASCIICAPABLE : number = 2 export var KB_NUMBERSANDPUNC : number = 3 export var KB_URL : number = 4 export var KB_NUMBERPAD : number = 5 export var KB_PHONEPAD : number = 6 export var KB_NAMEPHONEPAD : number = 7 export var KB_EMAIL : number = 8 export var KB_DECIMALPAD : number = 9 export var KB_TWITTER : number = 16 export var KB_WEBSERACH : number = 17 export var TEXT_DEFAULT : number = 1 export var TEXT_AUTO_CAP_TYPE_NONE : number = 1 << 2 export var TEXT_AUTO_CAP_TYPE_WORDS : number = 1 << 3 export var TEXT_AUTO_CAP_TYPE_SENTENCES : number = 1 << 4 export var TEXT_AUTO_CAP_TYPE_ALL : number = 1 << 5 export var TEXT_AUTO_COMPLETE_YES : number = 1 << 6 export var TEXT_AUTO_COMPLETE_NO : number = 1 << 7 export var TEXT_AUTO_CHECKING_YES : number = 1 << 8 export var TEXT_AUTO_CHECKING_NO : number = 1 << 9 export var TEXT_PASSWORD : number = 1 << 10 } }
Hope that helps,
Regards,
Marcus Smith
On 2 Jul 2016, at 06:58, Renaud Pawlak notifications@github.com wrote:
Could you please be more specific with the error/context? Having several constants in the same interface is totally fine with JSweet AFAIK, and I have just added a test https://github.com/cincheo/jsweet/commit/ca9dfef10e4f51f9bfe15e05ca5cd004de642d2a to make sure it works (it passes).
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cincheo/jsweet/issues/140#issuecomment-230085820, or mute the thread https://github.com/notifications/unsubscribe/AHx1pMo6RNI8KQCwlPT60DiJjtmsCyc4ks5qRf32gaJpZM4JDG_z.
Thanks! Got it. I have fixed it in the current snapshot and will commit.
That's great thanks. Also a friend pointed out that for the attributes shouldn't they be defined as const rather than var?
Sent from Yahoo Mail on Android
On Sun, 3 Jul, 2016 at 8:27, Renaud Pawlaknotifications@github.com wrote:
Thanks! Got it. I have fixed it in the current snapshot and will commit.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Yep, sure, static final vars should generate const variables. It is not that crucial when using JSweet because static final vars are immutable for Java anyways, but it is indeed nicer for generated code. If you feel that it is important to you, don't hesitate to open an issue (or even to contribute). It should be pretty straightforward to support.
Ok I will do thanks - my self and my colleague are pretty keen on this type of thing as we already transpire o support native iOS and android :) As a side note would you have any pointers to supporting submodule dependencies defined in gradle? For instance we already transpire our Java into objective-c using j2objc. The lower git submodules define the core interfaces and functionality of the app. The higher you go the more specific to apps the code gets, but all native Java. The issue I noticed was transpiling the lower submodules to ts/js, the gradle would then transpile the one above but failed due to not finding the code defined in the submodules. It might be a config issue my end or I might need to flatten it all out. Just thought I'd ask on the off chance.... Please don't get annoyed if we start raising loads of requests - we expect to be heavy users over the next few month.
Sent from Yahoo Mail on Android
On Sun, 3 Jul, 2016 at 8:42, Renaud Pawlaknotifications@github.com wrote:
Yep, sure, static final vars should generate const variables. It is not that crucial when using JSweet because static final vars are immutable for Java anyways, but it is indeed nicer for generated code. If you feel that it is important to you, don't hesitate to open an issue (or even to contribute). It should be pretty straightforward to support.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I am currently using the gradle plugin to transpile java into javascript and typescript and it is failing due to one of my interface having more than one constant attribute. For instance this will work
public interface Foo { int CONSTANT_TEST = 1; void setSomethingInFooImpl(); }
but this will not
public interface Foo { int CONSTANT_TEST = 1; int CONSTANT_TEST2 = 2; void setSomethingInFooImpl(); }
Any suggestions?