StoreTyped(double value) { IntPtr ptr = this.allocator.Alloc((uint)Marshal.SizeOf(typeof(PyFloatObject))); CPyMarshal.WriteIntField(ptr, typeof(PyFloatObject), "ob_refcnt", 1); CPyMarshal.WritePtrField(ptr, typeof(PyFloatObject), "ob_type", this.PyFloat_Type); CPyMarshal.WriteDoubleField(ptr, typeof(PyFloatObject), "ob_fval", value); this.map.Associate(ptr, value); return(ptr); }
StoreTyped(Complex value) { IntPtr ptr = this.allocator.Alloc((uint)Marshal.SizeOf(typeof(PyComplexObject))); CPyMarshal.WriteIntField(ptr, typeof(PyComplexObject), "ob_refcnt", 1); CPyMarshal.WritePtrField(ptr, typeof(PyComplexObject), "ob_type", this.PyComplex_Type); IntPtr cpxptr = CPyMarshal.GetField(ptr, typeof(PyComplexObject), "cval"); CPyMarshal.WriteDoubleField(cpxptr, typeof(Py_complex), "real", value.Real); CPyMarshal.WriteDoubleField(cpxptr, typeof(Py_complex), "imag", value.Imaginary); this.map.Associate(ptr, value); return(ptr); }