示例#1
0
 internal static void NpyObject_Init(NpyObject_HEAD a, NpyTypeObject t)
 {
     a.nob_refcnt       = 1;
     a.nob_type         = t;
     a.nob_interface    = null;
     a.nob_magic_number = npy_defs.NPY_VALID_MAGIC;
 }
 private static void Npy_INCREF(NpyObject_HEAD Head)
 {
     lock (Head)
     {
         if ((1 == ++Head.nob_refcnt) && null != Head.nob_interface)
         {
             //_NpyInterface_Incref(arr.Head.nob_interface, ref arr.Head.nob_interface);
         }
     }
     return;
 }
示例#3
0
        internal static void NpyArrayAccess_Dealloc(NpyObject_HEAD obj)
        {
            Debug.Assert(npy_defs.NPY_VALID_MAGIC == obj.nob_magic_number);
            Debug.Assert(0 == obj.nob_refcnt);

            // Clear the interface pointer because some deallocators temporarily increment the
            // reference count on the object for some reason.  This causes callbacks into the
            // managed world that we do not want (and is added overhead).
            obj.nob_interface = null;

            // Calls the type-specific deallocation route.  This routine releases any references
            // held by the object itself prior to actually freeing the memory.
            obj.nob_type.ntp_dealloc(obj);
        }
示例#4
0
        /* Returns the interface pointer for the object.  If the interface pointer is null and the interface allocator
         *  function is defined, the interface is created and that instance is returned.  This allows types such as
         *  iterators that typically don't need a wrapper to skip that step until needed. */

        internal static object Npy_INTERFACE(NpyObject_HEAD m1)
        {
            if (null != m1.nob_interface)
            {
                return(m1.nob_interface);
            }

            if (null != m1.nob_type.ntp_interface_alloc)
            {
                m1.nob_type.ntp_interface_alloc(m1, ref m1.nob_interface);
                return(m1.nob_interface);
            }

            return(null);
        }
        private static void Npy_DECREF(NpyObject_HEAD Head)
        {
            lock (Head)
            {
                Debug.Assert(Head.nob_refcnt > 0);

                if (0 == --Head.nob_refcnt)
                {
                    if (null != Head.nob_interface)
                    {
                        //_NpyInterface_Decref(arr.Head.nob_interface, ref arr.Head.nob_interface);
                    }
                    else
                    {
                        Head.nob_magic_number = (UInt32)npy_defs.NPY_INVALID_MAGIC;
                    }
                }
            }
            return;
        }
示例#6
0
        // This function is here because the Npy_INTERFACE macro does some
        // magic with creating interface objects on an as-needed basis so it's
        // more code than simply reading the nob_interface field.

        internal static object NpyArrayAccess_ToInterface(NpyObject_HEAD obj)
        {
            Debug.Assert(npy_defs.NPY_VALID_MAGIC == obj.nob_magic_number);
            return(Npy_INTERFACE(obj));
        }
示例#7
0
 internal static void NpyArrayAccess_Decref(NpyObject_HEAD obj)
 {
     Debug.Assert(npy_defs.NPY_VALID_MAGIC == obj.nob_magic_number);
     Npy_DECREF(obj);
 }
示例#8
0
        // This function is here because the Npy_INTERFACE macro does some
        // magic with creating interface objects on an as-needed basis so it's
        // more code than simply reading the nob_interface field.

        internal static object NpyArrayAccess_ToInterface(NpyObject_HEAD obj)
        {
            return(numpyinternal.NpyArrayAccess_ToInterface(obj));
        }
示例#9
0
 internal static void NpyArrayAccess_Decref(NpyObject_HEAD obj)
 {
     numpyinternal.NpyArrayAccess_Decref(obj);
 }
示例#10
0
 public static void NpyArrayAccess_Dealloc(NpyObject_HEAD obj)
 {
     numpyinternal.NpyArrayAccess_Dealloc(obj);
 }