Changes between Version 32 and Version 33 of j2p
- Timestamp:
- 06/21/23 11:18:56 (17 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
j2p
v32 v33 30 30 The mechanism assumes a fixed mapping from java to python objects, as in the table below. This fixed mapping is needed to ensure the translator can be sure which objects will appear on the python side of the translation, so that proper actions can be taken to further the translation. 31 31 32 built-in "primitives" 32 ==== constructs 33 The {{{private}}} keyword is reflected by the python convention of adding "__" to private fields function names and method names 34 35 The {{{static}}} keyword results in fields being set in the class definition object. 36 37 Fields in Java have to be initialized in the __init__ function in the python translation. 38 39 Overloaded methods can not be handled by default python and need to be handled using an external library {{{multidispatch==0.6.0}}} and result in additional annotations {{{@dispatch(...)}}} in the translated code. 40 41 ==== built-in "primitives" 33 42 ||=java=||=python=||=remarks=|| 34 43 ||String||str|| … … 39 48 ||Set||set|| 40 49 41 built-in classes50 ==== built-in classes 42 51 ||=java=||=python=||=remarks=|| 43 52 ||Class||type|| … … 46 55 If function calls in python deliver a wrong object (not matching the above mapping), the translator has to inject additional code to convert it to the proper object. For example, {{{Map.getKeys()}}} in python would be {{{set(map.keys())}}} where the extra {{{set}}} converts the dict_keys into a proper set. 47 56 48 Some more notes:57 ==== More notes: 49 58 * some classes like {{{Arrays}}} or {{{Override}}} do not have a direct python equivalent. calls to static functions in these classes can still be translated. 50 59 * Different java classes, eg {{{Map}}} {{{AbstractMap}}} and {{{HashMap}}}, may translate to the same python class ({{{map}}}). This can be done because translation is only 1 way.