Top Fields Constructors Methods
org.python.compiler

public Class ProxyMaker

extends ProxyCodeHelpers
implements ClassConstants, Opcodes
Class Inheritance
All Implemented Interfaces
org.objectweb.asm.Opcodes, org.python.compiler.ClassConstants
Known Direct Subclasses
org.python.compiler.AdapterMaker, org.python.compiler.JavaMaker
Imports
java.io.OutputStream, java.lang.reflect.Constructor, .Method, .Modifier, java.util.Set, org.objectweb.asm.Label, .Opcodes, org.python.core.Py, .PyException, org.python.util.Generic

Field Summary

Modifier and TypeField and Description
public ClassFile
protected final Class<?>[]
public String
myClass

The name of the class to build.

pack-priv Set<String>
pack-priv Set<String>
protected final Class<?>
pack-priv Set<String>
Inherited from org.python.compiler.ProxyCodeHelpers:
tBooleantBytetCharactertDoubletFloattIntegertLongtNonetOthertShorttVoidtypes

Constructor Summary

AccessConstructor and Description
public
ProxyMaker(String superclassName, Class<?> superclass)

Creates a proxy class maker that produces classes named org.python.proxies.(superclassName) with superclass as an implemented interface or extended class, depending on the its type.

public
ProxyMaker(String proxyClassName, Class<?> superclass, Class<?>... interfaces)

Creates a proxy class maker that produces classes named proxyClassName that extends superclass and implements the interfaces in interfaces.

Method Summary

Modifier and TypeMethod and Description
protected void
public void
public void
addConstructor(String name, Class<?>[] parameters, Class<?> ret, String sig, int access)

protected void
addConstructor(Class<?>[] parameters, int access)

Adds a constructor that calls through to superclass.

public void
addConstructorMethodCode(String pyName, Class<?>[] parameters, Class<?>[] exceptions, int access, Class<?> declaringClass, Code code)

A constructor that is also a method (!)

public void
public void
addMethod(Method method, int access)

public void
addMethod(String name, Class<?> ret, Class<?>[] parameters, Class<?>[] exceptions, int access, Class<?> declaringClass)

Adds a method of the given name to the class being implemented.

public void
addMethod(String
of the java method
name
,
String
name of the python method to which the java method proxies (useful for clamped objects)
pyName
,
Class<?>
return type
ret
,
Class<?>[]
parameter types
parameters
,
Class<?>[]
throwable exception types
exceptions
,
int access, Class<?> declaringClass, ProxyCodeHelpers.AnnotationDescr[]
method annotations
methodAnnotations
,
ProxyCodeHelpers.AnnotationDescr[][]
parameter annotations
parameterAnnotations
)

Generates and adds a proxy method to the proxy class

protected void
protected Code
addOpenConstructor(Constructor<?> constructor)

Adds a constructor that calls through to the superclass constructor with the same signature and leaves the returned Code open for more operations.

public void
public void
addSuperMethod(Method method, int access)

public void
addSuperMethod(String methodName, String superName, String declClass, Class<?>[] parameters, Class<?> ret, String sig, int access)

public void
build(OutputStream out)

Builds this proxy and writes its bytecode to out.

public void
protected void
callInitProxy(Class<?>[] parameters, Code code)

Calls __initProxy__ on this class with the given types of parameters, which must be available as arguments to the currently called method in the order of the parameters.

public void
callMethod(Code code, String name, Class<?>[] parameters, Class<?> ret, Class<?>[] exceptions)

public void
callSuper(Code code, String name, String superclass, Class<?>[] parameters, Class<?> ret, boolean doReturn)

public void
public void
doJavaCall(Code code, String name, String type, String jcallName)

public void
getArgs(Code code, Class<?>[] parameters)

private String
protected void
protected void
visitConstructor(Constructor<?> constructor)

Called for every constructor on the proxy's superclass that can be overridden by the proxy class.

protected void
visitConstructors()

Visits constructors from this proxy's superclass.

protected void
visitMethod(Method method)

Called for every method on the proxy's superclass and interfaces that can be overridden by the proxy class.

protected void
visitMethods(Class<?> klass)

Visits all methods declared on the given class and classes in its inheritance hierarchy.

protected void
Inherited from org.python.compiler.ProxyCodeHelpers:
doNullReturndoReturnfillTypesfindPythongetTypemakeSigmakeSigmapClassmapClassesmapExceptionsmapTypenotImplementedAbstractMethod

Field Detail

classfileback to summary
public ClassFile classfile
interfacesback to summary
protected final Class<?>[] interfaces
myClassback to summary
public String myClass

The name of the class to build.

namesback to summary
pack-priv Set<String> names
namesAndSigsback to summary
pack-priv Set<String> namesAndSigs
superclassback to summary
protected final Class<?> superclass
supernamesback to summary
pack-priv Set<String> supernames

Constructor Detail

ProxyMakerback to summary
public ProxyMaker(String superclassName, Class<?> superclass)

Creates a proxy class maker that produces classes named org.python.proxies.(superclassName) with superclass as an implemented interface or extended class, depending on the its type.

Annotations
@Deprecated
ProxyMakerback to summary
public ProxyMaker(String proxyClassName, Class<?> superclass, Class<?>... interfaces)

Creates a proxy class maker that produces classes named proxyClassName that extends superclass and implements the interfaces in interfaces.

Method Detail

addClassAnnotationback to summary
protected void addClassAnnotation(ProxyCodeHelpers.AnnotationDescr annotation)
addClassDictInitback to summary
public void addClassDictInit() throws Exception
addConstructorback to summary
public void addConstructor(String name, Class<?>[] parameters, Class<?> ret, String sig, int access) throws Exception
addConstructorback to summary
protected void addConstructor(Class<?>[] parameters, int access) throws Exception

Adds a constructor that calls through to superclass.

addConstructorMethodCodeback to summary
public void addConstructorMethodCode(String pyName, Class<?>[] parameters, Class<?>[] exceptions, int access, Class<?> declaringClass, Code code) throws Exception

A constructor that is also a method (!)

addConstructorsback to summary
public void addConstructors(Class<?> c) throws Exception
addMethodback to summary
public void addMethod(Method method, int access) throws Exception
addMethodback to summary
public void addMethod(String name, Class<?> ret, Class<?>[] parameters, Class<?>[] exceptions, int access, Class<?> declaringClass) throws Exception

Adds a method of the given name to the class being implemented. If declaringClass is null, the generated method will expect to find an object of the method's name in the Python object and call it. If it isn't null, if an object is found in the Python object, it'll be called. Otherwise the superclass will be called. No checking is done to guarantee that the superclass has a method with the same signature.

addMethodback to summary
public void addMethod(String name, String pyName, Class<?> ret, Class<?>[] parameters, Class<?>[] exceptions, int access, Class<?> declaringClass, ProxyCodeHelpers.AnnotationDescr[] methodAnnotations, ProxyCodeHelpers.AnnotationDescr[][] parameterAnnotations) throws Exception

Generates and adds a proxy method to the proxy class

Parameters
name:String

of the java method

pyName:String

name of the python method to which the java method proxies (useful for clamped objects)

ret:Class<?>

return type

parameters:Class<?>[]

parameter types

exceptions:Class<?>[]

throwable exception types

methodAnnotations:ProxyCodeHelpers.AnnotationDescr[]

method annotations

parameterAnnotations:ProxyCodeHelpers.AnnotationDescr[][]

parameter annotations

addMethodsback to summary
protected void addMethods(Class<?> c, Set<String> t) throws Exception
addOpenConstructorback to summary
protected Code addOpenConstructor(Constructor<?> constructor) throws Exception

Adds a constructor that calls through to the superclass constructor with the same signature and leaves the returned Code open for more operations. The caller of this method must add a return to the Code.

addProxyback to summary
public void addProxy() throws Exception
addSuperMethodback to summary
public void addSuperMethod(Method method, int access) throws Exception
addSuperMethodback to summary
public void addSuperMethod(String methodName, String superName, String declClass, Class<?>[] parameters, Class<?> ret, String sig, int access) throws Exception
buildback to summary
public void build(OutputStream out) throws Exception

Builds this proxy and writes its bytecode to out.

buildback to summary
public void build() throws Exception
callInitProxyback to summary
protected void callInitProxy(Class<?>[] parameters, Code code) throws Exception

Calls __initProxy__ on this class with the given types of parameters, which must be available as arguments to the currently called method in the order of the parameters.

callMethodback to summary
public void callMethod(Code code, String name, Class<?>[] parameters, Class<?> ret, Class<?>[] exceptions) throws Exception
callSuperback to summary
public void callSuper(Code code, String name, String superclass, Class<?>[] parameters, Class<?> ret, boolean doReturn) throws Exception
doConstantsback to summary
public void doConstants() throws Exception
doJavaCallback to summary
public void doJavaCall(Code code, String name, String type, String jcallName) throws Exception
getArgsback to summary
public void getArgs(Code code, Class<?>[] parameters) throws Exception
methodStringback to summary
private String methodString(Method m)
visitClassAnnotationsback to summary
protected void visitClassAnnotations() throws Exception
visitConstructorback to summary
protected void visitConstructor(Constructor<?> constructor) throws Exception

Called for every constructor on the proxy's superclass that can be overridden by the proxy class.

visitConstructorsback to summary
protected void visitConstructors() throws Exception

Visits constructors from this proxy's superclass.

visitMethodback to summary
protected void visitMethod(Method method) throws Exception

Called for every method on the proxy's superclass and interfaces that can be overridden by the proxy class. If the proxy wants to perform Python lookup and calling, addMethod(Method, int) or one of its more complex forms should be called. For abstract methods, addMethod must be called.

visitMethodsback to summary
protected void visitMethods(Class<?> klass) throws Exception

Visits all methods declared on the given class and classes in its inheritance hierarchy. Methods visible to subclasses are added to seen.

visitMethodsback to summary
protected void visitMethods() throws Exception