From: <cg...@us...> - 2009-08-11 06:45:10
|
Revision: 6662 http://jython.svn.sourceforge.net/jython/?rev=6662&view=rev Author: cgroves Date: 2009-08-11 06:45:00 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Documentation and formatting cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PyOverridableNew.java trunk/jython/src/org/python/expose/ExposedNew.java trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java trunk/jython/src/org/python/expose/generate/NewExposer.java Modified: trunk/jython/src/org/python/core/PyOverridableNew.java =================================================================== --- trunk/jython/src/org/python/core/PyOverridableNew.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/core/PyOverridableNew.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -1,32 +1,30 @@ package org.python.core; - /** - * A __new__ function that tells its subclasses to just init if __new__ is being - * called on the type the function was defined on. Otherwise, it just leaves - * initting up to the subtype otherwise. + * A __new__ function that tells its subclasses to just init if __new__ is being called on the type + * the function was defined on. Otherwise, it just leaves initting up to the subtype otherwise. */ public abstract class PyOverridableNew extends PyNewWrapper { @Override public PyObject new_impl(boolean init, PyType subtype, PyObject[] args, String[] keywords) { - if (for_type==subtype) { + if (for_type == subtype) { return createOfType(init, args, keywords); } else { return createOfSubtype(subtype); } } - + /** * Called when new is invoked on the type the new was defined on. - * + * * @param init - if the new object should be initted. * @param args - args passed to call * @param keywords - keywords passed to call * @return - the new object. */ public abstract PyObject createOfType(boolean init, PyObject[] args, String[] keywords); - + /** Called when new is invoked on a subtype of for_type. */ public abstract PyObject createOfSubtype(PyType subtype); } Modified: trunk/jython/src/org/python/expose/ExposedNew.java =================================================================== --- trunk/jython/src/org/python/expose/ExposedNew.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/ExposedNew.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -8,23 +8,22 @@ import org.python.core.PyInteger; /** + * <p> * Can appear on two forms of methods to indicate a method should be part of the __new__ object * creation. Can only appear once per exposed type. - * + *<p> * In the first form, the method must be static and take the arguments * <code>PyNewWrapper new_, boolean init, PyType - subtype, PyObject[] args, String[] keywords</code>. - * In this case, the method has full responsibility for creating and initting the object and will be - * invoked for every subtype of this exposed type. Essentially its for object instantation that must - * be called for every instance of that object. See {@link PyInteger#int_new} for an example of this - * type of ExposedNew. - * + subtype, PyObject[] args, String[] keywords</code>. In this case, the method has full + * responsibility for creating and initting the object and will be invoked for every subtype of this + * exposed type. Essentially it's for object instantiation that must be called for every instance of + * that object. See {@link PyInteger#int_new} for an example of this type of ExposedNew. + *<p> * In the second form, the method must be an instance method that takes the standard Jython call * arguments, <code>PyObject[] args, String[] keywords</code>. In this case, the basic new * functionality is handled by PyOverridableNew and the method with ExposedNew is called as __init__ * as part of that process. This allows subtypes to completely redefine new and create objects * however they like. - * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) Modified: trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -170,13 +170,13 @@ methodExposers, descExposers.values(), newExposer); - for(MethodExposer exposer : methodExposers) { + for (MethodExposer exposer : methodExposers) { addInnerClass(exposer.getGeneratedType()); } - for(DescriptorExposer exposer : descExposers.values()) { + for (DescriptorExposer exposer : descExposers.values()) { addInnerClass(exposer.getGeneratedType()); } - if(newExposer != null) { + if (newExposer != null) { addInnerClass(newExposer.getGeneratedType()); } addInnerClass(typeExposer.getGeneratedType()); Modified: trunk/jython/src/org/python/expose/generate/NewExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -1,12 +1,8 @@ package org.python.expose.generate; -import java.lang.reflect.Method; - import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.python.core.PyNewWrapper; -import org.python.core.PyObject; -import org.python.core.PyType; public class NewExposer extends Exposer { @@ -18,13 +14,13 @@ super(PyNewWrapper.class, onType.getClassName() + "$exposed___new__"); this.onType = onType; this.name = methodName; - if((access & Opcodes.ACC_STATIC) == 0) { + if ((access & Opcodes.ACC_STATIC) == 0) { throwInvalid("Full methods for @ExposedNew must be static"); } - if(!Type.getReturnType(desc).equals(PYOBJ)) { + if (!Type.getReturnType(desc).equals(PYOBJ)) { throwInvalid("@ExposedNew methods must return PyObject"); } - if(exceptions != null && exceptions.length > 0) { + if (exceptions != null && exceptions.length > 0) { throwInvalid("@ExposedNew methods may not throw checked exceptions"); } } @@ -59,9 +55,5 @@ } public static final String NEW_DESCRIPTOR = Type.getMethodDescriptor(PYOBJ, - new Type[] {PYNEWWRAPPER, - BOOLEAN, - PYTYPE, - APYOBJ, - ASTRING}); + new Type[] {PYNEWWRAPPER, BOOLEAN, PYTYPE, APYOBJ, ASTRING}); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |