Skip to content

Commit 09752de

Browse files
committed
[GR-70981] Make native slot wrappers context-specific. Fixes #557.
PullRequest: graalpython/4073
2 parents 4f77e65 + dcb27dc commit 09752de

File tree

1 file changed

+11
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,20 @@ protected Object execute(Object[] arguments) throws UnsupportedTypeException, Ar
136136
}
137137

138138
@ExportMessage
139+
@TruffleBoundary
139140
protected boolean isPointer() {
140-
return isNative();
141+
long pointer = PythonContext.get(null).getCApiContext().getClosurePointer(this);
142+
return pointer != -1;
141143
}
142144

143145
@ExportMessage
144-
protected long asPointer() {
145-
return getNativePointer();
146+
@TruffleBoundary
147+
protected long asPointer() throws UnsupportedMessageException {
148+
long pointer = PythonContext.get(null).getCApiContext().getClosurePointer(this);
149+
if (pointer == -1) {
150+
throw UnsupportedMessageException.create();
151+
}
152+
return pointer;
146153
}
147154

148155
protected abstract String getSignature();
@@ -153,7 +160,7 @@ protected void toNative(
153160
@CachedLibrary(limit = "1") SignatureLibrary signatureLibrary) {
154161
if (!isPointer()) {
155162
CApiContext cApiContext = PythonContext.get(null).getCApiContext();
156-
setNativePointer(cApiContext.registerClosure(getSignature(), this, getDelegate(), signatureLibrary));
163+
cApiContext.registerClosure(getSignature(), this, getDelegate(), signatureLibrary);
157164
}
158165
}
159166

0 commit comments

Comments
 (0)