[Numpy-svn] r6242 - branches/fix_float_format/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Dec 29 22:57:36 EST 2008


Author: cdavid
Date: 2008-12-29 21:57:33 -0600 (Mon, 29 Dec 2008)
New Revision: 6242

Modified:
   branches/fix_float_format/numpy/core/src/scalartypes.inc.src
Log:
Start working on tp_print implementation for scalar types: add the C functions.

Modified: branches/fix_float_format/numpy/core/src/scalartypes.inc.src
===================================================================
--- branches/fix_float_format/numpy/core/src/scalartypes.inc.src	2008-12-30 03:56:54 UTC (rev 6241)
+++ branches/fix_float_format/numpy/core/src/scalartypes.inc.src	2008-12-30 03:57:33 UTC (rev 6242)
@@ -774,7 +774,47 @@
 /**end repeat1**/
 /**end repeat**/
 
+/*
+ * float type print (control print a, where a is a float type instance)
+ */
+/**begin repeat
+ * #name=float, double, longdouble#
+ * #Name=Float, Double, LongDouble#
+ * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
+ */
 
+static int
+ at name@type_print(PyObject *v, FILE *fp, int flags)
+{
+	char buf[100];
+        @name@ val = ((Py at Name@ScalarObject *)v)->obval;
+
+	format_ at name@(buf, sizeof(buf), val,
+		      (flags & Py_PRINT_RAW) ? @NAME at PREC_STR : @NAME at PREC_REPR);
+	Py_BEGIN_ALLOW_THREADS
+	fputs(buf, fp);
+	Py_END_ALLOW_THREADS
+	return 0;
+}
+
+static int
+c at name@type_print(PyObject *v, FILE *fp, int flags)
+{
+        /* Size of buf: twice sizeof(real) + 2 (for the parenthesis) */
+	char buf[202];
+        c at name@ val = ((PyC at Name@ScalarObject *)v)->obval;
+
+	format_c at name@(buf, sizeof(buf), val,
+		       (flags & Py_PRINT_RAW) ? @NAME at PREC_STR : @NAME at PREC_REPR);
+	Py_BEGIN_ALLOW_THREADS
+	fputs(buf, fp);
+	Py_END_ALLOW_THREADS
+	return 0;
+}
+
+/**end repeat**/
+
+
 /*
  * Could improve this with a PyLong_FromLongDouble(longdouble ldval)
  * but this would need some more work...




More information about the Numpy-svn mailing list