|
78 | 78 | import com.oracle.graal.python.builtins.objects.cell.PCell;
|
79 | 79 | import com.oracle.graal.python.builtins.objects.cext.CExtNodes;
|
80 | 80 | import com.oracle.graal.python.builtins.objects.cext.PythonNativeClass;
|
| 81 | +import com.oracle.graal.python.builtins.objects.cext.PythonNativeVoidPtr; |
81 | 82 | import com.oracle.graal.python.builtins.objects.code.PCode;
|
82 | 83 | import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes;
|
83 | 84 | import com.oracle.graal.python.builtins.objects.common.HashingStorage.DictEntry;
|
@@ -1002,6 +1003,16 @@ public Object createInt(LazyPythonClass cls, long arg, @SuppressWarnings("unused
|
1002 | 1003 | return factory().createInt(cls, arg);
|
1003 | 1004 | }
|
1004 | 1005 |
|
| 1006 | + @Specialization(guards = "isNoValue(keywordArg)") |
| 1007 | + public Object createInt(LazyPythonClass cls, PythonNativeVoidPtr arg, @SuppressWarnings("unused") PNone keywordArg) { |
| 1008 | + if (isPrimitiveInt(cls)) { |
| 1009 | + return arg; |
| 1010 | + } else { |
| 1011 | + CompilerDirectives.transferToInterpreter(); |
| 1012 | + throw new IllegalStateException("cannot wrap void ptr in int subclass"); |
| 1013 | + } |
| 1014 | + } |
| 1015 | + |
1005 | 1016 | @Specialization(guards = "isNoValue(keywordArg)")
|
1006 | 1017 | public Object createInt(LazyPythonClass cls, double arg, @SuppressWarnings("unused") PNone keywordArg,
|
1007 | 1018 | @Cached("createBinaryProfile()") ConditionProfile isIntProfile) {
|
@@ -1178,7 +1189,7 @@ public Object createInt(LazyPythonClass cls, Object obj, PNone keywordArg,
|
1178 | 1189 | }
|
1179 | 1190 |
|
1180 | 1191 | protected static boolean isHandledType(Object obj) {
|
1181 |
| - return PGuards.isInteger(obj) || obj instanceof Double || obj instanceof Boolean || PGuards.isString(obj) || PGuards.isBytes(obj); |
| 1192 | + return PGuards.isInteger(obj) || obj instanceof Double || obj instanceof Boolean || PGuards.isString(obj) || PGuards.isBytes(obj) || obj instanceof PythonNativeVoidPtr; |
1182 | 1193 | }
|
1183 | 1194 |
|
1184 | 1195 | private String toString(PIBytesLike pByteArray) {
|
|
0 commit comments