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

numpy-svn@scip... numpy-svn@scip...
Mon Dec 29 21:57:36 CST 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
+@name@type_print(PyObject *v, FILE *fp, int flags)
+{
+	char buf[100];
+        @name@ val = ((Py@Name@ScalarObject *)v)->obval;
+
+	format_@name@(buf, sizeof(buf), val,
+		      (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@PREC_REPR);
+	Py_BEGIN_ALLOW_THREADS
+	fputs(buf, fp);
+	Py_END_ALLOW_THREADS
+	return 0;
+}
+
+static int
+c@name@type_print(PyObject *v, FILE *fp, int flags)
+{
+        /* Size of buf: twice sizeof(real) + 2 (for the parenthesis) */
+	char buf[202];
+        c@name@ val = ((PyC@Name@ScalarObject *)v)->obval;
+
+	format_c@name@(buf, sizeof(buf), val,
+		       (flags & Py_PRINT_RAW) ? @NAME@PREC_STR : @NAME@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