|
| 1 | +## |
| 2 | +# This is an example of how to perform per-module configuration |
| 3 | +# for translating java interfaces to zope interfaces. |
| 4 | +# |
1 | 5 | from java2python.mod import basic |
| 6 | +from java2python.config import default |
2 | 7 |
|
3 | 8 |
|
4 | | -def setZopeInterface(iface): |
5 | | - print '##### iface.bases:', iface.bases |
6 | | - iface.bases[:] = ['zope.interface.Interface'] |
7 | | - print '#### set zope interface', iface.bases |
| 9 | +# the j2py default head handlers for interfaces includes ABCMeta as a |
| 10 | +# metaclass. we certainly don't want that, so we redefine the list |
| 11 | +# here to only the doc string handler: |
| 12 | +interfaceHeadHandlers = [ |
| 13 | + basic.simpleDocString, |
| 14 | +] |
8 | 15 |
|
9 | | -interfacePostWalkHandlers = [ |
10 | | - setZopeInterface, |
11 | | - ] |
12 | 16 |
|
| 17 | +# this j2py default is also not what we want, so we redefine it: |
| 18 | +methodPrologueHandlers = [ |
| 19 | + basic.maybeClassMethod, |
| 20 | +] |
13 | 21 |
|
14 | | -# override, not supplement: |
15 | | -interfaceHeadHandlers = [ |
16 | | -# basic.simpleDocString, |
17 | | - ] |
18 | 22 |
|
| 23 | +# instead of the default bases, this handler supplies the base zope |
| 24 | +# Interface class for Java interfaces: |
| 25 | +interfaceBaseHandlers = [ |
| 26 | + basic.zopeInterfaceBases, |
| 27 | +] |
| 28 | + |
| 29 | + |
| 30 | +# the parser adds implemented interfaces to the class bases list. |
| 31 | +# this handler checks to see if any of those bases are interfaces, and |
| 32 | +# if so, supresses them in favor of 'object' as the only base: |
| 33 | +classBaseHandlers = [ |
| 34 | + basic.zopeImplementsClassBases, |
| 35 | +] |
| 36 | + |
| 37 | + |
| 38 | +# this handler adds a line like "zope.interface.implements(IFoo)" for |
| 39 | +# each interface implemented by a Java class: |
| 40 | +classHeadHandlers = [ |
| 41 | + basic.zopeImplementsClassHead, |
| 42 | +] |
19 | 43 |
|
20 | | -methodPrologueHandlers = [ |
21 | 44 |
|
22 | | - ] |
| 45 | +# this handler supresses the "self" parameter on method signatures for |
| 46 | +# zope Interface definitions: |
| 47 | +methodParamHandlers = [ |
| 48 | + basic.zopeInterfaceMethodParams, |
| 49 | +] |
0 commit comments