diff src/specifier.h @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 3d6bfa290dbd
children 6330739388db
line wrap: on
line diff
--- a/src/specifier.h	Mon Aug 13 10:27:41 2007 +0200
+++ b/src/specifier.h	Mon Aug 13 10:28:48 2007 +0200
@@ -44,14 +44,14 @@
   /* Validate method: Given an instantiator, verify that it's
      valid for this specifier type.  If not, signal an error.
 
-     If this functions is not present, all instantiators are
+     If this function is not present, all instantiators are
      considered valid. */
   void (*validate_method) (Lisp_Object instantiator);
 
   /* Validate-matchspec method: Given a matchspec, verify that it's
      valid for this specifier type.  If not, signal an error.
 
-     If this functions is not present, *no* matchspecs are considered
+     If this function is not present, *no* matchspecs are considered
      valid.  Note that this differs from validate_method(). */
   void (*validate_matchspec_method) (Lisp_Object matchspec);
 
@@ -98,7 +98,7 @@
   /* This is a straight list of instantiators. */
   Lisp_Object global_specs;
 
-  /* These are all assoc lists where the key is type of object the
+  /* These are all assoc lists where the key is the type of object the
      list represents (buffer, window, etc.) and the associated list is
      the actual list of instantiators. */
   Lisp_Object device_specs;
@@ -130,32 +130,33 @@
 #define HAS_SPECMETH_P(sp, m) (!!RAW_SPECMETH (sp, m))
 #define SPECMETH(sp, m, args) (((sp)->methods->m##_method) args)
 
-/* Call a void-returning specifier method, if it exists */
-#define MAYBE_SPECMETH(sp, m, args)				\
-do {								\
-  struct Lisp_Specifier *_maybe_specmeth_sp = (sp);		\
-  if (HAS_SPECMETH_P (_maybe_specmeth_sp, m))			\
-    SPECMETH (_maybe_specmeth_sp, m, args);			\
+/* Call a void-returning specifier method, if it exists.  */
+#define MAYBE_SPECMETH(sp, m, args) do {		\
+  struct Lisp_Specifier *_maybe_specmeth_sp = (sp);	\
+  if (HAS_SPECMETH_P (_maybe_specmeth_sp, m))		\
+    SPECMETH (_maybe_specmeth_sp, m, args);		\
 } while (0)
 
-MAC_DECLARE_EXTERN (struct Lisp_Specifier *, MTspecmeth_or_given)
-
-/* Call a specifier method, if it exists; otherwise return
-   the specified value */
-
-#define SPECMETH_OR_GIVEN(sp, m, args, given)				\
-MAC_BEGIN								\
-  MAC_DECLARE (struct Lisp_Specifier *, MTspecmeth_or_given, sp)	\
-  HAS_SPECMETH_P (MTspecmeth_or_given, m) ?				\
-    SPECMETH (MTspecmeth_or_given, m, args) : (given)			\
-MAC_END
-
 /***** Defining new specifier types *****/
 
-#define DECLARE_SPECIFIER_TYPE(type) \
+#ifdef ERROR_CHECK_TYPECHECK
+#define DECLARE_SPECIFIER_TYPE(type)					\
+extern struct specifier_methods * type##_specifier_methods;		\
+INLINE struct type##_specifier *					\
+error_check_##type##_specifier_data (struct Lisp_Specifier *sp);	\
+INLINE struct type##_specifier *					\
+error_check_##type##_specifier_data (struct Lisp_Specifier *sp)		\
+{									\
+  assert (SPECIFIER_TYPE_P (sp, type));					\
+  return (struct type##_specifier *) sp->data;				\
+}									\
+DECLARE_NOTHING
+#else
+#define DECLARE_SPECIFIER_TYPE(type)				\
 extern struct specifier_methods * type##_specifier_methods
+#endif /* ERROR_CHECK_TYPECHECK */
 
-#define DEFINE_SPECIFIER_TYPE(type) \
+#define DEFINE_SPECIFIER_TYPE(type)			\
 struct specifier_methods * type##_specifier_methods
 
 #define INITIALIZE_SPECIFIER_TYPE(type, obj_name, pred_sym) do {	\
@@ -163,36 +164,30 @@
  type##_specifier_methods->name = obj_name;				\
  defsymbol (&type##_specifier_methods->predicate_symbol, pred_sym);	\
  add_entry_to_specifier_type_list (Q##type, type##_specifier_methods);	\
-} while (0)								\
+} while (0)
 
 #define INITIALIZE_SPECIFIER_TYPE_WITH_DATA(type, obj_name, pred_sym)	\
-  do {									\
-    INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym);		\
-    type##_specifier_methods->extra_data_size =				\
-      sizeof (struct type##_specifier);					\
-  } while (0)
+do {									\
+  INITIALIZE_SPECIFIER_TYPE (type, obj_name, pred_sym);			\
+  type##_specifier_methods->extra_data_size =				\
+    sizeof (struct type##_specifier);					\
+} while (0)
 
-/* Declare that specifier-type TYPE has method M; used in
+/* Declare that specifier-type TYPE has method METH; used in
    initialization routines */
-#define SPECIFIER_HAS_METHOD(type, m) \
-  (type##_specifier_methods->m##_method = type##_##m)
+#define SPECIFIER_HAS_METHOD(type, meth) \
+  (type##_specifier_methods->meth##_method = type##_##meth)
 
 /***** Macros for accessing specifier types *****/
 
-#define SPECIFIER_TYPE_P(sp, type)		\
+#define SPECIFIER_TYPE_P(sp, type) \
   ((sp)->methods == type##_specifier_methods)
 
 #ifdef ERROR_CHECK_TYPECHECK
-MAC_DECLARE_EXTERN (struct Lisp_Specifier *, MTspecifier_data)
-# define SPECIFIER_TYPE_DATA(sp, type)				\
-MAC_BEGIN							\
-  MAC_DECLARE (struct Lisp_Specifier *, MTspecifier_data, sp)	\
-  assert (SPECIFIER_TYPE_P (MTspecifier_data, type))		\
-  MAC_SEP							\
-  (struct type##_specifier *) MTspecifier_data->data		\
-MAC_END
+# define SPECIFIER_TYPE_DATA(sp, type) \
+   error_check_##type##_specifier_data (sp)
 #else
-# define SPECIFIER_TYPE_DATA(sp, type)		\
+# define SPECIFIER_TYPE_DATA(sp, type) \
   ((struct type##_specifier *) (sp)->data)
 #endif
 
@@ -202,22 +197,18 @@
 #define XSETSPECIFIER_TYPE(x, p, type) XSETSPECIFIER (x, p)
 #define SPECIFIER_TYPEP(x, type)				\
   (SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), type))
-#define CHECK_SPECIFIER_TYPE(x, type)				\
-  do {								\
-    CHECK_SPECIFIER (x);					\
-    if (!(SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x),	\
-					       type)))		\
-      dead_wrong_type_argument					\
-	(type##_specifier_methods->predicate_symbol, x);	\
-  } while (0)
-#define CONCHECK_SPECIFIER_TYPE(x, type)			\
-  do {								\
-    CONCHECK_SPECIFIER (x);					\
-    if (!(SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x),	\
-					       type)))		\
-      x = wrong_type_argument					\
-	(type##_specifier_methods->predicate_symbol, x);	\
-  } while (0)
+#define CHECK_SPECIFIER_TYPE(x, type) do {		\
+  CHECK_SPECIFIER (x);					\
+  if (!SPECIFIER_TYPE_P (XSPECIFIER (x), type))		\
+    dead_wrong_type_argument				\
+      (type##_specifier_methods->predicate_symbol, x);	\
+} while (0)
+#define CONCHECK_SPECIFIER_TYPE(x, type) do {		\
+  CONCHECK_SPECIFIER (x);				\
+  if (!(SPECIFIER_TYPEP (x, type)))			\
+    x = wrong_type_argument				\
+      (type##_specifier_methods->predicate_symbol, x);	\
+} while (0)
 
 /***** Miscellaneous structures *****/
 
@@ -251,32 +242,38 @@
 				  Lisp_Object oldval);
 };
 
-extern Lisp_Object decode_locale (Lisp_Object locale);
-extern Lisp_Object decode_locale_list (Lisp_Object locale);
-extern Lisp_Object decode_domain (Lisp_Object domain);
+EXFUN (Fcopy_specifier, 6);
+EXFUN (Fmake_specifier, 1);
+EXFUN (Fset_specifier_dirty_flag, 1);
+EXFUN (Fspecifier_instance, 4);
+EXFUN (Fvalid_specifier_locale_p, 1);
+
+extern Lisp_Object Qfallback, Qnatnum;
+
+Lisp_Object decode_locale_list (Lisp_Object locale);
 extern enum spec_add_meth
 decode_how_to_add_specification (Lisp_Object how_to_add);
-extern Lisp_Object decode_specifier_tag_set (Lisp_Object tag_set);
+Lisp_Object decode_specifier_tag_set (Lisp_Object tag_set);
 
-extern void add_entry_to_specifier_type_list (Lisp_Object symbol,
-					      struct specifier_methods *meths);
-extern void set_specifier_caching (Lisp_Object specifier,
-				   int struct_window_offset,
-				   void (*value_changed_in_window)
-				   (Lisp_Object specifier, struct window *w,
-				    Lisp_Object oldval),
-				   int struct_frame_offset,
-				   void (*value_changed_in_frame)
-				   (Lisp_Object specifier, struct frame *f,
-				    Lisp_Object oldval));
-extern void set_specifier_fallback (Lisp_Object specifier,
-				    Lisp_Object fallback);
-extern void recompute_all_cached_specifiers_in_window (struct window *w);
-extern void recompute_all_cached_specifiers_in_frame (struct frame *f);
+void add_entry_to_specifier_type_list (Lisp_Object symbol,
+				       struct specifier_methods *meths);
+void set_specifier_caching (Lisp_Object specifier,
+			    int struct_window_offset,
+			    void (*value_changed_in_window)
+			    (Lisp_Object specifier, struct window *w,
+			     Lisp_Object oldval),
+			    int struct_frame_offset,
+			    void (*value_changed_in_frame)
+			    (Lisp_Object specifier, struct frame *f,
+			     Lisp_Object oldval));
+void set_specifier_fallback (Lisp_Object specifier,
+			     Lisp_Object fallback);
+void recompute_all_cached_specifiers_in_window (struct window *w);
+void recompute_all_cached_specifiers_in_frame (struct frame *f);
 
-extern void cleanup_specifiers (void);
-extern void prune_specifiers (int (*obj_marked_p) (Lisp_Object));
-extern void setup_device_initial_specifier_tags (struct device *d);
+void cleanup_specifiers (void);
+void prune_specifiers (int (*obj_marked_p) (Lisp_Object));
+void setup_device_initial_specifier_tags (struct device *d);
 void kill_specifier_buffer_locals (Lisp_Object buffer);
 
 DECLARE_SPECIFIER_TYPE (generic);