diff src/number.c @ 2551:9f70af3ac939

[xemacs-hg @ 2005-02-03 16:14:02 by james] Commit Olivier Galibert's dumper updates for bignums and use them. See xemacs-patches message with ID <ps8y685c6p.fsf@diannao.ittc.ku.edu>.
author james
date Thu, 03 Feb 2005 16:14:08 +0000
parents 3d8143fc88e1
children ae5285944c74
line wrap: on
line diff
--- a/src/number.c	Thu Feb 03 07:30:22 2005 +0000
+++ b/src/number.c	Thu Feb 03 16:14:08 2005 +0000
@@ -64,12 +64,43 @@
   return bignum_hashcode (XBIGNUM_DATA (obj));
 }
 
+static void
+bignum_convert (const void *object, void **data, Bytecount *size)
+{
+  CIbyte *bstr = bignum_to_string (*(bignum *)object, 10);
+  *data = bstr;
+  *size = strlen(bstr)+1;
+}
+
+static void
+bignum_convfree (const void * UNUSED (object), void *data,
+		 Bytecount UNUSED (size))
+{
+  xfree (data, void *);
+}
+
+static void *
+bignum_deconvert (void *object, void *data, Bytecount UNUSED (size))
+{
+  bignum *b = (bignum *) object;
+  bignum_init(*b);
+  bignum_set_string(*b, (const char *) data, 10);
+  return object;
+}
+
+static const struct opaque_convert_functions bignum_opc = {
+  bignum_convert,
+  bignum_convfree,
+  bignum_deconvert
+};
+
 static const struct memory_description bignum_description[] = {
-  { XD_OPAQUE_PTR, offsetof (Lisp_Bignum, data) },
+  { XD_OPAQUE_DATA_CONVERTIBLE, offsetof (Lisp_Bignum, data),
+    0, { &bignum_opc }, XD_FLAG_NO_KKCC },
   { XD_END }
 };
 
-DEFINE_BASIC_LRECORD_IMPLEMENTATION ("bignum", bignum, 0, 0, bignum_print,
+DEFINE_BASIC_LRECORD_IMPLEMENTATION ("bignum", bignum, 1, 0, bignum_print,
 				     0, bignum_equal, bignum_hash,
 				     bignum_description, Lisp_Bignum);
 
@@ -770,13 +801,8 @@
 
 #ifdef HAVE_BIGFLOAT
 #ifdef HAVE_BIGNUM
-  /* Uncomment the next two lines and remove the line below them when dumping
-     bignums becomes possible. */
-  /*
   Vbigfloat_max_prec = make_bignum (0L);
   bignum_set_ulong (XBIGNUM_DATA (Vbigfloat_max_prec), ULONG_MAX);
-  */
-  Vbigfloat_max_prec = make_int (EMACS_INT_MAX);
 #else
   Vbigfloat_max_prec = make_int (EMACS_INT_MAX);
 #endif