comparison src/objects.c @ 4426:515b91f904c1

Fix specifier inheritance behavior This patch ensures that no fallback is used if so requested, when the specifier instantiation process involves inheritance (for instance, a face [property] inheriting from another face [property]).
author Didier Verna <didier@xemacs.org>
date Tue, 26 Feb 2008 18:02:34 +0100
parents 98af8a976fc3
children a23ac8f90a49
comparison
equal deleted inserted replaced
4425:bfb8a26de3cb 4426:515b91f904c1
101 int escapeflag) 101 int escapeflag)
102 { 102 {
103 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); 103 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
104 if (print_readably) 104 if (print_readably)
105 printing_unreadable_object ("#<color-instance 0x%x>", 105 printing_unreadable_object ("#<color-instance 0x%x>",
106 c->header.uid); 106 c->header.uid);
107 write_fmt_string_lisp (printcharfun, "#<color-instance %s", 1, c->name); 107 write_fmt_string_lisp (printcharfun, "#<color-instance %s", 1, c->name);
108 write_fmt_string_lisp (printcharfun, " on %s", 1, c->device); 108 write_fmt_string_lisp (printcharfun, " on %s", 1, c->device);
109 if (!NILP (c->device)) /* Vthe_null_color_instance */ 109 if (!NILP (c->device)) /* Vthe_null_color_instance */
110 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance, 110 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance,
111 (c, printcharfun, escapeflag)); 111 (c, printcharfun, escapeflag));
151 151
152 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance, 152 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
153 0, /*dumpable-flag*/ 153 0, /*dumpable-flag*/
154 mark_color_instance, print_color_instance, 154 mark_color_instance, print_color_instance,
155 finalize_color_instance, color_instance_equal, 155 finalize_color_instance, color_instance_equal,
156 color_instance_hash, 156 color_instance_hash,
157 color_instance_description, 157 color_instance_description,
158 Lisp_Color_Instance); 158 Lisp_Color_Instance);
159 159
160 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /* 160 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /*
161 Return a new `color-instance' object named NAME (a string). 161 Return a new `color-instance' object named NAME (a string).
293 { XD_INT, offsetof (Lisp_Font_Instance, font_instance_type) }, 293 { XD_INT, offsetof (Lisp_Font_Instance, font_instance_type) },
294 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, name)}, 294 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, name)},
295 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, truename)}, 295 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, truename)},
296 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, device)}, 296 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, device)},
297 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, charset)}, 297 { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, charset)},
298 { XD_UNION, offsetof (Lisp_Font_Instance, data), 298 { XD_UNION, offsetof (Lisp_Font_Instance, data),
299 XD_INDIRECT (0, 0), { &font_instance_data_description } }, 299 XD_INDIRECT (0, 0), { &font_instance_data_description } },
300 { XD_END } 300 { XD_END }
301 }; 301 };
302 302
303 303
594 of for `equal' */ 594 of for `equal' */
595 595
596 static Lisp_Object 596 static Lisp_Object
597 color_instantiate (Lisp_Object specifier, Lisp_Object UNUSED (matchspec), 597 color_instantiate (Lisp_Object specifier, Lisp_Object UNUSED (matchspec),
598 Lisp_Object domain, Lisp_Object instantiator, 598 Lisp_Object domain, Lisp_Object instantiator,
599 Lisp_Object depth) 599 Lisp_Object depth, int no_fallback)
600 { 600 {
601 /* When called, we're inside of call_with_suspended_errors(), 601 /* When called, we're inside of call_with_suspended_errors(),
602 so we can freely error. */ 602 so we can freely error. */
603 Lisp_Object device = DOMAIN_DEVICE (domain); 603 Lisp_Object device = DOMAIN_DEVICE (domain);
604 struct device *d = XDEVICE (device); 604 struct device *d = XDEVICE (device);
605 605
606 if (COLOR_INSTANCEP (instantiator)) 606 if (COLOR_INSTANCEP (instantiator))
607 { 607 {
608 /* If we are on the same device then we're done. Otherwise change 608 /* If we are on the same device then we're done. Otherwise change
609 the instantiator to the name used to generate the pixel and let the 609 the instantiator to the name used to generate the pixel and let the
610 STRINGP case deal with it. */ 610 STRINGP case deal with it. */
611 if (NILP (device) /* Vthe_null_color_instance */ 611 if (NILP (device) /* Vthe_null_color_instance */
612 || EQ (device, XCOLOR_INSTANCE (instantiator)->device)) 612 || EQ (device, XCOLOR_INSTANCE (instantiator)->device))
613 return instantiator; 613 return instantiator;
614 else 614 else
615 instantiator = Fcolor_instance_name (instantiator); 615 instantiator = Fcolor_instance_name (instantiator);
616 } 616 }
617 617
645 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)))) 645 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier))))
646 gui_error ("Color specifier not attached to a face", 646 gui_error ("Color specifier not attached to a face",
647 instantiator); 647 instantiator);
648 return (FACE_PROPERTY_INSTANCE_1 648 return (FACE_PROPERTY_INSTANCE_1
649 (Fget_face (XVECTOR_DATA (instantiator)[0]), 649 (Fget_face (XVECTOR_DATA (instantiator)[0]),
650 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)), 650 COLOR_SPECIFIER_FACE_PROPERTY
651 domain, ERROR_ME, 0, depth)); 651 (XCOLOR_SPECIFIER (specifier)),
652 domain, ERROR_ME, no_fallback, depth));
652 653
653 case 2: 654 case 2:
654 return (FACE_PROPERTY_INSTANCE_1 655 return (FACE_PROPERTY_INSTANCE_1
655 (Fget_face (XVECTOR_DATA (instantiator)[0]), 656 (Fget_face (XVECTOR_DATA (instantiator)[0]),
656 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, 0, depth)); 657 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME,
658 no_fallback, depth));
657 659
658 default: 660 default:
659 ABORT (); 661 ABORT ();
660 } 662 }
661 } 663 }
828 { 830 {
829 struct device *d = XDEVICE (XCAR (devcons)); 831 struct device *d = XDEVICE (XCAR (devcons));
830 hash_table = Fgethash (charset, d->charset_font_cache_stage_1, 832 hash_table = Fgethash (charset, d->charset_font_cache_stage_1,
831 Qunbound); 833 Qunbound);
832 if (!UNBOUNDP (hash_table)) 834 if (!UNBOUNDP (hash_table))
833 Fclrhash (hash_table); 835 Fclrhash (hash_table);
834 hash_table = Fgethash (charset, d->charset_font_cache_stage_2, 836 hash_table = Fgethash (charset, d->charset_font_cache_stage_2,
835 Qunbound); 837 Qunbound);
836 if (!UNBOUNDP (hash_table)) 838 if (!UNBOUNDP (hash_table))
837 Fclrhash (hash_table); 839 Fclrhash (hash_table);
838 } 840 }
839 } 841 }
840 842
841 #endif /* MULE */ 843 #endif /* MULE */
842 844
843 845
844 static Lisp_Object 846 static Lisp_Object
845 font_instantiate (Lisp_Object UNUSED (specifier), 847 font_instantiate (Lisp_Object UNUSED (specifier),
846 Lisp_Object USED_IF_MULE (matchspec), 848 Lisp_Object USED_IF_MULE (matchspec),
847 Lisp_Object domain, Lisp_Object instantiator, 849 Lisp_Object domain, Lisp_Object instantiator,
848 Lisp_Object depth) 850 Lisp_Object depth, int no_fallback)
849 { 851 {
850 /* When called, we're inside of call_with_suspended_errors(), 852 /* When called, we're inside of call_with_suspended_errors(),
851 so we can freely error. */ 853 so we can freely error. */
852 Lisp_Object device = DOMAIN_DEVICE (domain); 854 Lisp_Object device = DOMAIN_DEVICE (domain);
853 struct device *d = XDEVICE (device); 855 struct device *d = XDEVICE (device);
875 #endif 877 #endif
876 878
877 if (FONT_INSTANCEP (instantiator)) 879 if (FONT_INSTANCEP (instantiator))
878 { 880 {
879 if (NILP (device) 881 if (NILP (device)
880 || EQ (device, XFONT_INSTANCE (instantiator)->device)) 882 || EQ (device, XFONT_INSTANCE (instantiator)->device))
881 { 883 {
882 #ifdef MULE 884 #ifdef MULE
883 if (font_spec_matches_charset (d, charset, 0, 885 if (font_spec_matches_charset (d, charset, 0,
884 Ffont_instance_truename 886 Ffont_instance_truename
885 (instantiator), 887 (instantiator),
893 if (STRINGP (instantiator)) 895 if (STRINGP (instantiator))
894 { 896 {
895 #ifdef MULE 897 #ifdef MULE
896 /* #### rename these caches. */ 898 /* #### rename these caches. */
897 Lisp_Object cache = stage ? d->charset_font_cache_stage_2 : 899 Lisp_Object cache = stage ? d->charset_font_cache_stage_2 :
898 d->charset_font_cache_stage_1; 900 d->charset_font_cache_stage_1;
899 #else 901 #else
900 Lisp_Object cache = d->font_instance_cache; 902 Lisp_Object cache = d->font_instance_cache;
901 #endif 903 #endif
902 904
903 #ifdef MULE 905 #ifdef MULE
924 926
925 if (UNBOUNDP (matching_font)) 927 if (UNBOUNDP (matching_font))
926 { 928 {
927 /* make sure we cache the failures, too. */ 929 /* make sure we cache the failures, too. */
928 matching_font = 930 matching_font =
929 DEVMETH_OR_GIVEN (d, find_charset_font, 931 DEVMETH_OR_GIVEN (d, find_charset_font,
930 (device, instantiator, charset, stage), 932 (device, instantiator, charset, stage),
931 instantiator); 933 instantiator);
932 Fputhash (instantiator, matching_font, hash_table); 934 Fputhash (instantiator, matching_font, hash_table);
933 } 935 }
934 if (NILP (matching_font)) 936 if (NILP (matching_font))
935 return Qunbound; 937 return Qunbound;
936 instantiator = matching_font; 938 instantiator = matching_font;
954 Lisp_Object match_inst = Qunbound; 956 Lisp_Object match_inst = Qunbound;
955 assert (XVECTOR_LENGTH (instantiator) == 1); 957 assert (XVECTOR_LENGTH (instantiator) == 1);
956 958
957 match_inst = face_property_matching_instance 959 match_inst = face_property_matching_instance
958 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, 960 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
959 charset, domain, ERROR_ME, 0, depth, initial); 961 charset, domain, ERROR_ME, no_fallback, depth, initial);
960 962
961 if (UNBOUNDP(match_inst)) 963 if (UNBOUNDP(match_inst))
962 { 964 {
963 match_inst = face_property_matching_instance 965 match_inst = face_property_matching_instance
964 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, 966 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
965 charset, domain, ERROR_ME, 0, depth, final); 967 charset, domain, ERROR_ME, no_fallback, depth, final);
966 } 968 }
967 969
968 return match_inst; 970 return match_inst;
969 971
970 } 972 }
1065 1067
1066 static Lisp_Object 1068 static Lisp_Object
1067 face_boolean_instantiate (Lisp_Object specifier, 1069 face_boolean_instantiate (Lisp_Object specifier,
1068 Lisp_Object UNUSED (matchspec), 1070 Lisp_Object UNUSED (matchspec),
1069 Lisp_Object domain, Lisp_Object instantiator, 1071 Lisp_Object domain, Lisp_Object instantiator,
1070 Lisp_Object depth) 1072 Lisp_Object depth, int no_fallback)
1071 { 1073 {
1072 /* When called, we're inside of call_with_suspended_errors(), 1074 /* When called, we're inside of call_with_suspended_errors(),
1073 so we can freely error. */ 1075 so we can freely error. */
1074 if (NILP (instantiator) || EQ (instantiator, Qt)) 1076 if (NILP (instantiator) || EQ (instantiator, Qt))
1075 return instantiator; 1077 return instantiator;
1092 (XFACE_BOOLEAN_SPECIFIER (specifier)); 1094 (XFACE_BOOLEAN_SPECIFIER (specifier));
1093 } 1095 }
1094 1096
1095 retval = (FACE_PROPERTY_INSTANCE_1 1097 retval = (FACE_PROPERTY_INSTANCE_1
1096 (Fget_face (XVECTOR_DATA (instantiator)[0]), 1098 (Fget_face (XVECTOR_DATA (instantiator)[0]),
1097 prop, domain, ERROR_ME, 0, depth)); 1099 prop, domain, ERROR_ME, no_fallback, depth));
1098 1100
1099 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2])) 1101 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2]))
1100 retval = NILP (retval) ? Qt : Qnil; 1102 retval = NILP (retval) ? Qt : Qnil;
1101 1103
1102 return retval; 1104 return retval;