Created
September 1, 2013 22:14
-
-
Save natural/6407668 to your computer and use it in GitHub Desktop.
example j2py config file to throw away interfaces when generating python code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from java2python.config.default import astTransforms | |
from java2python.lang.selector import Type | |
from java2python.lang import tokens | |
interfaces = [] | |
def throwAwayInterface(node, config): | |
interfaces.append(node.firstChildOfType(tokens.IDENT).text) | |
node.parent.children.remove(node) | |
def replaceInterfaces(node, config): | |
for token in node.findChildren(): | |
if token.type == tokens.IDENT and token.text in interfaces: | |
token.parent.children.remove(token) | |
astTransforms.extend([ | |
(Type('INTERFACE'), throwAwayInterface), | |
(Type('IMPLEMENTS_CLAUSE'), replaceInterfaces) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment