|
27 | 27 |
|
28 | 28 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbols.FUN_ADD_NATIVE_SLOTS;
|
29 | 29 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbols.FUN_PY_OBJECT_NEW;
|
| 30 | +import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbols.FUN_PY_TRUFFLE_MEMORYVIEW_FROM_OBJECT; |
30 | 31 | import static com.oracle.graal.python.builtins.objects.range.RangeUtils.canBeInt;
|
31 | 32 | import static com.oracle.graal.python.builtins.objects.range.RangeUtils.canBePint;
|
32 | 33 | import static com.oracle.graal.python.builtins.objects.type.TypeBuiltins.TYPE_ITEMSIZE;
|
|
121 | 122 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes;
|
122 | 123 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction;
|
123 | 124 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory;
|
124 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbols; |
125 | 125 | import com.oracle.graal.python.builtins.objects.code.CodeNodes;
|
126 | 126 | import com.oracle.graal.python.builtins.objects.code.PCode;
|
127 | 127 | import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes;
|
@@ -3321,10 +3321,10 @@ public boolean hasSetItem(Object object) {
|
3321 | 3321 | @Builtin(name = MEMORYVIEW, minNumOfPositionalArgs = 2, parameterNames = {"$cls", "object"}, constructsClass = PythonBuiltinClassType.PMemoryView)
|
3322 | 3322 | @GenerateNodeFactory
|
3323 | 3323 | public abstract static class MemoryViewNode extends PythonBuiltinNode {
|
3324 |
| - public abstract PMemoryView execute(Object cls, Object object); |
| 3324 | + public abstract PMemoryView execute(VirtualFrame frame, Object cls, Object object); |
3325 | 3325 |
|
3326 |
| - public final PMemoryView execute(Object object) { |
3327 |
| - return execute(PythonBuiltinClassType.PMemoryView, object); |
| 3326 | + public final PMemoryView execute(VirtualFrame frame, Object object) { |
| 3327 | + return execute(frame, PythonBuiltinClassType.PMemoryView, object); |
3328 | 3328 | }
|
3329 | 3329 |
|
3330 | 3330 | // TODO arrays should support buffer protocol too, but their implementation would be
|
@@ -3358,11 +3358,20 @@ PMemoryView fromMemoryView(@SuppressWarnings("unused") Object cls, PMemoryView o
|
3358 | 3358 | }
|
3359 | 3359 |
|
3360 | 3360 | @Specialization
|
3361 |
| - static PMemoryView fromNative(@SuppressWarnings("unused") Object cls, PythonAbstractNativeObject object, |
| 3361 | + PMemoryView fromNative(VirtualFrame frame, @SuppressWarnings("unused") Object cls, PythonAbstractNativeObject object, |
| 3362 | + @Cached ForeignCallContext foreignCallContext, |
3362 | 3363 | @Cached CExtNodes.ToSulongNode toSulongNode,
|
3363 | 3364 | @Cached CExtNodes.AsPythonObjectNode asPythonObjectNode,
|
3364 |
| - @Cached PCallCapiFunction callCapiFunction) { |
3365 |
| - return (PMemoryView) asPythonObjectNode.execute(callCapiFunction.call(NativeCAPISymbols.FUN_PY_TRUFFLE_MEMORYVIEW_FROM_OBJECT, toSulongNode.execute(object))); |
| 3365 | + @Cached PCallCapiFunction callCapiFunction, |
| 3366 | + @Cached PythonCextBuiltins.DefaultCheckFunctionResultNode checkFunctionResultNode) { |
| 3367 | + Object state = foreignCallContext.enter(frame, getContext(), this); |
| 3368 | + try { |
| 3369 | + Object result = callCapiFunction.call(FUN_PY_TRUFFLE_MEMORYVIEW_FROM_OBJECT, toSulongNode.execute(object)); |
| 3370 | + checkFunctionResultNode.execute(FUN_PY_TRUFFLE_MEMORYVIEW_FROM_OBJECT, result); |
| 3371 | + return (PMemoryView) asPythonObjectNode.execute(result); |
| 3372 | + } finally { |
| 3373 | + foreignCallContext.exit(frame, getContext(), state); |
| 3374 | + } |
3366 | 3375 | }
|
3367 | 3376 |
|
3368 | 3377 | @Fallback
|
|
0 commit comments