You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <wme...@us...> - 2009-09-04 02:39:03
|
Revision: 6748 http://jython.svn.sourceforge.net/jython/?rev=6748&view=rev Author: wmeissner Date: 2009-09-04 02:38:53 +0000 (Fri, 04 Sep 2009) Log Message: ----------- When a Structure subclass is instantiated with an argument list, fill out the structure contents with the values Modified Paths: -------------- branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-04 01:31:51 UTC (rev 6747) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-04 02:38:53 UTC (rev 6748) @@ -75,31 +75,26 @@ def build(self): return jffi.StructLayout(fields = self.fields, union = self.union) -class _StructMetaClass(type): - def __new__(cls, name, bases, dict): - try: - layout = dict['_jffi_type'] = _StructLayoutBuilder().add_fields(dict['_fields_']).build() +class _AggregateMetaClass(type): + def __new_aggregate__(cls, name, bases, dict, union = False): + if dict.has_key('_fields_'): + layout = dict['_jffi_type'] = _StructLayoutBuilder(union).add_fields(dict['_fields_']).build() # make all fields accessible via .foo for f in dict['_fields_']: dict[f[0]] = layout[f[0]] - except: - pass return type.__new__(cls, name, bases, dict) + __new_aggregate__ = staticmethod(__new_aggregate__) + +class _StructMetaClass(_AggregateMetaClass): + def __new__(cls, name, bases, dict): + return _AggregateMetaClass.__new_aggregate__(cls, name, bases, dict, union = False) + class _UnionMetaClass(type): def __new__(cls, name, bases, dict): - try: - layout = dict['_jffi_type'] = _StructLayoutBuilder().add_fields(dict['_fields_'], union = True).build() - # make all fields accessible via .foo - for f in dict['_fields_']: - dict[f[0]] = layout[f[0]] - except: - pass + return _AggregateMetaClass.__new_aggregate__(cls, name, bases, dict, union = True) - - return type.__new__(cls, name, bases, dict) - class Structure(jffi.Structure): __metaclass__ = _StructMetaClass @@ -107,12 +102,10 @@ __metaclass__ = _UnionMetaClass def sizeof(type): - if isinstance(type, jffi.CData): + if hasattr(type, '_jffi_type'): return type._jffi_type.size - elif hasattr(type, '_type_'): - return _TypeMap[type.__getattribute__('_type_')] else: - raise TypeError("invalid ctype") + raise TypeError("this type has no size") def alignment(type): return type._jffi_type.alignment Modified: branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java 2009-09-04 01:31:51 UTC (rev 6747) +++ branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java 2009-09-04 02:38:53 UTC (rev 6748) @@ -1,7 +1,10 @@ package org.python.modules.jffi; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.python.core.ArgParser; import org.python.core.Py; @@ -22,15 +25,18 @@ TYPE.fastGetDict().__setitem__("ScalarField", ScalarField.TYPE); } - private final Map<PyObject, Field> fieldMap; + private final Map<Object, Field> fieldMap; + private final List<Field> fields; StructLayout(Field[] fields, com.kenai.jffi.Type struct, MemoryOp op) { super(NativeType.STRUCT, struct, op); - Map<PyObject, Field> m = new HashMap<PyObject, Field>(fields.length); + Map<Object, Field> m = new HashMap<Object, Field>(fields.length); for (Field f : fields) { m.put(f.name, f); + m.put(f.name.toString(), f); } this.fieldMap = m; + this.fields = Collections.unmodifiableList(Arrays.asList(fields)); } @ExposedType(name = "jffi.StructLayout.Field", base = PyObject.class) @@ -152,6 +158,14 @@ return fieldMap.get(name); } + Field getField(String name) { + return fieldMap.get(name); + } + + List<Field> getFieldList() { + return fields; + } + @Override public PyObject __getitem__(PyObject key) { StructLayout.Field f = getField(key); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-04 01:31:51 UTC (rev 6747) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-04 02:38:53 UTC (rev 6748) @@ -1,6 +1,9 @@ package org.python.modules.jffi; +import java.lang.reflect.Field; +import java.util.List; +import org.python.core.ArgParser; import org.python.core.Py; import org.python.core.PyNewWrapper; import org.python.core.PyObject; @@ -30,12 +33,30 @@ public static PyObject Structure_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { - PyObject layout = subtype.__getattr__("_jffi_type"); - if (!(layout instanceof StructLayout)) { + PyObject jffi_type = subtype.__getattr__("_jffi_type"); + if (!(jffi_type instanceof StructLayout)) { throw Py.TypeError("invalid _jffi_type for " + subtype.fastGetName() + "; should be instance of jffi.StructLayout"); } - return new Structure(subtype, (StructLayout) layout); + StructLayout layout = (StructLayout) jffi_type; + Structure s = new Structure(subtype, layout); + if (args.length > 0) { + int n = args.length - keywords.length; + List<StructLayout.Field> fields = layout.getFieldList(); + Memory m = s.getMemory(); + // First, do non-keyword args in order + for (int i = 0; i < n; ++i) { + StructLayout.Field f = fields.get(i); + f.op.put(m, f.offset, args[i]); + } + + // Now handle the keyworded args by looking up the field + for (int i = n; i < args.length; ++i) { + StructLayout.Field f = layout.getField(keywords[i - n]); + f.op.put(m, f.offset, args[i]); + } + } + return s; } protected final void initReferenceMemory(Memory m) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-09-04 01:31:58
|
Revision: 6747 http://jython.svn.sourceforge.net/jython/?rev=6747&view=rev Author: wmeissner Date: 2009-09-04 01:31:51 +0000 (Fri, 04 Sep 2009) Log Message: ----------- Remove getAddress() from the Pointer interface Modified Paths: -------------- branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java branches/ctypes-jffi/src/org/python/modules/jffi/Function.java branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java Added Paths: ----------- branches/ctypes-jffi/src/org/python/modules/jffi/BasePointer.java Modified: branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -19,10 +19,6 @@ m.putAddress(0, memory); } - public final long getAddress() { - return getMemory().getAddress(); - } - public final DirectMemory getMemory() { return hasReferenceMemory() ? getReferenceMemory().getMemory(0) : memory; } Added: branches/ctypes-jffi/src/org/python/modules/jffi/BasePointer.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/BasePointer.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/BasePointer.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -0,0 +1,33 @@ +package org.python.modules.jffi; + +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyType; +import org.python.expose.ExposedGet; + +public abstract class BasePointer extends PyObject implements Pointer { + + BasePointer(PyType subtype) { + super(subtype); + } + + @ExposedGet(name = "address") + public PyObject address() { + return Py.newInteger(getMemory().getAddress()); + } + + @Override + public boolean __nonzero__() { + return !getMemory().isNull(); + } + + @Override + public PyObject __int__() { + return address(); + } + + @Override + public PyObject __long__() { + return address(); + } +} Modified: branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -16,11 +16,12 @@ this.memory = memory; } - public long getAddress() { - return getMemory().getAddress(); - } - public final DirectMemory getMemory() { return memory; } + + @Override + public boolean __nonzero__() { + return !getMemory().isNull(); + } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -445,7 +445,7 @@ public void marshal(HeapInvocationBuffer buffer, PyObject parameter) { if (parameter instanceof Pointer) { - buffer.putAddress(((Pointer) parameter).getAddress()); + buffer.putAddress(((Pointer) parameter).getMemory().getAddress()); } else if (parameter == Py.None) { buffer.putAddress(0); } else { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -56,37 +56,25 @@ } @ExposedType(name = "jffi.DynamicLibrary.Symbol", base = PyObject.class) - public static class Symbol extends PyObject implements Pointer { + public static class Symbol extends BasePointer { public static final PyType TYPE = PyType.fromClass(Symbol.class); final DynamicLibrary library; final DirectMemory memory; @ExposedGet - public final long address; - - @ExposedGet public final String name; public Symbol(DynamicLibrary library, String name, DirectMemory memory) { + super(TYPE); this.library = library; this.name = name; this.memory = memory; - this.address = memory.getAddress(); } - public final long getAddress() { - return address; - } - public final DirectMemory getMemory() { return memory; } - - @Override - public boolean __nonzero__() { - return !getMemory().isNull(); - } } public static final class TextSymbol extends Symbol implements ExposeAsSuperclass { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Function.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Function.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Function.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -13,7 +13,7 @@ import org.python.expose.ExposedType; @ExposedType(name = "jffi.Function", base = PyObject.class) -public class Function extends PyObject implements Pointer { +public class Function extends BasePointer implements Pointer { public static final PyType TYPE = PyType.fromClass(Function.class); private final Pointer pointer; @@ -29,15 +29,11 @@ public final String name; @ExposedGet - public final long address; - - @ExposedGet @ExposedSet public PyObject restype; Function(PyType type, Pointer address) { super(type); - this.address = address.getAddress(); this.library = null; this.name = "<anonymous>"; this.pointer = address; @@ -48,7 +44,6 @@ this.library = sym.library; this.name = sym.name; this.pointer = sym; - this.address = sym.getAddress(); } @ExposedNew @@ -66,14 +61,10 @@ } } - public long getAddress() { - return address; - } - public DirectMemory getMemory() { return pointer.getMemory(); } - + @Override public PyObject fastGetDict() { return dict; @@ -166,7 +157,7 @@ if (invoker != null) { return invoker; } - return createInvoker(address, returnType, parameterTypes); + return createInvoker(getMemory().getAddress(), returnType, parameterTypes); } private synchronized final Invoker createInvoker(long address, CType returnType, CType[] parameterTypes) { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -201,7 +201,7 @@ public final void put(Memory mem, long offset, PyObject value) { if (value instanceof Pointer) { - mem.putAddress(offset, ((Pointer) value).getAddress()); + mem.putAddress(offset, ((Pointer) value).getMemory().getAddress()); } else if (value == Py.None) { mem.putAddress(offset, 0); } else { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -2,6 +2,5 @@ package org.python.modules.jffi; public interface Pointer { - long getAddress(); DirectMemory getMemory(); } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-04 00:43:55 UTC (rev 6746) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-04 01:31:51 UTC (rev 6747) @@ -67,10 +67,6 @@ f.op.put(getReferenceMemory(), f.offset, value); } - public long getAddress() { - return getMemory().getAddress(); - } - public DirectMemory getMemory() { return getReferenceMemory(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-09-04 00:44:12
|
Revision: 6746 http://jython.svn.sourceforge.net/jython/?rev=6746&view=rev Author: wmeissner Date: 2009-09-04 00:43:55 +0000 (Fri, 04 Sep 2009) Log Message: ----------- Implement c_char_p properly, and string return values Modified Paths: -------------- branches/ctypes-jffi/CoreExposed.includes branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/BoundedNativeMemory.java branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java branches/ctypes-jffi/src/org/python/modules/jffi/FastIntInvokerFactory.java branches/ctypes-jffi/src/org/python/modules/jffi/HeapMemory.java branches/ctypes-jffi/src/org/python/modules/jffi/Memory.java branches/ctypes-jffi/src/org/python/modules/jffi/NativeMemory.java branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java branches/ctypes-jffi/src/org/python/modules/jffi/Util.java branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java Added Paths: ----------- branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java branches/ctypes-jffi/src/org/python/modules/jffi/StringCData.java Modified: branches/ctypes-jffi/CoreExposed.includes =================================================================== --- branches/ctypes-jffi/CoreExposed.includes 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/CoreExposed.includes 2009-09-04 00:43:55 UTC (rev 6746) @@ -63,6 +63,7 @@ org/python/modules/jffi/PointerCData.class org/python/modules/jffi/Structure.class org/python/modules/jffi/ScalarCData.class +org/python/modules/jffi/StringCData.class org/python/modules/jffi/StructLayout.class org/python/modules/jffi/StructLayout$Field.class org/python/modules/jffi/StructLayout$ScalarField.class Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-04 00:43:55 UTC (rev 6746) @@ -208,7 +208,7 @@ c_size_t = c_ulong c_ssize_t = c_long -class c_char_p(_ScalarCData): +class c_char_p(jffi.StringCData): _type_ = 'z' _jffi_type = jffi.Type.STRING Added: branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/AbstractMemoryCData.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -0,0 +1,29 @@ + +package org.python.modules.jffi; + +import org.python.core.PyType; + +public abstract class AbstractMemoryCData extends CData implements Pointer { + protected DirectMemory memory; + + AbstractMemoryCData(PyType subtype, CType type, DirectMemory memory) { + super(subtype, type); + this.memory = memory; + } + @Override + public boolean __nonzero__() { + return !getMemory().isNull(); + } + + protected void initReferenceMemory(Memory m) { + m.putAddress(0, memory); + } + + public final long getAddress() { + return getMemory().getAddress(); + } + + public final DirectMemory getMemory() { + return hasReferenceMemory() ? getReferenceMemory().getMemory(0) : memory; + } +} Modified: branches/ctypes-jffi/src/org/python/modules/jffi/BoundedNativeMemory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/BoundedNativeMemory.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/BoundedNativeMemory.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -100,7 +100,18 @@ final long ptr = IO.getAddress(address + offset); return ptr != 0 ? new NativeMemory(ptr) : null; } + + public final byte[] getZeroTerminatedByteArray(long offset) { + checkBounds(offset, 1); + return IO.getZeroTerminatedByteArray(address + offset, (int) (size - offset)); + } + public void putZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len) { + // Ensure room for terminating zero byte + checkBounds(offset, len + 1); + IO.putZeroTerminatedByteArray(address + offset, bytes, off, len); + } + public final void putByte(long offset, byte value) { checkBounds(offset, 1); IO.putByte(address + offset, value); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -74,6 +74,9 @@ case POINTER: return new PointerInvoker(function, marshallers); + case STRING: + return new StringInvoker(function, marshallers); + default: break; } @@ -325,6 +328,17 @@ return Py.newLong(jffiInvoker.invokeAddress(jffiFunction, convertArguments(args))); } } + + private static final class StringInvoker extends BaseInvoker { + private static final com.kenai.jffi.MemoryIO IO = com.kenai.jffi.MemoryIO.getInstance(); + public StringInvoker(Function function, ParameterMarshaller[] marshallers) { + super(function, marshallers); + } + + public final PyObject invoke(PyObject[] args) { + return Util.newString(jffiInvoker.invokeAddress(jffiFunction, convertArguments(args))); + } + } /*------------------------------------------------------------------------*/ static abstract class BaseMarshaller implements ParameterMarshaller { @@ -414,7 +428,9 @@ public static final ParameterMarshaller INSTANCE = new StringMarshaller(); public void marshal(HeapInvocationBuffer buffer, PyObject parameter) { - if (parameter instanceof PyNone) { + if (parameter instanceof StringCData) { + buffer.putAddress(((StringCData) parameter).getMemory().getAddress()); + } else if (parameter instanceof PyNone) { buffer.putAddress(0); } else { byte[] bytes = parameter.toString().getBytes(); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/FastIntInvokerFactory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/FastIntInvokerFactory.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/FastIntInvokerFactory.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -87,6 +87,9 @@ case FLOAT: return Platform.getPlatform().getCPU() == Platform.CPU.I386 || Platform.getPlatform().getCPU() == Platform.CPU.X86_64; + + case STRING: + return Platform.getPlatform().addressSize() == 32; } } return false; @@ -283,6 +286,12 @@ } break; + case STRING: + if (Platform.getPlatform().addressSize() == 32) { + return StringResultConverter.INSTANCE; + } + break; + default: break; } @@ -570,6 +579,16 @@ } /** + * Converts a native string address result into into a python string instance + */ + static final class StringResultConverter extends BaseResultConverter { + public static final IntResultConverter INSTANCE = new StringResultConverter(); + public final PyObject pyValue(int value) { + return Util.newString(value); + } + } + + /** * Base class for all integer parameter converters. */ static abstract class BaseParameterConverter implements IntParameterConverter { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/HeapMemory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/HeapMemory.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/HeapMemory.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -121,6 +121,14 @@ return IO.getAddress(buffer, index(offset)); } + public final byte[] getZeroTerminatedByteArray(long offset) { + checkBounds(offset, 1); + int len = indexOf(offset, (byte) 0); + byte[] bytes = new byte[len != -1 ? len : length - (int) offset]; + System.arraycopy(buffer, index(offset), bytes, 0, bytes.length); + return bytes; + } + public final void putByte(long offset, byte value) { checkBounds(offset, 1); buffer[index(offset)] = value; @@ -163,6 +171,14 @@ checkBounds(offset, ADDRESS_SIZE); IO.putAddress(buffer, index(offset), value); } + + public void putZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len) { + // Ensure room for terminating zero byte + checkBounds(offset, len + 1); + System.arraycopy(bytes, off, buffer, index(offset), len); + buffer[len] = (byte) 0; + } + public final void get(long offset, byte[] dst, int off, int len) { checkBounds(offset, len); System.arraycopy(buffer, index(offset), dst, off, len); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Memory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Memory.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Memory.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -113,6 +113,14 @@ * pointed to by the address. */ public DirectMemory getMemory(long offset); + + /** + * Reads a zero terminated byte array (e.g. an ascii or utf-8 string) + * + * @param offset The offset within the memory area of the start of the string. + * @return A byte array containing a copy of the data. + */ + public byte[] getZeroTerminatedByteArray(long offset); /** * Writes an 8 bit integer value to the memory area at the specified offset. @@ -185,8 +193,18 @@ * @param value The pointer value to write to the memory location. */ public void putAddress(long offset, long value); - + /** + * Writes a byte array to memory, and appends a zero terminator + * + * @param offset The offset within the memory area of the start of the string. + * @param bytes The byte array to write to the memory. + * @param off The offset with the byte array to start copying. + * @param maxlen The number of bytes of the byte array to write to the memory area. (not including zero byte) + */ + public void putZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len); + + /** * Reads an array of bytes from the memory area at the specified offset. * * @param offset The offset within the memory area to read the bytes. Modified: branches/ctypes-jffi/src/org/python/modules/jffi/NativeMemory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/NativeMemory.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/NativeMemory.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -83,6 +83,14 @@ return ptr != 0 ? new NativeMemory(ptr) : null; } + public final byte[] getZeroTerminatedByteArray(long offset) { + return IO.getZeroTerminatedByteArray(address + offset); + } + + public void putZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len) { + IO.putZeroTerminatedByteArray(address + offset, bytes, off, len); + } + public final void putByte(long offset, byte value) { IO.putByte(address + offset, value); } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -11,15 +11,13 @@ import org.python.expose.ExposedType; @ExposedType(name = "jffi.PointerCData", base = CData.class) -public class PointerCData extends CData implements Pointer { +public class PointerCData extends AbstractMemoryCData implements Pointer { public static final PyType TYPE = PyType.fromClass(PointerCData.class); - private final DirectMemory memory; final MemoryOp componentMemoryOp; PointerCData(PyType subtype, CType type, DirectMemory memory, MemoryOp componentMemoryOp) { - super(subtype, type); - this.memory = memory; + super(subtype, type, memory); this.componentMemoryOp = componentMemoryOp; } @@ -59,23 +57,4 @@ public void setContents(PyObject value) { componentMemoryOp.put(getMemory(), 0, value); } - - @Override - public boolean __nonzero__() { - return !getMemory().isNull(); - } - - - protected void initReferenceMemory(Memory m) { - m.putAddress(0, memory); - } - - public final long getAddress() { - return getMemory().getAddress(); - } - - public final DirectMemory getMemory() { - return hasReferenceMemory() ? getReferenceMemory().getMemory(0) : memory; - } - } Added: branches/ctypes-jffi/src/org/python/modules/jffi/StringCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/StringCData.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/StringCData.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -0,0 +1,70 @@ + +package org.python.modules.jffi; + +import org.python.core.Py; +import org.python.core.PyNewWrapper; +import org.python.core.PyObject; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; + +@ExposedType(name = "jffi.StringCData", base = CData.class) +public class StringCData extends AbstractMemoryCData { + public static final PyType TYPE = PyType.fromClass(StringCData.class); + + public StringCData(PyType pytype, CType ctype, DirectMemory m) { + super(pytype, ctype, m); + } + + @ExposedNew + public static PyObject StringCData_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + + // No args == create NULL pointer + if (args.length == 0) { + return new StringCData(subtype, CType.typeOf(subtype), NullMemory.INSTANCE); + } + + byte[] str = args[0].asString().getBytes(); + DirectMemory m = AllocatedNativeMemory.allocate(str.length + 1, false); + m.putZeroTerminatedByteArray(0, str, 0, str.length); + return new StringCData(subtype, CType.typeOf(subtype), m); + } + + @ExposedGet(name = "value") + public PyObject getValue() { + Memory m = getMemory(); + return !m.isNull() + ? Py.newString(new String(m.getZeroTerminatedByteArray(0))) + : Py.None; + } + + + @ExposedSet(name = "value") + public void setValue(PyObject value) { + byte[] str = value.asString().getBytes(); + DirectMemory m = AllocatedNativeMemory.allocate(str.length + 1, false); + m.putZeroTerminatedByteArray(0, str, 0, str.length); + this.memory = m; + if (hasReferenceMemory()) { + getReferenceMemory().putAddress(0, m); + } + } + + @Override + public final String toString() { + return getType().getName() + "(" + getValue().toString() + ")"; + } + + @Override + public String asString() { + Memory m = getMemory(); + return !m.isNull() + ? new String(m.getZeroTerminatedByteArray(0)) + : null; + } + + +} Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Util.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Util.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Util.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -8,6 +8,8 @@ import org.python.core.PyObject; final class Util { + private static final com.kenai.jffi.MemoryIO IO = com.kenai.jffi.MemoryIO.getInstance(); + private Util() {} public static final PyObject newSigned8(int value) { @@ -47,6 +49,12 @@ : Py.newInteger(value); } + public static final PyObject newString(long address) { + return address != 0 + ? Py.newString(new String(IO.getZeroTerminatedByteArray(address))) + : Py.None; + } + public static final byte int8Value(PyObject parameter) { return (byte) parameter.asInt(); } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-09-03 15:45:59 UTC (rev 6745) +++ branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-09-04 00:43:55 UTC (rev 6746) @@ -23,6 +23,7 @@ dict.__setitem__("CData", CData.TYPE); dict.__setitem__("PointerCData", PointerCData.TYPE); dict.__setitem__("ScalarCData", ScalarCData.TYPE); + dict.__setitem__("StringCData", StringCData.TYPE); dict.__setitem__("Structure", Structure.TYPE); dict.__setitem__("StructLayout", StructLayout.TYPE); dict.__setitem__("FUNCFLAG_STDCALL", Py.newInteger(FUNCFLAG_STDCALL)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-09-03 15:46:07
|
Revision: 6745 http://jython.svn.sourceforge.net/jython/?rev=6745&view=rev Author: wmeissner Date: 2009-09-03 15:45:59 +0000 (Thu, 03 Sep 2009) Log Message: ----------- Add _type_ attribute to basic ctypes classes, and add c_bool Modified Paths: -------------- branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/CType.java branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java branches/ctypes-jffi/src/org/python/modules/jffi/NativeType.java branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-03 15:02:40 UTC (rev 6744) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-03 15:45:59 UTC (rev 6745) @@ -1,5 +1,23 @@ import jffi +_TypeMap = { + 'b': jffi.Type.BYTE, + 'B': jffi.Type.UBYTE, + 'h': jffi.Type.SHORT, + 'H': jffi.Type.USHORT, + 'i': jffi.Type.INT, + 'I': jffi.Type.UINT, + 'l': jffi.Type.LONG, + 'L': jffi.Type.ULONG, + 'q': jffi.Type.LONGLONG, + 'Q': jffi.Type.ULONGLONG, + 'f': jffi.Type.FLOAT, + 'd': jffi.Type.DOUBLE, + '?': jffi.Type.BOOL, + 'z': jffi.Type.STRING, + 'P': jffi.Type.POINTER +} + class _CTypeMetaClass(type): def __new__(cls, name, bases, dict): @@ -89,7 +107,12 @@ __metaclass__ = _UnionMetaClass def sizeof(type): - return type._jffi_type.size + if isinstance(type, jffi.CData): + return type._jffi_type.size + elif hasattr(type, '_type_'): + return _TypeMap[type.__getattribute__('_type_')] + else: + raise TypeError("invalid ctype") def alignment(type): return type._jffi_type.alignment @@ -121,40 +144,56 @@ _pointer_type_cache[ctype] = ptype return ptype +class c_bool(_ScalarCData): + _type_ = "?" + _jffi_type = jffi.Type.BOOL + class c_byte(_ScalarCData): + _type_ = 'b' _jffi_type = jffi.Type.BYTE class c_ubyte(_ScalarCData): + _type_ = 'B' _jffi_type = jffi.Type.UBYTE class c_short(_ScalarCData): + _type_ = 'h' _jffi_type = jffi.Type.SHORT class c_ushort(_ScalarCData): + _type_ = 'H' _jffi_type = jffi.Type.USHORT class c_int(_ScalarCData): + _type_ = 'i' _jffi_type = jffi.Type.INT class c_uint(_ScalarCData): + _type_ = 'I' _jffi_type = jffi.Type.UINT class c_longlong(_ScalarCData): + _type_ = 'q' _jffi_type = jffi.Type.LONGLONG class c_ulonglong(_ScalarCData): + _type_ = 'Q' _jffi_type = jffi.Type.ULONGLONG class c_long(_ScalarCData): + _type_ = 'l' _jffi_type = jffi.Type.LONG class c_ulong(_ScalarCData): + _type_ = 'L' _jffi_type = jffi.Type.ULONG class c_float(_ScalarCData): + _type_ = 'f' _jffi_type = jffi.Type.FLOAT class c_double(_ScalarCData): + _type_ = 'd' _jffi_type = jffi.Type.DOUBLE c_int8 = c_byte @@ -170,9 +209,11 @@ c_ssize_t = c_long class c_char_p(_ScalarCData): + _type_ = 'z' _jffi_type = jffi.Type.STRING class c_void_p(_ScalarCData): + _type_ = 'P' _jffi_type = jffi.Type.POINTER class _Function(jffi.Function): Modified: branches/ctypes-jffi/src/org/python/modules/jffi/CType.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/CType.java 2009-09-03 15:02:40 UTC (rev 6744) +++ branches/ctypes-jffi/src/org/python/modules/jffi/CType.java 2009-09-03 15:45:59 UTC (rev 6745) @@ -20,6 +20,7 @@ TYPE.fastGetDict().__setitem__("Pointer", Pointer.TYPE); } public static final CType VOID = primitive(NativeType.VOID); + public static final CType BOOL = primitive(NativeType.BOOL); public static final CType BYTE = primitive(NativeType.BYTE); public static final CType UBYTE = primitive(NativeType.UBYTE); public static final CType SHORT = primitive(NativeType.SHORT); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-03 15:02:40 UTC (rev 6744) +++ branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-03 15:45:59 UTC (rev 6745) @@ -11,6 +11,7 @@ abstract class MemoryOp { public static final MemoryOp INVALID = new InvalidOp(); public static final MemoryOp VOID = new VoidOp(); + public static final MemoryOp BOOL = new BooleanOp(); public static final MemoryOp INT8 = new Signed8(); public static final MemoryOp UINT8 = new Unsigned8(); public static final MemoryOp INT16 = new Signed16(); @@ -58,6 +59,8 @@ return POINTER; case STRING: return STRING; + case BOOL: + return BOOL; default: throw new UnsupportedOperationException("No MemoryOp for " + type); } @@ -85,6 +88,17 @@ throw Py.TypeError("Attempting to read void from memory"); } } + + private static final class BooleanOp extends MemoryOp { + public final void put(Memory mem, long offset, PyObject value) { + mem.putInt(offset, value.__nonzero__() ? 1 : 0); + } + + public final PyObject get(Memory mem, long offset) { + return Py.newBoolean(mem.getInt(offset) != 0); + } + } + static final class Signed8 extends MemoryOp { public final void put(Memory mem, long offset, PyObject value) { mem.putByte(offset, Util.int8Value(value)); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/NativeType.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/NativeType.java 2009-09-03 15:02:40 UTC (rev 6744) +++ branches/ctypes-jffi/src/org/python/modules/jffi/NativeType.java 2009-09-03 15:45:59 UTC (rev 6745) @@ -4,6 +4,7 @@ public enum NativeType { VOID, + BOOL, BYTE, UBYTE, SHORT, @@ -34,6 +35,7 @@ case USHORT: return com.kenai.jffi.Type.UINT16; case INT: + case BOOL: return com.kenai.jffi.Type.SINT32; case UINT: return com.kenai.jffi.Type.UINT32; Modified: branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-09-03 15:02:40 UTC (rev 6744) +++ branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-09-03 15:45:59 UTC (rev 6745) @@ -20,6 +20,7 @@ dict.__setitem__("DynamicLibrary", DynamicLibrary.TYPE); dict.__setitem__("Type", CType.TYPE); dict.__setitem__("Function", Function.TYPE); + dict.__setitem__("CData", CData.TYPE); dict.__setitem__("PointerCData", PointerCData.TYPE); dict.__setitem__("ScalarCData", ScalarCData.TYPE); dict.__setitem__("Structure", Structure.TYPE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-09-03 15:02:48
|
Revision: 6744 http://jython.svn.sourceforge.net/jython/?rev=6744&view=rev Author: wmeissner Date: 2009-09-03 15:02:40 +0000 (Thu, 03 Sep 2009) Log Message: ----------- Use a slightly more lightweight ByReference instance for byref() parameters. Add CData#getMemoryOp() instead of storing the memoryOp in CData Modified Paths: -------------- branches/ctypes-jffi/CoreExposed.includes branches/ctypes-jffi/src/org/python/modules/jffi/CData.java branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java Added Paths: ----------- branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java Modified: branches/ctypes-jffi/CoreExposed.includes =================================================================== --- branches/ctypes-jffi/CoreExposed.includes 2009-09-02 07:20:36 UTC (rev 6743) +++ branches/ctypes-jffi/CoreExposed.includes 2009-09-03 15:02:40 UTC (rev 6744) @@ -52,6 +52,7 @@ org/python/modules/_csv/PyWriter.class org/python/modules/_functools/PyPartial.class org/python/modules/_hashlib$Hash.class +org/python/modules/jffi/ByReference.class org/python/modules/jffi/CData.class org/python/modules/jffi/CType.class org/python/modules/jffi/CType$Array.class Added: branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/ByReference.java 2009-09-03 15:02:40 UTC (rev 6744) @@ -0,0 +1,26 @@ + +package org.python.modules.jffi; + +import org.python.core.PyObject; +import org.python.core.PyType; +import org.python.expose.ExposedType; + +@ExposedType(name = "jffi.ByReference", base = PyObject.class) +public final class ByReference extends PyObject implements Pointer { + public static final PyType TYPE = PyType.fromClass(ByReference.class); + + private final DirectMemory memory; + + ByReference(CType componentType, DirectMemory memory) { + super(TYPE); + this.memory = memory; + } + + public long getAddress() { + return getMemory().getAddress(); + } + + public final DirectMemory getMemory() { + return memory; + } +} Modified: branches/ctypes-jffi/src/org/python/modules/jffi/CData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/CData.java 2009-09-02 07:20:36 UTC (rev 6743) +++ branches/ctypes-jffi/src/org/python/modules/jffi/CData.java 2009-09-03 15:02:40 UTC (rev 6744) @@ -10,22 +10,26 @@ @ExposedType(name = "jffi.CData", base = PyObject.class) public abstract class CData extends PyObject { public static final PyType TYPE = PyType.fromClass(CData.class); + + private final CType ctype; - final MemoryOp memoryOp; - final CType type; - private DirectMemory referenceMemory; - CData(PyType subtype, CType type, MemoryOp memoryOp) { + CData(PyType subtype, CType type) { super(subtype); - this.type = type; - this.memoryOp = memoryOp; + this.ctype = type; this.referenceMemory = null; } - + + /** + * Wraps up this object in a pointer that can be passed to native code. + * The byref() return value cannot be used as anything other than a parameter. + * + * @return A ByReference instance pointing to this object's native memory. + */ @ExposedMethod(names= { "byref" }) public PyObject byref() { - return new PointerCData(PointerCData.TYPE, type, getReferenceMemory(), memoryOp); + return new ByReference(ctype, getReferenceMemory()); } @ExposedMethod(names= { "pointer" }) @@ -34,9 +38,17 @@ throw Py.TypeError("expected type"); } - return new PointerCData((PyType) pytype, type, getReferenceMemory(), memoryOp); + return new PointerCData((PyType) pytype, CType.typeOf(pytype), getReferenceMemory(), getMemoryOp()); } + final CType getCType() { + return ctype; + } + + MemoryOp getMemoryOp() { + return getCType().getMemoryOp(); + } + final boolean hasReferenceMemory() { return referenceMemory != null; } @@ -63,7 +75,7 @@ } protected DirectMemory allocateReferenceMemory() { - DirectMemory m = AllocatedNativeMemory.allocate(type.size(), false); + DirectMemory m = AllocatedNativeMemory.allocate(getCType().size(), false); initReferenceMemory(m); this.referenceMemory = m; return m; Modified: branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-02 07:20:36 UTC (rev 6743) +++ branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-03 15:02:40 UTC (rev 6744) @@ -188,8 +188,10 @@ public final void put(Memory mem, long offset, PyObject value) { if (value instanceof Pointer) { mem.putAddress(offset, ((Pointer) value).getAddress()); + } else if (value == Py.None) { + mem.putAddress(offset, 0); } else { - mem.putAddress(offset, Util.int64Value(value)); + throw Py.RuntimeError("invalid pointer"); } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java 2009-09-02 07:20:36 UTC (rev 6743) +++ branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java 2009-09-03 15:02:40 UTC (rev 6744) @@ -18,16 +18,11 @@ final MemoryOp componentMemoryOp; PointerCData(PyType subtype, CType type, DirectMemory memory, MemoryOp componentMemoryOp) { - super(subtype, type, type.getMemoryOp()); + super(subtype, type); this.memory = memory; this.componentMemoryOp = componentMemoryOp; } - - PointerCData(CType type, DirectMemory memory, MemoryOp componentMemoryOp) { - this(TYPE, type, memory, componentMemoryOp); - } - - + @ExposedNew public static PyObject PointerCData_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { @@ -38,18 +33,20 @@ throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); } - CType.Pointer type = (CType.Pointer) jffi_type; + CType.Pointer pointerType = (CType.Pointer) jffi_type; + // No args == create NULL pointer if (args.length == 0) { - return new PointerCData(subtype, type, NullMemory.INSTANCE, type.componentMemoryOp); + return new PointerCData(subtype, pointerType, NullMemory.INSTANCE, pointerType.componentMemoryOp); } + PyObject value = args[0]; - if (value instanceof CData && value.getType().isSubType(type.pyComponentType)) { + if (value instanceof CData && value.getType().isSubType(pointerType.pyComponentType)) { - return new PointerCData(subtype, type, ((CData) value).getReferenceMemory(), type.componentMemoryOp); + return new PointerCData(subtype, pointerType, ((CData) value).getReferenceMemory(), pointerType.componentMemoryOp); } else { - throw Py.TypeError("expected " + type.pyComponentType.getName() + " instead of " + value.getType().getName()); + throw Py.TypeError("expected " + pointerType.pyComponentType.getName() + " instead of " + value.getType().getName()); } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java 2009-09-02 07:20:36 UTC (rev 6743) +++ branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java 2009-09-03 15:02:40 UTC (rev 6744) @@ -37,19 +37,19 @@ return cdata; } - ScalarCData(PyType pyType, CType.Builtin type) { - super(pyType, type, type.getMemoryOp()); + ScalarCData(PyType pytype, CType.Builtin ctype) { + super(pytype, ctype); } protected final void initReferenceMemory(Memory m) { - memoryOp.put(m, 0, value); + getMemoryOp().put(m, 0, value); } @ExposedGet(name = "value") public PyObject getValue() { // If native memory has been allocated, read the value from there if (hasReferenceMemory()) { - return memoryOp.get(getReferenceMemory(), 0); + return getMemoryOp().get(getReferenceMemory(), 0); } return value; @@ -61,7 +61,7 @@ this.value = value; // If native memory has been allocated, sync the value to memory if (hasReferenceMemory()) { - memoryOp.put(getReferenceMemory(), 0, value); + getMemoryOp().put(getReferenceMemory(), 0, value); } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-02 07:20:36 UTC (rev 6743) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-03 15:02:40 UTC (rev 6744) @@ -13,14 +13,16 @@ public static final PyType TYPE = PyType.fromClass(Structure.class); private final StructLayout layout; + private final MemoryOp memoryOp; Structure(PyType pyType, StructLayout layout) { this(pyType, layout, AllocatedNativeMemory.allocate(layout.size(), true)); } Structure(PyType pyType, StructLayout layout, Memory m) { - super(pyType, layout, new MemoryOp.StructOp(pyType, layout)); + super(pyType, layout); this.layout = layout; + this.memoryOp = new MemoryOp.StructOp(pyType, layout); setReferenceMemory(m); } @@ -40,6 +42,11 @@ throw Py.RuntimeError("reference memory already initialized"); } + @Override + MemoryOp getMemoryOp() { + return memoryOp; + } + StructLayout.Field getField(PyObject key) { StructLayout.Field f = layout.getField(key); if (f == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-09-02 07:20:45
|
Revision: 6743 http://jython.svn.sourceforge.net/jython/?rev=6743&view=rev Author: wmeissner Date: 2009-09-02 07:20:36 +0000 (Wed, 02 Sep 2009) Log Message: ----------- Implement structs with simple (non-bitfield) scalar members Modified Paths: -------------- branches/ctypes-jffi/CoreExposed.includes branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/CData.java branches/ctypes-jffi/src/org/python/modules/jffi/CType.java branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java Added Paths: ----------- branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java Modified: branches/ctypes-jffi/CoreExposed.includes =================================================================== --- branches/ctypes-jffi/CoreExposed.includes 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/CoreExposed.includes 2009-09-02 07:20:36 UTC (rev 6743) @@ -60,7 +60,11 @@ org/python/modules/jffi/DynamicLibrary$Symbol.class org/python/modules/jffi/Function.class org/python/modules/jffi/PointerCData.class +org/python/modules/jffi/Structure.class org/python/modules/jffi/ScalarCData.class +org/python/modules/jffi/StructLayout.class +org/python/modules/jffi/StructLayout$Field.class +org/python/modules/jffi/StructLayout$ScalarField.class org/python/modules/_threading/Condition.class org/python/modules/_threading/Lock.class org/python/modules/_weakref/CallableProxyType.class Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-09-02 07:20:36 UTC (rev 6743) @@ -24,6 +24,70 @@ def __len__(self): return self._jffi_type.length +class _StructLayoutBuilder(object): + def __init__(self, union = False): + self.size = 0 + self.offset = 0 + self.fields = [] + self.union = union + + def align(self, offset, align): + return align + ((offset - 1) & ~(align - 1)); + + def add_fields(self, fields): + for f in fields: + self.add_field(f) + return self + + def add_field(self, f): + if not issubclass(f[1], _ScalarCData): + raise RuntimeError("non-scalar fields not supported") + + if len(f) != 2: + raise RuntimeError("structs with bitfields not supported") + + self.offset = self.align(self.offset, alignment(f[1])) + self.fields.append(jffi.StructLayout.ScalarField(f[0], f[1], self.offset)) + if not self.union: + self.offset += sizeof(f[1]) + self.size = max(self.offset, sizeof(f[1])) + + return self + + def build(self): + return jffi.StructLayout(fields = self.fields, union = self.union) + +class _StructMetaClass(type): + def __new__(cls, name, bases, dict): + try: + layout = dict['_jffi_type'] = _StructLayoutBuilder().add_fields(dict['_fields_']).build() + # make all fields accessible via .foo + for f in dict['_fields_']: + dict[f[0]] = layout[f[0]] + except: + pass + + return type.__new__(cls, name, bases, dict) + +class _UnionMetaClass(type): + def __new__(cls, name, bases, dict): + try: + layout = dict['_jffi_type'] = _StructLayoutBuilder().add_fields(dict['_fields_'], union = True).build() + # make all fields accessible via .foo + for f in dict['_fields_']: + dict[f[0]] = layout[f[0]] + except: + pass + + + return type.__new__(cls, name, bases, dict) + +class Structure(jffi.Structure): + __metaclass__ = _StructMetaClass + +class Union(jffi.Structure): + __metaclass__ = _UnionMetaClass + def sizeof(type): return type._jffi_type.size @@ -34,7 +98,7 @@ return cdata.byref() def pointer(cdata): - return cdata.pointer() + return cdata.pointer(POINTER(cdata.__class__)) _pointer_type_cache = {} def POINTER(ctype): @@ -170,14 +234,3 @@ return self._dlltype(name) cdll = LibraryLoader(CDLL) - -# -#class _StructMetaClass(type): -# def __new__(cls, name, bases, dict): -# for attr in dict: -# if attr == '_fields_': -# print "%s has attr %s" % (name, attr) -# return type.__new__(cls, name, bases, dict) -# -#class Structure: -# __metaclass__ = _StructMetaClass Modified: branches/ctypes-jffi/src/org/python/modules/jffi/CData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/CData.java 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/src/org/python/modules/jffi/CData.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -23,11 +23,20 @@ this.referenceMemory = null; } - @ExposedMethod(names= { "byref", "pointer" }) + @ExposedMethod(names= { "byref" }) public PyObject byref() { - return new PointerCData(type, getReferenceMemory(), memoryOp); + return new PointerCData(PointerCData.TYPE, type, getReferenceMemory(), memoryOp); } + @ExposedMethod(names= { "pointer" }) + public PyObject pointer(PyObject pytype) { + if (!(pytype instanceof PyType)) { + throw Py.TypeError("expected type"); + } + + return new PointerCData((PyType) pytype, type, getReferenceMemory(), memoryOp); + } + final boolean hasReferenceMemory() { return referenceMemory != null; } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/CType.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/CType.java 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/src/org/python/modules/jffi/CType.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -152,12 +152,14 @@ final MemoryOp componentMemoryOp; Pointer(PyType subtype, PyType pyComponentType, CType componentType) { - super(NativeType.POINTER, com.kenai.jffi.Type.POINTER, MemoryOp.POINTER); + super(NativeType.POINTER, com.kenai.jffi.Type.POINTER, new MemoryOp.PointerOp(subtype, CType.POINTER)); this.pyComponentType = pyComponentType; this.componentType = componentType; if (pyComponentType.isSubType(ScalarCData.TYPE)) { - this.componentMemoryOp = new ScalarOp(MemoryOp.getMemoryOp(componentType.getNativeType()), pyComponentType); + this.componentMemoryOp = new ScalarOp(componentType.getMemoryOp(), pyComponentType); + } else if (pyComponentType.isSubType(Structure.TYPE)) { + this.componentMemoryOp = new MemoryOp.StructOp(pyComponentType); } else { throw Py.TypeError("pointer only supported for scalar types"); } @@ -168,15 +170,15 @@ public static PyObject Pointer_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { + if (args.length != 1) { + throw Py.TypeError(String.format("__init__() takes exactly 1 argument (%d given)", args.length)); + } + Pointer p = typeCache.get(args[0]); if (p != null) { return p; } - if (args.length != 1) { - throw Py.TypeError(String.format("__init__() takes exactly 1 argument (%d given)", args.length)); - } - if (!(args[0] instanceof PyType)) { throw Py.TypeError("expected ctypes class"); } @@ -217,5 +219,7 @@ return result; } } + + } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -430,6 +430,8 @@ public void marshal(HeapInvocationBuffer buffer, PyObject parameter) { if (parameter instanceof Pointer) { buffer.putAddress(((Pointer) parameter).getAddress()); + } else if (parameter == Py.None) { + buffer.putAddress(0); } else { throw Py.TypeError("expected pointer argument"); } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -3,6 +3,7 @@ import org.python.core.Py; import org.python.core.PyObject; +import org.python.core.PyType; /** * Defines memory operations for a primitive type @@ -20,7 +21,7 @@ public static final MemoryOp UINT64 = new Unsigned64(); public static final MemoryOp FLOAT = new Float32(); public static final MemoryOp DOUBLE = new Float64(); - public static final MemoryOp POINTER = new PointerOp(); + public static final MemoryOp POINTER = new PointerOp(PointerCData.TYPE, CType.POINTER); public static final MemoryOp STRING = new StringOp(); public static final MemoryOp getMemoryOp(NativeType type) { @@ -175,7 +176,15 @@ return Py.newFloat(mem.getDouble(offset)); } } - private static final class PointerOp extends MemoryOp { + static final class PointerOp extends MemoryOp { + private final PyType pytype; + private final CType ctype; + + public PointerOp(PyType pytype, CType ctype) { + this.pytype = pytype; + this.ctype = ctype; + } + public final void put(Memory mem, long offset, PyObject value) { if (value instanceof Pointer) { mem.putAddress(offset, ((Pointer) value).getAddress()); @@ -186,9 +195,10 @@ public final PyObject get(Memory mem, long offset) { DirectMemory dm = new NativeMemory(mem.getAddress(offset)); - return new PointerCData(CType.POINTER, dm, INVALID); + return new PointerCData(pytype, ctype, dm, INVALID); } } + private static final class StringOp extends MemoryOp { public final void put(Memory mem, long offset, PyObject value) { throw Py.NotImplementedError("Cannot set String"); @@ -198,4 +208,32 @@ throw Py.NotImplementedError("Cannot get String"); } } + + static final class StructOp extends MemoryOp { + + private final PyType type; + private final StructLayout layout; + + public StructOp(PyType type) { + this.type = type; + PyObject l = type.__getattr__("_jffi_type"); + if (!(l instanceof StructLayout)) { + throw Py.TypeError("invalid _jffi_type for " + type.fastGetName() + "; should be instance of jffi.StructLayout"); + } + this.layout = (StructLayout) l; + } + + public StructOp(PyType type, StructLayout layout) { + this.type = type; + this.layout = layout; + } + + public final void put(Memory mem, long offset, PyObject value) { + throw Py.NotImplementedError("not implemented"); + } + + public final PyObject get(Memory mem, long offset) { + return new Structure(type, layout, mem.slice(offset)); + } + } } Added: branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/StructLayout.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -0,0 +1,160 @@ + +package org.python.modules.jffi; + +import java.util.HashMap; +import java.util.Map; +import org.python.core.ArgParser; +import org.python.core.Py; +import org.python.core.PyList; +import org.python.core.PyNewWrapper; +import org.python.core.PyObject; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedType; + +@ExposedType(name = "jffi.StructLayout", base = CType.class) +public class StructLayout extends CType { + public static final PyType TYPE = PyType.fromClass(StructLayout.class); + static { + TYPE.fastGetDict().__setitem__("Field", Field.TYPE); + TYPE.fastGetDict().__setitem__("ScalarField", ScalarField.TYPE); + } + + private final Map<PyObject, Field> fieldMap; + + StructLayout(Field[] fields, com.kenai.jffi.Type struct, MemoryOp op) { + super(NativeType.STRUCT, struct, op); + Map<PyObject, Field> m = new HashMap<PyObject, Field>(fields.length); + for (Field f : fields) { + m.put(f.name, f); + } + this.fieldMap = m; + } + + @ExposedType(name = "jffi.StructLayout.Field", base = PyObject.class) + public static class Field extends PyObject { + public static final PyType TYPE = PyType.fromClass(Field.class); + @ExposedGet + final CType ctype; + + @ExposedGet + final int offset; + + final PyObject name; + + final MemoryOp op; + + Field(PyObject name, CType ctype, int offset, MemoryOp op) { + this.name = name; + this.ctype = ctype; + this.offset = offset; + this.op = op; + } + + Field(PyObject name, CType ctype, int offset) { + this(name, ctype, offset, ctype.getMemoryOp()); + } + + private static org.python.modules.jffi.Pointer asPointer(PyObject obj) { + if (!(obj instanceof org.python.modules.jffi.Pointer)) { + throw Py.TypeError("expected pointer"); + } + + return (org.python.modules.jffi.Pointer) obj; + } + + @Override + public PyObject __get__(PyObject obj, PyObject type) { + return Field___get__(obj, type); + } + + @Override + public void __set__(PyObject obj, PyObject value) { + Field___set__(obj, value); + } + + @ExposedMethod + public PyObject Field___get__(PyObject obj, PyObject type) { + return op.get(asPointer(obj).getMemory(), offset); + } + + @ExposedMethod + public void Field___set__(PyObject obj, PyObject value) { + op.put(asPointer(obj).getMemory(), offset, value); + } + + + @ExposedMethod(names={"get" }) + PyObject get(PyObject obj) { + return op.get(asPointer(obj).getMemory(), offset); + } + + @ExposedMethod(names={"set"}) + PyObject set(PyObject obj, PyObject value) { + + op.put(asPointer(obj).getMemory(), offset, value); + + return value; + } + } + + @ExposedNew + public static PyObject StructLayout_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + + ArgParser ap = new ArgParser("__init__", args, keywords, new String[] { "fields", "union" }, 1); + + if (!(ap.getPyObject(0) instanceof PyList)) { + throw Py.TypeError("expected list of jffi.StructLayout.Field"); + } + + PyList pyFields = (PyList) ap.getPyObject(0); + com.kenai.jffi.Type[] fieldTypes = new com.kenai.jffi.Type[pyFields.size()]; + Field[] fields = new Field[pyFields.size()]; + + for (int i = 0; i < fields.length; ++i) { + PyObject pyField = pyFields.pyget(i); + if (!(pyField instanceof Field)) { + throw Py.TypeError(String.format("element %d of field list is not an instance of jffi.StructLayout.Field", i)); + } + Field f = (Field) pyField; + fields[i] = f; + fieldTypes[i] = f.ctype.jffiType; + } + + com.kenai.jffi.Type jffiType = ap.getPyObject(1, Py.False).__nonzero__() + ? new com.kenai.jffi.Union(fieldTypes) + : new com.kenai.jffi.Struct(fieldTypes); + + return new StructLayout(fields, jffiType, MemoryOp.INVALID); + } + + @ExposedType(name = "jffi.StructLayout.ScalarField", base = Field.class) + public static class ScalarField extends Field { + public static final PyType TYPE = PyType.fromClass(ScalarField.class); + + public ScalarField(PyObject name, CType ctype, int offset) { + super(name, ctype, offset); + } + + @ExposedNew + public static PyObject ScalarField_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("__init__", args, keywords, new String[] { "name", "type", "offset"}); + + return new ScalarField(ap.getPyObject(0), CType.typeOf(ap.getPyObject(1)), ap.getInt(2)); + } + } + + Field getField(PyObject name) { + return fieldMap.get(name); + } + + @Override + public PyObject __getitem__(PyObject key) { + StructLayout.Field f = getField(key); + return f != null ? f : Py.None; + } +} Added: branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Structure.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -0,0 +1,71 @@ + +package org.python.modules.jffi; + +import org.python.core.Py; +import org.python.core.PyNewWrapper; +import org.python.core.PyObject; +import org.python.core.PyType; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedType; + +@ExposedType(name = "jffi.Structure", base = CData.class) +public class Structure extends CData implements Pointer { + public static final PyType TYPE = PyType.fromClass(Structure.class); + + private final StructLayout layout; + + Structure(PyType pyType, StructLayout layout) { + this(pyType, layout, AllocatedNativeMemory.allocate(layout.size(), true)); + } + + Structure(PyType pyType, StructLayout layout, Memory m) { + super(pyType, layout, new MemoryOp.StructOp(pyType, layout)); + this.layout = layout; + setReferenceMemory(m); + } + + @ExposedNew + public static PyObject Structure_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + + PyObject layout = subtype.__getattr__("_jffi_type"); + if (!(layout instanceof StructLayout)) { + throw Py.TypeError("invalid _jffi_type for " + subtype.fastGetName() + "; should be instance of jffi.StructLayout"); + } + + return new Structure(subtype, (StructLayout) layout); + } + + protected final void initReferenceMemory(Memory m) { + throw Py.RuntimeError("reference memory already initialized"); + } + + StructLayout.Field getField(PyObject key) { + StructLayout.Field f = layout.getField(key); + if (f == null) { + throw Py.NameError(String.format("struct %s has no field '%s'", getType().fastGetName(), key.toString())); + } + return f; + } + + @Override + public PyObject __getitem__(PyObject key) { + StructLayout.Field f = getField(key); + return f.op.get(getReferenceMemory(), f.offset); + } + + @Override + public void __setitem__(PyObject key, PyObject value) { + StructLayout.Field f = getField(key); + f.op.put(getReferenceMemory(), f.offset, value); + } + + public long getAddress() { + return getMemory().getAddress(); + } + + public DirectMemory getMemory() { + return getReferenceMemory(); + } + +} Modified: branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-09-01 14:27:33 UTC (rev 6742) +++ branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-09-02 07:20:36 UTC (rev 6743) @@ -22,6 +22,8 @@ dict.__setitem__("Function", Function.TYPE); dict.__setitem__("PointerCData", PointerCData.TYPE); dict.__setitem__("ScalarCData", ScalarCData.TYPE); + dict.__setitem__("Structure", Structure.TYPE); + dict.__setitem__("StructLayout", StructLayout.TYPE); dict.__setitem__("FUNCFLAG_STDCALL", Py.newInteger(FUNCFLAG_STDCALL)); dict.__setitem__("FUNCFLAG_CDECL", Py.newInteger(FUNCFLAG_CDECL)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 14:27:41
|
Revision: 6742 http://jython.svn.sourceforge.net/jython/?rev=6742&view=rev Author: fwierzbicki Date: 2009-09-01 14:27:33 +0000 (Tue, 01 Sep 2009) Log Message: ----------- tag 2.5.1rc1 Added Paths: ----------- tags/Release_2_5_1rc1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 14:26:07
|
Revision: 6741 http://jython.svn.sourceforge.net/jython/?rev=6741&view=rev Author: fwierzbicki Date: 2009-09-01 14:25:55 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Crud, also update the version text strings. Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-09-01 14:24:42 UTC (rev 6740) +++ trunk/jython/build.xml 2009-09-01 14:25:55 UTC (rev 6741) @@ -124,8 +124,8 @@ <property name="PY_RELEASE_LEVEL_SNAPSHOT" value="170"/> <!-- 0xAA --> <!-- The current version info --> - <property name="jython.version" value="2.5.0+"/> - <property name="jython.version.noplus" value="2.5.0"/> + <property name="jython.version" value="2.5.1+"/> + <property name="jython.version.noplus" value="2.5.1"/> <property name="jython.major_version" value="2"/> <property name="jython.minor_version" value="5"/> <property name="jython.micro_version" value="1"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 14:24:48
|
Revision: 6740 http://jython.svn.sourceforge.net/jython/?rev=6740&view=rev Author: fwierzbicki Date: 2009-09-01 14:24:42 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Mark release as Gamma level (release candidate) and serial of 1. Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-09-01 14:02:31 UTC (rev 6739) +++ trunk/jython/build.xml 2009-09-01 14:24:42 UTC (rev 6740) @@ -129,8 +129,8 @@ <property name="jython.major_version" value="2"/> <property name="jython.minor_version" value="5"/> <property name="jython.micro_version" value="1"/> - <property name="jython.release_level" value="${PY_RELEASE_LEVEL_FINAL}"/> - <property name="jython.release_serial" value="0"/> + <property name="jython.release_level" value="${PY_RELEASE_LEVEL_GAMMA}"/> + <property name="jython.release_serial" value="1"/> <condition property="do.snapshot.build"> <isset property="snapshot.revision" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 14:02:39
|
Revision: 6739 http://jython.svn.sourceforge.net/jython/?rev=6739&view=rev Author: fwierzbicki Date: 2009-09-01 14:02:31 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Update README Modified Paths: -------------- trunk/jython/README.txt Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2009-09-01 13:59:14 UTC (rev 6738) +++ trunk/jython/README.txt 2009-09-01 14:02:31 UTC (rev 6739) @@ -1,11 +1,10 @@ -Welcome to Jython 2.5.0 -======================= +Welcome to Jython 2.5.1rc1 +========================== -This is the final release of the 2.5.0 version of Jython and brings us up to -language level compatibility with the 2.5 version of CPython. This release has -had a strong focus on CPython compatibility, and so this release of Jython can -run more pure Python apps then any previous release. Please see the NEWS file -for detailed release notes. +This is the first release candidate of the 2.5.1 version of Jython. This +release fixes a number of bugs, including some major errors when using +coroutines and when using relative imports. Please see the NEWS file for +detailed release notes. The release was compiled on Mac OS X with JDK 5 and requires JDK 5 to run. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 13:59:21
|
Revision: 6738 http://jython.svn.sourceforge.net/jython/?rev=6738&view=rev Author: fwierzbicki Date: 2009-09-01 13:59:14 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Update version numbers. Modified Paths: -------------- trunk/jython/NEWS trunk/jython/build.xml Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-09-01 13:57:52 UTC (rev 6737) +++ trunk/jython/NEWS 2009-09-01 13:59:14 UTC (rev 6738) @@ -1,6 +1,6 @@ Jython NEWS -Jython 2.5.1 +Jython 2.5.1rc1 New Features - Upgraded to ANTLR 3.1.3 - [ 1859477 ] Dynamically loaded ServletFilters like PyServlet Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-09-01 13:57:52 UTC (rev 6737) +++ trunk/jython/build.xml 2009-09-01 13:59:14 UTC (rev 6738) @@ -128,7 +128,7 @@ <property name="jython.version.noplus" value="2.5.0"/> <property name="jython.major_version" value="2"/> <property name="jython.minor_version" value="5"/> - <property name="jython.micro_version" value="0"/> + <property name="jython.micro_version" value="1"/> <property name="jython.release_level" value="${PY_RELEASE_LEVEL_FINAL}"/> <property name="jython.release_serial" value="0"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-09-01 13:57:59
|
Revision: 6737 http://jython.svn.sourceforge.net/jython/?rev=6737&view=rev Author: fwierzbicki Date: 2009-09-01 13:57:52 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Increment APIVersion for coroutine bugfixes in compiler. Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-08-31 18:47:55 UTC (rev 6736) +++ trunk/jython/src/org/python/core/imp.java 2009-09-01 13:57:52 UTC (rev 6737) @@ -21,7 +21,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - private static final int APIVersion = 24; + private static final int APIVersion = 25; public static final int NO_MTIME = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-31 18:48:02
|
Revision: 6736 http://jython.svn.sourceforge.net/jython/?rev=6736&view=rev Author: fwierzbicki Date: 2009-08-31 18:47:55 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Update NEWS Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-08-31 18:46:06 UTC (rev 6735) +++ trunk/jython/NEWS 2009-08-31 18:47:55 UTC (rev 6736) @@ -29,6 +29,7 @@ - [ 1430 ] Oracle JDBC Connection close - [ 1406 ] Parsing a simple PEP 342 coroutine crashes Jython 2.5 - [ 1407 ] ClassCastException in plain Python coroutine + - [ 1424 ] Relative imports do not work in some cases Jython 2.5.0 The same as rc4. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-31 18:46:13
|
Revision: 6735 http://jython.svn.sourceforge.net/jython/?rev=6735&view=rev Author: fwierzbicki Date: 2009-08-31 18:46:06 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Fix for http://bugs.jython.org/issue1424 "Relative imports do not work in some cases". Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-08-31 17:40:57 UTC (rev 6734) +++ trunk/jython/src/org/python/core/imp.java 2009-08-31 18:46:06 UTC (rev 6735) @@ -619,7 +619,7 @@ */ private static PyObject import_next(PyObject mod, StringBuilder parentNameBuffer, String name, String outerFullName, PyObject fromlist) { - if (parentNameBuffer.length() > 0) { + if (parentNameBuffer.length() > 0 && name != null && name.length() > 0) { parentNameBuffer.append('.'); } parentNameBuffer.append(name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-31 17:41:10
|
Revision: 6734 http://jython.svn.sourceforge.net/jython/?rev=6734&view=rev Author: fwierzbicki Date: 2009-08-31 17:40:57 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Merged revisions 6489-6522,6525-6539,6543-6550,6552-6558,6566-6568,6570-6571,6575,6580-6623,6626-6659,6662-6665,6667-6698,6710,6713,6717-6719,6724-6725 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ................ r6489 | amak | 2009-06-21 18:19:53 -0400 (Sun, 21 Jun 2009) | 1 line Checking in a partial fix for issue 1378. This fix stops the AttributeError. But further work is needed to determine what cpython errno constants the java SSL exceptions should map to. ................ r6490 | cgroves | 2009-06-22 02:32:34 -0400 (Mon, 22 Jun 2009) | 4 lines Add enough of mockrunner to run servlet tests and use that to run the modjy tests and some new PyServlet tests from our regular build. ................ r6491 | cgroves | 2009-06-22 02:48:53 -0400 (Mon, 22 Jun 2009) | 1 line Coding conventions and modernization ................ r6492 | cgroves | 2009-06-22 04:27:10 -0400 (Mon, 22 Jun 2009) | 1 line Add jfeinberg's PyFilter from #1859477. Still need to test this in an actual ServletContainer ................ r6493 | cgroves | 2009-06-22 04:43:07 -0400 (Mon, 22 Jun 2009) | 4 lines Windows line endings to unix, tabs to spaces, unused import removal, and general coding standard conformity. ................ r6494 | fwierzbicki | 2009-06-22 12:38:12 -0400 (Mon, 22 Jun 2009) | 2 lines Upgraded to ANTLR 3.1.3 ................ r6495 | fwierzbicki | 2009-06-22 22:20:07 -0400 (Mon, 22 Jun 2009) | 2 lines Part 1 of making PythonPartial.g diffable from Python.g. ................ r6496 | cgroves | 2009-06-23 02:17:57 -0400 (Tue, 23 Jun 2009) | 3 lines Break an initializer clas out of PyServlet to keep PyServlet from being a ServletContextListener. ................ r6497 | cgroves | 2009-06-23 02:21:59 -0400 (Tue, 23 Jun 2009) | 1 line Adding jfeinberg for PyFilter ................ r6498 | cgroves | 2009-06-23 02:51:07 -0400 (Tue, 23 Jun 2009) | 1 line Don't extend PyReflectedField in PyBeanEventProperty. Fixes Issue1377 by keeping PyJavaType from accessing field spuriously on PyBeanEventProperties. ................ r6499 | cgroves | 2009-06-23 03:50:56 -0400 (Tue, 23 Jun 2009) | 1 line NEWS updates ................ r6500 | cgroves | 2009-06-28 22:23:57 -0400 (Sun, 28 Jun 2009) | 1 line Adding a test for bug #1381 that doesn't actually cause the problem described ................ r6501 | cgroves | 2009-06-29 01:42:24 -0400 (Mon, 29 Jun 2009) | 1 line Update error message for PyServlet not being a ServletContextListener ................ r6502 | cgroves | 2009-06-29 02:13:29 -0400 (Mon, 29 Jun 2009) | 1 line Add the root dir and WEB-INF/jython to sys.path for PyFilters as well as PyServlets ................ r6503 | cgroves | 2009-06-29 02:25:28 -0400 (Mon, 29 Jun 2009) | 1 line Explain how to set python.home for the context initializer ................ r6504 | cgroves | 2009-06-30 02:09:12 -0400 (Tue, 30 Jun 2009) | 3 lines Add a test from Sven Reimers that actually tickles issue 1381 and fix it. ................ r6505 | cgroves | 2009-06-30 02:11:20 -0400 (Tue, 30 Jun 2009) | 1 line Keep forgetting to update this ................ r6506 | amak | 2009-07-03 11:45:08 -0400 (Fri, 03 Jul 2009) | 4 lines 1. Added support for the AI_PASSIVE flag 2. Added support for the AI_CANONNAME flag 3. Added unit tests for same 4. Split out getaddrinfo unit tests into their own test case class ................ r6507 | fwierzbicki | 2009-07-03 19:10:43 -0400 (Fri, 03 Jul 2009) | 3 lines Make PythonPartial easier to diff w/ Python.g, and small whitespace fix in Python.g. ................ r6508 | fwierzbicki | 2009-07-05 10:55:44 -0400 (Sun, 05 Jul 2009) | 3 lines Last of the "make PythonPartial.g diffable from Python.g". Now on to actually fixing some PythonPartial problems. ................ r6509 | fwierzbicki | 2009-07-05 14:07:53 -0400 (Sun, 05 Jul 2009) | 2 lines PythonPartial now has it's own lexer. ................ r6510 | fwierzbicki | 2009-07-05 18:34:44 -0400 (Sun, 05 Jul 2009) | 2 lines Whitespace fixes for easier diffs. ................ r6511 | fwierzbicki | 2009-07-05 18:58:57 -0400 (Sun, 05 Jul 2009) | 3 lines Now that PythonPartial has a separate Lexer, remove behavior related to variable "partial". ................ r6512 | fwierzbicki | 2009-07-06 09:47:19 -0400 (Mon, 06 Jul 2009) | 3 lines Fix for http://bugs.jython.org/issue1365 "continuation lines fail in interactive interpreter". ................ r6513 | fwierzbicki | 2009-07-06 10:15:32 -0400 (Mon, 06 Jul 2009) | 4 lines The grammar cleanup in the last few checkins also fixed http://bugs.jython.org/issue1366 "parsing of lamda expression fails" where certain lambda expressions failed to parse in interactive mode. ................ r6514 | fwierzbicki | 2009-07-06 12:31:40 -0400 (Mon, 06 Jul 2009) | 4 lines Tightened interactive parse of partial strings. Two of the commented out tests for test_codeop now pass. Unfortunately one new test fails, but it is less serious than the two that are now fixed, so commented it out for now. ................ r6515 | fwierzbicki | 2009-07-06 14:02:32 -0400 (Mon, 06 Jul 2009) | 2 lines Whitespace cleanup. ................ r6516 | fwierzbicki | 2009-07-06 22:24:24 -0400 (Mon, 06 Jul 2009) | 3 lines Start of a Base grammar that is the common code from Python.g and PythonPartial.g. ................ r6517 | pjenvey | 2009-07-06 23:41:42 -0400 (Mon, 06 Jul 2009) | 3 lines convert unicode hashlib input to str via defaultencoding fixes #1189 ................ r6518 | pjenvey | 2009-07-07 00:49:12 -0400 (Tue, 07 Jul 2009) | 1 line unused method ................ r6519 | amak | 2009-07-07 07:05:16 -0400 (Tue, 07 Jul 2009) | 2 lines Commenting out a single test that gives varying results across platforms, and thus cannot be reliably tested. Also some whitespace cleanup. ................ r6520 | amak | 2009-07-07 07:36:34 -0400 (Tue, 07 Jul 2009) | 1 line Commenting out all AI_CANONNAME tests for now. Much further research needed; may never be cross-platform testable. ................ r6521 | fwierzbicki | 2009-07-07 08:43:53 -0400 (Tue, 07 Jul 2009) | 2 lines More whitespace cleanup and "diff shrinking" between all of the grammars. ................ r6522 | amak | 2009-07-07 13:29:56 -0400 (Tue, 07 Jul 2009) | 1 line Fixing a previously unspotted bug in modjy's handling of imports in .pth files. ................ r6525 | amak | 2009-07-07 17:13:06 -0400 (Tue, 07 Jul 2009) | 1 line Javadoc corrections. ................ r6526 | cgroves | 2009-07-08 21:47:52 -0400 (Wed, 08 Jul 2009) | 1 line Ensure that Thread.group is None since we're not doing anything with it, and that's what CPython does ................ r6527 | zyasoft | 2009-07-11 02:47:49 -0400 (Sat, 11 Jul 2009) | 16 lines Added the ContextManager interface and supporting code to enable context mgmt through the with-statement to be efficiently inlined by the JVM. The ContextManager interface allows for direct calls via invokeinterface of __enter__ and __exit__ instead of requiring getattr. ContextGuard is used to wrap managers that don't support this Java interface. threading.Lock (=RLock) and Condition are now written in Java for performance and support the new ContextManager protocol. This addresses some of the performance issues that Tobias blogged on http://journal.thobe.org/2009/06/performance-of-synchronization.html Bumped bytecode magic. ................ r6528 | pjenvey | 2009-07-11 18:38:33 -0400 (Sat, 11 Jul 2009) | 1 line small refactor ................ r6529 | pjenvey | 2009-07-11 19:22:13 -0400 (Sat, 11 Jul 2009) | 4 lines don't encode unicode when printing to an intercepted stream thanks Pekka Klarck fixes #1802339 ................ r6530 | fwierzbicki | 2009-07-11 20:18:02 -0400 (Sat, 11 Jul 2009) | 2 lines upped memory for antlr task. Needed for (at least) JDK 6 on OS X. ................ r6531 | fwierzbicki | 2009-07-11 20:53:25 -0400 (Sat, 11 Jul 2009) | 3 lines reducing heap memory for antlr task from 1024 to 128 since that appears to be enough for the problematic case (JDK 6 on OS X). ................ r6532 | cgroves | 2009-07-12 01:41:43 -0400 (Sun, 12 Jul 2009) | 4 lines Set the name of the produced proxy class to the value from __javaclass__ if it's set in the Python class. ................ r6533 | cgroves | 2009-07-12 04:07:51 -0400 (Sun, 12 Jul 2009) | 3 lines Add javaproxy_dir to sys, and if it's set, compile Java proxies to that directory. ................ r6534 | cgroves | 2009-07-12 14:14:32 -0400 (Sun, 12 Jul 2009) | 1 line Whoops, isEmpty is a 1.6 method ................ r6535 | thobes | 2009-07-13 11:29:30 -0400 (Mon, 13 Jul 2009) | 5 lines Fixed incompatibility with CPython in the new ContextManager protocol, the evaluation order in the implementation was not as specified by PEP 343. According to PEP 343 the __exit__ attribute should be accessed and stored before the __enter__ attribute is accessed and invoked. ................ r6536 | fwierzbicki | 2009-07-13 12:32:44 -0400 (Mon, 13 Jul 2009) | 6 lines Fix for http://bugs.jython.org/issue645615 "cannot import through symbolic links". Now only explicitely enforcing case sensative imports on Windows and Mac. In the presense of both case insensative systems and symlinks there may be a performance penalty, as we walk the directory looking for exact matches in this case. This is the same method used in CPython. ................ r6537 | thobes | 2009-07-14 22:31:42 -0400 (Tue, 14 Jul 2009) | 2 lines Performance improvements for list multiplication. ................ r6538 | thobes | 2009-07-14 22:34:53 -0400 (Tue, 14 Jul 2009) | 5 lines Added a tentative implementation of an optimized call path for using generators as context managers (as contextlib.contextmanager does by wrapping generators). This implementation unwraps the code object and wraps it in context manager instead of wrapping the entire generator in a context manager. ................ r6539 | thobes | 2009-07-15 16:05:51 -0400 (Wed, 15 Jul 2009) | 9 lines Changed the ContextManager interface to get the exception as one argument, this reduces the need fo object (re-) creation. This also reduces the overhead even more for the optimized context managers, since parts of the code that was previously generated in the compiled Python code is now part of the library in ContextGuard. Also fixed a bug in the code for turning generator functions into optimized context managers. ................ r6543 | pjenvey | 2009-07-19 01:33:37 -0400 (Sun, 19 Jul 2009) | 2 lines cleanup/coding standards ................ r6544 | pjenvey | 2009-07-19 01:35:22 -0400 (Sun, 19 Jul 2009) | 2 lines have the dbapi Binary type convert strs to byte arrays ................ r6545 | cgroves | 2009-07-19 02:16:59 -0400 (Sun, 19 Jul 2009) | 4 lines Properties are fixed once they're set, so there's no need to set them conditionally. Don't force an overwrite on the registry file in dev builds. ................ r6546 | cgroves | 2009-07-19 02:23:03 -0400 (Sun, 19 Jul 2009) | 1 line Eclipse needs jna now ................ r6547 | cgroves | 2009-07-19 02:49:49 -0400 (Sun, 19 Jul 2009) | 1 line Move version-init into init as it wasn't used separately, and add a fileset to the jarring to shut up ant's spurious warning about no files being included ................ r6548 | cgroves | 2009-07-19 04:15:53 -0400 (Sun, 19 Jul 2009) | 8 lines Add an ant task to compile proxies This works by naively importing the modules with the proxy output directory set to the destination configured in the ant task. Eventually it's going to need to work with our Lib directory to generate proxies for all of our Java subclasses, but it currently fails miserably on various modules that aren't expecting to be straight-up imported. ................ r6549 | fwierzbicki | 2009-07-20 00:13:32 -0400 (Mon, 20 Jul 2009) | 2 lines whitespace (tabs->spaces) ................ r6550 | thobes | 2009-07-20 05:41:42 -0400 (Mon, 20 Jul 2009) | 10 lines Fix for problem with compiling coroutines, yield was not allowed in the iterator expression of for-nodes. Example of failing code: def err(): for x in (yield): pass Fixed by deferring the allocation of the registers for storing the iter until after the iter expression is evaluated. ................ r6552 | pjenvey | 2009-07-20 20:56:33 -0400 (Mon, 20 Jul 2009) | 2 lines coding standards: 4 space indents, remove redundant parens, whitespace ................ r6553 | pjenvey | 2009-07-20 21:00:16 -0400 (Mon, 20 Jul 2009) | 3 lines ensure all DBAPI cursor functions throw a "cursor is closed" exception when appropriate ................ r6554 | pjenvey | 2009-07-20 22:48:53 -0400 (Mon, 20 Jul 2009) | 2 lines accept unicode statements and return unicode for cursor description's name ................ r6555 | thobes | 2009-07-21 16:55:55 -0400 (Tue, 21 Jul 2009) | 2 lines Fix for issue 1407. ................ r6556 | thobes | 2009-07-21 17:53:56 -0400 (Tue, 21 Jul 2009) | 8 lines Fix for a problem I discovered with the thread state being stored on yield in generators. This could have lead to faulty behaviour if the next resumption of the generator is from another thread or memory leaks if the generator is kept around longer than the lifetime of the thread. This fix does not have ideal memory footprint, one slot in the stored stack content array is left empty (where the thread state should have been), but it works, such minor memory optimizations can be saved for later. ................ r6557 | amak | 2009-07-21 19:06:14 -0400 (Tue, 21 Jul 2009) | 3 lines 1. Fixed a bug where send in UDP sockets whereby a send() on a connected UDP socket raised an NPE. 2. Added tests for same for both timeout and non-timeout code paths. 3. Dropped the "finishConnect" method for UDP sockets: DatagramChannels and DatagramSockts don't have finishConnect() methods, since UDP "connections" are not like TCP stateful connections: UDP connections are more akin to address filters, and cannot be "finished". ................ r6558 | pjenvey | 2009-07-21 22:18:24 -0400 (Tue, 21 Jul 2009) | 1 line better repr ................ r6566 | nriley | 2009-07-22 23:26:56 -0400 (Wed, 22 Jul 2009) | 1 line svnmerge property for JSR 223 branch ................ r6567 | nriley | 2009-07-23 01:14:58 -0400 (Thu, 23 Jul 2009) | 45 lines Merged revisions 6285,6541,6551,6559-6565 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/jsr223 ........ r6285 | zyasoft | 2009-05-02 01:13:13 -0500 (Sat, 02 May 2009) | 2 lines Some initial code, just to get it going. ........ r6541 | nriley | 2009-07-17 00:27:51 -0500 (Fri, 17 Jul 2009) | 1 line JSR 223 support for compile and eval of Strings. ........ r6551 | nriley | 2009-07-20 12:35:01 -0500 (Mon, 20 Jul 2009) | 1 line JSR 223: test Python exceptions as well as syntax errors. ........ r6559 | nriley | 2009-07-22 16:15:39 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: support for compile and eval with Readers. ........ r6560 | nriley | 2009-07-22 18:51:47 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: fix comments in ParserFacade. ........ r6561 | nriley | 2009-07-22 18:52:00 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: set PySystemState for separate compile/execute. ........ r6562 | nriley | 2009-07-22 18:52:08 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: standardize argument naming. ........ r6563 | nriley | 2009-07-22 18:52:19 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: bindings support. ........ r6564 | nriley | 2009-07-22 22:12:10 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: getInterface support; clean up and factor exception transformation. ........ r6565 | nriley | 2009-07-22 22:12:52 -0500 (Wed, 22 Jul 2009) | 1 line JSR 223: Invocable implementation. ........ ................ r6568 | nriley | 2009-07-23 01:15:49 -0400 (Thu, 23 Jul 2009) | 3 lines Removed merge tracking for "svnmerge" for https://jython.svn.sourceforge.net/svnroot/jython/branches/jsr223 ................ r6570 | nriley | 2009-07-23 02:31:56 -0400 (Thu, 23 Jul 2009) | 1 line Restore some accidentally-reverted changes from the JSR 223 merge. ................ r6571 | nriley | 2009-07-23 03:37:58 -0400 (Thu, 23 Jul 2009) | 1 line Support JSR 223 on JDK 5 with LiveTribe implementation; update NEWS. ................ r6575 | pjenvey | 2009-07-24 00:58:46 -0400 (Fri, 24 Jul 2009) | 1 line coding standards/whitespace ................ r6580 | pjenvey | 2009-07-24 22:34:28 -0400 (Fri, 24 Jul 2009) | 2 lines don't convert mysql YEAR columns to datetime.dates ................ r6581 | fwierzbicki | 2009-07-25 10:37:44 -0400 (Sat, 25 Jul 2009) | 3 lines Remove the goofy imports since we no longer support JDK 1.1, but keep the API around for backwards compatibility. ................ r6582 | fwierzbicki | 2009-07-25 10:38:23 -0400 (Sat, 25 Jul 2009) | 2 lines Oops, left test code in. ................ r6583 | pjenvey | 2009-07-25 17:39:13 -0400 (Sat, 25 Jul 2009) | 3 lines read LONGVARCHAR from a character stream Reader since it's destined for unicode. for better TEXT handling on mysql ................ r6584 | pjenvey | 2009-07-25 18:16:39 -0400 (Sat, 25 Jul 2009) | 3 lines from: http://svn.python.org/projects/python/branches/release25-maint/Lib/weakref.py@45853 ................ r6585 | pjenvey | 2009-07-25 18:34:45 -0400 (Sat, 25 Jul 2009) | 4 lines quiet KeyErrors triggered during weakref callbacks. these don't seem to happen on the ref counting GC because the ref is always collected before the callback can be triggered ................ r6586 | nriley | 2009-07-26 03:45:38 -0400 (Sun, 26 Jul 2009) | 1 line JSR 223: use Writer and ErrorWriter from ScriptContext; remove unnecessary PySystemState setting. ................ r6587 | nriley | 2009-07-26 04:16:22 -0400 (Sun, 26 Jul 2009) | 1 line JSR 223: Use PY_MAJOR_VERSION.PY_MINOR_VERSION for language version. ................ r6588 | nriley | 2009-07-26 04:16:28 -0400 (Sun, 26 Jul 2009) | 1 line Remove some unused imports. ................ r6589 | cgroves | 2009-07-26 11:23:38 -0400 (Sun, 26 Jul 2009) | 1 line Grooming ................ r6590 | cgroves | 2009-07-26 12:32:05 -0400 (Sun, 26 Jul 2009) | 3 lines Add Py.javas2pys. It takes a varargs array of Object and returns a corresponding array of PyObject. ................ r6591 | cgroves | 2009-07-26 12:34:54 -0400 (Sun, 26 Jul 2009) | 1 line Me wrap you long line. ................ r6592 | fwierzbicki | 2009-07-27 13:22:32 -0400 (Mon, 27 Jul 2009) | 2 lines Clean up indent. ................ r6593 | fwierzbicki | 2009-07-27 15:30:01 -0400 (Mon, 27 Jul 2009) | 2 lines Get our Lexer to properly fail for trailing whitespace in single mode. ................ r6594 | fwierzbicki | 2009-07-27 16:39:10 -0400 (Mon, 27 Jul 2009) | 2 lines Now handling trailing backslashes in single mode more like CPython. ................ r6595 | fwierzbicki | 2009-07-28 09:29:09 -0400 (Tue, 28 Jul 2009) | 3 lines Only one test still failing for us - will require a large change in PythonPartial.g to fix. ................ r6596 | fwierzbicki | 2009-07-28 09:57:07 -0400 (Tue, 28 Jul 2009) | 2 lines Make diff w/Python.g smaller. ................ r6597 | fwierzbicki | 2009-07-28 09:58:03 -0400 (Tue, 28 Jul 2009) | 2 lines Remove tests made redundant by test_codeop.py. ................ r6598 | fwierzbicki | 2009-07-29 23:10:33 -0400 (Wed, 29 Jul 2009) | 2 lines Remove compiler warning. ................ r6599 | pjenvey | 2009-07-29 23:11:24 -0400 (Wed, 29 Jul 2009) | 2 lines handle null array results fixes #1413 ................ r6600 | pjenvey | 2009-07-29 23:12:37 -0400 (Wed, 29 Jul 2009) | 1 line changelog r6599 ................ r6601 | fwierzbicki | 2009-07-29 23:38:40 -0400 (Wed, 29 Jul 2009) | 4 lines Fix compiler warnings. Note that I am not replacing Vectors with Lists, etc (as much as I'd like to) since this is a minor release and most of these are public fields (yuck). ................ r6602 | fwierzbicki | 2009-07-30 00:11:55 -0400 (Thu, 30 Jul 2009) | 4 lines Finished warnings in compiler package. Again, being extra careful to avoid messing with public interfaces. Deprecated LineNumberTable instead of deleting, even though I'm sure it isn't used. ................ r6603 | fwierzbicki | 2009-07-30 00:40:15 -0400 (Thu, 30 Jul 2009) | 3 lines Oops, created new cast warnings in compiler package, fixed. Also fixed some of the warnings in the antlr package, but things are a little tricky there. ................ r6604 | fwierzbicki | 2009-07-30 08:09:14 -0400 (Thu, 30 Jul 2009) | 2 lines More compiler warning fixes. ................ r6605 | fwierzbicki | 2009-07-30 10:31:06 -0400 (Thu, 30 Jul 2009) | 3 lines Moved a few tests from test_codeop_jy to test_codeop as they are valid for both CPython and Jython. Prepping to push these and a few more upstream to CPython. ................ r6606 | fwierzbicki | 2009-07-30 10:36:21 -0400 (Thu, 30 Jul 2009) | 2 lines Beefing up tests for partial sentences in interactive mode. ................ r6607 | fwierzbicki | 2009-07-30 10:42:55 -0400 (Thu, 30 Jul 2009) | 3 lines Statement "try:" was not working in interactive mode. Added tests for the basic try: partial sentences. ................ r6608 | fwierzbicki | 2009-07-30 10:46:38 -0400 (Thu, 30 Jul 2009) | 5 lines As CPython trunk: assert_ -> assertTrue ................ r6609 | fwierzbicki | 2009-07-30 11:11:03 -0400 (Thu, 30 Jul 2009) | 3 lines Excercise all of the partial valid sentences that I can think of to avoid screwing up things like "try:" in the future. ................ r6610 | pjenvey | 2009-07-31 00:52:17 -0400 (Fri, 31 Jul 2009) | 3 lines o read CLOBs into unicode instead of str o cleanup the DataHandler.read and have them close their input ................ r6611 | pjenvey | 2009-07-31 01:01:54 -0400 (Fri, 31 Jul 2009) | 1 line quiet warnings, some coding standards ................ r6612 | pjenvey | 2009-07-31 01:02:10 -0400 (Fri, 31 Jul 2009) | 1 line quiet warnings ................ r6613 | fwierzbicki | 2009-07-31 10:41:13 -0400 (Fri, 31 Jul 2009) | 2 lines Added Override annotations. ................ r6614 | fwierzbicki | 2009-07-31 11:33:23 -0400 (Fri, 31 Jul 2009) | 2 lines Add @Overides, remove unused import, fix a shadowed variable. ................ r6615 | nriley | 2009-07-31 15:19:46 -0400 (Fri, 31 Jul 2009) | 1 line Undeprecate PythonInterpreter.set{Out,Err} since JSR 223 needs them. ................ r6616 | nriley | 2009-07-31 15:19:56 -0400 (Fri, 31 Jul 2009) | 1 line Make clear which encoding can't be found. ................ r6617 | nriley | 2009-07-31 15:20:05 -0400 (Fri, 31 Jul 2009) | 1 line Set python.home for singlejavatest so ScriptEngineIOTest works. ................ r6618 | nriley | 2009-07-31 15:20:24 -0400 (Fri, 31 Jul 2009) | 1 line stdin redirection for JSR 223 and PythonInterpreter, contributed by Jim White. Fixes #1408. ................ r6619 | pjenvey | 2009-08-01 15:36:10 -0400 (Sat, 01 Aug 2009) | 1 line carry over nanoseconds in datetime to Timestamp conversions ................ r6620 | pjenvey | 2009-08-01 17:15:59 -0400 (Sat, 01 Aug 2009) | 1 line fix arg parsing I broke in r6611 ................ r6621 | pjenvey | 2009-08-01 17:19:21 -0400 (Sat, 01 Aug 2009) | 1 line no longer needed ................ r6622 | nriley | 2009-08-01 20:09:03 -0400 (Sat, 01 Aug 2009) | 1 line Set python.home for javatest as well, so ScriptEngineIOTest works. ................ r6623 | fwierzbicki | 2009-08-02 13:13:16 -0400 (Sun, 02 Aug 2009) | 3 lines Moved the rest of the tests that could be moved from test_codeop_jy to test_codeop.py. ................ r6626 | cgroves | 2009-08-02 19:52:18 -0400 (Sun, 02 Aug 2009) | 1 line Use the Java class name instead of _new_impl for Java constructors. Fixes issue #1393 ................ r6627 | cgroves | 2009-08-03 02:30:19 -0400 (Mon, 03 Aug 2009) | 5 lines Force static initialization on PyObject subclasses with Class.forName when looking for TypeBuilders. This gets rid of the need to access some static variable on exposed classes before handing them over to Python code. ................ r6628 | thobes | 2009-08-03 20:06:16 -0400 (Mon, 03 Aug 2009) | 4 lines Imported patches by "Andrea" for issues 1412 and 1419, also for {PyList,PyTuple}.toArray(Object[]); as well as adding link to core javadoc. ................ r6629 | fwierzbicki | 2009-08-04 15:54:15 -0400 (Tue, 04 Aug 2009) | 5 lines cleanup of antlr/adapter/*Adapter classes in prep to fix http://bugs.jython.org/issue1415. Checked in change to asdl_antlr.py but haven't applied it yet (since this generates lots of changes in the check in that obscures the real changes). Next checkin will apply the codegen. ................ r6630 | fwierzbicki | 2009-08-04 19:50:44 -0400 (Tue, 04 Aug 2009) | 3 lines Another step towards fixing #1415. Now handling arg parsing of AST nodes more like CPython (well, once the AST codegen is done). ................ r6631 | fwierzbicki | 2009-08-04 19:52:49 -0400 (Tue, 04 Aug 2009) | 2 lines AST codegen, should fix http://bugs.jython.org/issue1415 ................ r6632 | fwierzbicki | 2009-08-04 19:56:50 -0400 (Tue, 04 Aug 2009) | 3 lines Added test and NEWS for http://bugs.jython.org/issue1415 "ast Node creation fails with no arg constructors". ................ r6633 | pjenvey | 2009-08-06 01:10:26 -0400 (Thu, 06 Aug 2009) | 1 line include precision/scale in NUMERIC/TINYINT metadata ................ r6634 | leosoto | 2009-08-06 16:17:09 -0400 (Thu, 06 Aug 2009) | 1 line Handle exceptions when running a JAR file through -jar cmdline switch. Fixes http://bugs.jython.org/issue1405 ................ r6635 | pjenvey | 2009-08-08 20:05:01 -0400 (Sat, 08 Aug 2009) | 4 lines handle Oracle TIMESTAMPTZ/LTZ (currently dropping the tz like cx_oracle does) and specially handle its DATE and NUMERIC refs #1421 ................ r6636 | fwierzbicki | 2009-08-10 12:48:17 -0400 (Mon, 10 Aug 2009) | 4 lines Ran these through reindent.py. These are the files that resulted in fairly trivial changes. The files os.py, dbexts.py, and isql.py resulted in large changes, so I'll look at them one at a time. ................ r6637 | fwierzbicki | 2009-08-10 13:01:32 -0400 (Mon, 10 Aug 2009) | 2 lines reindent. Trivial except for the class at the top that had 2 space indents. ................ r6638 | fwierzbicki | 2009-08-10 13:05:49 -0400 (Mon, 10 Aug 2009) | 3 lines big reindent -- unfortunately the entire file is 8-space indents. Guessing it was once converted from tabs to spaces. ................ r6639 | fwierzbicki | 2009-08-10 13:06:51 -0400 (Mon, 10 Aug 2009) | 2 lines reindent. Another large 8 space indent -> 4 space indent. ................ r6640 | fwierzbicki | 2009-08-10 13:13:06 -0400 (Mon, 10 Aug 2009) | 2 lines reindent (mainly 8 space -> 4 space) ................ r6641 | fwierzbicki | 2009-08-10 13:13:59 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindent. ................ r6642 | fwierzbicki | 2009-08-10 13:14:52 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6643 | fwierzbicki | 2009-08-10 13:15:48 -0400 (Mon, 10 Aug 2009) | 2 lines reindent. ................ r6644 | fwierzbicki | 2009-08-10 13:16:57 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6645 | fwierzbicki | 2009-08-10 13:17:35 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6646 | fwierzbicki | 2009-08-10 13:22:46 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindent. ................ r6647 | fwierzbicki | 2009-08-10 13:23:22 -0400 (Mon, 10 Aug 2009) | 2 lines Large reindents, mainly 8 space -> 4 space indents. ................ r6648 | fwierzbicki | 2009-08-10 13:24:15 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindent. ................ r6649 | fwierzbicki | 2009-08-10 13:32:50 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6650 | fwierzbicki | 2009-08-10 13:35:54 -0400 (Mon, 10 Aug 2009) | 2 lines Reindents. ................ r6651 | fwierzbicki | 2009-08-10 13:39:21 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6652 | fwierzbicki | 2009-08-10 13:58:16 -0400 (Mon, 10 Aug 2009) | 2 lines Reindents. ................ r6653 | fwierzbicki | 2009-08-10 14:15:24 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6654 | fwierzbicki | 2009-08-10 14:30:18 -0400 (Mon, 10 Aug 2009) | 3 lines Merge test_bugfixes into test_exceptions, since test_bugfixes is a poor name and it was testing exception behaviors. ................ r6655 | fwierzbicki | 2009-08-10 14:56:57 -0400 (Mon, 10 Aug 2009) | 2 lines Reindent. ................ r6656 | fwierzbicki | 2009-08-10 14:58:58 -0400 (Mon, 10 Aug 2009) | 2 lines Reindent, mainly 8 space -> 4 space ................ r6657 | fwierzbicki | 2009-08-10 15:01:48 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6658 | fwierzbicki | 2009-08-10 15:04:35 -0400 (Mon, 10 Aug 2009) | 2 lines Reindent, mostly 8 space -> 4 space. ................ r6659 | fwierzbicki | 2009-08-10 15:05:11 -0400 (Mon, 10 Aug 2009) | 2 lines Trivial reindents. ................ r6662 | cgroves | 2009-08-11 02:45:00 -0400 (Tue, 11 Aug 2009) | 1 line Documentation and formatting cleanup ................ r6663 | pjenvey | 2009-08-11 23:12:07 -0400 (Tue, 11 Aug 2009) | 2 lines cleanup/quiet warnings ................ r6664 | fwierzbicki | 2009-08-12 21:54:15 -0400 (Wed, 12 Aug 2009) | 2 lines Better lineno col_offset match with CPython on elif. ................ r6665 | fwierzbicki | 2009-08-12 22:49:57 -0400 (Wed, 12 Aug 2009) | 2 lines Adjusted BinOp lineno and col_offset to align better with CPython. ................ r6667 | pjenvey | 2009-08-15 21:11:01 -0400 (Sat, 15 Aug 2009) | 2 lines allow Oracle's touchy DML returning ResultSet to be used here ................ r6668 | pjenvey | 2009-08-15 21:30:38 -0400 (Sat, 15 Aug 2009) | 3 lines steal Python3's _wrap_close to fix popen files' close to return the exit status when its non-zero ................ r6669 | pjenvey | 2009-08-15 21:32:41 -0400 (Sat, 15 Aug 2009) | 1 line changelog r6668, fixes #1434 ................ r6670 | pjenvey | 2009-08-15 22:36:35 -0400 (Sat, 15 Aug 2009) | 1 line preserve our old exit code behavior ................ r6671 | fwierzbicki | 2009-08-15 22:49:27 -0400 (Sat, 15 Aug 2009) | 2 lines Better match with CPython for col_offset on BoolOp with left arg in parens. ................ r6672 | fwierzbicki | 2009-08-15 22:51:07 -0400 (Sat, 15 Aug 2009) | 2 lines Bugfix for test ast generation code. ................ r6673 | fwierzbicki | 2009-08-15 22:55:25 -0400 (Sat, 15 Aug 2009) | 2 lines Added tests for BoolOp and parens. ................ r6674 | fwierzbicki | 2009-08-15 23:04:08 -0400 (Sat, 15 Aug 2009) | 2 lines Fix col_offset for some NOT expressions. ................ r6675 | cgroves | 2009-08-16 04:11:44 -0400 (Sun, 16 Aug 2009) | 1 line Have lookup call through to lookup_where rather than duplicating the lookup functionality ................ r6676 | cgroves | 2009-08-16 06:28:49 -0400 (Sun, 16 Aug 2009) | 1 line Continue looking for methods to merge up the inheritance chain if the non-public class being merged has a parent that's non-public as well. Fixes issue 1430. ................ r6677 | fwierzbicki | 2009-08-16 10:26:06 -0400 (Sun, 16 Aug 2009) | 2 lines Fix for http://bugs.jython.org/issue1439: Can't write() array.array ................ r6678 | fwierzbicki | 2009-08-16 10:32:28 -0400 (Sun, 16 Aug 2009) | 2 lines Update NEWS. ................ r6679 | fwierzbicki | 2009-08-16 11:32:04 -0400 (Sun, 16 Aug 2009) | 2 lines Test file.write(array) ................ r6680 | fwierzbicki | 2009-08-16 13:46:24 -0400 (Sun, 16 Aug 2009) | 3 lines Added some bug fixes to NEWS that didn't make it in before. Also re-ordered my most recent additions since most people grow the fix list downwards :) ................ r6681 | fwierzbicki | 2009-08-16 14:21:50 -0400 (Sun, 16 Aug 2009) | 2 lines Found a couple more closed bugs that didn't make it into NEWS. ................ r6682 | cgroves | 2009-08-16 18:25:58 -0400 (Sun, 16 Aug 2009) | 3 lines Remove the ant exposer from Eclipse as it never seemed to work. ................ r6683 | pjenvey | 2009-08-16 18:40:47 -0400 (Sun, 16 Aug 2009) | 2 lines restrict array writes to binary mode ................ r6684 | pjenvey | 2009-08-16 19:39:05 -0400 (Sun, 16 Aug 2009) | 1 line fix javadoc, small cleanup ................ r6685 | cgroves | 2009-08-16 20:17:36 -0400 (Sun, 16 Aug 2009) | 5 lines WHERE_PLACEHOLDER could hold on to a reference to a type for a while, and it's causing static initialization problems. Screw using a static array and just pass in null if we don't want to know where the item was found. ................ r6686 | pjenvey | 2009-08-16 21:43:09 -0400 (Sun, 16 Aug 2009) | 2 lines fix writelines' handling of non-strs and not resetting softspace ................ r6687 | pjenvey | 2009-08-16 21:47:30 -0400 (Sun, 16 Aug 2009) | 1 line quiet warnings ................ r6688 | fwierzbicki | 2009-08-16 22:29:34 -0400 (Sun, 16 Aug 2009) | 5 lines Added ast tests for "naked tuples" in for statements like: for a,b in c: pass ................ r6689 | fwierzbicki | 2009-08-16 22:30:53 -0400 (Sun, 16 Aug 2009) | 3 lines Removed dynamic scope on expr::lparen. Need to pass the lparen info up to each rule anyway. ................ r6690 | fwierzbicki | 2009-08-16 23:15:31 -0400 (Sun, 16 Aug 2009) | 4 lines Better match of CPython col_offset for factors with parens like: (a - b) * c ................ r6691 | fwierzbicki | 2009-08-17 09:25:59 -0400 (Mon, 17 Aug 2009) | 2 lines Better BinOp col_offsets. ................ r6692 | fwierzbicki | 2009-08-17 14:41:12 -0400 (Mon, 17 Aug 2009) | 3 lines Added "devclean": deletes everything but the generated antlr files, cachedir, and Lib. ................ r6693 | pjenvey | 2009-08-17 22:19:12 -0400 (Mon, 17 Aug 2009) | 1 line small cleanup ................ r6694 | pjenvey | 2009-08-17 22:44:03 -0400 (Mon, 17 Aug 2009) | 2 lines add __unicode__ ................ r6695 | fwierzbicki | 2009-08-19 09:23:14 -0400 (Wed, 19 Aug 2009) | 6 lines A simple class that allows a jarred up Jython app with a __run__.py to run with java -jar myapp.jar as long as it is specified as the main class in the manifest. ................ r6696 | fwierzbicki | 2009-08-19 10:30:14 -0400 (Wed, 19 Aug 2009) | 2 lines Added support for "jython -J-classpath cp_arg_goes_here" in jython unix shell. ................ r6697 | fwierzbicki | 2009-08-19 10:31:17 -0400 (Wed, 19 Aug 2009) | 2 lines Need to add the shell support for -J-classpath to NEWS ................ r6698 | otmarhumbel | 2009-08-19 12:15:00 -0400 (Wed, 19 Aug 2009) | 1 line add livetribe-jsr223-2.0.5.jar to the eclipse .classpath to enable compilation of the jsr223 packages ................ r6710 | fwierzbicki | 2009-08-23 13:35:06 -0400 (Sun, 23 Aug 2009) | 3 lines From CPython http://svn.python.org/python/trunk/Parser/asdl.py@74541 ................ r6713 | cgroves | 2009-08-23 15:47:55 -0400 (Sun, 23 Aug 2009) | 1 line Roll back 6532-6534 and 6548 to keep __javaname__ and sys.javaproxy_dir from going out with 2.5.1. __javaname__ just went away in favor of a naming proxymaker on the customizable-proxymaker branch, and sys.javaproxy_dir doesn't make sense without named proxies. I'll need to re-commit 6533, 6534 and 6548 when I merge customizable-proxymaker to trunk. ................ r6717 | leosoto | 2009-08-23 23:30:29 -0400 (Sun, 23 Aug 2009) | 1 line Fixing typo in org.pyton.modules.thread.thread docs ................ r6718 | cgroves | 2009-08-25 03:59:28 -0400 (Tue, 25 Aug 2009) | 1 line Need to flush the underlying io object after writing our buffer to it to get things really flushed. Fixes issue #1433. ................ r6719 | pjenvey | 2009-08-26 00:19:39 -0400 (Wed, 26 Aug 2009) | 2 lines always flush the raw io, even when nothing is buffered ................ r6724 | pjenvey | 2009-08-29 13:54:06 -0400 (Sat, 29 Aug 2009) | 1 line use @Override ................ r6725 | pjenvey | 2009-08-29 14:30:16 -0400 (Sat, 29 Aug 2009) | 4 lines treat line buffered read streams as the default buffered mode. CPython 2 line buffered read uses a different bufsize than the default depending on the platform (sometimes smaller, sometimes bigger) ................ Modified Paths: -------------- branches/jy26/.classpath branches/jy26/.project branches/jy26/ACKNOWLEDGMENTS branches/jy26/CoreExposed.includes branches/jy26/Lib/_rawffi.py branches/jy26/Lib/codeop.py branches/jy26/Lib/datetime.py branches/jy26/Lib/dbexts.py branches/jy26/Lib/fileinput.py branches/jy26/Lib/isql.py branches/jy26/Lib/javapath.py branches/jy26/Lib/javashell.py branches/jy26/Lib/os.py branches/jy26/Lib/pawt/__init__.py branches/jy26/Lib/pawt/colors.py branches/jy26/Lib/pawt/swing.py branches/jy26/Lib/pkgutil.py branches/jy26/Lib/posixpath.py branches/jy26/Lib/readline.py branches/jy26/Lib/signal.py branches/jy26/Lib/socket.py branches/jy26/Lib/subprocess.py branches/jy26/Lib/telnetlib.py branches/jy26/Lib/test/Graph.py branches/jy26/Lib/test/anygui.py branches/jy26/Lib/test/jser2_classes.py branches/jy26/Lib/test/regrtest.py branches/jy26/Lib/test/test_SimpleXMLRPCServer.py branches/jy26/Lib/test/test__rawffi.py branches/jy26/Lib/test/test_array.py branches/jy26/Lib/test/test_array_jy.py branches/jy26/Lib/test/test_ast.py branches/jy26/Lib/test/test_ast_jy.py branches/jy26/Lib/test/test_bigmem.py branches/jy26/Lib/test/test_builtin.py branches/jy26/Lib/test/test_builtin_jy.py branches/jy26/Lib/test/test_cmath_jy.py branches/jy26/Lib/test/test_codeop.py branches/jy26/Lib/test/test_codeop_jy.py branches/jy26/Lib/test/test_coerce_jy.py branches/jy26/Lib/test/test_compile_jy.py branches/jy26/Lib/test/test_concat_jy.py branches/jy26/Lib/test/test_descr_jy.py branches/jy26/Lib/test/test_dict2java.py branches/jy26/Lib/test/test_exceptions_jy.py branches/jy26/Lib/test/test_float_jy.py branches/jy26/Lib/test/test_func_syntax_jy.py branches/jy26/Lib/test/test_grammar_jy.py branches/jy26/Lib/test/test_import_jy.py branches/jy26/Lib/test/test_importhooks.py branches/jy26/Lib/test/test_java_integration.py branches/jy26/Lib/test/test_java_list_delegate.py branches/jy26/Lib/test/test_java_subclasses.py branches/jy26/Lib/test/test_java_visibility.py branches/jy26/Lib/test/test_javalist.py branches/jy26/Lib/test/test_javashell.py branches/jy26/Lib/test/test_jbasic.py branches/jy26/Lib/test/test_joverload.py branches/jy26/Lib/test/test_jser.py branches/jy26/Lib/test/test_jy_generators.py branches/jy26/Lib/test/test_jy_internals.py branches/jy26/Lib/test/test_list_jy.py branches/jy26/Lib/test/test_marshal.py branches/jy26/Lib/test/test_metaclass_support/simpleclass.py branches/jy26/Lib/test/test_module.py branches/jy26/Lib/test/test_pbcvm.py branches/jy26/Lib/test/test_pythoninterpreter_jy.py branches/jy26/Lib/test/test_random.py branches/jy26/Lib/test/test_re.py branches/jy26/Lib/test/test_re_jy.py branches/jy26/Lib/test/test_sax.py branches/jy26/Lib/test/test_sax_jy.py branches/jy26/Lib/test/test_set_jy.py branches/jy26/Lib/test/test_socket.py branches/jy26/Lib/test/test_sort.py branches/jy26/Lib/test/test_sort_jy.py branches/jy26/Lib/test/test_str2unicode.py branches/jy26/Lib/test/test_stringmap.py branches/jy26/Lib/test/test_subclasses.py branches/jy26/Lib/test/test_subclasses_jy.py branches/jy26/Lib/test/test_sys_jy.py branches/jy26/Lib/test/test_thread_jy.py branches/jy26/Lib/test/test_thread_local.py branches/jy26/Lib/test/test_threading.py branches/jy26/Lib/test/test_threading_jy.py branches/jy26/Lib/test/test_timeit.py branches/jy26/Lib/test/test_trace.py branches/jy26/Lib/test/test_trace_threaded.py branches/jy26/Lib/test/test_tuple.py branches/jy26/Lib/test/test_unicode_jy.py branches/jy26/Lib/test/test_userdict.py branches/jy26/Lib/test/test_weakref.py branches/jy26/Lib/test/test_with.py branches/jy26/Lib/test/test_xml_etree_jy.py branches/jy26/Lib/test/test_zipimport_jy.py branches/jy26/Lib/test/whrandom.py branches/jy26/Lib/test/zxjdbc/dbextstest.py branches/jy26/Lib/test/zxjdbc/jndi.py branches/jy26/Lib/test/zxjdbc/runner.py branches/jy26/Lib/test/zxjdbc/sptest.py branches/jy26/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py branches/jy26/Lib/test/zxjdbc/zxtest.py branches/jy26/Lib/threading.py branches/jy26/Lib/unicodedata.py branches/jy26/Lib/xml/Uri.py branches/jy26/Lib/xml/dom/minidom.py branches/jy26/Lib/xml/dom/pulldom.py branches/jy26/Lib/xml/parsers/expat.py branches/jy26/Lib/xml/sax/_exceptions.py branches/jy26/Lib/xml/sax/drivers2/drv_javasax.py branches/jy26/Lib/xml/sax/handler.py branches/jy26/Lib/xml/sax/saxutils.py branches/jy26/Lib/zlib.py branches/jy26/NEWS branches/jy26/ast/asdl.py branches/jy26/ast/asdl_antlr.py branches/jy26/build.xml branches/jy26/grammar/Python.g branches/jy26/grammar/PythonPartial.g branches/jy26/src/com/xhaus/modjy/ModjyJServlet.java branches/jy26/src/com/ziclix/python/sql/DataHandler.java branches/jy26/src/com/ziclix/python/sql/Fetch.java branches/jy26/src/com/ziclix/python/sql/JDBC20DataHandler.java branches/jy26/src/com/ziclix/python/sql/Jython22DataHandler.java branches/jy26/src/com/ziclix/python/sql/PyConnection.java branches/jy26/src/com/ziclix/python/sql/PyCursor.java branches/jy26/src/com/ziclix/python/sql/PyExtendedCursor.java branches/jy26/src/com/ziclix/python/sql/PyStatement.java branches/jy26/src/com/ziclix/python/sql/connect/Connectx.java branches/jy26/src/com/ziclix/python/sql/connect/Lookup.java branches/jy26/src/com/ziclix/python/sql/handler/InformixDataHandler.java branches/jy26/src/com/ziclix/python/sql/handler/MySQLDataHandler.java branches/jy26/src/com/ziclix/python/sql/handler/OracleDataHandler.java branches/jy26/src/com/ziclix/python/sql/util/PyArgParser.java branches/jy26/src/com/ziclix/python/sql/util/Queue.java branches/jy26/src/com/ziclix/python/sql/zxJDBC.java branches/jy26/src/org/python/antlr/AST.java branches/jy26/src/org/python/antlr/BaseParser.java branches/jy26/src/org/python/antlr/GrammarActions.java branches/jy26/src/org/python/antlr/ParseException.java branches/jy26/src/org/python/antlr/PythonErrorNode.java branches/jy26/src/org/python/antlr/PythonTokenSource.java branches/jy26/src/org/python/antlr/PythonTree.java branches/jy26/src/org/python/antlr/PythonTreeAdaptor.java branches/jy26/src/org/python/antlr/adapter/AliasAdapter.java branches/jy26/src/org/python/antlr/adapter/AstAdapters.java branches/jy26/src/org/python/antlr/adapter/CmpopAdapter.java branches/jy26/src/org/python/antlr/adapter/ComprehensionAdapter.java branches/jy26/src/org/python/antlr/adapter/ExcepthandlerAdapter.java branches/jy26/src/org/python/antlr/adapter/ExprAdapter.java branches/jy26/src/org/python/antlr/adapter/IdentifierAdapter.java branches/jy26/src/org/python/antlr/adapter/KeywordAdapter.java branches/jy26/src/org/python/antlr/adapter/SliceAdapter.java branches/jy26/src/org/python/antlr/adapter/StmtAdapter.java branches/jy26/src/org/python/antlr/ast/Assert.java branches/jy26/src/org/python/antlr/ast/Assign.java branches/jy26/src/org/python/antlr/ast/Attribute.java branches/jy26/src/org/python/antlr/ast/AugAssign.java branches/jy26/src/org/python/antlr/ast/BinOp.java branches/jy26/src/org/python/antlr/ast/BoolOp.java branches/jy26/src/org/python/antlr/ast/Break.java branches/jy26/src/org/python/antlr/ast/Call.java branches/jy26/src/org/python/antlr/ast/ClassDef.java branches/jy26/src/org/python/antlr/ast/Compare.java branches/jy26/src/org/python/antlr/ast/Continue.java branches/jy26/src/org/python/antlr/ast/Delete.java branches/jy26/src/org/python/antlr/ast/Dict.java branches/jy26/src/org/python/antlr/ast/Ellipsis.java branches/jy26/src/org/python/antlr/ast/ExceptHandler.java branches/jy26/src/org/python/antlr/ast/Exec.java branches/jy26/src/org/python/antlr/ast/Expr.java branches/jy26/src/org/python/antlr/ast/Expression.java branches/jy26/src/org/python/antlr/ast/ExtSlice.java branches/jy26/src/org/python/antlr/ast/For.java branches/jy26/src/org/python/antlr/ast/FunctionDef.java branches/jy26/src/org/python/antlr/ast/GeneratorExp.java branches/jy26/src/org/python/antlr/ast/Global.java branches/jy26/src/org/python/antlr/ast/If.java branches/jy26/src/org/python/antlr/ast/IfExp.java branches/jy26/src/org/python/antlr/ast/Import.java branches/jy26/src/org/python/antlr/ast/ImportFrom.java branches/jy26/src/org/python/antlr/ast/Index.java branches/jy26/src/org/python/antlr/ast/Interactive.java branches/jy26/src/org/python/antlr/ast/Lambda.java branches/jy26/src/org/python/antlr/ast/List.java branches/jy26/src/org/python/antlr/ast/ListComp.java branches/jy26/src/org/python/antlr/ast/Module.java branches/jy26/src/org/python/antlr/ast/Name.java branches/jy26/src/org/python/antlr/ast/Num.java branches/jy26/src/org/python/antlr/ast/Pass.java branches/jy26/src/org/python/antlr/ast/Print.java branches/jy26/src/org/python/antlr/ast/Raise.java branches/jy26/src/org/python/antlr/ast/Repr.java branches/jy26/src/org/python/antlr/ast/Return.java branches/jy26/src/org/python/antlr/ast/Slice.java branches/jy26/src/org/python/antlr/ast/Str.java branches/jy26/src/org/python/antlr/ast/Subscript.java branches/jy26/src/org/python/antlr/ast/Suite.java branches/jy26/src/org/python/antlr/ast/TryExcept.java branches/jy26/src/org/python/antlr/ast/TryFinally.java branches/jy26/src/org/python/antlr/ast/Tuple.java branches/jy26/src/org/python/antlr/ast/UnaryOp.java branches/jy26/src/org/python/antlr/ast/While.java branches/jy26/src/org/python/antlr/ast/With.java branches/jy26/src/org/python/antlr/ast/Yield.java branches/jy26/src/org/python/antlr/ast/alias.java branches/jy26/src/org/python/antlr/ast/arguments.java branches/jy26/src/org/python/antlr/ast/comprehension.java branches/jy26/src/org/python/antlr/ast/keyword.java branches/jy26/src/org/python/compiler/AdapterMaker.java branches/jy26/src/org/python/compiler/ClassConstants.java branches/jy26/src/org/python/compiler/ClassFile.java branches/jy26/src/org/python/compiler/Code.java branches/jy26/src/org/python/compiler/CodeCompiler.java branches/jy26/src/org/python/compiler/JavaMaker.java branches/jy26/src/org/python/compiler/LineNumberTable.java branches/jy26/src/org/python/compiler/Module.java branches/jy26/src/org/python/compiler/ProxyMaker.java branches/jy26/src/org/python/compiler/ScopeInfo.java branches/jy26/src/org/python/compiler/ScopesCompiler.java branches/jy26/src/org/python/compiler/SymInfo.java branches/jy26/src/org/python/core/ArgParser.java branches/jy26/src/org/python/core/MakeProxies.java branches/jy26/src/org/python/core/ParserFacade.java branches/jy26/src/org/python/core/Py.java branches/jy26/src/org/python/core/PyBeanEventProperty.java branches/jy26/src/org/python/core/PyBeanProperty.java branches/jy26/src/org/python/core/PyFile.java branches/jy26/src/org/python/core/PyFileWriter.java branches/jy26/src/org/python/core/PyFinalizableInstance.java branches/jy26/src/org/python/core/PyJavaType.java branches/jy26/src/org/python/core/PyList.java branches/jy26/src/org/python/core/PyObject.java branches/jy26/src/org/python/core/PyOverridableNew.java branches/jy26/src/org/python/core/PyReflectedField.java branches/jy26/src/org/python/core/PySystemState.java branches/jy26/src/org/python/core/PyTuple.java branches/jy26/src/org/python/core/PyType.java branches/jy26/src/org/python/core/PythonTraceFunction.java branches/jy26/src/org/python/core/StdoutWrapper.java branches/jy26/src/org/python/core/__builtin__.java branches/jy26/src/org/python/core/codecs.java branches/jy26/src/org/python/core/imp.java branches/jy26/src/org/python/core/io/BinaryIOWrapper.java branches/jy26/src/org/python/core/io/BufferedIOMixin.java branches/jy26/src/org/python/core/io/BufferedRandom.java branches/jy26/src/org/python/core/io/BufferedReader.java branches/jy26/src/org/python/core/io/BufferedWriter.java branches/jy26/src/org/python/core/io/DatagramSocketIO.java branches/jy26/src/org/python/core/io/FileIO.java branches/jy26/src/org/python/core/io/LineBufferedRandom.java branches/jy26/src/org/python/core/io/LineBufferedWriter.java branches/jy26/src/org/python/core/io/RawIOBase.java branches/jy26/src/org/python/core/io/ServerSocketIO.java branches/jy26/src/org/python/core/io/SocketIO.java branches/jy26/src/org/python/core/io/SocketIOBase.java branches/jy26/src/org/python/core/io/StreamIO.java branches/jy26/src/org/python/core/io/TextIOBase.java branches/jy26/src/org/python/core/io/TextIOWrapper.java branches/jy26/src/org/python/core/io/UniversalIOWrapper.java branches/jy26/src/org/python/core/util/ByteSwapper.java branches/jy26/src/org/python/core/util/ConcurrentHashSet.java branches/jy26/src/org/python/expose/ExposedNew.java branches/jy26/src/org/python/expose/generate/ExposedTypeProcessor.java branches/jy26/src/org/python/expose/generate/NewExposer.java branches/jy26/src/org/python/modules/Setup.java branches/jy26/src/org/python/modules/_collections/Collections.java branches/jy26/src/org/python/modules/_collections/PyDeque.java branches/jy26/src/org/python/modules/_hashlib.java branches/jy26/src/org/python/modules/thread/thread.java branches/jy26/src/org/python/util/PyServlet.java branches/jy26/src/org/python/util/PythonInterpreter.java branches/jy26/src/org/python/util/jython.java branches/jy26/src/shell/jython branches/jy26/tests/java/org/python/antlr/PythonPartialTester.java branches/jy26/tests/modjy/build.xml branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestAppInvocation.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestBase.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestContentHeaders.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestEnviron.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestHeaders.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestReturnIterable.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestWSGIStreams.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestWebInf.java branches/jy26/tests/modjy/java/com/xhaus/modjy/ModjyTestWriteCallable.java Added Paths: ----------- branches/jy26/Lib/test/pyservlet/ branches/jy26/Lib/test/pyservlet/__init__.py branches/jy26/Lib/test/pyservlet/basic.py branches/jy26/Lib/test/pyservlet/empty.py branches/jy26/Lib/test/pyservlet/filter.py branches/jy26/Lib/test/pyservlet/increment.py branches/jy26/Lib/test/pyservlet/updated_basic.py branches/jy26/Lib/test/test_hashlib_jy.py branches/jy26/Lib/weakref.py branches/jy26/extlibs/antlr-3.1.3.jar branches/jy26/extlibs/antlr-runtime-3.1.3.jar branches/jy26/extlibs/livetribe-jsr223-2.0.5.jar branches/jy26/extlibs/mockrunner-0.4.1/ branches/jy26/extlibs/mockrunner-0.4.1/jar/ branches/jy26/extlibs/mockrunner-0.4.1/jar/commons-logging-1.0.4.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/j2ee1.3/ branches/jy26/extlibs/mockrunner-0.4.1/jar/j2ee1.3/servlet.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/jakarta-oro-2.0.8.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/jdom.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/nekohtml.jar branches/jy26/extlibs/mockrunner-0.4.1/lib/ branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/ branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/ branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/dependencies.txt branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar branches/jy26/extlibs/mockrunner-0.4.1/readme.txt branches/jy26/grammar/Base.g branches/jy26/src/META-INF/ branches/jy26/src/META-INF/services/ branches/jy26/src/META-INF/services/javax.script.ScriptEngineFactory branches/jy26/src/org/python/core/ContextGuard.java branches/jy26/src/org/python/core/ContextManager.java branches/jy26/src/org/python/core/PyFileReader.java branches/jy26/src/org/python/core/util/PlatformUtil.java branches/jy26/src/org/python/jsr223/ branches/jy26/src/org/python/jsr223/PyScriptEngine.java branches/jy26/src/org/python/jsr223/PyScriptEngineFactory.java branches/jy26/src/org/python/jsr223/PyScriptEngineScope.java branches/jy26/src/org/python/modules/_threading/ branches/jy26/src/org/python/modules/_threading/Condition.java branches/jy26/src/org/python/modules/_threading/Lock.java branches/jy26/src/org/python/modules/_threading/_threading.java branches/jy26/src/org/python/util/JarRunner.java branches/jy26/src/org/python/util/PyFilter.java branches/jy26/src/org/python/util/PyServletInitializer.java branches/jy26/tests/java/org/python/jsr223/ branches/jy26/tests/java/org/python/jsr223/ScriptEngineIOTest.java branches/jy26/tests/java/org/python/jsr223/ScriptEngineTest.java branches/jy26/tests/java/org/python/tests/RedundantInterfaceDeclarations.java branches/jy26/tests/java/org/python/tests/multihidden/ branches/jy26/tests/java/org/python/tests/multihidden/BaseConnection.java branches/jy26/tests/java/org/python/tests/multihidden/SpecialConnection.java branches/jy26/tests/modjy/java/org/ branches/jy26/tests/modjy/java/org/python/ branches/jy26/tests/modjy/java/org/python/util/ branches/jy26/tests/modjy/java/org/python/util/PyFilterTest.java branches/jy26/tests/modjy/java/org/python/util/PyServletTest.java Removed Paths: ------------- branches/jy26/.externalToolBuilders/ branches/jy26/Lib/test/pyservlet/__init__.py branches/jy26/Lib/test/pyservlet/basic.py branches/jy26/Lib/test/pyservlet/empty.py branches/jy26/Lib/test/pyservlet/filter.py branches/jy26/Lib/test/pyservlet/increment.py branches/jy26/Lib/test/pyservlet/updated_basic.py branches/jy26/Lib/test/test_bugfixes.py branches/jy26/extlibs/antlr-3.1.2.jar branches/jy26/extlibs/antlr-runtime-3.1.2.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/ branches/jy26/extlibs/mockrunner-0.4.1/jar/commons-logging-1.0.4.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/j2ee1.3/ branches/jy26/extlibs/mockrunner-0.4.1/jar/j2ee1.3/servlet.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/jakarta-oro-2.0.8.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/jdom.jar branches/jy26/extlibs/mockrunner-0.4.1/jar/nekohtml.jar branches/jy26/extlibs/mockrunner-0.4.1/lib/ branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/ branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/ branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/dependencies.txt branches/jy26/extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar branches/jy26/extlibs/mockrunner-0.4.1/readme.txt branches/jy26/src/META-INF/services/ branches/jy26/src/META-INF/services/javax.script.ScriptEngineFactory branches/jy26/src/org/python/jsr223/PyScriptEngine.java branches/jy26/src/org/python/jsr223/PyScriptEngineFactory.java branches/jy26/src/org/python/jsr223/PyScriptEngineScope.java branches/jy26/src/org/python/modules/_threading/Condition.java branches/jy26/src/org/python/modules/_threading/Lock.java branches/jy26/src/org/python/modules/_threading/_threading.java branches/jy26/tests/java/org/python/jsr223/ScriptEngineIOTest.java branches/jy26/tests/java/org/python/jsr223/ScriptEngineTest.java branches/jy26/tests/java/org/python/tests/multihidden/BaseConnection.java branches/jy26/tests/java/org/python/tests/multihidden/SpecialConnection.java branches/jy26/tests/modjy/java/org/python/ branches/jy26/tests/modjy/java/org/python/util/ branches/jy26/tests/modjy/java/org/python/util/PyFilterTest.java branches/jy26/tests/modjy/java/org/python/util/PyServletTest.java Property Changed: ---------------- branches/jy26/extlibs/xercesImpl-2.9.1.jar branches/jy26/tests/modjy/ Modified: branches/jy26/.classpath =================================================================== --- branches/jy26/.classpath 2009-08-31 14:38:24 UTC (rev 6733) +++ branches/jy26/.classpath 2009-08-31 17:40:57 UTC (rev 6734) @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry excluding="com/ziclix/python/sql/handler/InformixDataHandler.java|com/ziclix/python/sql/handler/OracleDataHandler.java" kind="src" output="build/classes" path="src"/> - <classpathentry kind="src" output="build/classes" path="build/gensrc"/> - <classpathentry kind="src" output="build/classes" path="tests/java"/> - <classpathentry kind="src" path="bugtests/classes"/> + <classpathentry excluding="com/ziclix/python/sql/handler/InformixDataHandler.java|com/ziclix/python/sql/handler/OracleDataHandler.java" kind="src" path="src"/> + <classpathentry kind="src" path="tests/modjy/java"/> + <classpathentry kind="src" path="build/gensrc"/> + <classpathentry kind="src" path="tests/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> <classpathentry kind="lib" path="extlibs/jline-0.9.95-SNAPSHOT.jar"/> @@ -13,10 +13,14 @@ <classpathentry kind="lib" path="extlibs/postgresql-8.3-603.jdbc4.jar"/> <classpathentry kind="lib" path="extlibs/servlet-api-2.5.jar"/> <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/> - <classpathentry kind="lib" path="extlibs/antlr-runtime-3.1.2.jar"/> + <classpathentry kind="lib" path="extlibs/antlr-runtime-3.1.3.jar"/> <classpathentry kind="lib" path="extlibs/asm-3.1.jar"/> <classpathentry kind="lib" path="extlibs/asm-commons-3.1.jar"/> <classpathentry kind="lib" path="extlibs/constantine-0.4.jar"/> <classpathentry kind="lib" path="extlibs/jna-posix.jar"/> - <classpathentry kind="output" path="bugtests/classes"/> + <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/jar/jdom.jar"/> + <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> + <classpathentry kind="lib" path="extlibs/jna.jar"/> + <classpathentry kind="lib" path="extlibs/livetribe-js... [truncated message content] |
From: <wme...@us...> - 2009-08-31 14:38:33
|
Revision: 6733 http://jython.svn.sourceforge.net/jython/?rev=6733&view=rev Author: wmeissner Date: 2009-08-31 14:38:24 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Rework Pointer and CData a lot to make PointerCData (and hopefully ArrayCData and StructCData) easier to implement Modified Paths: -------------- branches/ctypes-jffi/CoreExposed.includes branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/CData.java branches/ctypes-jffi/src/org/python/modules/jffi/CType.java branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java branches/ctypes-jffi/src/org/python/modules/jffi/Function.java branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java Added Paths: ----------- branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java Modified: branches/ctypes-jffi/CoreExposed.includes =================================================================== --- branches/ctypes-jffi/CoreExposed.includes 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/CoreExposed.includes 2009-08-31 14:38:24 UTC (rev 6733) @@ -59,7 +59,7 @@ org/python/modules/jffi/DynamicLibrary.class org/python/modules/jffi/DynamicLibrary$Symbol.class org/python/modules/jffi/Function.class -org/python/modules/jffi/Pointer.class +org/python/modules/jffi/PointerCData.class org/python/modules/jffi/ScalarCData.class org/python/modules/_threading/Condition.class org/python/modules/_threading/Lock.class Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-08-31 14:38:24 UTC (rev 6733) @@ -53,7 +53,7 @@ name = mod.__name__ dict["__module__"] = name - ptype = type("LP_%s" % (ctype.__name__,), (jffi.Pointer,), dict) + ptype = type("LP_%s" % (ctype.__name__,), (jffi.PointerCData,), dict) _pointer_type_cache[ctype] = ptype return ptype Modified: branches/ctypes-jffi/src/org/python/modules/jffi/CData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/CData.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/CData.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -4,9 +4,7 @@ import org.python.core.Py; import org.python.core.PyObject; import org.python.core.PyType; -import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; -import org.python.expose.ExposedSet; import org.python.expose.ExposedType; @ExposedType(name = "jffi.CData", base = PyObject.class) @@ -16,65 +14,55 @@ final MemoryOp memoryOp; final CType type; - private Memory contentMemory; - private PyObject value; + private DirectMemory referenceMemory; CData(PyType subtype, CType type, MemoryOp memoryOp) { super(subtype); this.type = type; this.memoryOp = memoryOp; - this.value = Py.None; - this.contentMemory = null; + this.referenceMemory = null; } - - @ExposedGet(name = "value") - public PyObject getValue() { - // If native memory has been allocated, read the value from there - if (contentMemory != null) { - return memoryOp.get(contentMemory, 0); - } - - return value; - } - - - @ExposedSet(name = "value") - public void setValue(PyObject value) { - this.value = value; - // If native memory has been allocated, sync the value to memory - if (contentMemory != null) { - memoryOp.put(contentMemory, 0, value); - } - } - + @ExposedMethod(names= { "byref", "pointer" }) public PyObject byref() { - return new Pointer((DirectMemory) getContentMemory(), memoryOp); + return new PointerCData(type, getReferenceMemory(), memoryOp); } - boolean hasValueMemory() { - return contentMemory != null; + final boolean hasReferenceMemory() { + return referenceMemory != null; } - void setContentMemory(Memory memory) { + final void setReferenceMemory(Memory memory) { if (!(memory instanceof DirectMemory)) { throw Py.TypeError("invalid memory"); } - this.contentMemory = memory; + this.referenceMemory = (DirectMemory) memory; } - Memory getContentMemory() { - if (contentMemory != null) { - return contentMemory; + /** + * Returns the memory used when creating a reference to this instance. + * e.g. via byref(obj) + * + * @return The reference memory for this object + */ + public final DirectMemory getReferenceMemory() { + if (referenceMemory != null) { + return referenceMemory; } - return allocateDirect(); + return allocateReferenceMemory(); } - private DirectMemory allocateDirect() { + protected DirectMemory allocateReferenceMemory() { DirectMemory m = AllocatedNativeMemory.allocate(type.size(), false); - memoryOp.put(m, 0, value); - contentMemory = m; + initReferenceMemory(m); + this.referenceMemory = m; return m; } + + public Memory getContentMemory() { + return getReferenceMemory(); + } + + protected abstract void initReferenceMemory(Memory m); } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/CType.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/CType.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/CType.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -91,7 +91,7 @@ } } - private static CType typeOf(PyObject obj) { + static CType typeOf(PyObject obj) { if (obj instanceof CType) { return (CType) obj; } @@ -192,21 +192,6 @@ return String.format("<jffi.Type.Pointer component_type=%s>", componentType.toString()); } - @Override - public PyObject __call__(PyObject value) { - if (value == Py.None) { - - return new org.python.modules.jffi.Pointer(new NullMemory(), componentMemoryOp); - - } else if (value.getType().isSubType(pyComponentType) && value instanceof CData) { - - return new org.python.modules.jffi.Pointer((DirectMemory) ((CData) value).getContentMemory(), componentMemoryOp); - - } else { - throw Py.TypeError("expected " + pyComponentType.getName() + " instead of " + value.getType().getName()); - } - } - private static final class ScalarOp extends MemoryOp { private final MemoryOp op; private final PyType type; @@ -226,8 +211,8 @@ // Point the CData to the backing memory so all value gets/sets // update the same memory this pointer points to // - if (result instanceof CData) { - ((CData) result).setContentMemory(mem); + if (result instanceof ScalarCData) { + ((ScalarCData) result).setReferenceMemory(mem); } return result; } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -131,6 +131,8 @@ private static final ParameterMarshaller getMarshaller(CType type) { if (type instanceof CType.Builtin) { return getMarshaller(type.getNativeType()); + } else if (type instanceof CType.Pointer) { + return PointerMarshaller.INSTANCE; } else { throw Py.RuntimeError("Unsupported parameter type: " + type); } @@ -427,7 +429,7 @@ public void marshal(HeapInvocationBuffer buffer, PyObject parameter) { if (parameter instanceof Pointer) { - buffer.putAddress(((Pointer) parameter).address); + buffer.putAddress(((Pointer) parameter).getAddress()); } else { throw Py.TypeError("expected pointer argument"); } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DynamicLibrary.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -2,7 +2,6 @@ package org.python.modules.jffi; import com.kenai.jffi.Library; -import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyObject; import org.python.core.PyType; @@ -43,7 +42,7 @@ @ExposedMethod public final PyObject find_symbol(PyObject name) { long address = findSymbol(name); - return new Symbol(this, name.asString(), address, new NativeMemory(address)); + return new Symbol(this, name.asString(), new NativeMemory(address)); } @ExposedMethod @@ -56,31 +55,49 @@ return new DataSymbol(this, name.asString(), findSymbol(name)); } - @ExposedType(name = "jffi.DynamicLibrary.Symbol", base = Pointer.class) - public static class Symbol extends Pointer { + @ExposedType(name = "jffi.DynamicLibrary.Symbol", base = PyObject.class) + public static class Symbol extends PyObject implements Pointer { public static final PyType TYPE = PyType.fromClass(Symbol.class); final DynamicLibrary library; + final DirectMemory memory; @ExposedGet + public final long address; + + @ExposedGet public final String name; - public Symbol(DynamicLibrary library, String name, long address, DirectMemory memory) { - super(address, memory); + public Symbol(DynamicLibrary library, String name, DirectMemory memory) { this.library = library; this.name = name; + this.memory = memory; + this.address = memory.getAddress(); } + + public final long getAddress() { + return address; + } + + public final DirectMemory getMemory() { + return memory; + } + + @Override + public boolean __nonzero__() { + return !getMemory().isNull(); + } } - public static class TextSymbol extends Symbol implements ExposeAsSuperclass { + public static final class TextSymbol extends Symbol implements ExposeAsSuperclass { public TextSymbol(DynamicLibrary lib, String name, long address) { - super(lib, name, address, new NativeMemory(address)); + super(lib, name, new NativeMemory(address)); } } - public static class DataSymbol extends Symbol implements ExposeAsSuperclass { + public static final class DataSymbol extends Symbol implements ExposeAsSuperclass { public DataSymbol(DynamicLibrary lib, String name, long address) { - super(lib, name, address, new NativeMemory(address)); + super(lib, name, new NativeMemory(address)); } } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Function.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Function.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Function.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -12,8 +12,8 @@ import org.python.expose.ExposedSet; import org.python.expose.ExposedType; -@ExposedType(name = "jffi.Function", base = Pointer.class) -public class Function extends Pointer { +@ExposedType(name = "jffi.Function", base = PyObject.class) +public class Function extends PyObject implements Pointer { public static final PyType TYPE = PyType.fromClass(Function.class); private final Pointer pointer; @@ -27,37 +27,37 @@ @ExposedGet public final String name; - + @ExposedGet + public final long address; + + @ExposedGet @ExposedSet public PyObject restype; - Function(PyType type, Pointer address, DirectMemory memory) { - super(type, address.address, memory); + Function(PyType type, Pointer address) { + super(type); + this.address = address.getAddress(); this.library = null; this.name = "<anonymous>"; this.pointer = address; } - Function(PyType type, Pointer address) { - this(type, address, new NativeMemory(address.address)); + Function(PyType type, DynamicLibrary.Symbol sym) { + super(type); + this.library = sym.library; + this.name = sym.name; + this.pointer = sym; + this.address = sym.getAddress(); } - Function(PyType type, DynamicLibrary library, String name, long address) { - super(type, address, new NativeMemory(address)); - this.library = library; - this.name = name; - this.pointer = null; - } - @ExposedNew public static PyObject Function_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { if (args[0] instanceof Pointer) { if (args[0] instanceof DynamicLibrary.Symbol) { - DynamicLibrary.Symbol sym = (DynamicLibrary.Symbol) args[0]; - return new Function(subtype, sym.library, sym.name, sym.address); + return new Function(subtype, (DynamicLibrary.Symbol) args[0]); } else { return new Function(subtype, (Pointer) args[0]); } @@ -66,6 +66,14 @@ } } + public long getAddress() { + return address; + } + + public DirectMemory getMemory() { + return pointer.getMemory(); + } + @Override public PyObject fastGetDict() { return dict; @@ -125,6 +133,8 @@ @ExposedSet(name = "_jffi_argtypes") public void setParameterTypes(PyObject parameterTypes) { + this.invoker = null; // invalidate old invoker + // Removing the parameter types defaults back to varargs if (parameterTypes == Py.None) { this.parameterTypes = null; @@ -144,10 +154,13 @@ paramTypes[i] = (CType) t; } - this.invoker = null; // invalidate old invoker this.parameterTypes = paramTypes; } + @Override + public boolean __nonzero__() { + return !getMemory().isNull(); + } private final Invoker getInvoker() { if (invoker != null) { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/MemoryOp.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -178,7 +178,7 @@ private static final class PointerOp extends MemoryOp { public final void put(Memory mem, long offset, PyObject value) { if (value instanceof Pointer) { - mem.putAddress(offset, ((Pointer) value).address); + mem.putAddress(offset, ((Pointer) value).getAddress()); } else { mem.putAddress(offset, Util.int64Value(value)); } @@ -186,7 +186,7 @@ public final PyObject get(Memory mem, long offset) { DirectMemory dm = new NativeMemory(mem.getAddress(offset)); - return new Pointer(dm.getAddress(), dm); + return new PointerCData(CType.POINTER, dm, INVALID); } } private static final class StringOp extends MemoryOp { Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -1,78 +1,7 @@ package org.python.modules.jffi; -import org.python.core.Py; -import org.python.core.PyNewWrapper; -import org.python.core.PyObject; -import org.python.core.PyType; -import org.python.expose.ExposedGet; -import org.python.expose.ExposedNew; -import org.python.expose.ExposedSet; -import org.python.expose.ExposedType; - -@ExposedType(name = "jffi.Pointer", base = PyObject.class) -public class Pointer extends PyObject { - public static final PyType TYPE = PyType.fromClass(Pointer.class); - - @ExposedGet - public final long address; - - final Memory memory; - final MemoryOp componentMemoryOp; - - public Pointer(PyType type, long address, Memory memory) { - super(type); - this.address = address; - this.memory = memory; - this.componentMemoryOp = MemoryOp.INVALID; - } - - public Pointer(long address, Memory memory) { - this.address = address; - this.memory = memory; - this.componentMemoryOp = MemoryOp.INVALID; - } - - Pointer(DirectMemory memory, MemoryOp componentMemoryOp) { - this(TYPE, memory, componentMemoryOp); - } - - Pointer(PyType subtype, DirectMemory memory, MemoryOp componentMemoryOp) { - super(subtype); - this.address = memory.getAddress(); - this.memory = memory; - this.componentMemoryOp = componentMemoryOp; - } - - @ExposedNew - public static PyObject Pointer_new(PyNewWrapper new_, boolean init, PyType subtype, - PyObject[] args, String[] keywords) { - - PyObject jffi_type = subtype.__getattr__("_jffi_type"); - - if (!(jffi_type instanceof CType.Pointer)) { - throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); - } - - CType.Pointer type = (CType.Pointer) jffi_type; - - if (args.length == 0) { - return new Pointer(subtype, NullMemory.INSTANCE, type.componentMemoryOp); - } - DirectMemory contents = AllocatedNativeMemory.allocate(type.componentType.size(), false); - type.componentMemoryOp.put(contents, 0, args[0]); - - return new Pointer(subtype, contents, type.componentMemoryOp); - } - - @ExposedGet(name="contents") - public PyObject contents() { - return componentMemoryOp.get(memory, 0); - } - - @ExposedSet(name="contents") - public void contents(PyObject value) { - componentMemoryOp.put(memory, 0, value); - } - +public interface Pointer { + long getAddress(); + DirectMemory getMemory(); } Added: branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java (rev 0) +++ branches/ctypes-jffi/src/org/python/modules/jffi/PointerCData.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -0,0 +1,84 @@ + +package org.python.modules.jffi; + +import org.python.core.Py; +import org.python.core.PyNewWrapper; +import org.python.core.PyObject; +import org.python.core.PyType; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; + +@ExposedType(name = "jffi.PointerCData", base = CData.class) +public class PointerCData extends CData implements Pointer { + public static final PyType TYPE = PyType.fromClass(PointerCData.class); + + private final DirectMemory memory; + final MemoryOp componentMemoryOp; + + PointerCData(PyType subtype, CType type, DirectMemory memory, MemoryOp componentMemoryOp) { + super(subtype, type, type.getMemoryOp()); + this.memory = memory; + this.componentMemoryOp = componentMemoryOp; + } + + PointerCData(CType type, DirectMemory memory, MemoryOp componentMemoryOp) { + this(TYPE, type, memory, componentMemoryOp); + } + + + @ExposedNew + public static PyObject PointerCData_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + + PyObject jffi_type = subtype.__getattr__("_jffi_type"); + + if (!(jffi_type instanceof CType.Pointer)) { + throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); + } + + CType.Pointer type = (CType.Pointer) jffi_type; + + if (args.length == 0) { + return new PointerCData(subtype, type, NullMemory.INSTANCE, type.componentMemoryOp); + } + PyObject value = args[0]; + if (value instanceof CData && value.getType().isSubType(type.pyComponentType)) { + + return new PointerCData(subtype, type, ((CData) value).getReferenceMemory(), type.componentMemoryOp); + + } else { + throw Py.TypeError("expected " + type.pyComponentType.getName() + " instead of " + value.getType().getName()); + } + } + + @ExposedGet(name="contents") + public PyObject getContents() { + return componentMemoryOp.get(getMemory(), 0); + } + + @ExposedSet(name="contents") + public void setContents(PyObject value) { + componentMemoryOp.put(getMemory(), 0, value); + } + + @Override + public boolean __nonzero__() { + return !getMemory().isNull(); + } + + + protected void initReferenceMemory(Memory m) { + m.putAddress(0, memory); + } + + public final long getAddress() { + return getMemory().getAddress(); + } + + public final DirectMemory getMemory() { + return hasReferenceMemory() ? getReferenceMemory().getMemory(0) : memory; + } + +} Modified: branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/ScalarCData.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -7,14 +7,18 @@ import org.python.core.PyObject; import org.python.core.PyObject.ConversionException; import org.python.core.PyType; +import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; import org.python.expose.ExposedType; @ExposedType(name = "jffi.ScalarCData", base = CData.class) public class ScalarCData extends CData { public static final PyType TYPE = PyType.fromClass(ScalarCData.class); + private PyObject value = Py.None; + @ExposedNew public static PyObject ScalarCData_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { @@ -35,8 +39,33 @@ ScalarCData(PyType pyType, CType.Builtin type) { super(pyType, type, type.getMemoryOp()); - } + } + protected final void initReferenceMemory(Memory m) { + memoryOp.put(m, 0, value); + } + + @ExposedGet(name = "value") + public PyObject getValue() { + // If native memory has been allocated, read the value from there + if (hasReferenceMemory()) { + return memoryOp.get(getReferenceMemory(), 0); + } + + return value; + } + + + @ExposedSet(name = "value") + public void setValue(PyObject value) { + this.value = value; + // If native memory has been allocated, sync the value to memory + if (hasReferenceMemory()) { + memoryOp.put(getReferenceMemory(), 0, value); + } + } + + @Override public int asInt() { return getValue().asInt(); Modified: branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-08-31 07:40:56 UTC (rev 6732) +++ branches/ctypes-jffi/src/org/python/modules/jffi/jffi.java 2009-08-31 14:38:24 UTC (rev 6733) @@ -19,8 +19,8 @@ dict.__setitem__("__name__", Py.newString("jffi")); dict.__setitem__("DynamicLibrary", DynamicLibrary.TYPE); dict.__setitem__("Type", CType.TYPE); - dict.__setitem__("Pointer", Pointer.TYPE); dict.__setitem__("Function", Function.TYPE); + dict.__setitem__("PointerCData", PointerCData.TYPE); dict.__setitem__("ScalarCData", ScalarCData.TYPE); dict.__setitem__("FUNCFLAG_STDCALL", Py.newInteger(FUNCFLAG_STDCALL)); dict.__setitem__("FUNCFLAG_CDECL", Py.newInteger(FUNCFLAG_CDECL)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-08-31 08:54:10
|
Revision: 6732 http://jython.svn.sourceforge.net/jython/?rev=6732&view=rev Author: wmeissner Date: 2009-08-31 07:40:56 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Start implementing POINTER() Modified Paths: -------------- branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-08-30 23:31:13 UTC (rev 6731) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-08-31 07:40:56 UTC (rev 6732) @@ -36,10 +36,27 @@ def pointer(cdata): return cdata.pointer() -def POINTER(type): -# return jffi.Type.Pointer(type) - return c_void_p +_pointer_type_cache = {} +def POINTER(ctype): + # If a pointer class for the C type has been created, re-use it + if _pointer_type_cache.has_key(ctype): + return _pointer_type_cache[ctype] + # Create a new class for this particular C type + dict = { '_jffi_type': jffi.Type.Pointer(ctype) } + # Look back up the stack frame to find out the module this new type is declared in + import inspect + mod = inspect.getmodule(inspect.stack()[1][0]) + if mod is None: + name = "__main__" + else: + name = mod.__name__ + dict["__module__"] = name + + ptype = type("LP_%s" % (ctype.__name__,), (jffi.Pointer,), dict) + _pointer_type_cache[ctype] = ptype + return ptype + class c_byte(_ScalarCData): _jffi_type = jffi.Type.BYTE Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java 2009-08-30 23:31:13 UTC (rev 6731) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Pointer.java 2009-08-31 07:40:56 UTC (rev 6732) @@ -1,9 +1,13 @@ package org.python.modules.jffi; +import org.python.core.Py; +import org.python.core.PyNewWrapper; import org.python.core.PyObject; import org.python.core.PyType; import org.python.expose.ExposedGet; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; import org.python.expose.ExposedType; @ExposedType(name = "jffi.Pointer", base = PyObject.class) @@ -40,9 +44,35 @@ this.componentMemoryOp = componentMemoryOp; } + @ExposedNew + public static PyObject Pointer_new(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + + PyObject jffi_type = subtype.__getattr__("_jffi_type"); + + if (!(jffi_type instanceof CType.Pointer)) { + throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); + } + + CType.Pointer type = (CType.Pointer) jffi_type; + + if (args.length == 0) { + return new Pointer(subtype, NullMemory.INSTANCE, type.componentMemoryOp); + } + DirectMemory contents = AllocatedNativeMemory.allocate(type.componentType.size(), false); + type.componentMemoryOp.put(contents, 0, args[0]); + + return new Pointer(subtype, contents, type.componentMemoryOp); + } + @ExposedGet(name="contents") public PyObject contents() { return componentMemoryOp.get(memory, 0); } + @ExposedSet(name="contents") + public void contents(PyObject value) { + componentMemoryOp.put(memory, 0, value); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wme...@us...> - 2009-08-31 01:13:45
|
Revision: 6731 http://jython.svn.sourceforge.net/jython/?rev=6731&view=rev Author: wmeissner Date: 2009-08-30 23:31:13 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Fix some pointer and unsigned int parameter handling Modified Paths: -------------- branches/ctypes-jffi/Lib/ctypes/__init__.py branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java branches/ctypes-jffi/src/org/python/modules/jffi/Util.java Property Changed: ---------------- branches/ctypes-jffi/Lib/ctypes/ Property changes on: branches/ctypes-jffi/Lib/ctypes ___________________________________________________________________ Added: svn:ignore + *.class Modified: branches/ctypes-jffi/Lib/ctypes/__init__.py =================================================================== --- branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-08-30 22:17:24 UTC (rev 6730) +++ branches/ctypes-jffi/Lib/ctypes/__init__.py 2009-08-30 23:31:13 UTC (rev 6731) @@ -37,7 +37,8 @@ return cdata.pointer() def POINTER(type): - return jffi.Type.Pointer(type._jffi_type, type) +# return jffi.Type.Pointer(type) + return c_void_p class c_byte(_ScalarCData): _jffi_type = jffi.Type.BYTE Modified: branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-08-30 22:17:24 UTC (rev 6730) +++ branches/ctypes-jffi/src/org/python/modules/jffi/DefaultInvokerFactory.java 2009-08-30 23:31:13 UTC (rev 6731) @@ -372,7 +372,7 @@ public static final ParameterMarshaller INSTANCE = new Unsigned32Marshaller(); public void marshal(HeapInvocationBuffer buffer, PyObject arg) { - buffer.putInt((int) Util.int32Value(arg)); + buffer.putInt((int) Util.uint32Value(arg)); } } Modified: branches/ctypes-jffi/src/org/python/modules/jffi/Util.java =================================================================== --- branches/ctypes-jffi/src/org/python/modules/jffi/Util.java 2009-08-30 22:17:24 UTC (rev 6730) +++ branches/ctypes-jffi/src/org/python/modules/jffi/Util.java 2009-08-30 23:31:13 UTC (rev 6731) @@ -67,8 +67,14 @@ return parameter.asInt(); } - public static final int uint32Value(PyObject parameter) { - return parameter.asInt(); + public static final int uint32Value(PyObject value) { + if (value instanceof PyInteger) { + return value.asInt(); + } else if (value instanceof PyLong) { + return (int) ((PyLong) value).asLong(0); + } else { + return (int) __long__value(value); + } } public static final long int64Value(PyObject value) { @@ -82,7 +88,13 @@ } public static final long uint64Value(PyObject value) { - return int64Value(value); + if (value instanceof PyLong) { + return ((PyLong) value).getValue().longValue(); + } else if (value instanceof PyInteger) { + return value.asInt(); + } else { + return __long__value(value); + } } public static final float floatValue(PyObject parameter) { @@ -93,6 +105,16 @@ return parameter.asDouble(); } + private static final long __long__value(PyObject value) { + PyObject l = value.__long__(); + if (l instanceof PyLong) { + return ((PyLong) l).getValue().longValue(); + } else if (l instanceof PyInteger) { + return value.asInt(); + } + throw Py.TypeError("invalid __long__() result"); + } + public static final void checkBounds(long size, long off, long len) { if ((off | len | (off + len) | (size - (off + len))) < 0) { throw Py.IndexError("Memory access offset=" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-08-30 22:17:33
|
Revision: 6730 http://jython.svn.sourceforge.net/jython/?rev=6730&view=rev Author: cgroves Date: 2009-08-30 22:17:24 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Hide more of ProxyMaker's internals to make it clearer how to subclass it. Modified Paths: -------------- branches/customizable-proxymaker/src/org/python/compiler/AdapterMaker.java branches/customizable-proxymaker/src/org/python/compiler/JavaMaker.java branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java Modified: branches/customizable-proxymaker/src/org/python/compiler/AdapterMaker.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/AdapterMaker.java 2009-08-30 22:15:47 UTC (rev 6729) +++ branches/customizable-proxymaker/src/org/python/compiler/AdapterMaker.java 2009-08-30 22:17:24 UTC (rev 6730) @@ -5,7 +5,6 @@ import java.util.HashSet; import org.objectweb.asm.Label; -import org.objectweb.asm.Opcodes; public class AdapterMaker extends ProxyMaker { @@ -17,19 +16,20 @@ protected void build() { classfile.addInterface(mapClass(interfaces[0])); visitMethods(interfaces[0], new HashSet<MethodDescr>()); - visitConstructors(); - for (String name : names) { - classfile.addField(name, $pyObj, Opcodes.ACC_PUBLIC); + try { + addConstructor(Object.class.getConstructor()); + } catch (NoSuchMethodException e) { + throw new RuntimeException( + "Object.class doesn't have a no-arg constructor? What the dickens?", e); } } @Override - protected void addMethod(Method method) { + protected void addOverrideMethod(Method method) { Class<?>[] parameters = method.getParameterTypes(); Class<?> ret = method.getReturnType(); String name = method.getName(); - names.add(name); - Code code = classfile.addMethod(name, makeSig(ret, parameters), Opcodes.ACC_PUBLIC); + Code code = classfile.addMethod(name, makeSig(ret, parameters), ACC_PUBLIC); code.aload(0); code.getfield(classfile.name, name, $pyObj); code.dup(); @@ -38,5 +38,6 @@ callMethod(code, name, parameters, ret, method.getExceptionTypes()); code.label(returnNull); doNullReturn(code, ret); + classfile.addField(name, $pyObj, ACC_PUBLIC); } } Modified: branches/customizable-proxymaker/src/org/python/compiler/JavaMaker.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/JavaMaker.java 2009-08-30 22:15:47 UTC (rev 6729) +++ branches/customizable-proxymaker/src/org/python/compiler/JavaMaker.java 2009-08-30 22:17:24 UTC (rev 6730) @@ -1,6 +1,7 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.compiler; +import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -32,12 +33,18 @@ } @Override - public void addConstructor(Class<?>[] parameters, int access) { + protected void build() { + super.build(); + + addInitProxy(); + } + + @Override + public void visitConstructor(Constructor<?> constructor) + { /* Need a fancy constructor for the Java side of things */ - String sig = makeSig(Void.TYPE, parameters); - Code code = classfile.addMethod("<init>", sig, access); - callSuper(code, "<init>", mapClass(superclass), parameters, Void.TYPE, false); - callInitProxy(parameters, code); + Code code = addOpenConstructor(constructor); + callInitProxy(constructor.getParameterTypes(), code); } /** @@ -51,11 +58,7 @@ code.visitInsn(RETURN); } - @Override - public void addProxy() { - super.addProxy(); - - // _initProxy method + protected void addInitProxy() { Code code = classfile.addMethod("__initProxy__", makeSig("V", $objArr), Modifier.PUBLIC); code.visitVarInsn(ALOAD, 0); Modified: branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java 2009-08-30 22:15:47 UTC (rev 6729) +++ branches/customizable-proxymaker/src/org/python/compiler/ProxyCodeHelpers.java 2009-08-30 22:17:24 UTC (rev 6730) @@ -2,36 +2,38 @@ import java.util.Map; +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; import org.python.util.Generic; /** * Various static methods and constants used in generating bytecode for proxy classes. */ -public class ProxyCodeHelpers { +public class ProxyCodeHelpers implements ClassConstants, Opcodes { - public static final int tBoolean = 0; + private static final int tBoolean = 0; - public static final int tByte = 1; + private static final int tByte = 1; - public static final int tShort = 2; + private static final int tShort = 2; - public static final int tInteger = 3; + private static final int tInteger = 3; - public static final int tLong = 4; + private static final int tLong = 4; - public static final int tFloat = 5; + private static final int tFloat = 5; - public static final int tDouble = 6; + private static final int tDouble = 6; - public static final int tCharacter = 7; + private static final int tCharacter = 7; - public static final int tVoid = 8; + private static final int tVoid = 8; - public static final int tOther = 9; + private static final int tOther = 9; - public static final int tNone = 10; + private static final int tNone = 10; - public static Map<Class<?>, Integer> types = Generic.map(); + private static Map<Class<?>, Integer> types = Generic.map(); static { types.put(Boolean.TYPE, tBoolean); types.put(Byte.TYPE, tByte); @@ -44,7 +46,7 @@ types.put(Void.TYPE, tVoid); } - public static int getType(Class<?> c) { + private static int getType(Class<?> c) { if (c == null) { return tNone; } @@ -56,6 +58,62 @@ } } + protected static void getArgs(Code code, Class<?>[] parameters) { + if (parameters.length == 0) { + code.getstatic("org/python/core/Py", "EmptyObjects", $pyObjArr); + } else { + code.iconst(parameters.length); + code.anewarray("java/lang/Object"); + + int array = code.getLocal("[org/python/core/PyObject"); + code.astore(array); + + int local_index; + int i; + for (i=0, local_index=1; i<parameters.length; i++) { + code.aload(array); + code.iconst(i); + + switch (getType(parameters[i])) { + case tBoolean: + case tByte: + case tShort: + case tInteger: + code.iload(local_index); + local_index += 1; + code.invokestatic("org/python/core/Py", "newInteger", "(I)" + $pyInteger); + break; + case tLong: + code.lload(local_index); + local_index += 2; + code.invokestatic("org/python/core/Py", "newInteger", "(J)" + $pyObj); + break; + case tFloat: + code.fload(local_index); + local_index += 1; + code.invokestatic("org/python/core/Py", "newFloat", "(F)" + $pyFloat); + break; + case tDouble: + code.dload(local_index); + local_index += 2; + code.invokestatic("org/python/core/Py", "newFloat", "(D)" + $pyFloat); + break; + case tCharacter: + code.iload(local_index); + local_index += 1; + code.invokestatic("org/python/core/Py", "newString", "(C)" + $pyStr); + break; + default: + code.aload(local_index); + local_index += 1; + break; + } + code.aastore(); + } + code.aload(array); + } + } + public static String[] mapClasses(Class<?>[] classes) { String[] mapped = new String[classes.length]; for (int i = 0; i < mapped.length; i++) { @@ -65,7 +123,10 @@ } public static String mapClass(Class<?> c) { - String name = c.getName(); + return mapClass(c.getName()); + } + + public static String mapClass(String name) { int index = name.indexOf("."); if (index == -1) { return name; @@ -82,7 +143,7 @@ return buf.toString(); } - public static String mapType(Class<?> type) { + private static String mapType(Class<?> type) { if (type.isArray()) return "[" + mapType(type.getComponentType()); switch(getType(type)){ @@ -187,4 +248,155 @@ break; } } + + public static void callSuper(Code code, + String name, + String superclass, + Class<?>[] parameters, + Class<?> ret, + boolean doReturn) { + code.aload(0); + int local_index; + int i; + for (i=0, local_index=1; i<parameters.length; i++) { + switch(getType(parameters[i])) { + case tCharacter: + case tBoolean: + case tByte: + case tShort: + case tInteger: + code.iload(local_index); + local_index += 1; + break; + case tLong: + code.lload(local_index); + local_index += 2; + break; + case tFloat: + code.fload(local_index); + local_index += 1; + break; + case tDouble: + code.dload(local_index); + local_index += 2; + break; + default: + code.aload(local_index); + local_index += 1; + break; + } + } + code.invokespecial(superclass, name, makeSig(ret, parameters)); + + if (doReturn) { + doReturn(code, ret); + } + } + + public static void callMethod(Code code, + String name, + Class<?>[] parameters, + Class<?> ret, + Class<?>[] exceptions) { + Label start = null; + Label end = null; + + String jcallName = "_jcall"; + int instLocal = 0; + + if (exceptions.length > 0) { + start = new Label(); + end = new Label(); + jcallName = "_jcallexc"; + instLocal = code.getLocal("org/python/core/PyObject"); + code.astore(instLocal); + code.label(start); + code.aload(instLocal); + } + + getArgs(code, parameters); + + switch (getType(ret)) { + case tCharacter: + doJavaCall(code, "char", "C", jcallName); + break; + case tBoolean: + doJavaCall(code, "boolean", "Z", jcallName); + break; + case tByte: + case tShort: + case tInteger: + doJavaCall(code, "int", "I", jcallName); + break; + case tLong: + doJavaCall(code, "long", "J", jcallName); + break; + case tFloat: + doJavaCall(code, "float", "F", jcallName); + break; + case tDouble: + doJavaCall(code, "double", "D", jcallName); + break; + case tVoid: + doJavaCall(code, "void", "V", jcallName); + break; + default: + code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); + code.ldc(ret.getName()); + code.invokestatic("java/lang/Class","forName", makeSig($clss, $str)); + code.invokestatic("org/python/core/Py", "tojava", makeSig($obj, $pyObj, $clss)); + // I guess I need this checkcast to keep the verifier happy + code.checkcast(mapClass(ret)); + break; + } + if (end != null) { + code.label(end); + } + + doReturn(code, ret); + + if (exceptions.length > 0) { + boolean throwableFound = false; + + Label handlerStart = null; + for (Class<?> exception : exceptions) { + handlerStart = new Label(); + code.label(handlerStart); + int excLocal = code.getLocal("java/lang/Throwable"); + code.astore(excLocal); + + code.aload(excLocal); + code.athrow(); + + code.visitTryCatchBlock(start, end, handlerStart, mapClass(exception)); + doNullReturn(code, ret); + + code.freeLocal(excLocal); + if (exception == Throwable.class) + throwableFound = true; + } + + if (!throwableFound) { + // The final catch (Throwable) + handlerStart = new Label(); + code.label(handlerStart); + int excLocal = code.getLocal("java/lang/Throwable"); + code.astore(excLocal); + code.aload(instLocal); + code.aload(excLocal); + + code.invokevirtual("org/python/core/PyObject", "_jthrow", makeSig("V", $throwable)); + code.visitTryCatchBlock(start, end, handlerStart, "java/lang/Throwable"); + + code.freeLocal(excLocal); + doNullReturn(code, ret); + } + code.freeLocal(instLocal); + } + } + + private static void doJavaCall(Code code, String name, String type, String jcallName) { + code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); + code.invokestatic("org/python/core/Py", "py2" + name, makeSig(type, $pyObj)); + } } Modified: branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java 2009-08-30 22:15:47 UTC (rev 6729) +++ branches/customizable-proxymaker/src/org/python/compiler/ProxyMaker.java 2009-08-30 22:17:24 UTC (rev 6730) @@ -7,7 +7,6 @@ import java.util.Set; import org.objectweb.asm.Label; -import org.objectweb.asm.Opcodes; import org.python.core.Py; import org.python.core.PyMethod; import org.python.core.PyObject; @@ -15,7 +14,7 @@ import org.python.core.PyReflectedFunction; import org.python.util.Generic; -public class ProxyMaker extends ProxyCodeHelpers implements ClassConstants, Opcodes { +public class ProxyMaker extends ProxyCodeHelpers { /** * Retrieves <code>name</code> from the PyObject in <code>proxy</code> if it's defined in * Python. This is a specialized helper function for internal PyProxy use. @@ -45,28 +44,13 @@ protected final Class<?> superclass; protected final Class<?>[] interfaces; - protected final Set<String> names = Generic.set(); - protected final Set<String> supernames = Generic.set(); + private final Set<String> names = Generic.set(); + private final Set<String> supernames = Generic.set(); protected ClassFile classfile; /** The name of the class to build. */ public String proxyClassName; /** - * Creates a proxy class maker that produces classes named - * <code>org.python.proxies.(superclassName)</code> with <code>superclass</code> as an - * implemented interface or extended class, depending on the its type. - * - * @deprecated - Use {@link ProxyMaker#ProxyMaker(String, Class, Class[]) - */ - @Deprecated - public ProxyMaker(String superclassName, Class<?> superclass) { - this("org.python.proxies." + superclassName, - superclass.isInterface() ? Object.class : superclass, - superclass.isInterface() ? new Class<?>[] { superclass} : new Class<?>[0]); - - } - - /** * Creates a proxy class maker that produces classes named <code>proxyClassName</code> that * extends <code>superclass</code> and implements the interfaces in <code>interfaces</code>. */ @@ -99,12 +83,11 @@ * Builds this proxy and returns its bytecode. */ public synchronized byte[] make() { - classfile = new ClassFile(proxyClassName, mapClass(superclass), Modifier.PUBLIC - | Modifier.SYNCHRONIZED); + classfile = new ClassFile(proxyClassName, mapClass(superclass)); build(); - names.clear(); - supernames.clear(); - return classfile.create(); + byte[] result = classfile.create(); + classfile = null; + return result; } /** @@ -120,223 +103,17 @@ visitMethods(); addClassDictInit(); + names.clear(); + supernames.clear(); } - protected void callSuper(Code code, - String name, - String superclass, - Class<?>[] parameters, - Class<?> ret, boolean doReturn) { - - code.aload(0); - int local_index; - int i; - for (i=0, local_index=1; i<parameters.length; i++) { - switch(getType(parameters[i])) { - case tCharacter: - case tBoolean: - case tByte: - case tShort: - case tInteger: - code.iload(local_index); - local_index += 1; - break; - case tLong: - code.lload(local_index); - local_index += 2; - break; - case tFloat: - code.fload(local_index); - local_index += 1; - break; - case tDouble: - code.dload(local_index); - local_index += 2; - break; - default: - code.aload(local_index); - local_index += 1; - break; - } - } - code.invokespecial(superclass, name, makeSig(ret, parameters)); - - if (doReturn) { - doReturn(code, ret); - } - } - - protected void doJavaCall(Code code, String name, String type, String jcallName) { - code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); - code.invokestatic("org/python/core/Py", "py2" + name, makeSig(type, $pyObj)); - } - - - protected void getArgs(Code code, Class<?>[] parameters) { - if (parameters.length == 0) { - code.getstatic("org/python/core/Py", "EmptyObjects", $pyObjArr); - } else { - code.iconst(parameters.length); - code.anewarray("java/lang/Object"); - - int array = code.getLocal("[org/python/core/PyObject"); - code.astore(array); - - int local_index; - int i; - for (i=0, local_index=1; i<parameters.length; i++) { - code.aload(array); - code.iconst(i); - - switch (getType(parameters[i])) { - case tBoolean: - case tByte: - case tShort: - case tInteger: - code.iload(local_index); - local_index += 1; - code.invokestatic("org/python/core/Py", "newInteger", "(I)" + $pyInteger); - break; - case tLong: - code.lload(local_index); - local_index += 2; - code.invokestatic("org/python/core/Py", "newInteger", "(J)" + $pyObj); - break; - case tFloat: - code.fload(local_index); - local_index += 1; - code.invokestatic("org/python/core/Py", "newFloat", "(F)" + $pyFloat); - break; - case tDouble: - code.dload(local_index); - local_index += 2; - code.invokestatic("org/python/core/Py", "newFloat", "(D)" + $pyFloat); - break; - case tCharacter: - code.iload(local_index); - local_index += 1; - code.invokestatic("org/python/core/Py", "newString", "(C)" + $pyStr); - break; - default: - code.aload(local_index); - local_index += 1; - break; - } - code.aastore(); - } - code.aload(array); - } - } - - protected void callMethod(Code code, - String name, - Class<?>[] parameters, - Class<?> ret, - Class<?>[] exceptions) { - Label start = null; - Label end = null; - - String jcallName = "_jcall"; - int instLocal = 0; - - if (exceptions.length > 0) { - start = new Label(); - end = new Label(); - jcallName = "_jcallexc"; - instLocal = code.getLocal("org/python/core/PyObject"); - code.astore(instLocal); - code.label(start); - code.aload(instLocal); - } - - getArgs(code, parameters); - - switch (getType(ret)) { - case tCharacter: - doJavaCall(code, "char", "C", jcallName); - break; - case tBoolean: - doJavaCall(code, "boolean", "Z", jcallName); - break; - case tByte: - case tShort: - case tInteger: - doJavaCall(code, "int", "I", jcallName); - break; - case tLong: - doJavaCall(code, "long", "J", jcallName); - break; - case tFloat: - doJavaCall(code, "float", "F", jcallName); - break; - case tDouble: - doJavaCall(code, "double", "D", jcallName); - break; - case tVoid: - doJavaCall(code, "void", "V", jcallName); - break; - default: - code.invokevirtual("org/python/core/PyObject", jcallName, makeSig($pyObj, $objArr)); - code.ldc(ret.getName()); - code.invokestatic("java/lang/Class","forName", makeSig($clss, $str)); - code.invokestatic("org/python/core/Py", "tojava", makeSig($obj, $pyObj, $clss)); - // I guess I need this checkcast to keep the verifier happy - code.checkcast(mapClass(ret)); - break; - } - if (end != null) { - code.label(end); - } - - doReturn(code, ret); - - if (exceptions.length > 0) { - boolean throwableFound = false; - - Label handlerStart = null; - for (Class<?> exception : exceptions) { - handlerStart = new Label(); - code.label(handlerStart); - int excLocal = code.getLocal("java/lang/Throwable"); - code.astore(excLocal); - - code.aload(excLocal); - code.athrow(); - - code.visitTryCatchBlock(start, end, handlerStart, mapClass(exception)); - doNullReturn(code, ret); - - code.freeLocal(excLocal); - if (exception == Throwable.class) - throwableFound = true; - } - - if (!throwableFound) { - // The final catch (Throwable) - handlerStart = new Label(); - code.label(handlerStart); - int excLocal = code.getLocal("java/lang/Throwable"); - code.astore(excLocal); - code.aload(instLocal); - code.aload(excLocal); - - code.invokevirtual("org/python/core/PyObject", "_jthrow", makeSig("V", $throwable)); - code.visitTryCatchBlock(start, end, handlerStart, "java/lang/Throwable"); - - code.freeLocal(excLocal); - doNullReturn(code, ret); - } - code.freeLocal(instLocal); - } - } - /** * Adds an override of <code>method</code> to the class being implemented. If * <code>method</code> is abstract, 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 abstract, if an object is found * in the Python object, it'll be called. Otherwise the superclass will be called. */ - protected void addMethod(Method method) { + protected void addOverrideMethod(Method method) { boolean isAbstract = Modifier.isAbstract(method.getModifiers()); addMethod(method.getName(), method.getReturnType(), method.getParameterTypes(), @@ -351,11 +128,10 @@ * @param - the modifier to be used on the generated method. */ protected void addMethod(String name, - Class<?> ret, - Class<?>[] parameters, - Class<?>[] exceptions, - int modifier) { - addMethod(name, ret, parameters, exceptions, modifier, null); + Class<?> ret, + Class<?>[] parameters, + Class<?>[] exceptions) { + addMethod(name, ret, parameters, exceptions, Modifier.PUBLIC, null); } /** @@ -365,12 +141,12 @@ * 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. */ - protected void addMethod(String name, - Class<?> ret, - Class<?>[] parameters, - Class<?>[] exceptions, - int access, - Class<?> declaringClass) { + private void addMethod(String name, + Class<?> ret, + Class<?>[] parameters, + Class<?>[] exceptions, + int access, + Class<?> declaringClass) { names.add(name); Code code = classfile.addMethod(name, makeSig(ret, parameters), access, mapClasses(exceptions)); @@ -461,85 +237,54 @@ } } + /** Adds a constructor that calls through to superclass and returns immediately. */ + protected void addConstructor(Constructor<?> constructor) { + Code code = addOpenConstructor(constructor); + doReturn(code, superclass); + } + /** - * Visits all methods declared on the given class and classes in its inheritance hierarchy. - * Methods visible to subclasses are added to <code>seen</code>. + * Adds a constructor that calls through to superclass and leaves the returned Code open for + * more operations. The caller of this method must add a return to the returned Code. */ - protected void visitMethods(Class<?> klass, Set<MethodDescr> seen) { - for (Method method : klass.getDeclaredMethods()) { + protected Code addOpenConstructor(Constructor<?> constructor) { + String sig = makeSig(Void.TYPE, constructor.getParameterTypes()); + Code code = classfile.addMethod("<init>", sig, ACC_PUBLIC, + mapClasses(constructor.getExceptionTypes())); + callSuper(code, "<init>", mapClass(superclass), constructor.getParameterTypes(), Void.TYPE, + false); + return code; + } - int access = method.getModifiers(); - if (Modifier.isStatic(access) || Modifier.isPrivate(access) || - PyReflectedFunction.isPackagedProtected(access)) { - // package protected and private aren't visible to our class, so they don't enter - // into the namespace, and likewise for static methods, regardless of their access. - - // TODO - allow overriding of package protected methods if the generated class is in - // the same package, throw an exception otherwise. + /** + * Visits constructors from this proxy's superclass. + */ + private void visitConstructors() { + for (Constructor<?> constructor : superclass.getDeclaredConstructors()) { + if (Modifier.isPrivate(constructor.getModifiers())) { continue; } - - if (!seen.add(new MethodDescr(method))) { - // A method with the same signature has already been added, skip this. - continue; - } - - // TODO - Track accessible final methods in their own Set, protect from overrides - if (Modifier.isFinal(access)) { - if (Modifier.isProtected(access)) { - addSuperMethod(method); - } - continue; - } - visitMethod(method); + visitConstructor(constructor); } - - Class<?> superClass = klass.getSuperclass(); - if (superClass != null) { - visitMethods(superClass, seen); - } - - for (Class<?> iface : klass.getInterfaces()) { - visitMethods(iface, seen); - } } /** - * Called for every method on the proxy's superclass and interfaces that can be overriden by the - * proxy class. If the proxy wants to perform Python lookup and calling for the method, - * {@link #addMethod(Method)} should be called. For abstract methods, addMethod must be called. + * 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 for the method, + * {@link #addOverrideMethod(Method)} should be called. For abstract methods, addMethod must be + * called. */ protected void visitMethod(Method method) { - addMethod(method); + addOverrideMethod(method); } - /** Adds a constructor that calls through to superclass. */ - protected void addConstructor(Class<?>[] parameters, int access) { - String sig = makeSig(Void.TYPE, parameters); - Code code = classfile.addMethod("<init>", sig, access); - callSuper(code, "<init>", mapClass(superclass), parameters, Void.TYPE, true); - } /** - * Visits constructors from this proxy's superclass. + * Called for every constructor on the proxy's superclass that can be overridden by + * the proxy class. */ - protected Set<ConstructorDescr> visitConstructors() { - Set<ConstructorDescr> added = Generic.set(); - for (Constructor<?> constructor : superclass.getDeclaredConstructors()) { - int access = constructor.getModifiers(); - if (Modifier.isPrivate(access)) { - continue; - } - if (Modifier.isNative(access)) { - access = access & ~Modifier.NATIVE; - } - if (Modifier.isProtected(access)) { - access = access & ~Modifier.PROTECTED | Modifier.PUBLIC; - } - addConstructor(constructor.getParameterTypes(), access); - added.add(new ConstructorDescr(constructor)); - } - return added; + protected void visitConstructor(Constructor<?> constructor) { + addConstructor(constructor); } // Super methods are added for the following three reasons: @@ -568,11 +313,11 @@ addSuperMethod(methodName, superName, superClass, parameters, ret); } - protected void addSuperMethod(String methodName, - String superName, - String declClass, - Class<?>[] parameters, - Class<?> ret) { + private void addSuperMethod(String methodName, + String superName, + String declClass, + Class<?>[] parameters, + Class<?> ret) { if (methodName.startsWith("super__")) { /* rationale: JC java-class, P proxy-class subclassing JC in order to avoid infinite recursion P should define super__foo @@ -597,7 +342,7 @@ /** * Adds the methods and fields necessary to implement PyProxy. */ - protected void addProxy() { + private void addProxy() { classfile.addField("__proxy", $pyObj, Modifier.PROTECTED); Code code = classfile.addMethod("_setPyInstance", makeSig("V", $pyObj), Modifier.PUBLIC); code.aload(0); @@ -628,7 +373,7 @@ /** * Adds the classDictInit static method to fill in __supernames__ on the class' dict */ - protected void addClassDictInit() { + private void addClassDictInit() { classfile.addInterface(mapClass(org.python.core.ClassDictInit.class)); Code code = classfile.addMethod("classDictInit", makeSig("V", $pyObj), Modifier.PUBLIC | Modifier.STATIC); @@ -643,7 +388,50 @@ code.return_(); } - protected Set<MethodDescr> visitMethods() { + /** + * Visits all methods declared on the given class and classes in its inheritance hierarchy. + * Methods visible to subclasses are added to <code>seen</code>. + */ + void visitMethods(Class<?> klass, Set<MethodDescr> seen) { + for (Method method : klass.getDeclaredMethods()) { + + int access = method.getModifiers(); + if (Modifier.isStatic(access) || Modifier.isPrivate(access) || + PyReflectedFunction.isPackagedProtected(access)) { + // package protected and private aren't visible to our class, so they don't enter + // into the namespace, and likewise for static methods, regardless of their access. + + // TODO - allow overriding of package protected methods if the generated class is in + // the same package, throw an exception otherwise. + continue; + } + + if (!seen.add(new MethodDescr(method))) { + // A method with the same signature has already been added, skip this. + continue; + } + + // TODO - Track accessible final methods in their own Set, protect from overrides + if (Modifier.isFinal(access)) { + if (Modifier.isProtected(access)) { + addSuperMethod(method); + } + continue; + } + visitMethod(method); + } + + Class<?> superClass = klass.getSuperclass(); + if (superClass != null) { + visitMethods(superClass, seen); + } + + for (Class<?> iface : klass.getInterfaces()) { + visitMethods(iface, seen); + } + } + + private Set<MethodDescr> visitMethods() { Set<MethodDescr> seenmethods = Generic.set(); visitMethods(superclass, seenmethods); for (Class<?> iface : interfaces) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-08-30 22:16:00
|
Revision: 6729 http://jython.svn.sourceforge.net/jython/?rev=6729&view=rev Author: cgroves Date: 2009-08-30 22:15:47 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Make ClassFile a little more amenable to being exposed to the public. Hide all of its internal fields, document its methods, and remove unused constructors. Modified Paths: -------------- branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java branches/customizable-proxymaker/src/org/python/compiler/CodeCompiler.java branches/customizable-proxymaker/src/org/python/compiler/Module.java Modified: branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java 2009-08-30 16:19:33 UTC (rev 6728) +++ branches/customizable-proxymaker/src/org/python/compiler/ClassFile.java 2009-08-30 22:15:47 UTC (rev 6729) @@ -1,11 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.compiler; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.objectweb.asm.AnnotationVisitor; @@ -13,123 +8,132 @@ import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.python.core.imp; +import org.python.util.Generic; +/** + * Generates bytecode for a Java class. + */ public class ClassFile { - ClassWriter cw; - int access; - long mtime; - public String name; - String superclass; - String sfilename; - String[] interfaces; - List<MethodVisitor> methodVisitors; - List<FieldVisitor> fieldVisitors; + final String name; + private final String superclass; + private final String sourceFilename; + private final long mtime; + private final List<String> interfaces = Generic.list(); + private final List<MethodVisitor> methodVisitors = Generic.list(); + private final List<FieldVisitor> fieldVisitors = Generic.list(); + private final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - public static String fixName(String n) { - if (n.indexOf('.') == -1) { - return n; - } - char[] c = n.toCharArray(); - for (int i = 0; i < c.length; i++) { - if (c[i] == '.') { - c[i] = '/'; - } - } - return new String(c); + /** + * Creates a generator for a class of the given name. + * + * @param name + * - The name of the class in internal form. + * @param superclass + * - The name of the superclass of the generated class in internal form. + */ + public ClassFile(String name, String superclass) { + this(name, superclass, imp.NO_MTIME, null); } - public ClassFile(String name) { - this(name, "java/lang/Object", Opcodes.ACC_SYNCHRONIZED | Opcodes.ACC_PUBLIC, - org.python.core.imp.NO_MTIME); - } - - public ClassFile(String name, String superclass, int access) { - this(name, superclass, access, org.python.core.imp.NO_MTIME); - } - - public ClassFile(String name, String superclass, int access, long mtime) { - this.name = fixName(name); - this.superclass = fixName(superclass); - this.interfaces = new String[0]; - this.access = access; + /** + * Creates a generator for a class of the given name. + * + * @param name + * - The name of the class in internal form. + * @param superclass + * - The name of the superclass of the generated class in internal form. + * @param mtime + * - the time the source was last modified, or {@link imp#NO_MTIME} if it's unknown. + * @param sourceFilename + * - The source file this class is derived from. + */ + public ClassFile(String name, String superclass, long mtime, String sourceFilename) { + this.name = name; + this.superclass = superclass; this.mtime = mtime; - - cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - methodVisitors = Collections.synchronizedList(new ArrayList<MethodVisitor>()); - fieldVisitors = Collections.synchronizedList(new ArrayList<FieldVisitor>()); + this.sourceFilename = sourceFilename; } - public void setSource(String name) { - sfilename = name; - } - + /** + * Adds the given interface class name in internal form to the list of interfaces this class + * implements. + */ public void addInterface(String name) { - String[] new_interfaces = new String[interfaces.length+1]; - System.arraycopy(interfaces, 0, new_interfaces, 0, interfaces.length); - new_interfaces[interfaces.length] = name; - interfaces = new_interfaces; + interfaces.add(name); } - public Code addMethod(String name, String type, int access) { - return addMethod(name, type, access, null); - } - - public Code addMethod(String name, String type, int access, String[] exceptions) { - MethodVisitor mv = cw.visitMethod(access, name, type, null, exceptions); - Code pmv = new Code(mv, type, access); + /** + * Adds a method to the class under construction. The returned Code should be filled in with the + * body of the method. + * + * @param name + * - the method's name. + * @param descriptor + * - the method descriptor as built by {@link Type#getMethodDescriptor}. + * @param access + * - the method's access level as constructed from {@link Opcodes}. + */ + public Code addMethod(String name, String descriptor, int access, String... exceptions) { + MethodVisitor mv = cw.visitMethod(access, name, descriptor, null, exceptions); + Code pmv = new Code(mv, descriptor, access); methodVisitors.add(pmv); return pmv; } - public void addField(String name, String type, int access) { - FieldVisitor fv = cw.visitField(access, name, type, null, null); - fieldVisitors.add(fv); + /** + * Adds a field to the class under construction. + * + * @param name + * - the field's name. + * @param descriptor + * - the field descriptor as built by {@link Type#getDescriptor(Class)}. + * @param access + * - the method's access level as constructed from {@link Opcodes}. + */ + public void addField(String name, String descriptor, int access) { + fieldVisitors.add(cw.visitField(access, name, descriptor, null, null)); } - public void endFields() { - for (FieldVisitor fv : fieldVisitors) { - fv.visitEnd(); - } - } - - public void endMethods() { - for (int i = 0; i < methodVisitors.size(); i++) { - MethodVisitor mv = methodVisitors.get(i); - mv.visitMaxs(0, 0); - mv.visitEnd(); - } - } - - public void write(OutputStream stream) throws IOException { - byte[] ba = create(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(ba.length); - baos.write(ba, 0, ba.length); - baos.writeTo(stream); - baos.close(); - } - + /** + * Creates the bytecode for the class as it currently stands. This may only be called once per + * ClassFile. + */ public byte[] create() { - cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, this.name, null, - this.superclass, interfaces); + cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, name, null, superclass, + interfaces.toArray(new String[interfaces.size()])); AnnotationVisitor av = cw.visitAnnotation("Lorg/python/compiler/APIVersion;", true); // XXX: should imp.java really house this value or should imp.java point into // org.python.compiler? - av.visit("value", new Integer(imp.getAPIVersion())); + av.visit("value", imp.getAPIVersion()); av.visitEnd(); av = cw.visitAnnotation("Lorg/python/compiler/MTime;", true); av.visit("value", new Long(mtime)); av.visitEnd(); - if (sfilename != null) { - cw.visitSource(sfilename, null); + if (sourceFilename != null) { + cw.visitSource(sourceFilename, null); } endFields(); endMethods(); return cw.toByteArray(); } + + private void endFields() { + for (FieldVisitor fv : fieldVisitors) { + fv.visitEnd(); + } + } + + private void endMethods() { + for (MethodVisitor mv : methodVisitors) { + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + } } Modified: branches/customizable-proxymaker/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/CodeCompiler.java 2009-08-30 16:19:33 UTC (rev 6728) +++ branches/customizable-proxymaker/src/org/python/compiler/CodeCompiler.java 2009-08-30 22:15:47 UTC (rev 6729) @@ -82,7 +82,6 @@ import org.python.core.PyObject; import org.python.core.PyString; import org.python.core.PyUnicode; -import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; @@ -101,7 +100,6 @@ public static final int AUGSET=4; public Module module; - public ClassWriter cw; public Code code; public CodeCompiler mrefs; public CompilerFlags cflags; @@ -145,7 +143,6 @@ this.print_results = print_results; mrefs = this; - cw = module.classfile.cw; continueLabels = new Stack<Label>(); breakLabels = new Stack<Label>(); Modified: branches/customizable-proxymaker/src/org/python/compiler/Module.java =================================================================== --- branches/customizable-proxymaker/src/org/python/compiler/Module.java 2009-08-30 16:19:33 UTC (rev 6728) +++ branches/customizable-proxymaker/src/org/python/compiler/Module.java 2009-08-30 22:15:47 UTC (rev 6729) @@ -296,7 +296,6 @@ public class Module implements Opcodes, ClassConstants, CompilationContext { ClassFile classfile; - Constant filename; String sfilename; public Constant mainCode; public boolean linenumbers; @@ -304,30 +303,17 @@ Hashtable<PythonTree,ScopeInfo> scopes; long mtime; - public Module(String name, String filename, boolean linenumbers) { - this(name, filename, linenumbers, org.python.core.imp.NO_MTIME); - } - public Module(String name, String filename, boolean linenumbers, long mtime) { this.linenumbers = linenumbers; this.mtime = mtime; - classfile = new ClassFile(name, "org/python/core/PyFunctionTable", - ACC_SYNCHRONIZED | ACC_PUBLIC, mtime); + classfile = new ClassFile(name, "org/python/core/PyFunctionTable", mtime, sfilename); constants = new Hashtable<Constant,Constant>(); sfilename = filename; - if (filename != null) - this.filename = PyString(filename); - else - this.filename = null; codes = new ArrayList<PyCodeConstant>(); futures = new Future(); scopes = new Hashtable<PythonTree,ScopeInfo>(); } - public Module(String name) { - this(name, name+".py", true, org.python.core.imp.NO_MTIME); - } - // This block of code handles the pool of Python Constants Hashtable<Constant,Constant> constants; @@ -608,10 +594,7 @@ addFunctions(); classfile.addInterface("org/python/core/PyRunnable"); - if (sfilename != null) { - classfile.setSource(sfilename); - } - classfile.write(stream); + stream.write(classfile.create()); } // Implementation of CompilationContext This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-30 16:19:39
|
Revision: 6728 http://jython.svn.sourceforge.net/jython/?rev=6728&view=rev Author: fwierzbicki Date: 2009-08-30 16:19:33 +0000 (Sun, 30 Aug 2009) Log Message: ----------- removed pbcvm branch dep Property Changed: ---------------- branches/jy26/ Property changes on: branches/jy26 ___________________________________________________________________ Modified: svnmerge-integrated - /branches/pbcvm:1-6045 /trunk/jython:1-6477 + /trunk/jython:1-6477 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-30 16:08:15
|
Revision: 6727 http://jython.svn.sourceforge.net/jython/?rev=6727&view=rev Author: fwierzbicki Date: 2009-08-30 16:07:59 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-6477" from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython Property Changed: ---------------- branches/jy26/ Property changes on: branches/jy26 ___________________________________________________________________ Modified: svnmerge-integrated - /branches/pbcvm:1-6045 + /branches/pbcvm:1-6045 /trunk/jython:1-6477 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-30 16:05:15
|
Revision: 6726 http://jython.svn.sourceforge.net/jython/?rev=6726&view=rev Author: fwierzbicki Date: 2009-08-30 16:05:08 +0000 (Sun, 30 Aug 2009) Log Message: ----------- Switching back to 2.5 libs to see if unladen swallow tests will run. Property Changed: ---------------- branches/jy26/ Property changes on: branches/jy26 ___________________________________________________________________ Modified: svn:externals - CPythonLib -r73469 http://svn.python.org/projects/python/branches/release26-maint/Lib/ + CPythonLib -r73469 http://svn.python.org/projects/python/branches/release25-maint/Lib/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-29 18:30:37
|
Revision: 6725 http://jython.svn.sourceforge.net/jython/?rev=6725&view=rev Author: pjenvey Date: 2009-08-29 18:30:16 +0000 (Sat, 29 Aug 2009) Log Message: ----------- treat line buffered read streams as the default buffered mode. CPython 2 line buffered read uses a different bufsize than the default depending on the platform (sometimes smaller, sometimes bigger) Modified Paths: -------------- trunk/jython/src/org/python/core/PyFile.java Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2009-08-29 17:54:06 UTC (rev 6724) +++ trunk/jython/src/org/python/core/PyFile.java 2009-08-29 18:30:16 UTC (rev 6725) @@ -196,7 +196,7 @@ buffer = lineBuffered ? new LineBufferedWriter(raw) : new BufferedWriter(raw, bufsize); } else if (reading) { // Line buffering is for output only - buffer = new BufferedReader(raw, lineBuffered ? 0 : bufsize); + buffer = new BufferedReader(raw, lineBuffered ? IOBase.DEFAULT_BUFFER_SIZE : bufsize); } else { // Should never happen throw Py.ValueError("unknown mode: '" + mode + "'"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-29 17:54:24
|
Revision: 6724 http://jython.svn.sourceforge.net/jython/?rev=6724&view=rev Author: pjenvey Date: 2009-08-29 17:54:06 +0000 (Sat, 29 Aug 2009) Log Message: ----------- use @Override Modified Paths: -------------- trunk/jython/src/org/python/core/io/BinaryIOWrapper.java trunk/jython/src/org/python/core/io/BufferedIOMixin.java trunk/jython/src/org/python/core/io/BufferedRandom.java trunk/jython/src/org/python/core/io/BufferedReader.java trunk/jython/src/org/python/core/io/BufferedWriter.java trunk/jython/src/org/python/core/io/DatagramSocketIO.java trunk/jython/src/org/python/core/io/FileIO.java trunk/jython/src/org/python/core/io/LineBufferedRandom.java trunk/jython/src/org/python/core/io/LineBufferedWriter.java trunk/jython/src/org/python/core/io/RawIOBase.java trunk/jython/src/org/python/core/io/ServerSocketIO.java trunk/jython/src/org/python/core/io/SocketIO.java trunk/jython/src/org/python/core/io/SocketIOBase.java trunk/jython/src/org/python/core/io/StreamIO.java trunk/jython/src/org/python/core/io/TextIOBase.java trunk/jython/src/org/python/core/io/TextIOWrapper.java trunk/jython/src/org/python/core/io/UniversalIOWrapper.java Modified: trunk/jython/src/org/python/core/io/BinaryIOWrapper.java =================================================================== --- trunk/jython/src/org/python/core/io/BinaryIOWrapper.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/BinaryIOWrapper.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -22,7 +22,7 @@ super(bufferedIO); } - /** {@inheritDoc} */ + @Override public String read(int size) { if (size < 0) { return readall(); @@ -51,7 +51,7 @@ return StringUtil.fromBytes(data); } - /** {@inheritDoc} */ + @Override public String readall() { if (!readahead.hasRemaining()) { return StringUtil.fromBytes(bufferedIO.readall()); @@ -66,7 +66,7 @@ return StringUtil.fromBytes(all); } - /** {@inheritDoc} */ + @Override public String readline(int size) { // Avoid ByteBuffer (this.readahead) and StringBuilder // (this.builder) method calls in the inner loop by reading @@ -110,7 +110,7 @@ return drainBuilder(); } - /** {@inheritDoc} */ + @Override public int write(String buf) { if (readahead.hasRemaining()) { clearReadahead(); Modified: trunk/jython/src/org/python/core/io/BufferedIOMixin.java =================================================================== --- trunk/jython/src/org/python/core/io/BufferedIOMixin.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/BufferedIOMixin.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -44,27 +44,27 @@ this.bufferSize = bufferSize; } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { return rawIO.seek(pos, whence); } - /** {@inheritDoc} */ + @Override public long tell() { return rawIO.tell(); } - /** {@inheritDoc} */ + @Override public long truncate(long size) { return rawIO.truncate(size); } - /** {@inheritDoc} */ + @Override public void flush() { rawIO.flush(); } - /** {@inheritDoc} */ + @Override public void close() { if (closed()) { return; @@ -80,27 +80,27 @@ rawIO.close(); } - /** {@inheritDoc} */ + @Override public RawIOBase fileno() { return rawIO.fileno(); } - /** {@inheritDoc} */ + @Override public boolean isatty() { return rawIO.isatty(); } - /** {@inheritDoc} */ + @Override public boolean readable() { return rawIO.readable(); } - /** {@inheritDoc} */ + @Override public boolean writable() { return rawIO.writable(); } - /** {@inheritDoc} */ + @Override public boolean closed() { return rawIO.closed(); } Modified: trunk/jython/src/org/python/core/io/BufferedRandom.java =================================================================== --- trunk/jython/src/org/python/core/io/BufferedRandom.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/BufferedRandom.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -37,7 +37,7 @@ this.writer = new BufferedWriter(rawIO, bufferSize); } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { flush(); // First do the raw seek, then empty the read buffer, so that @@ -47,7 +47,7 @@ return pos; } - /** {@inheritDoc} */ + @Override public long tell() { if (writer.buffered()) { return writer.tell(); @@ -55,25 +55,25 @@ return reader.tell(); } - /** {@inheritDoc} */ + @Override public ByteBuffer read(int size) { flush(); return reader.read(size); } - /** {@inheritDoc} */ + @Override public ByteBuffer readall() { flush(); return reader.readall(); } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer bytes) { flush(); return reader.readinto(bytes); } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer bytes) { if (reader.buffered()) { reader.clear(); @@ -81,19 +81,19 @@ return writer.write(bytes); } - /** {@inheritDoc} */ + @Override public ByteBuffer peek(int size) { flush(); return reader.peek(size); } - /** {@inheritDoc} */ + @Override public int read1(ByteBuffer bytes) { flush(); return reader.read1(bytes); } - /** {@inheritDoc} */ + @Override public void flush() { writer.flush(); } Modified: trunk/jython/src/org/python/core/io/BufferedReader.java =================================================================== --- trunk/jython/src/org/python/core/io/BufferedReader.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/BufferedReader.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -27,7 +27,7 @@ clear(); } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer bytes) { int size = bytes.remaining(); @@ -57,7 +57,7 @@ return (int)read; } - /** {@inheritDoc} */ + @Override public ByteBuffer readall() { ByteBuffer remaining = rawIO.readall(); @@ -73,7 +73,7 @@ return all; } - /** {@inheritDoc} */ + @Override public ByteBuffer peek(int size) { if (buffer.remaining() < Math.min(size, bufferSize)) { // Prepare to fill the buffer @@ -89,7 +89,7 @@ return buffer; } - /** {@inheritDoc} */ + @Override public int read1(ByteBuffer bytes) { int size = bytes.remaining(); if (size == 0) { @@ -106,12 +106,12 @@ return readinto(bytes); } - /** {@inheritDoc} */ + @Override public long tell() { return rawIO.tell() - buffer.remaining(); } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { if (whence == 1) { pos -= buffer.remaining(); @@ -121,17 +121,17 @@ return pos; } - /** {@inheritDoc} */ + @Override public boolean buffered() { return buffer.hasRemaining(); } - /** {@inheritDoc} */ + @Override public void clear() { buffer.clear().limit(0); } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer bytes) { // Never writable; just raise the appropriate exception checkClosed(); @@ -139,7 +139,7 @@ return -1; } - /** {@inheritDoc} */ + @Override public boolean writable() { return false; } Modified: trunk/jython/src/org/python/core/io/BufferedWriter.java =================================================================== --- trunk/jython/src/org/python/core/io/BufferedWriter.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/BufferedWriter.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -26,7 +26,7 @@ buffer = ByteBuffer.allocate(this.bufferSize); } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer bytes) { if (bufferSize == 0) { return rawIO.write(bytes); @@ -70,7 +70,7 @@ return totalToWrite; } - /** {@inheritDoc} */ + @Override public void flush() { if (buffer.position() > 0) { buffer.flip(); @@ -82,23 +82,23 @@ super.flush(); } - /** {@inheritDoc} */ + @Override public long tell() { return rawIO.tell() + buffer.position(); } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { flush(); return rawIO.seek(pos, whence); } - /** {@inheritDoc} */ + @Override public boolean buffered() { return buffer.position() > 0; } - /** {@inheritDoc} */ + @Override public ByteBuffer readall() { // Never readable; just raise the appropriate exception checkClosed(); @@ -106,7 +106,7 @@ return null; } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer bytes) { // Never readable; just raise the appropriate exception checkClosed(); @@ -114,7 +114,7 @@ return -1; } - /** {@inheritDoc} */ + @Override public int read1(ByteBuffer bytes) { // Never readable; just raise the appropriate exception checkClosed(); @@ -122,7 +122,7 @@ return -1; } - /** {@inheritDoc} */ + @Override public boolean readable() { return false; } Modified: trunk/jython/src/org/python/core/io/DatagramSocketIO.java =================================================================== --- trunk/jython/src/org/python/core/io/DatagramSocketIO.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/DatagramSocketIO.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -29,7 +29,7 @@ this.socketChannel = socketChannel; } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer buf) { checkClosed(); checkReadable(); @@ -57,7 +57,7 @@ } } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer buf) { checkClosed(); checkWritable(); @@ -85,7 +85,7 @@ } } - /** {@inheritDoc} */ + @Override public void close() { if (closed()) { return; @@ -98,7 +98,7 @@ super.close(); } - /** {@inheritDoc} */ + @Override public Channel getChannel() { return socketChannel; } Modified: trunk/jython/src/org/python/core/io/FileIO.java =================================================================== --- trunk/jython/src/org/python/core/io/FileIO.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/FileIO.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -180,7 +180,7 @@ } } - /** {@inheritDoc} */ + @Override public boolean isatty() { checkClosed(); if (file == null) { @@ -193,7 +193,7 @@ } } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer buf) { checkClosed(); checkReadable(); @@ -252,7 +252,7 @@ return all; } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer buf) { checkClosed(); checkWritable(); @@ -280,7 +280,7 @@ } } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { checkClosed(); try { @@ -303,7 +303,7 @@ } } - /** {@inheritDoc} */ + @Override public long tell() { checkClosed(); try { @@ -313,7 +313,7 @@ } } - /** {@inheritDoc} */ + @Override public long truncate(long size) { checkClosed(); checkWritable(); @@ -328,7 +328,7 @@ return size; } - /** {@inheritDoc} */ + @Override public void close() { if (closed()) { return; @@ -351,17 +351,17 @@ return readable() ? Channels.newInputStream(fileChannel) : super.asInputStream(); } - /** {@inheritDoc} */ + @Override public boolean readable() { return reading || plus; } - /** {@inheritDoc} */ + @Override public boolean writable() { return writing; } - /** {@inheritDoc} */ + @Override public Channel getChannel() { return fileChannel; } Modified: trunk/jython/src/org/python/core/io/LineBufferedRandom.java =================================================================== --- trunk/jython/src/org/python/core/io/LineBufferedRandom.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/LineBufferedRandom.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -19,7 +19,7 @@ super(rawIO, 1); } - /** {@inheritDoc} */ + @Override protected void initChildBuffers() { // Line buffering is for output only this.reader = new BufferedReader(rawIO, 0); Modified: trunk/jython/src/org/python/core/io/LineBufferedWriter.java =================================================================== --- trunk/jython/src/org/python/core/io/LineBufferedWriter.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/LineBufferedWriter.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -21,7 +21,7 @@ buffer = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE); } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer bytes) { int size = bytes.remaining(); Modified: trunk/jython/src/org/python/core/io/RawIOBase.java =================================================================== --- trunk/jython/src/org/python/core/io/RawIOBase.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/RawIOBase.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -155,7 +155,7 @@ return count; } - /** {@inheritDoc} */ + @Override public RawIOBase fileno() { checkClosed(); return this; Modified: trunk/jython/src/org/python/core/io/ServerSocketIO.java =================================================================== --- trunk/jython/src/org/python/core/io/ServerSocketIO.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/ServerSocketIO.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -30,21 +30,21 @@ this.socketChannel = socketChannel; } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer buf) { checkClosed(); checkReadable(); throw Py.IOError(Errno.ENOTCONN); } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer buf) { checkClosed(); checkWritable(); throw Py.IOError(Errno.EBADF); } - /** {@inheritDoc} */ + @Override public void close() { if (closed()) { return; @@ -57,7 +57,7 @@ super.close(); } - /** {@inheritDoc} */ + @Override public Channel getChannel() { return socketChannel; } Modified: trunk/jython/src/org/python/core/io/SocketIO.java =================================================================== --- trunk/jython/src/org/python/core/io/SocketIO.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/SocketIO.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -29,7 +29,7 @@ this.socketChannel = socketChannel; } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer buf) { checkClosed(); checkReadable(); @@ -57,7 +57,7 @@ } } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer buf) { checkClosed(); checkWritable(); @@ -85,7 +85,7 @@ } } - /** {@inheritDoc} */ + @Override public void close() { if (closed()) { return; @@ -98,7 +98,7 @@ super.close(); } - /** {@inheritDoc} */ + @Override public Channel getChannel() { return socketChannel; } Modified: trunk/jython/src/org/python/core/io/SocketIOBase.java =================================================================== --- trunk/jython/src/org/python/core/io/SocketIOBase.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/SocketIOBase.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -45,12 +45,12 @@ } } - /** {@inheritDoc} */ + @Override public boolean readable() { return readable; } - /** {@inheritDoc} */ + @Override public boolean writable() { return writable; } Modified: trunk/jython/src/org/python/core/io/StreamIO.java =================================================================== --- trunk/jython/src/org/python/core/io/StreamIO.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/StreamIO.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -111,7 +111,7 @@ this.outputStream = outputStream; } - /** {@inheritDoc} */ + @Override public int readinto(ByteBuffer buf) { checkClosed(); checkReadable(); @@ -122,7 +122,7 @@ } } - /** {@inheritDoc} */ + @Override public int write(ByteBuffer buf) { checkClosed(); checkWritable(); @@ -133,7 +133,7 @@ } } - /** {@inheritDoc} */ + @Override public void flush() { if (outputStream == null) { return; @@ -145,7 +145,7 @@ } } - /** {@inheritDoc} */ + @Override public void close() { if (closed()) { return; @@ -217,7 +217,7 @@ return null; } - /** {@inheritDoc} */ + @Override public boolean isatty() { checkClosed(); @@ -234,12 +234,12 @@ return FileUtil.isatty(fd); } - /** {@inheritDoc} */ + @Override public boolean readable() { return readChannel != null; } - /** {@inheritDoc} */ + @Override public boolean writable() { return writeChannel != null; } @@ -266,7 +266,7 @@ return super.asInputStream(); } - /** {@inheritDoc} */ + @Override public Channel getChannel() { return readable() ? readChannel : writeChannel; } Modified: trunk/jython/src/org/python/core/io/TextIOBase.java =================================================================== --- trunk/jython/src/org/python/core/io/TextIOBase.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/TextIOBase.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -129,7 +129,7 @@ return -1; } - /** {@inheritDoc} */ + @Override public long truncate(long pos) { long initialPos = tell(); flush(); @@ -143,49 +143,49 @@ return pos; } - /** {@inheritDoc} */ + @Override public void flush() { bufferedIO.flush(); } - /** {@inheritDoc} */ + @Override public void close() { bufferedIO.close(); } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { pos = bufferedIO.seek(pos, whence); clearReadahead(); return pos; } - /** {@inheritDoc} */ + @Override public long tell() { return bufferedIO.tell() - readahead.remaining(); } - /** {@inheritDoc} */ + @Override public RawIOBase fileno() { return bufferedIO.fileno(); } - /** {@inheritDoc} */ + @Override public boolean isatty() { return bufferedIO.isatty(); } - /** {@inheritDoc} */ + @Override public boolean readable() { return bufferedIO.readable(); } - /** {@inheritDoc} */ + @Override public boolean writable() { return bufferedIO.writable(); } - /** {@inheritDoc} */ + @Override public boolean closed() { return bufferedIO.closed(); } Modified: trunk/jython/src/org/python/core/io/TextIOWrapper.java =================================================================== --- trunk/jython/src/org/python/core/io/TextIOWrapper.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/TextIOWrapper.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -37,7 +37,7 @@ newlineIsLF = newline.equals("\n"); } - /** {@inheritDoc} */ + @Override public String read(int size) { if (newlineIsLF) { return super.read(size); @@ -98,7 +98,7 @@ return new String(builderArray, 0, builderPos); } - /** {@inheritDoc} */ + @Override public String readall() { if (newlineIsLF) { return super.readall(); @@ -172,7 +172,7 @@ return destPos - destStartPos; } - /** {@inheritDoc} */ + @Override public String readline(int size) { if (newlineIsLF) { return super.readline(size); @@ -252,7 +252,7 @@ return drainBuilder(); } - /** {@inheritDoc} */ + @Override public int write(String buf) { if (!newlineIsLF) { buf = LF_PATTERN.matcher(buf).replaceAll(newline); Modified: trunk/jython/src/org/python/core/io/UniversalIOWrapper.java =================================================================== --- trunk/jython/src/org/python/core/io/UniversalIOWrapper.java 2009-08-26 10:33:22 UTC (rev 6723) +++ trunk/jython/src/org/python/core/io/UniversalIOWrapper.java 2009-08-29 17:54:06 UTC (rev 6724) @@ -33,7 +33,7 @@ super(bufferedIO); } - /** {@inheritDoc} */ + @Override public String read(int size) { if (size < 0) { return readall(); @@ -105,7 +105,7 @@ return new String(builderArray, 0, builderPos); } - /** {@inheritDoc} */ + @Override public String readall() { // Read the remainder of file ByteBuffer remaining = bufferedIO.readall(); @@ -179,7 +179,7 @@ return destPos - destStartPos; } - /** {@inheritDoc} */ + @Override public String readline(int size) { // Avoid ByteBuffer (this.readahead) and StringBuilder // (this.builder) method calls in the inner loop by reading @@ -268,7 +268,7 @@ return drainBuilder(); } - /** {@inheritDoc} */ + @Override public int write(String buf) { // Universal newlines doesn't support writing; just raise the // appropriate exception @@ -277,14 +277,14 @@ return -1; } - /** {@inheritDoc} */ + @Override public long seek(long pos, int whence) { pos = super.seek(pos, whence); skipNextLF = false; return pos; } - /** {@inheritDoc} */ + @Override public long tell() { long pos = super.tell(); if (skipNextLF) { @@ -305,7 +305,7 @@ return pos; } - /** {@inheritDoc} */ + @Override public PyObject getNewlines() { int size = newlineTypes.size(); if (size == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |