コード例 #1
0
 PyComplex_AsCComplex(IntPtr objPtr)
 {
     double real = -1.0;
     double imag = 0.0;
     try
     {
         object obj = this.Retrieve(objPtr);
         if (obj == null)
         {
             throw PythonOps.TypeError("PyComplex_AsCComplex: None cannot be turned into a complex");
         }
         if (obj.GetType() == typeof(Complex64))
         {
             Complex64 complex = (Complex64)obj;
             real = complex.Real;
             imag = complex.Imag;
         }
         else
         {
             real = this.PyFloat_AsDouble(objPtr);
         }
     }
     catch (Exception e)
     {
         this.LastException = e;
     }
     Py_complex result = new Py_complex();
     result.real = real;
     result.imag = imag;
     return result;
 }
コード例 #2
0
        PyComplex_AsCComplex(IntPtr objPtr)
        {
            double real = -1.0;
            double imag = 0.0;

            try
            {
                object obj = this.Retrieve(objPtr);
                if (obj == null)
                {
                    throw PythonOps.TypeError("PyComplex_AsCComplex: None cannot be turned into a complex");
                }
                if (obj.GetType() == typeof(Complex))
                {
                    Complex complex = (Complex)obj;
                    real = complex.Real;
                    imag = complex.Imaginary;
                }
                else
                {
                    real = this.PyFloat_AsDouble(objPtr);
                }
            }
            catch (Exception e)
            {
                this.LastException = e;
            }
            Py_complex result = new Py_complex();

            result.real = real;
            result.imag = imag;
            return(result);
        }