X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fspecifier.h;h=17461cbfedf8d394952deb123445f00824c5c589;hb=2891e64f8bb46fe9f3d6647d4c866c41d8e4633c;hp=506319e9b2edfeef1ca5e0b8a77debc6d1b8587d;hpb=ea1ea793fe6e244ef5555ed983423a204101af13;p=chise%2Fxemacs-chise.git- diff --git a/src/specifier.h b/src/specifier.h index 506319e..17461cb 100644 --- a/src/specifier.h +++ b/src/specifier.h @@ -21,8 +21,8 @@ Boston, MA 02111-1307, USA. */ /* Synched up with: Not in FSF. */ -#ifndef _XEMACS_SPECIFIER_H_ -#define _XEMACS_SPECIFIER_H_ +#ifndef INCLUDED_specifier_h_ +#define INCLUDED_specifier_h_ /* MAGIC SPECIFIERS @@ -87,7 +87,7 @@ extern const struct struct_description specifier_methods_description; struct specifier_methods { - CONST char *name; + const char *name; Lisp_Object predicate_symbol; /* Implementation specific methods: */ @@ -124,6 +124,13 @@ struct specifier_methods valid. */ void (*validate_method) (Lisp_Object instantiator); + + /* Copy method: Given an instantiator, copy the bits that we need to + for this specifier type. + + If this function is not present, then Fcopy_tree is used. */ + Lisp_Object (*copy_instantiator_method) (Lisp_Object instantiator); + /* Validate-matchspec method: Given a matchspec, verify that it's valid for this specifier type. If not, signal an error. @@ -230,9 +237,10 @@ struct Lisp_Specifier /* type-specific extra data attached to a specifier */ char data[1]; }; +typedef struct Lisp_Specifier Lisp_Specifier; -DECLARE_LRECORD (specifier, struct Lisp_Specifier); -#define XSPECIFIER(x) XRECORD (x, specifier, struct Lisp_Specifier) +DECLARE_LRECORD (specifier, Lisp_Specifier); +#define XSPECIFIER(x) XRECORD (x, specifier, Lisp_Specifier) #define XSETSPECIFIER(x, p) XSETRECORD (x, p, specifier) #define SPECIFIERP(x) RECORDP (x, specifier) #define CHECK_SPECIFIER(x) CHECK_RECORD (x, specifier) @@ -245,24 +253,24 @@ DECLARE_LRECORD (specifier, struct Lisp_Specifier); #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); \ +#define MAYBE_SPECMETH(sp, m, args) do { \ + Lisp_Specifier *maybe_specmeth_sp = (sp); \ + if (HAS_SPECMETH_P (maybe_specmeth_sp, m)) \ + SPECMETH (maybe_specmeth_sp, m, args); \ } while (0) /***** Defining new specifier types *****/ -#define specifier_data_offset (offsetof(struct Lisp_Specifier, data)) +#define specifier_data_offset (offsetof (Lisp_Specifier, data)) extern const struct lrecord_description specifier_empty_extra_description[]; #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) \ +INLINE_HEADER struct type##_specifier * \ +error_check_##type##_specifier_data (Lisp_Specifier *sp); \ +INLINE_HEADER struct type##_specifier * \ +error_check_##type##_specifier_data (Lisp_Specifier *sp) \ { \ if (SPECIFIERP (sp->magic_parent)) \ { \ @@ -274,13 +282,22 @@ error_check_##type##_specifier_data (struct Lisp_Specifier *sp) \ assert (SPECIFIER_TYPE_P (sp, type)); \ return (struct type##_specifier *) sp->data; \ } \ +INLINE_HEADER Lisp_Specifier * \ +error_check_##type##_specifier_type (Lisp_Object obj); \ +INLINE_HEADER Lisp_Specifier * \ +error_check_##type##_specifier_type (Lisp_Object obj) \ +{ \ + Lisp_Specifier *sp = XSPECIFIER (obj); \ + assert (SPECIFIER_TYPE_P (sp, type)); \ + return sp; \ +} \ DECLARE_NOTHING #else -#define DECLARE_SPECIFIER_TYPE(type) \ +#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 { \ @@ -288,12 +305,12 @@ struct specifier_methods * type##_specifier_methods type##_specifier_methods->name = obj_name; \ type##_specifier_methods->extra_description = \ specifier_empty_extra_description; \ - defsymbol_nodump (&type##_specifier_methods->predicate_symbol, pred_sym); \ - add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \ - dumpstruct (&type##_specifier_methods, &specifier_methods_description); \ + defsymbol_nodump (&type##_specifier_methods->predicate_symbol, pred_sym); \ + add_entry_to_specifier_type_list (Q##type, type##_specifier_methods); \ + dumpstruct (&type##_specifier_methods, &specifier_methods_description); \ } while (0) -#define REINITIALIZE_SPECIFIER_TYPE(type) do { \ +#define REINITIALIZE_SPECIFIER_TYPE(type) do { \ staticpro_nodump (&type##_specifier_methods->predicate_symbol); \ } while (0) @@ -336,11 +353,20 @@ do { \ : (sp)->data)) #endif -/* #### Need to create ERROR_CHECKING versions of these. */ +#ifdef ERROR_CHECK_TYPECHECK +# define XSPECIFIER_TYPE(x, type) \ + error_check_##type##_specifier_type (x) +# define XSETSPECIFIER_TYPE(x, p, type) do \ +{ \ + XSETSPECIFIER (x, p); \ + assert (SPECIFIER_TYPEP (XSPECIFIER(x), type)); \ +} while (0) +#else +# define XSPECIFIER_TYPE(x, type) XSPECIFIER (x) +# define XSETSPECIFIER_TYPE(x, p, type) XSETSPECIFIER (x, p) +#endif /* ERROR_CHECK_TYPE_CHECK */ -#define XSPECIFIER_TYPE(x, type) XSPECIFIER (x) -#define XSETSPECIFIER_TYPE(x, p, type) XSETSPECIFIER (x, p) -#define SPECIFIER_TYPEP(x, type) \ +#define SPECIFIER_TYPEP(x, type) \ (SPECIFIERP (x) && SPECIFIER_TYPE_P (XSPECIFIER (x), type)) #define CHECK_SPECIFIER_TYPE(x, type) do { \ CHECK_SPECIFIER (x); \ @@ -467,4 +493,4 @@ DECLARE_SPECIFIER_TYPE (display_table); #define CHECK_DISPLAYTABLE_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, display_table) #define CONCHECK_DISPLAYTABLE_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, display_table) -#endif /* _XEMACS_SPECIFIER_H_ */ +#endif /* INCLUDED_specifier_h_ */