Mercurial > hg > xemacs-beta
diff src/objects-tty.c @ 5118:e0db3c197671 ben-lisp-object
merge up to latest default branch, doesn't compile yet
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 21:18:49 -0600 |
parents | 3a87551bfeb5 |
children | d1247f3cc363 |
line wrap: on
line diff
--- a/src/objects-tty.c Sat Dec 26 00:20:27 2009 -0600 +++ b/src/objects-tty.c Sat Dec 26 21:18:49 2009 -0600 @@ -30,6 +30,12 @@ #include "device.h" #include "charset.h" +#ifdef NEW_GC +# define UNUSED_IF_NEW_GC(decl) UNUSED (decl) +#else +# define UNUSED_IF_NEW_GC(decl) decl +#endif + /* An alist mapping from color names to a cons of (FG-STRING, BG-STRING). */ Lisp_Object Vtty_color_alist; #if 0 /* This stuff doesn't quite work yet */ @@ -42,18 +48,32 @@ { XD_END } }; +#ifdef NEW_GC +DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-color-instance-data", + tty_color_instance_data, + 0, tty_color_instance_data_description_1, + struct tty_color_instance_data); +#else /* not NEW_GC */ const struct sized_memory_description tty_color_instance_data_description = { sizeof (struct tty_color_instance_data), tty_color_instance_data_description_1 }; +#endif /* not NEW_GC */ static const struct memory_description tty_font_instance_data_description_1 [] = { { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) }, { XD_END } }; +#ifdef NEW_GC +DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-font-instance-data", + tty_font_instance_data, 0, + tty_font_instance_data_description_1, + struct tty_font_instance_data); +#else /* not NEW_GC */ const struct sized_memory_description tty_font_instance_data_description = { sizeof (struct tty_font_instance_data), tty_font_instance_data_description_1 }; +#endif /* not NEW_GC */ DEFUN ("register-tty-color", Fregister_tty_color, 3, 3, 0, /* Register COLOR as a recognized TTY color. @@ -176,7 +196,12 @@ } /* Don't allocate the data until we're sure that we will succeed. */ +#ifdef NEW_GC + c->data = alloc_lrecord_type (struct tty_color_instance_data, + &lrecord_tty_color_instance_data); +#else /* not NEW_GC */ c->data = xnew (struct tty_color_instance_data); +#endif /* not NEW_GC */ COLOR_INSTANCE_TTY_SYMBOL (c) = name; return 1; @@ -196,10 +221,12 @@ } static void -tty_finalize_color_instance (Lisp_Color_Instance *c) +tty_finalize_color_instance (Lisp_Color_Instance *UNUSED_IF_NEW_GC (c)) { +#ifndef NEW_GC if (c->data) xfree (c->data, void *); +#endif /* not NEW_GC */ } static int @@ -254,7 +281,12 @@ } /* Don't allocate the data until we're sure that we will succeed. */ +#ifdef NEW_GC + f->data = alloc_lrecord_type (struct tty_font_instance_data, + &lrecord_tty_font_instance_data); +#else /* not NEW_GC */ f->data = xnew (struct tty_font_instance_data); +#endif /* not NEW_GC */ FONT_INSTANCE_TTY_CHARSET (f) = charset; #ifdef MULE if (CHARSETP (charset)) @@ -284,10 +316,12 @@ } static void -tty_finalize_font_instance (Lisp_Font_Instance *f) +tty_finalize_font_instance (Lisp_Font_Instance *UNUSED_IF_NEW_GC (f)) { +#ifndef NEW_GC if (f->data) xfree (f->data, void *); +#endif /* not NEW_GC */ } static Lisp_Object @@ -303,7 +337,7 @@ tty_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, const Ibyte *nonreloc, Lisp_Object reloc, Bytecount offset, Bytecount length, - int stage) + enum font_specifier_matchspec_stages stage) { const Ibyte *the_nonreloc = nonreloc; @@ -315,7 +349,7 @@ fixup_internal_substring (nonreloc, reloc, offset, &length); the_nonreloc += offset; - if (UNBOUNDP (charset)) + if (NILP (charset)) return !memchr (the_nonreloc, '/', length); the_nonreloc = (const Ibyte *) memchr (the_nonreloc, '/', length); if (!the_nonreloc) @@ -331,7 +365,8 @@ (the registry of) CHARSET. */ static Lisp_Object tty_find_charset_font (Lisp_Object device, Lisp_Object font, - Lisp_Object charset, int stage) + Lisp_Object charset, + enum font_specifier_matchspec_stages stage) { Ibyte *fontname = XSTRING_DATA (font); @@ -341,12 +376,12 @@ if (strchr ((const char *) fontname, '/')) { if (tty_font_spec_matches_charset (XDEVICE (device), charset, 0, - font, 0, -1, 0)) + font, 0, -1, initial)) return font; return Qnil; } - if (UNBOUNDP (charset)) + if (NILP (charset)) return font; return concat3 (font, build_string ("/"), @@ -363,6 +398,11 @@ void syms_of_objects_tty (void) { +#ifdef NEW_GC + INIT_LISP_OBJECT (tty_color_instance_data); + INIT_LISP_OBJECT (tty_font_instance_data); +#endif /* NEW_GC */ + DEFSUBR (Fregister_tty_color); DEFSUBR (Funregister_tty_color); DEFSUBR (Ffind_tty_color);