Last active
January 3, 2016 09:19
-
-
Save jimbaker/8441725 to your computer and use it in GitHub Desktop.
Possible Clamp DSL to support reflection on Java generics, which will then generate the necessary type signatures in Jython
This file contains 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
# Uses names from a motivating paste by Oti Humbel, http://pastebin.com/1deBqEAV | |
from some_source import View, IEntityView, EntityManagerPlug2 | |
# clamp_base is implemented, extends is a hypothetical class decorator similar to proposed support | |
# for Java class annotations that will rewrite the class bytecode with the necessary type signature data, using | |
# http://asm.ow2.org/asm40/javadoc/user/org/objectweb/asm/signature/SignatureVisitor.html | |
from clamp import clamp_base, extends | |
FooPackage = clamp_base(package="foo") | |
# need to be able to write the equivalent to this Java class | |
# public class JavaManager implements EntityManagerPlug2<View extends IEntityView> { ... } | |
# so that reflection on the generics used with the class, eg cls.getGenericInterfaces(), etc, still will work | |
@extends(View, IEntityView) | |
class PythonManager(EntityManagerPlug2, FooPackage): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment