You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/features.md
+28-37Lines changed: 28 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,8 +28,8 @@ Literals are copied from source to target with the following modifications:
28
28
*`null` is changed to `None`
29
29
*`false` is changed to `False`
30
30
*`true` is changed to `True`
31
-
* if necessary, floating point literals are modified to become valid Python values
32
-
* string and character literals are translated as Python strings
31
+
* if necessary, floating point literals are changed to valid Python values
32
+
* string and character literals are changed to Python strings
33
33
34
34
Transformation of literal values happens at the AST level; see the
35
35
`astTransforms` configuration value for details.
@@ -49,7 +49,7 @@ Ternary expressions are translated to their Python form (`val if condition else
49
49
50
50
All of the Java prefix operators are supported:
51
51
52
-
++ -- ! ~ + -
52
+
++ -- ! ~ + -
53
53
54
54
In the case of `++` and `--`, java2python translates to `+= 1` and `-= 1`. If necessary, those expressions are moved outside of statements.
55
55
@@ -59,7 +59,7 @@ All of the following assignment operators are translated into their Python equiv
59
59
60
60
= += -= *= /= &= |= ^= %= <<= >>=
61
61
62
-
The bit shift right (`>>>`)and bit shift assign right (`>>>=`) operators are mapped to a function; if java2python detects code that uses either of these, it replaces the operator with that function and includes the function within the output. This behavior is controlled by the `modulePrologueHandlers` config item.
62
+
The bit shift right (`>>>`)and bit shift assign right (`>>>=`) operators are mapped to a function; if java2python detects code that uses either of these, it replaces the operator with that function and includes the function within the output. This behavior is controlled by the `modulePrologueHandlers` config handler.
63
63
64
64
#### Infix Operators
65
65
@@ -74,75 +74,66 @@ Refer to the note above regarding bit shift right.
74
74
75
75
The basic Java types are mapped to Python types as follows:
76
76
77
-
byte => int
78
-
short => int
79
-
char => str
80
-
int => int
81
-
long => long
82
-
float => float
83
-
double => float
84
-
boolean => bool
77
+
*`byte`, `short`, `int`, and `long` become `int`
78
+
*`char` becomes `str`
79
+
*`float` and `double` become `float`
80
+
*`boolean` becomes `bool`
85
81
86
82
#### Types, Interfaces, Enums
87
83
88
84
Java classes, interfaces, and enums are translated into Python classes.
89
85
90
86
In the case of interfaces, the strategy is configurable. By default,
91
-
interfaces are translated to classes utilizing the ABCMeta class. The package
87
+
interfaces are translated to classes utilizing the `ABCMeta` class. The package
92
88
includes config handlers that can translate to simple classes (inheriting from
93
-
`object`), or from Zope Interfaces.
89
+
`object`), or from Zope Interfaces. Interface base types are controlled via the `interfaceBaseHandlers` config item. The `interfaceHeadHandlers` config item controls the
90
+
metaclass.
94
91
95
92
Enums are also translated via a configurable strategy. By default, enumerated
96
93
values are created as class attributes with string values. The package
97
-
includes a config handler to create class attributes with integer values.
94
+
includes a config handler to create class attributes with integer values. The config handler
95
+
that controls enumeration value construction is `enumValueHandler`.
96
+
98
97
99
98
#### Statements
100
99
101
100
##### assert
102
-
103
-
assert Expression [ : Expression] ;
101
+
Java `assert` statements are translated to equivalent Python `assert` statements.
104
102
105
103
##### if
104
+
Java `if` statements are translated to equivalent Python `if` statements.
106
105
107
-
if ParExpression Statement [else Statement]
108
106
109
107
##### for
110
-
111
-
for ( ForControl ) Statement
108
+
Java `for` statements are translated to equivalent Python `for` statements.
112
109
113
110
##### while and do
114
-
115
-
while ParExpression Statement
116
-
117
-
do Statement while ParExpression ;
111
+
Java `while` and `do` statements are translated to equivalent Python `while` statements.
118
112
119
113
##### try and catch
114
+
Java `try` and `catch` statements are translated to equivalent Python `try` and `except` statements.
Java `switch` and `case` statements are translated to equivalent Python `if` statements.
126
118
127
119
##### synchronized
128
120
129
-
synchronized ParExpression Block
121
+
The compiler currently discards the `synchronized` Java statement. This is incorrect behavior. The correct behavior is (and will be) to apply a synchronized decorator to a function wrapping the construct.
130
122
131
123
##### return
124
+
Java `return` statements are translated to equivalent Python `return` statements.
132
125
133
-
return [Expression] ;
134
126
135
127
##### throw
136
-
137
-
throw Expression ;
128
+
Java `throw` statements are translated to equivalent Python `throw` statements.
138
129
139
130
##### break
140
-
141
-
break [Identifier]
131
+
Java `break` statements are translated to equivalent Python `break` statements. However, a Java `break` statement with an identifier (e.g., `break FOO`) is not supported. If the compiler detects such a statement, a waring will be printed and the translated source will not
132
+
contain the original label.
142
133
143
134
###### continue
144
-
145
-
continue [Identifier]
135
+
Java `continue` statements are translated to equivalent Python `continue` statements. However, a Java `continue` statement with an identifier (e.g., `continue FOO`) is not supported. If the compiler detects such a statement, a waring will be printed and the translated source will not
0 commit comments