comparison src/objects.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 6ef8256a020a
children 5502045ec510 b5df3737028a
comparison
equal deleted inserted replaced
5014:c2e0c3af5fe3 5015:d95c102a96d3
1 /* Generic Objects and Functions. 1 /* Generic Objects and Functions.
2 Copyright (C) 1995 Free Software Foundation, Inc. 2 Copyright (C) 1995 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, 2002, 2004 Ben Wing. 4 Copyright (C) 1995, 1996, 2002, 2004, 2005, 2010 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
41 41
42 /* Objects that are substituted when an instantiation fails. 42 /* Objects that are substituted when an instantiation fails.
43 If we leave in the Qunbound value, we will probably get crashes. */ 43 If we leave in the Qunbound value, we will probably get crashes. */
44 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance; 44 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance;
45 45
46 /* Authors: Ben Wing, Chuck Thompson */ 46 /* Author: Ben Wing; some earlier code from Chuck Thompson, Jamie
47 Zawinski. */
47 48
48 DOESNT_RETURN 49 DOESNT_RETURN
49 finalose (void *ptr) 50 finalose (void *ptr)
50 { 51 {
51 Lisp_Object obj = wrap_pointer_1 (ptr); 52 Lisp_Object obj = wrap_pointer_1 (ptr);
843 } 844 }
844 } 845 }
845 846
846 #endif /* MULE */ 847 #endif /* MULE */
847 848
849 /* It's a little non-obvious what's going on here. Specifically:
850
851 MATCHSPEC is a somewhat bogus way in the specifier mechanism of passing
852 in additional information needed to instantiate some object. For fonts,
853 it's a cons of (CHARSET . SECOND-STAGE-P). SECOND-STAGE-P, if set,
854 means "try harder to find an appropriate font" and is a very bogus way
855 of dealing with the fact that it may not be possible to may a charset
856 directly onto a font; it's used esp. under Windows. @@#### We need to
857 change this so that MATCHSPEC is just a character.
858
859 When redisplay is building up its structure, and needs font info, it
860 calls functions in faces.c such as ensure_face_cachel_complete() (map
861 fonts needed for a string of text) or
862 ensure_face_cachel_contains_charset() (map fonts needed for a charset
863 derived from a single character). The former function calls the latter;
864 the latter calls face_property_matching_instance(); this constructs the
865 MATCHSPEC and calls specifier_instance_no_quit() twice (first stage and
866 second stage, updating MATCHSPEC appropriately). That function, in
867 turn, looks up the appropriate specifier method to do the instantiation,
868 which, lo and behold, is this function here (because we set it in
869 initialization using `SPECIFIER_HAS_METHOD (font, instantiate);'). We
870 in turn call the device method `find_charset_font', which maps to
871 mswindows_find_charset_font(), x_find_charset_font(), or similar, in
872 objects-msw.c or the like.
873
874 --ben */
848 875
849 static Lisp_Object 876 static Lisp_Object
850 font_instantiate (Lisp_Object UNUSED (specifier), 877 font_instantiate (Lisp_Object UNUSED (specifier),
851 Lisp_Object USED_IF_MULE (matchspec), 878 Lisp_Object USED_IF_MULE (matchspec),
852 Lisp_Object domain, Lisp_Object instantiator, 879 Lisp_Object domain, Lisp_Object instantiator,
857 Lisp_Object device = DOMAIN_DEVICE (domain); 884 Lisp_Object device = DOMAIN_DEVICE (domain);
858 struct device *d = XDEVICE (device); 885 struct device *d = XDEVICE (device);
859 Lisp_Object instance; 886 Lisp_Object instance;
860 Lisp_Object charset = Qnil; 887 Lisp_Object charset = Qnil;
861 #ifdef MULE 888 #ifdef MULE
862 enum font_specifier_matchspec_stages stage = initial; 889 enum font_specifier_matchspec_stages stage = STAGE_INITIAL;
863 890
864 if (!UNBOUNDP (matchspec)) 891 if (!UNBOUNDP (matchspec))
865 { 892 {
866 charset = Fget_charset (XCAR (matchspec)); 893 charset = Fget_charset (XCAR (matchspec));
867 894
868 #define FROB(new_stage) if (EQ(Q##new_stage, XCDR(matchspec))) \ 895 #define FROB(new_stage, enumstage) \
869 { \ 896 if (EQ(Q##new_stage, XCDR(matchspec))) \
870 stage = new_stage; \ 897 { \
898 stage = enumstage; \
871 } 899 }
872 900
873 FROB(initial) 901 FROB (initial, STAGE_INITIAL)
874 else FROB(final) 902 else FROB (final, STAGE_FINAL)
875 else assert(0); 903 else assert(0);
876 904
877 #undef FROB 905 #undef FROB
878 906
879 } 907 }
897 925
898 if (STRINGP (instantiator)) 926 if (STRINGP (instantiator))
899 { 927 {
900 #ifdef MULE 928 #ifdef MULE
901 /* #### rename these caches. */ 929 /* #### rename these caches. */
902 Lisp_Object cache = stage ? d->charset_font_cache_stage_2 : 930 Lisp_Object cache = stage == STAGE_FINAL ?
931 d->charset_font_cache_stage_2 :
903 d->charset_font_cache_stage_1; 932 d->charset_font_cache_stage_1;
904 #else 933 #else
905 Lisp_Object cache = d->font_instance_cache; 934 Lisp_Object cache = d->font_instance_cache;
906 #endif 935 #endif
907 936
959 Lisp_Object match_inst = Qunbound; 988 Lisp_Object match_inst = Qunbound;
960 assert (XVECTOR_LENGTH (instantiator) == 1); 989 assert (XVECTOR_LENGTH (instantiator) == 1);
961 990
962 match_inst = face_property_matching_instance 991 match_inst = face_property_matching_instance
963 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, 992 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
964 charset, domain, ERROR_ME, no_fallback, depth, initial); 993 charset, domain, ERROR_ME, no_fallback, depth, STAGE_INITIAL);
965 994
966 if (UNBOUNDP(match_inst)) 995 if (UNBOUNDP(match_inst))
967 { 996 {
968 match_inst = face_property_matching_instance 997 match_inst = face_property_matching_instance
969 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, 998 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
970 charset, domain, ERROR_ME, no_fallback, depth, final); 999 charset, domain, ERROR_ME, no_fallback, depth, STAGE_FINAL);
971 } 1000 }
972 1001
973 return match_inst; 1002 return match_inst;
974 1003
975 } 1004 }