Skip to content

Commit 764be76

Browse files
author
Troy Melhase
committed
Extends AST type replacements with remaining primitive types.
1 parent 7a6f0fb commit 764be76

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

java2python/config/default.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,13 @@
148148
(Type('TRUE'), transform.true2True),
149149
(Type('IDENT'), transform.keywordSafeIdent),
150150

151+
(Type('FLOATING_POINT_LITERAL'), transform.syntaxSafeFloatLiteral),
151152

152-
(Type('FLOATING_POINT_LITERAL'),
153-
transform.syntaxSafeFloatLiteral),
154-
155-
(Type('TYPE') > Type('BOOLEAN'),
156-
transform.typeSub),
157-
158-
(Type('TYPE') > Type('DOUBLE'),
159-
transform.typeSub),
153+
(Type('TYPE') > Type('BOOLEAN'), transform.typeSub),
154+
(Type('TYPE') > Type('BYTE'), transform.typeSub),
155+
(Type('TYPE') > Type('CHAR'), transform.typeSub),
156+
(Type('TYPE') > Type('DOUBLE'), transform.typeSub),
157+
(Type('TYPE') > Type('SHORT'), transform.typeSub),
160158

161159
(Type('TYPE') > Type('QUALIFIED_TYPE_IDENT') > Type('IDENT'),
162160
transform.typeSub),
@@ -202,6 +200,8 @@
202200
'boolean' : 'bool',
203201
'IndexOutOfBoundsException' : 'IndexError',
204202
'Integer' : 'int',
203+
'short' : 'int',
204+
'byte' : 'int',
205205
'Object' : 'object',
206206
'String' : 'str',
207207
'char' : 'str',

test/BasicTypes1.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class BasicTypes1 {
2+
char chr;
3+
byte byt;
4+
short shr;
5+
int in_t;
6+
long lng;
7+
float flt;
8+
double dbl;
9+
10+
public static void main(String[] args) {
11+
BasicTypes1 bt1 = new BasicTypes1();
12+
System.out.println(bt1.byt);
13+
System.out.println(bt1.shr);
14+
System.out.println(bt1.in_t);
15+
}
16+
17+
}

0 commit comments

Comments
 (0)