comparison 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
comparison
equal deleted inserted replaced
5014:c2e0c3af5fe3 5015:d95c102a96d3
1 /* "Face" primitives 1 /* "Face" primitives
2 Copyright (C) 1994 Free Software Foundation, Inc. 2 Copyright (C) 1994 Free Software Foundation, Inc.
3 Copyright (C) 1995 Board of Trustees, University of Illinois. 3 Copyright (C) 1995 Board of Trustees, University of Illinois.
4 Copyright (C) 1995, 1996, 2001, 2002, 2010 Ben Wing. 4 Copyright (C) 1995, 1996, 2001, 2002, 2005, 2010 Ben Wing.
5 Copyright (C) 1995 Sun Microsystems, Inc. 5 Copyright (C) 1995 Sun Microsystems, Inc.
6 6
7 This file is part of XEmacs. 7 This file is part of XEmacs.
8 8
9 XEmacs is free software; you can redistribute it and/or modify it 9 XEmacs is free software; you can redistribute it and/or modify it
587 Lisp_Object matchspec = Qunbound; 587 Lisp_Object matchspec = Qunbound;
588 struct gcpro gcpro1; 588 struct gcpro gcpro1;
589 589
590 if (!NILP (charset)) 590 if (!NILP (charset))
591 matchspec = noseeum_cons (charset, 591 matchspec = noseeum_cons (charset,
592 stage == initial ? Qinitial : Qfinal); 592 stage == STAGE_INITIAL ? Qinitial : Qfinal);
593 593
594 GCPRO1 (matchspec); 594 GCPRO1 (matchspec);
595 /* This call to specifier_instance_no_quit(), will end up calling
596 font_instantiate() if the property in a question is a font (currently,
597 this means EQ (property, Qfont), because only the face property named
598 `font' contains a font object). See the comments there. */
595 retval = specifier_instance_no_quit (Fget (face, property, Qnil), matchspec, 599 retval = specifier_instance_no_quit (Fget (face, property, Qnil), matchspec,
596 domain, errb, no_fallback, depth); 600 domain, errb, no_fallback, depth);
597 UNGCPRO; 601 UNGCPRO;
598 if (CONSP (matchspec)) 602 if (CONSP (matchspec))
599 free_cons (matchspec); 603 free_cons (matchspec);
600 604
601 if (UNBOUNDP (retval) && !no_fallback && final == stage) 605 if (UNBOUNDP (retval) && !no_fallback && STAGE_FINAL == stage)
602 { 606 {
603 if (EQ (property, Qfont)) 607 if (EQ (property, Qfont))
604 { 608 {
605 if (NILP (memq_no_quit (charset, 609 if (NILP (memq_no_quit (charset,
606 XFACE (face)->charsets_warned_about))) 610 XFACE (face)->charsets_warned_about)))
1157 shouldn't happen. */ 1161 shouldn't happen. */
1158 new_val = face_property_matching_instance (face, Qfont, charset, domain, 1162 new_val = face_property_matching_instance (face, Qfont, charset, domain,
1159 /* ERROR_ME_DEBUG_WARN is 1163 /* ERROR_ME_DEBUG_WARN is
1160 fine here. */ 1164 fine here. */
1161 ERROR_ME_DEBUG_WARN, 1, Qzero, 1165 ERROR_ME_DEBUG_WARN, 1, Qzero,
1162 initial); 1166 STAGE_INITIAL);
1163 DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, " 1167 DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, "
1164 "result was something %s\n", 1168 "result was something %s\n",
1165 XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)), 1169 XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)),
1166 XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))), 1170 XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))),
1167 UNBOUNDP(new_val) ? "not bound" : "bound"); 1171 UNBOUNDP(new_val) ? "not bound" : "bound");
1179 unlikely to have specified them herself, a common complaint. */ 1183 unlikely to have specified them herself, a common complaint. */
1180 new_val = face_property_matching_instance (face, Qfont, 1184 new_val = face_property_matching_instance (face, Qfont,
1181 charset, domain, 1185 charset, domain,
1182 ERROR_ME_DEBUG_WARN, 0, 1186 ERROR_ME_DEBUG_WARN, 0,
1183 Qzero, 1187 Qzero,
1184 initial); 1188 STAGE_INITIAL);
1185 1189
1186 DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, " 1190 DEBUG_FACES ("just called f_p_m_i on face %s, charset %s, initial, "
1187 "allow fallback, result was something %s\n", 1191 "allow fallback, result was something %s\n",
1188 XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)), 1192 XSTRING_DATA (XSYMBOL_NAME (XFACE (cachel->face)->name)),
1189 XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))), 1193 XSTRING_DATA (XSYMBOL_NAME (XCHARSET_NAME (charset))),
1190 UNBOUNDP(new_val) ? "not bound" : "bound"); 1194 UNBOUNDP (new_val) ? "not bound" : "bound");
1191 1195
1192 if (!UNBOUNDP(new_val)) 1196 if (!UNBOUNDP (new_val))
1193 { 1197 {
1194 break; 1198 break;
1195 } 1199 }
1196 1200
1197 bound = 1; 1201 bound = 1;
1198 /* Try the face itself with the final-stage specifiers. */ 1202 /* Try the face itself with the final-stage specifiers. */
1199 new_val = face_property_matching_instance (face, Qfont, 1203 new_val = face_property_matching_instance (face, Qfont,
1200 charset, domain, 1204 charset, domain,
1201 ERROR_ME_DEBUG_WARN, 1, 1205 ERROR_ME_DEBUG_WARN, 1,
1202 Qzero, 1206 Qzero,
1203 final); 1207 STAGE_FINAL);
1204 1208
1205 DEBUG_FACES("just called f_p_m_i on face %s, charset %s, final, " 1209 DEBUG_FACES("just called f_p_m_i on face %s, charset %s, final, "
1206 "result was something %s\n", 1210 "result was something %s\n",
1207 XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)), 1211 XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)),
1208 XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))), 1212 XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))),
1209 UNBOUNDP(new_val) ? "not bound" : "bound"); 1213 UNBOUNDP(new_val) ? "not bound" : "bound");
1210 /* Tell X11 redisplay that it should translate to iso10646-1. */ 1214 /* Tell X11 redisplay that it should translate to iso10646-1. */
1211 if (!UNBOUNDP(new_val)) 1215 if (!UNBOUNDP (new_val))
1212 { 1216 {
1213 final_stage = 1; 1217 final_stage = 1;
1214 break; 1218 break;
1215 } 1219 }
1216 1220
1220 allowing its final stage to be used. */ 1224 allowing its final stage to be used. */
1221 new_val = face_property_matching_instance (face, Qfont, 1225 new_val = face_property_matching_instance (face, Qfont,
1222 charset, domain, 1226 charset, domain,
1223 ERROR_ME_DEBUG_WARN, 0, 1227 ERROR_ME_DEBUG_WARN, 0,
1224 Qzero, 1228 Qzero,
1225 final); 1229 STAGE_FINAL);
1226 1230
1227 DEBUG_FACES("just called f_p_m_i on face %s, charset %s, initial, " 1231 DEBUG_FACES ("just called f_p_m_i on face %s, charset %s, initial, "
1228 "allow fallback, result was something %s\n", 1232 "allow fallback, result was something %s\n",
1229 XSTRING_DATA(XSYMBOL_NAME(XFACE(cachel->face)->name)), 1233 XSTRING_DATA (XSYMBOL_NAME (XFACE (cachel->face)->name)),
1230 XSTRING_DATA(XSYMBOL_NAME(XCHARSET_NAME(charset))), 1234 XSTRING_DATA (XSYMBOL_NAME (XCHARSET_NAME (charset))),
1231 UNBOUNDP(new_val) ? "not bound" : "bound"); 1235 UNBOUNDP (new_val) ? "not bound" : "bound");
1232 if (!UNBOUNDP(new_val)) 1236 if (!UNBOUNDP(new_val))
1233 { 1237 {
1234 /* Tell X11 redisplay that it should translate to iso10646-1. */ 1238 /* Tell X11 redisplay that it should translate to iso10646-1. */
1235 final_stage = 1; 1239 final_stage = 1;
1236 break; 1240 break;
2027 2031
2028 Lisp_Object Qone_dimensional, Qtwo_dimensional, Qx_coverage_instantiator; 2032 Lisp_Object Qone_dimensional, Qtwo_dimensional, Qx_coverage_instantiator;
2029 2033
2030 DEFUN ("specifier-tag-one-dimensional-p", 2034 DEFUN ("specifier-tag-one-dimensional-p",
2031 Fspecifier_tag_one_dimensional_p, 2035 Fspecifier_tag_one_dimensional_p,
2032 2, 2, 0, /* 2036 1, 1, 0, /*
2033 Return non-nil if (charset-dimension CHARSET) is 1. 2037 Return non-nil if (charset-dimension CHARSET) is 1.
2034 2038
2035 Used by the X11 platform font code; see `define-specifier-tag'. You 2039 Used by the X11 platform font code; see `define-specifier-tag'. You
2036 shouldn't ever need to call this yourself. 2040 shouldn't ever need to call this yourself.
2037 */ 2041 */
2038 (charset, UNUSED(stage))) 2042 (charset))
2039 { 2043 {
2040 CHECK_CHARSET(charset); 2044 CHECK_CHARSET (charset);
2041 return (1 == XCHARSET_DIMENSION(charset)) ? Qt : Qnil; 2045 return (1 == XCHARSET_DIMENSION (charset)) ? Qt : Qnil;
2042 } 2046 }
2043 2047
2044 DEFUN ("specifier-tag-two-dimensional-p", 2048 DEFUN ("specifier-tag-two-dimensional-p",
2045 Fspecifier_tag_two_dimensional_p, 2049 Fspecifier_tag_two_dimensional_p,
2046 2, 2, 0, /* 2050 1, 1, 0, /*
2047 Return non-nil if (charset-dimension CHARSET) is 2. 2051 Return non-nil if (charset-dimension CHARSET) is 2.
2048 2052
2049 Used by the X11 platform font code; see `define-specifier-tag'. You 2053 Used by the X11 platform font code; see `define-specifier-tag'. You
2050 shouldn't ever need to call this yourself. 2054 shouldn't ever need to call this yourself.
2051 */ 2055 */
2052 (charset, UNUSED(stage))) 2056 (charset))
2053 { 2057 {
2054 CHECK_CHARSET(charset); 2058 CHECK_CHARSET (charset);
2055 return (2 == XCHARSET_DIMENSION(charset)) ? Qt : Qnil; 2059 return (2 == XCHARSET_DIMENSION (charset)) ? Qt : Qnil;
2056 } 2060 }
2057 2061
2058 DEFUN ("specifier-tag-final-stage-p", 2062 DEFUN ("specifier-tag-final-stage-p",
2059 Fspecifier_tag_final_stage_p, 2063 Fspecifier_tag_final_stage_p,
2060 2, 2, 0, /* 2064 2, 2, 0, /*
2061 Return non-nil if STAGE is 'final. 2065 Return non-nil if STAGE is 'final.
2062 2066
2063 Used by the X11 platform font code for giving fallbacks; see 2067 Used by the X11 platform font code for giving fallbacks; see
2064 `define-specifier-tag'. You shouldn't ever need to call this. 2068 `define-specifier-tag'. You shouldn't ever need to call this.
2065 */ 2069 */
2066 (UNUSED(charset), stage)) 2070 (UNUSED (charset), stage))
2067 { 2071 {
2068 return EQ(stage, Qfinal) ? Qt : Qnil; 2072 return EQ (stage, Qfinal) ? Qt : Qnil;
2069 } 2073 }
2070 2074
2071 DEFUN ("specifier-tag-initial-stage-p", 2075 DEFUN ("specifier-tag-initial-stage-p",
2072 Fspecifier_tag_initial_stage_p, 2076 Fspecifier_tag_initial_stage_p,
2073 2, 2, 0, /* 2077 2, 2, 0, /*