Beispiel #1
0
        internal static void npy_initlib(NpyArray_FunctionDefs functionDefs, NpyInterface_WrapperFuncs wrapperFuncs,
                                         npy_tp_error_set error_set,
                                         npy_tp_error_occurred error_occurred,
                                         npy_tp_error_clear error_clear,
                                         npy_tp_cmp_priority cmp_priority,
                                         npy_interface_incref incref, npy_interface_decref decref,
                                         enable_threads et, disable_threads dt)
        {
            Npy_RefCntLock = new object();

            _NpyArrayWrapperFuncs = wrapperFuncs;

            npy_enable_threads  = et;
            npy_disable_threads = dt;

            // Verify that the structure definition is correct and has the memory layout
            // that we expect.

            Debug.Assert(null == functionDefs || npy_defs.NPY_VALID_MAGIC == functionDefs.sentinel);

            if (null != wrapperFuncs)
            {
                // Store the passed in set of wrapper funcs.  However, the CPython interface has the ufunc
                // code in a separate module which may have initialized the ufunc method prior to this so
                // we don't want to overwrite it.
                //        npy_interface_ufunc_new_wrapper x = _NpyArrayWrapperFuncs.ufunc_new_wrapper;
                //        memmove(&_NpyArrayWrapperFuncs, wrapperFuncs, sizeof(struct NpyInterface_WrapperFuncs));
                //if (null == wrapperFuncs.ufunc_new_wrapper) {
                //    _NpyArrayWrapperFuncs.ufunc_new_wrapper = x;
            }

            //NpyArrayIter_Type.ntp_interface_alloc = (npy_wrapper_construct)wrapperFuncs.iter_new_wrapper;
            //NpyArrayMultiIter_Type.ntp_interface_alloc = (npy_wrapper_construct)wrapperFuncs.multi_iter_new_wrapper;
            //NpyArrayNeighborhoodIter_Type = wrapperFuncs.neighbor_iter_new_wrapper;

            NpyErr_SetString_callback = error_set;
            NpyErr_Occurred_callback  = error_occurred;
            NpyErr_Clear_callback     = error_clear;
            Npy_CmpPriority           = cmp_priority;

            //_NpyInterface_Incref = incref;
            //_NpyInterface_Decref = decref;

            /* Must be last because it uses some of the above functions. */
            if (null != functionDefs)
            {
                _init_type_functions(functionDefs);
            }
            _init_builtin_descr_wrappers();
        }
Beispiel #2
0
        /* Initializes the library at startup. This functions must be called exactly once by the interface layer.*/
        internal static void npy_initlib(NpyArray_FunctionDefs functionDefs, NpyInterface_WrapperFuncs wrapperFuncs,
                                         npy_tp_error_set error_set,
                                         npy_tp_error_occurred error_occurred,
                                         npy_tp_error_clear error_clear,
                                         npy_tp_cmp_priority cmp_priority,
                                         npy_interface_incref incref, npy_interface_decref decref,
                                         enable_threads et, disable_threads dt)
        {
            numpyinternal.npy_initlib(functionDefs, wrapperFuncs,
                                      error_set,
                                      error_occurred,
                                      error_clear,
                                      cmp_priority,
                                      incref, decref,
                                      et, dt);

            numpyinternal._intialize_builtin_descrs();
        }