Skip to content

Commit 551f224

Browse files
author
Troy Melhase
committed
More work on features doc.
1 parent 821232f commit 551f224

File tree

1 file changed

+28
-37
lines changed

1 file changed

+28
-37
lines changed

doc/features.md

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Literals are copied from source to target with the following modifications:
2828
* `null` is changed to `None`
2929
* `false` is changed to `False`
3030
* `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
3333

3434
Transformation of literal values happens at the AST level; see the
3535
`astTransforms` configuration value for details.
@@ -49,7 +49,7 @@ Ternary expressions are translated to their Python form (`val if condition else
4949

5050
All of the Java prefix operators are supported:
5151

52-
++ -- ! ~ + -
52+
++ -- ! ~ + -
5353

5454
In the case of `++` and `--`, java2python translates to `+= 1` and `-= 1`. If necessary, those expressions are moved outside of statements.
5555

@@ -59,7 +59,7 @@ All of the following assignment operators are translated into their Python equiv
5959

6060
= += -= *= /= &= |= ^= %= <<= >>=
6161

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.
6363

6464
#### Infix Operators
6565

@@ -74,75 +74,66 @@ Refer to the note above regarding bit shift right.
7474

7575
The basic Java types are mapped to Python types as follows:
7676

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`
8581

8682
#### Types, Interfaces, Enums
8783

8884
Java classes, interfaces, and enums are translated into Python classes.
8985

9086
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
9288
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.
9491

9592
Enums are also translated via a configurable strategy. By default, enumerated
9693
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+
9897

9998
#### Statements
10099

101100
##### assert
102-
103-
assert Expression [ : Expression] ;
101+
Java `assert` statements are translated to equivalent Python `assert` statements.
104102

105103
##### if
104+
Java `if` statements are translated to equivalent Python `if` statements.
106105

107-
if ParExpression Statement [else Statement]
108106

109107
##### for
110-
111-
for ( ForControl ) Statement
108+
Java `for` statements are translated to equivalent Python `for` statements.
112109

113110
##### 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.
118112

119113
##### try and catch
114+
Java `try` and `catch` statements are translated to equivalent Python `try` and `except` statements.
120115

121-
try Block ( Catches | [Catches] finally Block )
122-
123-
##### switch
124-
125-
switch ParExpression { SwitchBlockStatementGroups }
116+
##### switch and case
117+
Java `switch` and `case` statements are translated to equivalent Python `if` statements.
126118

127119
##### synchronized
128120

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.
130122

131123
##### return
124+
Java `return` statements are translated to equivalent Python `return` statements.
132125

133-
return [Expression] ;
134126

135127
##### throw
136-
137-
throw Expression ;
128+
Java `throw` statements are translated to equivalent Python `throw` statements.
138129

139130
##### 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.
142133

143134
###### 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
136+
contain the original label.
146137

147138

148139

0 commit comments

Comments
 (0)