diff src/faces.c @ 5015:d95c102a96d3

cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings) -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-02-08 Ben Wing <ben@xemacs.org> * faces.c: * faces.c (face_property_matching_instance): * faces.c (ensure_face_cachel_contains_charset): * faces.h (FACE_FONT): * lisp.h: * lisp.h (enum font_specifier_matchspec_stages): * objects-msw.c: * objects-msw.c (mswindows_font_spec_matches_charset): * objects-msw.c (mswindows_find_charset_font): * objects-tty.c: * objects-tty.c (tty_font_spec_matches_charset): * objects-tty.c (tty_find_charset_font): * objects-xlike-inc.c: * objects-xlike-inc.c (XFUN): * objects-xlike-inc.c (xft_find_charset_font): * objects.c: * objects.c (font_instantiate): * objects.c (FROB): * specifier.c: * specifier.c (charset_matches_specifier_tag_set_p): * specifier.c (call_charset_predicate): * specifier.c (define_specifier_tag): * specifier.c (Fdefine_specifier_tag): * specifier.c (setup_charset_initial_specifier_tags): * specifier.c (specifier_instance_from_inst_list): * specifier.c (FROB): * specifier.c (vars_of_specifier): * specifier.h: Rename the specifier-font-matching stages in preparation for eliminating shadowed warnings, some other related fixes from ben-unicode-internal. 1. Rename raw enums: initial -> STAGE_INITIAL final -> STAGE_FINAL impossible -> NUM_MATCHSPEC_STAGES 2. Move `enum font_specifier_matchspec_stages' from specifier.h to lisp.h. 3. Whitespace changes to match coding standards. 4. Eliminate unused second argument STAGE in charset predicates that don't use it -- the code that calls the charset predicates is now smart enough to supply the right number of arguments automatically. 5. Add some long(ish) comments and authorial notices, esp. in objects.c. 6. In specifier.c, change Vcharset_tag_lists from a vector over leading bytes to a hash table over charsets. This change is unnecessary currently but doesn't hurt and will be required when we merge in Unicode-internal. 7. In specifier.c, extract out the code that calls charset predicates into a function call_charset_predicate().
author Ben Wing <ben@xemacs.org>
date Mon, 08 Feb 2010 16:51:25 -0600
parents ae48681c47fa
children d0c14ea98592 b5df3737028a
line wrap: on
line diff
--- a/src/faces.c	Mon Feb 08 07:00:24 2010 -0600
+++ b/src/faces.c	Mon Feb 08 16:51:25 2010 -0600
@@ -1,7 +1,7 @@
 /* "Face" primitives
    Copyright (C) 1994 Free Software Foundation, Inc.
    Copyright (C) 1995 Board of Trustees, University of Illinois.
-   Copyright (C) 1995, 1996, 2001, 2002, 2010 Ben Wing.
+   Copyright (C) 1995, 1996, 2001, 2002, 2005, 2010 Ben Wing.
    Copyright (C) 1995 Sun Microsystems, Inc.
 
 This file is part of XEmacs.
@@ -589,16 +589,20 @@
 
   if (!NILP (charset))
     matchspec = noseeum_cons (charset,
-			      stage == initial ? Qinitial : Qfinal);
+			      stage == STAGE_INITIAL ? Qinitial : Qfinal);
 
   GCPRO1 (matchspec);
+  /* This call to specifier_instance_no_quit(), will end up calling
+     font_instantiate() if the property in a question is a font (currently,
+     this means EQ (property, Qfont), because only the face property named
+     `font' contains a font object).  See the comments there. */
   retval = specifier_instance_no_quit (Fget (face, property, Qnil), matchspec,
 				       domain, errb, no_fallback, depth);
   UNGCPRO;
   if (CONSP (matchspec))
     free_cons (matchspec);
 
-  if (UNBOUNDP (retval) && !no_fallback && final == stage)
+  if (UNBOUNDP (retval) && !no_fallback && STAGE_FINAL == stage)
     {
       if (EQ (property, Qfont))
 	{
@@ -1159,7 +1163,7 @@
 					       /* ERROR_ME_DEBUG_WARN is
 						  fine here.  */
 					       ERROR_ME_DEBUG_WARN, 1, Qzero,
-					       initial);
+					       STAGE_INITIAL);
     DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, "
 		"result was something %s\n",
 		XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)),
@@ -1181,15 +1185,15 @@
 					       charset, domain,
 					       ERROR_ME_DEBUG_WARN, 0,
 					       Qzero,
-					       initial);
+					       STAGE_INITIAL);
 
-    DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, "
-		"allow fallback, result was something %s\n",
-		XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)),
-		XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))),
-		UNBOUNDP(new_val) ? "not bound" : "bound");
+    DEBUG_FACES ("just called f_p_m_i on face %s, charset %s, initial, "
+		 "allow fallback, result was something %s\n",
+		 XSTRING_DATA (XSYMBOL_NAME (XFACE (cachel->face)->name)),
+		 XSTRING_DATA (XSYMBOL_NAME (XCHARSET_NAME (charset))),
+		 UNBOUNDP (new_val) ? "not bound" : "bound");
 
-    if (!UNBOUNDP(new_val))
+    if (!UNBOUNDP (new_val))
       {
 	break;
       }
@@ -1200,7 +1204,7 @@
 					       charset, domain,
 					       ERROR_ME_DEBUG_WARN, 1,
 					       Qzero,
-					       final);
+					       STAGE_FINAL);
 
     DEBUG_FACES("just called f_p_m_i on face %s, charset %s, final, "
 		"result was something %s\n",
@@ -1208,7 +1212,7 @@
 		XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))),
 		UNBOUNDP(new_val) ? "not bound" : "bound");
     /* Tell X11 redisplay that it should translate to iso10646-1. */
-    if (!UNBOUNDP(new_val))
+    if (!UNBOUNDP (new_val))
       {
 	final_stage = 1;
 	break;
@@ -1222,13 +1226,13 @@
 					       charset, domain,
 					       ERROR_ME_DEBUG_WARN, 0,
 					       Qzero,
-					       final);
+					       STAGE_FINAL);
 
-    DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, "
-		"allow fallback, result was something %s\n",
-		XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)),
-		XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))),
-		UNBOUNDP(new_val) ? "not bound" : "bound");
+    DEBUG_FACES ("just called f_p_m_i on face %s, charset %s, initial, "
+		 "allow fallback, result was something %s\n",
+		 XSTRING_DATA (XSYMBOL_NAME (XFACE (cachel->face)->name)),
+		 XSTRING_DATA (XSYMBOL_NAME (XCHARSET_NAME (charset))),
+		 UNBOUNDP (new_val) ? "not bound" : "bound");
     if (!UNBOUNDP(new_val))
       {
 	/* Tell X11 redisplay that it should translate to iso10646-1. */
@@ -2029,30 +2033,30 @@
 
 DEFUN ("specifier-tag-one-dimensional-p",
        Fspecifier_tag_one_dimensional_p,
-       2, 2, 0, /*
+       1, 1, 0, /*
 Return non-nil if (charset-dimension CHARSET) is 1.
 
 Used by the X11 platform font code; see `define-specifier-tag'.  You
 shouldn't ever need to call this yourself.
 */
-       (charset, UNUSED(stage)))
+       (charset))
 {
-  CHECK_CHARSET(charset);
-  return (1 == XCHARSET_DIMENSION(charset)) ? Qt : Qnil;
+  CHECK_CHARSET (charset);
+  return (1 == XCHARSET_DIMENSION (charset)) ? Qt : Qnil;
 }
 
 DEFUN ("specifier-tag-two-dimensional-p",
        Fspecifier_tag_two_dimensional_p,
-       2, 2, 0, /*
+       1, 1, 0, /*
 Return non-nil if (charset-dimension CHARSET) is 2.
 
 Used by the X11 platform font code; see `define-specifier-tag'.  You
 shouldn't ever need to call this yourself.
 */
-       (charset, UNUSED(stage)))
+       (charset))
 {
-  CHECK_CHARSET(charset);
-  return (2 == XCHARSET_DIMENSION(charset)) ? Qt : Qnil;
+  CHECK_CHARSET (charset);
+  return (2 == XCHARSET_DIMENSION (charset)) ? Qt : Qnil;
 }
 
 DEFUN ("specifier-tag-final-stage-p",
@@ -2063,9 +2067,9 @@
 Used by the X11 platform font code for giving fallbacks; see
 `define-specifier-tag'.  You shouldn't ever need to call this.
 */
-       (UNUSED(charset), stage))
+       (UNUSED (charset), stage))
 {
-  return EQ(stage, Qfinal) ? Qt : Qnil;
+  return EQ (stage, Qfinal) ? Qt : Qnil;
 }
 
 DEFUN ("specifier-tag-initial-stage-p",