Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,20 @@ protected Object execute(Object[] arguments) throws UnsupportedTypeException, Ar
}

@ExportMessage
@TruffleBoundary
protected boolean isPointer() {
return isNative();
long pointer = PythonContext.get(null).getCApiContext().getClosurePointer(this);
return pointer != -1;
}

@ExportMessage
protected long asPointer() {
return getNativePointer();
@TruffleBoundary
protected long asPointer() throws UnsupportedMessageException {
long pointer = PythonContext.get(null).getCApiContext().getClosurePointer(this);
if (pointer == -1) {
throw UnsupportedMessageException.create();
}
return pointer;
}

protected abstract String getSignature();
Expand All @@ -153,7 +160,7 @@ protected void toNative(
@CachedLibrary(limit = "1") SignatureLibrary signatureLibrary) {
if (!isPointer()) {
CApiContext cApiContext = PythonContext.get(null).getCApiContext();
setNativePointer(cApiContext.registerClosure(getSignature(), this, getDelegate(), signatureLibrary));
cApiContext.registerClosure(getSignature(), this, getDelegate(), signatureLibrary);
}
}

Expand Down