private PyType_IsSubtype ( IntPtr t1, IntPtr t2 ) : bool | ||
t1 | IntPtr | |
t2 | IntPtr | |
Résultat | bool |
private static bool IsException(IntPtr pyObject) { var type = Runtime.PyObject_TYPE(pyObject); return(Runtime.PyObjectType_TypeCheck(type, Exceptions.BaseException) || Runtime.PyObjectType_TypeCheck(type, Runtime.PyTypeType) && Runtime.PyType_IsSubtype(pyObject, Exceptions.BaseException)); }
public static int magic(IntPtr ob) { if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) || (Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException)))) { return(ExceptionOffset.ob_data); } return(ob_data); }
public static int DictOffset(IntPtr ob) { #if (PYTHON32 || PYTHON33 || PYTHON33) if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) || (Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException)))) { return(ExceptionOffset.ob_dict); } #endif return(ob_dict); }
public static int Size(IntPtr ob) { if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) || (Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException)))) { return(ExceptionOffset.Size()); } #if PYTHON_WITH_PYDEBUG return(6 * IntPtr.Size); #else return(4 * IntPtr.Size); #endif }
public static int Size(IntPtr ob) { #if (PYTHON32 || PYTHON33 || PYTHON33) if ((Runtime.PyObject_TypeCheck(ob, Exceptions.BaseException) || (Runtime.PyType_Check(ob) && Runtime.PyType_IsSubtype(ob, Exceptions.BaseException)))) { return(ExceptionOffset.Size()); } #endif #if (Py_DEBUG) return(6 * IntPtr.Size); #else return(4 * IntPtr.Size); #endif }
/// <summary> /// Constructor /// </summary> /// <remarks> /// Create a scope based on a Python Module. /// </remarks> internal PyScope(IntPtr ptr, PyScopeManager manager) { if (!Runtime.PyType_IsSubtype(Runtime.PyObject_TYPE(ptr), Runtime.PyModuleType)) { throw new PyScopeException("object is not a module"); } Manager = manager ?? PyScopeManager.Global; obj = ptr; //Refcount of the variables not increase variables = Runtime.PyModule_GetDict(obj); Runtime.CheckExceptionOccurred(); Runtime.PyDict_SetItemString( variables, "__builtins__", Runtime.PyEval_GetBuiltins() ); this.Name = this.Get <string>("__name__"); }
/// <summary> /// Constructor /// </summary> /// <remarks> /// Create a scope based on a Python Module. /// </remarks> internal PyScope(ref NewReference ptr, PyScopeManager manager) { if (!Runtime.PyType_IsSubtype(Runtime.PyObject_TYPE(ptr), Runtime.PyModuleType)) { throw new PyScopeException("object is not a module"); } Manager = manager ?? PyScopeManager.Global; obj = ptr.MoveToPyObject(); //Refcount of the variables not increase variables = Runtime.PyModule_GetDict(Reference).DangerousGetAddress(); PythonException.ThrowIfIsNull(variables); int res = Runtime.PyDict_SetItem( VarsRef, PyIdentifier.__builtins__, Runtime.PyEval_GetBuiltins() ); PythonException.ThrowIfIsNotZero(res); this.Name = this.Get <string>("__name__"); }