Commits

Michele Bini  committed d9d0682

Helper macros for pseudovectors

  • Participants
  • Parent commits 7b61429

Comments (0)

Files changed (2)

File src/gtkutil.h

 typedef struct xg_menu_cb_data_
 {
   struct vectorlike_header header;
-#define XMENUCBDATA(a) ((xg_menu_cb_data *)XPNTR_OR_NULL(a))
-#define XSETMENUCBDATA(a, b) XSETPSEUDOVECTOR(a, b, PVEC_OTHER)
-
-#define MENUCBDATA_FIELD(n) n##__menucbdata_field
-#define MENUCBDATA_DECLARE(n) Lisp_Object MENUCBDATA_FIELD(n)
-#define MENUCBDATA_GET(s, n)     AREF((s), PSEUDOVECSIZE(xg_menu_cb_data, MENUCBDATA_FIELD(n)))
-#define MENUCBDATA_SET(s, n, v)  ASET((s), PSEUDOVECSIZE(xg_menu_cb_data, MENUCBDATA_FIELD(n)), (v))
-  MENUCBDATA_DECLARE(next);
-  MENUCBDATA_DECLARE(prev);
+#define XMENUCBDATA(a)  	 PVEC_TO_LISP  (xg_menu_cb_data_, (a))
+#define XSETMENUCBDATA(a, b)     PVEC_SETLISP  (xg_menu_cb_data_, (a), (b))
+#define MENUCBDATA_FIELD(n)      PVEC_FIELD    (xg_menu_cb_data_, n)
+#define MENUCBDATA_GET(s, n)     PVEC_GET      (xg_menu_cb_data_, (s), n)
+#define MENUCBDATA_SET(s, n, v)  PVEC_SET      (xg_menu_cb_data_, (s), n, (v))
+  Lisp_Object MENUCBDATA_FIELD(next);
+  Lisp_Object MENUCBDATA_FIELD(prev);
 #define XMENUCBNEXT(cbdata)           MENUCBDATA_GET(cbdata, next)
 #define XSETMENUCBNEXT(cbdata, x)     MENUCBDATA_SET(cbdata, next, x)
 #define XMENUCBPREV(cbdata)           MENUCBDATA_GET(cbdata, prev)
 #define XSETMENUCBPREV(cbdata, x)     MENUCBDATA_SET(cbdata, prev, x)
 
-  MENUCBDATA_DECLARE(menu_bar_vector);
+  Lisp_Object MENUCBDATA_FIELD(menu_bar_vector);
 #define XMENUBARVECTOR(cbdata)        MENUCBDATA_GET(cbdata, menu_bar_vector)
 #define XSETMENUBARVECTOR(cbdata, x)  MENUCBDATA_SET(cbdata, menu_bar_vector, x)
 
   struct vectorlike_header header;
 #define XMENUITEMCBDATA(a) ((xg_menu_item_cb_data *)XPNTR_OR_NULL(a))
 #define XSETMENUITEMCBDATA(a, b) XSETPSEUDOVECTOR(a, b, PVEC_OTHER)
-
 #define MENUITEMCBDATA_FIELD(n) n##__menuitemcbdata_field
 #define MENUITEMCBDATA_DECLARE(n) Lisp_Object MENUITEMCBDATA_FIELD(n)
 #define MENUITEMCBDATA_GET(s, n)     AREF((s), PSEUDOVECSIZE(xg_menu_item_cb_data, MENUITEMCBDATA_FIELD(n)))
 /* Number of bits to put in each character in the internal representation
    of bool vectors.  This should not vary across implementations.  */
 #define BOOL_VECTOR_BITS_PER_CHAR 8
+
+/* Macro-definition helper macros for pseudovectors */
+#define PVEC_TO_LISP(pvecname, a) 	       ((struct pvecname *)XPNTR_OR_NULL(a))
+#define PVEC_SETLISP(pvecname, a, b) 	       XSETPSEUDOVECTOR((a), (b), PVEC_OTHER)
+#define PVEC_FIELD(pvecname,field) 	       field##__##pvecname##__##pvec
+#define PVEC_GET(pvecname, vec, field) 	       AREF((vec), PSEUDOVECSIZE(struct pvecname, PVEC_FIELD(pvecname, field)))
+#define PVEC_SET(pvecname, vec, field, value)  ASET((vec), PSEUDOVECSIZE(struct pvecname, PVEC_FIELD(pvecname, field)), (value))
 
 /* These macros extract various sorts of values from a Lisp_Object.
  For example, if tem is a Lisp_Object whose type is Lisp_Cons,