PyType_IsSubtype() private méthode

private PyType_IsSubtype ( IntPtr t1, IntPtr t2 ) : bool
t1 IntPtr
t2 IntPtr
Résultat bool
Exemple #1
0
        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));
        }
Exemple #2
0
 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);
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        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
        }
Exemple #5
0
        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
        }
Exemple #6
0
        /// <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__");
        }
Exemple #7
0
        /// <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__");
        }