Skip to content

Commit 5a76a3e

Browse files
committed
Also allow Long in PythonAbstractNativeObject
1 parent e6b31d4 commit 5a76a3e

File tree

9 files changed

+16
-21
lines changed

9 files changed

+16
-21
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PythonCextBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ private static Object[] collect(MroSequenceStorage mro, int idx) {
926926
if (value != PNone.NO_VALUE) {
927927
Object[] tuple = (Object[]) value;
928928
assert tuple.length == 2;
929-
l.add(new PythonAbstractNativeObject((TruffleObject) tuple[idx]));
929+
l.add(new PythonAbstractNativeObject(tuple[idx]));
930930
}
931931
}
932932
return l.toArray();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonAbstractNativeObject.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
import com.oracle.truffle.api.dsl.Fallback;
7676
import com.oracle.truffle.api.dsl.Specialization;
7777
import com.oracle.truffle.api.interop.InteropLibrary;
78-
import com.oracle.truffle.api.interop.TruffleObject;
7978
import com.oracle.truffle.api.interop.UnsupportedMessageException;
8079
import com.oracle.truffle.api.library.CachedLibrary;
8180
import com.oracle.truffle.api.library.ExportLibrary;
@@ -89,9 +88,9 @@
8988
@ExportLibrary(PythonBufferAcquireLibrary.class)
9089
public final class PythonAbstractNativeObject extends PythonAbstractObject implements PythonNativeObject, PythonNativeClass {
9190

92-
public final TruffleObject object;
91+
public final Object object;
9392

94-
public PythonAbstractNativeObject(TruffleObject object) {
93+
public PythonAbstractNativeObject(Object object) {
9594
this.object = object;
9695
}
9796

@@ -105,7 +104,8 @@ public void lookupChanged() {
105104
throw new UnsupportedOperationException("not yet implemented");
106105
}
107106

108-
public TruffleObject getPtr() {
107+
@Override
108+
public Object getPtr() {
109109
return object;
110110
}
111111

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeClass.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
package com.oracle.graal.python.builtins.objects.cext;
4242

4343
import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
44-
import com.oracle.truffle.api.interop.TruffleObject;
4544
import com.oracle.truffle.api.object.HiddenKey;
4645

4746
/**
@@ -54,7 +53,7 @@ public interface PythonNativeClass extends PythonAbstractClass {
5453

5554
public static final HiddenKey INSTANCESHAPE = new HiddenKey("instanceshape");
5655

57-
TruffleObject getPtr();
56+
Object getPtr();
5857

5958
default String getName() {
6059
return String.format("PythonNativeClass(%s)", getPtr());

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeObject.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@
4040
*/
4141
package com.oracle.graal.python.builtins.objects.cext;
4242

43-
import com.oracle.truffle.api.interop.TruffleObject;
44-
4543
/**
4644
* A simple wrapper around objects created through the Python C API that can be cast to PyObject*.
4745
*/
4846
public interface PythonNativeObject {
4947

50-
TruffleObject getPtr();
48+
Object getPtr();
5149

5250
static boolean isInstance(Object object) {
5351
return object instanceof PythonAbstractNativeObject;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeVoidPtr.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
4545
import com.oracle.truffle.api.CompilerAsserts;
46-
import com.oracle.truffle.api.interop.TruffleObject;
4746

4847
/**
4948
* Represents the value of a native pointer as Python int.<br/>
@@ -55,17 +54,17 @@
5554
* this eager transformation using this wrapper.
5655
*/
5756
public class PythonNativeVoidPtr extends PythonAbstractObject {
58-
private final TruffleObject object;
57+
private final Object object;
5958
private final long nativePointerValue;
6059
private final boolean hasNativePointer;
6160

62-
public PythonNativeVoidPtr(TruffleObject object) {
61+
public PythonNativeVoidPtr(Object object) {
6362
this.object = object;
6463
this.nativePointerValue = 0;
6564
this.hasNativePointer = false;
6665
}
6766

68-
public PythonNativeVoidPtr(TruffleObject object, long nativePointerValue) {
67+
public PythonNativeVoidPtr(Object object, long nativePointerValue) {
6968
this.object = object;
7069
this.nativePointerValue = nativePointerValue;
7170
this.hasNativePointer = true;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static class NativeObjectReference extends WeakReference<PythonAbstractNativeObj
350350
/**
351351
* The associated native pointer object that needs to be released if this reference dies.
352352
*/
353-
final TruffleObject ptrObject;
353+
final Object ptrObject;
354354

355355
/** The ID of this reference, i.e., the index of the ref in the global reference list. */
356356
final int id;
@@ -374,7 +374,7 @@ public NativeObjectReference(PythonAbstractNativeObject referent, ReferenceQueue
374374
this.id = id;
375375
}
376376

377-
public TruffleObject getPtrObject() {
377+
public Object getPtrObject() {
378378
return ptrObject;
379379
}
380380

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ static Object doForeign(@SuppressWarnings("unused") CExtContext nativeContext, O
14471447
@Cached ConditionProfile isNullProfile) {
14481448
// this branch is not a shortcut; it actually returns a different object
14491449
if (isNullProfile.profile(interopLibrary.isNull(value))) {
1450-
return new PythonAbstractNativeObject((TruffleObject) value);
1450+
return new PythonAbstractNativeObject(value);
14511451
}
14521452
return asPythonObjectNode.execute(resolveHandleNode.execute(value));
14531453
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
import com.oracle.truffle.api.frame.VirtualFrame;
129129
import com.oracle.truffle.api.interop.ArityException;
130130
import com.oracle.truffle.api.interop.InteropLibrary;
131-
import com.oracle.truffle.api.interop.TruffleObject;
132131
import com.oracle.truffle.api.interop.UnknownIdentifierException;
133132
import com.oracle.truffle.api.interop.UnsupportedMessageException;
134133
import com.oracle.truffle.api.interop.UnsupportedTypeException;
@@ -1354,7 +1353,7 @@ protected Object[] prepareCArguments(VirtualFrame frame) {
13541353
CompilerDirectives.transferToInterpreterAndInvalidate();
13551354
throw PRaiseNode.raiseUncached(this, SystemError, "Attempting to getter function but object has no associated native space.");
13561355
}
1357-
objects[0] = new PythonAbstractNativeObject((TruffleObject) nativeSpacePtr);
1356+
objects[0] = new PythonAbstractNativeObject(nativeSpacePtr);
13581357
return objects;
13591358
}
13601359

@@ -1436,7 +1435,7 @@ protected Object[] prepareCArguments(VirtualFrame frame) {
14361435
CompilerDirectives.transferToInterpreterAndInvalidate();
14371436
throw PRaiseNode.raiseUncached(this, SystemError, "Attempting to setter function but object has no associated native space.");
14381437
}
1439-
objects[0] = new PythonAbstractNativeObject((TruffleObject) nativeSpacePtr);
1438+
objects[0] = new PythonAbstractNativeObject(nativeSpacePtr);
14401439
return objects;
14411440
}
14421441

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public final PythonObject createPythonObject(Object klass, Shape instanceShape)
274274
return trace(new PythonObject(klass, instanceShape));
275275
}
276276

277-
public final PythonNativeVoidPtr createNativeVoidPtr(TruffleObject obj) {
277+
public final PythonNativeVoidPtr createNativeVoidPtr(Object obj) {
278278
return trace(new PythonNativeVoidPtr(obj));
279279
}
280280

0 commit comments

Comments
 (0)