# HG changeset patch # User Ben Wing # Date 1263383353 21600 # Node ID a98ca464014781c6d1397158c5b72f7f06bffa99 # Parent a3c673c0720b469e4727d90d3c3e8dac324f1f47 clean up object print methods casetab.c, console.c, data.c, database.c, device-msw.c, device.c, eval.c, file-coding.c, frame.c, glyphs.c, gui.c, keymap.c, lisp.h, mule-charset.c, objects.c, print.c, process.c, tooltalk.c, ui-gtk.c, window.c: New function printing_unreadable_lcrecord(). Automatically prints the type name and pointer value of the object. Use it instead of printing_unreadable_object(); make that latter function local to print.c. window.c: During creation, window may have Qt as its buffer. Don't crash if trying to print such a window. diff -r a3c673c0720b -r a98ca4640147 src/ChangeLog --- a/src/ChangeLog Wed Jan 13 04:25:15 2010 -0600 +++ b/src/ChangeLog Wed Jan 13 05:49:13 2010 -0600 @@ -1,3 +1,47 @@ +2010-01-13 Ben Wing + + * casetab.c (print_case_table): + * console.c (print_console): + * data.c (print_weak_list): + * data.c (print_weak_box): + * data.c (print_ephemeron): + * data.c (ephemeron_equal): + * database.c (print_database): + * device-msw.c (print_devmode): + * device.c (print_device): + * eval.c: + * file-coding.c (print_coding_system): + * frame.c (print_frame): + * glyphs.c (print_image_instance): + * glyphs.c (print_glyph): + * gui.c: + * gui.c (print_gui_item): + * keymap.c (print_keymap): + * lisp.h: + * mule-charset.c (print_charset): + * objects.c (print_color_instance): + * objects.c (print_font_instance): + * print.c: + * print.c (printing_unreadable_object): + * print.c (printing_unreadable_lcrecord): + * print.c (default_object_printer): + * process.c (print_process): + * tooltalk.c: + * tooltalk.c (print_tooltalk_message): + * tooltalk.c (print_tooltalk_pattern): + * ui-gtk.c (ffi_object_printer): + * ui-gtk.c (emacs_gtk_object_printer): + * ui-gtk.c (emacs_gtk_boxed_printer): + * window.c (print_window): + New function printing_unreadable_lcrecord(). Automatically + prints the type name and pointer value of the object. Use it + instead of printing_unreadable_object(); make that latter + function local to print.c. + + * window.c (print_window): + During creation, window may have Qt as its buffer. Don't + crash if trying to print such a window. + 2010-01-13 Ben Wing * dynarr.c: diff -r a3c673c0720b -r a98ca4640147 src/casetab.c --- a/src/casetab.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/casetab.c Wed Jan 13 05:49:13 2010 -0600 @@ -105,7 +105,7 @@ { Lisp_Case_Table *ct = XCASE_TABLE (obj); if (print_readably) - printing_unreadable_object ("#", ct->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#", - XSTRING_DATA (con->name), con->header.uid); + printing_unreadable_lcrecord (obj, XSTRING_DATA (con->name)); write_fmt_string (printcharfun, "#<%s-console", !CONSOLE_LIVE_P (con) ? "dead" : CONSOLE_TYPE_NAME (con)); diff -r a3c673c0720b -r a98ca4640147 src/data.c --- a/src/data.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/data.c Wed Jan 13 05:49:13 2010 -0600 @@ -2592,7 +2592,7 @@ int UNUSED (escapeflag)) { if (print_readably) - printing_unreadable_object ("#"); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#", 2, encode_weak_list_type (XWEAK_LIST (obj)->type), @@ -3067,12 +3067,12 @@ } static void -print_weak_box (Lisp_Object UNUSED (obj), Lisp_Object printcharfun, +print_weak_box (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag)) { if (print_readably) - printing_unreadable_object ("#"); - write_fmt_string (printcharfun, "#"); + printing_unreadable_lcrecord (obj, 0); + write_fmt_string (printcharfun, "#"); /* #### fix */ } static int @@ -3293,12 +3293,12 @@ } static void -print_ephemeron (Lisp_Object UNUSED (obj), Lisp_Object printcharfun, +print_ephemeron (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag)) { if (print_readably) - printing_unreadable_object ("#"); - write_fmt_string (printcharfun, "#"); + printing_unreadable_lcrecord (obj, 0); + write_fmt_string (printcharfun, "#"); /* #### fix */ } static int diff -r a3c673c0720b -r a98ca4640147 src/database.c --- a/src/database.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/database.c Wed Jan 13 05:49:13 2010 -0600 @@ -216,7 +216,7 @@ Lisp_Database *db = XDATABASE (obj); if (print_readably) - printing_unreadable_object ("#", db->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#fname, db->funcs->get_type (db), diff -r a3c673c0720b -r a98ca4640147 src/device-msw.c --- a/src/device-msw.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/device-msw.c Wed Jan 13 05:49:13 2010 -0600 @@ -1154,8 +1154,7 @@ { Lisp_Devmode *dm = XDEVMODE (obj); if (print_readably) - printing_unreadable_object ("#", - dm->header.uid); + printing_unreadable_lcrecord (obj, 0); write_c_string (printcharfun, "#printer_name)) write_fmt_string_lisp (printcharfun, " for %S", 1, dm->printer_name); diff -r a3c673c0720b -r a98ca4640147 src/device.c --- a/src/device.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/device.c Wed Jan 13 05:49:13 2010 -0600 @@ -160,8 +160,7 @@ struct device *d = XDEVICE (obj); if (print_readably) - printing_unreadable_object ("#", - XSTRING_DATA (d->name), d->header.uid); + printing_unreadable_lcrecord (obj, XSTRING_DATA (d->name)); write_fmt_string (printcharfun, "#<%s-device", !DEVICE_LIVE_P (d) ? "dead" : DEVICE_TYPE_NAME (d)); diff -r a3c673c0720b -r a98ca4640147 src/eval.c --- a/src/eval.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/eval.c Wed Jan 13 05:49:13 2010 -0600 @@ -3140,20 +3140,6 @@ signal_error (Qout_of_memory, reason, frob); } -DOESNT_RETURN -printing_unreadable_object (const CIbyte *fmt, ...) -{ - Lisp_Object obj; - va_list args; - - va_start (args, fmt); - obj = emacs_vsprintf_string (CGETTEXT (fmt), args); - va_end (args); - - /* Fsignal GC-protects its args */ - signal_error (Qprinting_unreadable_object, 0, obj); -} - /************************************************************************/ /* User commands */ diff -r a3c673c0720b -r a98ca4640147 src/file-coding.c --- a/src/file-coding.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/file-coding.c Wed Jan 13 05:49:13 2010 -0600 @@ -297,8 +297,7 @@ { Lisp_Coding_System *c = XCODING_SYSTEM (obj); if (print_readably) - printing_unreadable_object - ("printing unreadable object #", c->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#name); print_coding_system_properties (obj, printcharfun); diff -r a3c673c0720b -r a98ca4640147 src/frame.c --- a/src/frame.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/frame.c Wed Jan 13 05:49:13 2010 -0600 @@ -274,8 +274,7 @@ struct frame *frm = XFRAME (obj); if (print_readably) - printing_unreadable_object ("#", - XSTRING_DATA (frm->name), frm->header.uid); + printing_unreadable_lcrecord (obj, XSTRING_DATA (frm->name)); write_fmt_string (printcharfun, "#<%s-frame ", !FRAME_LIVE_P (frm) ? "dead" : FRAME_TYPE_NAME (frm)); diff -r a3c673c0720b -r a98ca4640147 src/glyphs.c --- a/src/glyphs.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/glyphs.c Wed Jan 13 05:49:13 2010 -0600 @@ -992,8 +992,7 @@ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (obj); if (print_readably) - printing_unreadable_object ("#", - ii->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#name)) @@ -3693,7 +3692,7 @@ Lisp_Glyph *glyph = XGLYPH (obj); if (print_readably) - printing_unreadable_object ("#", glyph->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#image); diff -r a3c673c0720b -r a98ca4640147 src/gui.c --- a/src/gui.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/gui.c Wed Jan 13 05:49:13 2010 -0600 @@ -696,7 +696,7 @@ Lisp_Gui_Item *g = XGUI_ITEM (obj); if (print_readably) - printing_unreadable_object ("#", g->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string (printcharfun, "#", g->header.uid); } diff -r a3c673c0720b -r a98ca4640147 src/keymap.c --- a/src/keymap.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/keymap.c Wed Jan 13 05:49:13 2010 -0600 @@ -289,7 +289,7 @@ /* This function can GC */ Lisp_Keymap *keymap = XKEYMAP (obj); if (print_readably) - printing_unreadable_object ("#", keymap->header.uid); + printing_unreadable_lcrecord (obj, 0); write_c_string (printcharfun, "#name)) { diff -r a3c673c0720b -r a98ca4640147 src/lisp.h --- a/src/lisp.h Wed Jan 13 04:25:15 2010 -0600 +++ b/src/lisp.h Wed Jan 13 05:49:13 2010 -0600 @@ -4716,9 +4716,6 @@ Lisp_Object frob)); DECLARE_DOESNT_RETURN (stack_overflow (const CIbyte *reason, Lisp_Object frob)); -MODULE_API DECLARE_DOESNT_RETURN (printing_unreadable_object (const CIbyte *, - ...)) - PRINTF_ARGS (1, 2); Lisp_Object signal_void_function_error (Lisp_Object); Lisp_Object signal_invalid_function_error (Lisp_Object); @@ -5326,6 +5323,11 @@ Lisp_Object, Lisp_Object); void float_to_string (char *, double); void internal_object_printer (Lisp_Object, Lisp_Object, int); +MODULE_API DECLARE_DOESNT_RETURN (printing_unreadable_object (const CIbyte *, + ...)) + PRINTF_ARGS (1, 2); +DECLARE_DOESNT_RETURN (printing_unreadable_lcrecord (Lisp_Object obj, + const Ibyte *name)); /* Defined in rangetab.c */ EXFUN (Fclear_range_table, 1); diff -r a3c673c0720b -r a98ca4640147 src/mule-charset.c --- a/src/mule-charset.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/mule-charset.c Wed Jan 13 05:49:13 2010 -0600 @@ -141,10 +141,8 @@ Lisp_Charset *cs = XCHARSET (obj); if (print_readably) - printing_unreadable_object ("#", - XSTRING_DATA (XSYMBOL (CHARSET_NAME (cs))-> - name), - cs->header.uid); + printing_unreadable_lcrecord + (obj, XSTRING_DATA (XSYMBOL (XCHARSET_NAME (obj))->name)); write_fmt_string_lisp (printcharfun, "#", - c->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#name); write_fmt_string_lisp (printcharfun, " on %s", 1, c->device); if (!NILP (c->device)) /* Vthe_null_color_instance */ @@ -319,7 +318,7 @@ { Lisp_Font_Instance *f = XFONT_INSTANCE (obj); if (print_readably) - printing_unreadable_object ("#", f->header.uid); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#name); write_fmt_string_lisp (printcharfun, " on %s", 1, f->device); if (!NILP (f->device)) diff -r a3c673c0720b -r a98ca4640147 src/print.c --- a/src/print.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/print.c Wed Jan 13 05:49:13 2010 -0600 @@ -1485,13 +1485,41 @@ UNGCPRO; } -void -default_object_printer (Lisp_Object obj, Lisp_Object printcharfun, - int UNUSED (escapeflag)) +DOESNT_RETURN +printing_unreadable_object (const CIbyte *fmt, ...) +{ + Lisp_Object obj; + va_list args; + + va_start (args, fmt); + obj = emacs_vsprintf_string (CGETTEXT (fmt), args); + va_end (args); + + /* Fsignal GC-protects its args */ + signal_error (Qprinting_unreadable_object, 0, obj); +} + +DOESNT_RETURN +printing_unreadable_lcrecord (Lisp_Object obj, const Ibyte *name) { struct LCRECORD_HEADER *header = (struct LCRECORD_HEADER *) XPNTR (obj); - if (print_readably) +#ifndef NEW_GC + /* This must be a real lcrecord */ + assert (!LHEADER_IMPLEMENTATION (&header->lheader)->basic_p); +#endif + + if (name) + printing_unreadable_object + ("#<%s %s 0x%x>", +#ifdef NEW_GC + LHEADER_IMPLEMENTATION (header)->name, +#else /* not NEW_GC */ + LHEADER_IMPLEMENTATION (&header->lheader)->name, +#endif /* not NEW_GC */ + name, + header->uid); + else printing_unreadable_object ("#<%s 0x%x>", #ifdef NEW_GC @@ -1500,6 +1528,21 @@ LHEADER_IMPLEMENTATION (&header->lheader)->name, #endif /* not NEW_GC */ header->uid); +} + +void +default_object_printer (Lisp_Object obj, Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + struct LCRECORD_HEADER *header = (struct LCRECORD_HEADER *) XPNTR (obj); + +#ifndef NEW_GC + /* This must be a real lcrecord */ + assert (!LHEADER_IMPLEMENTATION (&header->lheader)->basic_p); +#endif + + if (print_readably) + printing_unreadable_lcrecord (obj, 0); write_fmt_string (printcharfun, "#<%s 0x%x>", #ifdef NEW_GC diff -r a3c673c0720b -r a98ca4640147 src/process.c --- a/src/process.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/process.c Wed Jan 13 05:49:13 2010 -0600 @@ -145,12 +145,12 @@ } static void -print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag) +print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) { - Lisp_Process *process = XPROCESS (object); + Lisp_Process *process = XPROCESS (obj); if (print_readably) - printing_unreadable_object ("#", XSTRING_DATA (process->name)); + printing_unreadable_lcrecord (obj, XSTRING_DATA (process->name)); if (!escapeflag) { @@ -158,7 +158,7 @@ } else { - int netp = network_connection_p (object); + int netp = network_connection_p (obj); write_c_string (printcharfun, netp ? GETTEXT ("#", - p->header.uid); + printing_unreadable_lcrecord (obj, 0); - write_fmt_string (printcharfun, "#", + write_fmt_string (printcharfun, "#", (long) (p->m), p->header.uid); } @@ -250,10 +249,9 @@ Lisp_Tooltalk_Pattern *p = XTOOLTALK_PATTERN (obj); if (print_readably) - printing_unreadable_object ("#", - p->header.uid); + printing_unreadable_lcrecord (obj, 0); - write_fmt_string (printcharfun, "#", + write_fmt_string (printcharfun, "#", (long) (p->p), p->header.uid); } diff -r a3c673c0720b -r a98ca4640147 src/ui-gtk.c --- a/src/ui-gtk.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/ui-gtk.c Wed Jan 13 05:49:13 2010 -0600 @@ -326,7 +326,7 @@ int UNUSED (escapeflag)) { if (print_readably) - printing_unreadable_object ("#", XFFI (obj)->function_ptr); + printing_unreadable_lcrecord (obj, 0); write_fmt_string_lisp (printcharfun, "#function_name); if (XFFI (obj)->n_args) @@ -796,7 +796,7 @@ int UNUSED (escapeflag)) { if (print_readably) - printing_unreadable_object ("#", XGTK_OBJECT (obj)->object); + printing_unreadable_lcrecord (obj, 0); write_c_string (printcharfun, "#alive_p) @@ -1115,7 +1115,7 @@ int UNUSED (escapeflag)) { if (print_readably) - printing_unreadable_object ("#", XGTK_BOXED (obj)->object); + printing_unreadable_lcrecord (obj, 0); write_c_string (printcharfun, "#object_type)); diff -r a3c673c0720b -r a98ca4640147 src/window.c --- a/src/window.c Wed Jan 13 04:25:15 2010 -0600 +++ b/src/window.c Wed Jan 13 05:49:13 2010 -0600 @@ -313,13 +313,19 @@ print_window (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag)) { + Lisp_Object buf; + if (print_readably) - printing_unreadable_object ("#", XWINDOW (obj)->header.uid); + printing_unreadable_lcrecord (obj, 0); write_c_string (printcharfun, "#buffer)) + buf = XWINDOW_BUFFER (obj); + if (EQ (buf, Qt)) + write_c_string (printcharfun, " during creation"); + else if (!NILP (buf)) { - Lisp_Object name = XBUFFER (XWINDOW (obj)->buffer)->name; + + Lisp_Object name = XBUFFER (buf)->name; write_fmt_string_lisp (printcharfun, " on %S", 1, name); } write_fmt_string (printcharfun, " 0x%x>", XWINDOW (obj)->header.uid);