* src/lisp.h (struct Lisp_Cons): Use INTERNAL_FIELD.
Remove obsolete comment.
(MVAR): New macro.
(struct Lisp_Overlay): Use INTERNAL_FIELD.
* src/alloc.c, src/buffer.c, src/buffer.h, src/fns.c: Adjust users.
* admin/coccinelle/overlay.cocci: Semantic patch to replace direct
access to Lisp_Object members of struct Lisp_Overlay to MVAR.
+2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * coccinelle/overlay.cocci: Semantic patch to replace direct
+ access to Lisp_Object members of struct Lisp_Overlay to MVAR.
+
2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
* coccinelle/symbol.cocci: Semantic patch to replace direct
--- /dev/null
+// Change direct access to Lisp_Object fields of struct
+// Lisp_Overlay to MVAR. Beginning M denotes "misc", and
+// MVAR is likely to be used for other second-class objects.
+@@
+struct Lisp_Overlay *V;
+Lisp_Object O;
+@@
+(
+- V->start
++ MVAR (V, start)
+|
+- V->end
++ MVAR (V, end)
+|
+- V->plist
++ MVAR (V, plist)
+
+|
+
+- XOVERLAY (O)->start
++ MVAR (XOVERLAY (O), start)
+|
+- XOVERLAY (O)->end
++ MVAR (XOVERLAY (O), end)
+|
+- XOVERLAY (O)->plist
++ MVAR (XOVERLAY (O), plist)
+)
+2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Use INTERNAL_FIELD for conses and overlays.
+ * lisp.h (struct Lisp_Cons): Use INTERNAL_FIELD.
+ Remove obsolete comment.
+ (MVAR): New macro.
+ (struct Lisp_Overlay): Use INTERNAL_FIELD.
+ * alloc.c, buffer.c, buffer.h, fns.c: Adjust users.
+
2012-08-01 Dmitry Antipov <dmantipov@yandex.ru>
Use INTERNAL_FIELD for symbols.
{
ptr->u.chain = cons_free_list;
#if GC_MARK_STACK
- ptr->car = Vdead;
+ CVAR (ptr, car) = Vdead;
#endif
cons_free_list = ptr;
consing_since_gc -= sizeof *ptr;
&& offset < (CONS_BLOCK_SIZE * sizeof b->conses[0])
&& (b != cons_block
|| offset / sizeof b->conses[0] < cons_block_index)
- && !EQ (((struct Lisp_Cons *) p)->car, Vdead));
+ && !EQ (CVAR ((struct Lisp_Cons *) p, car), Vdead));
}
else
return 0;
for (; ptr && !ptr->gcmarkbit; ptr = ptr->next)
{
ptr->gcmarkbit = 1;
- mark_object (ptr->start);
- mark_object (ptr->end);
- mark_object (ptr->plist);
+ mark_object (MVAR (ptr, start));
+ mark_object (MVAR (ptr, end));
+ mark_object (MVAR (ptr, plist));
}
}
CHECK_ALLOCATED_AND_LIVE (live_cons_p);
CONS_MARK (ptr);
/* If the cdr is nil, avoid recursion for the car. */
- if (EQ (ptr->u.cdr, Qnil))
+ if (EQ (CVAR (ptr, u.cdr), Qnil))
{
- obj = ptr->car;
+ obj = CVAR (ptr, car);
cdr_count = 0;
goto loop;
}
- mark_object (ptr->car);
- obj = ptr->u.cdr;
+ mark_object (CVAR (ptr, car));
+ obj = CVAR (ptr, u.cdr);
cdr_count++;
if (cdr_count == mark_object_loop_halt)
abort ();
cblk->conses[pos].u.chain = cons_free_list;
cons_free_list = &cblk->conses[pos];
#if GC_MARK_STACK
- cons_free_list->car = Vdead;
+ CVAR (cons_free_list, car) = Vdead;
#endif
}
else
Lisp_Object overlay, start, end;
struct Lisp_Marker *m;
- eassert (MARKERP (list->start));
- m = XMARKER (list->start);
+ eassert (MARKERP (MVAR (list, start)));
+ m = XMARKER (MVAR (list, start));
start = build_marker (b, m->charpos, m->bytepos);
XMARKER (start)->insertion_type = m->insertion_type;
- eassert (MARKERP (list->end));
- m = XMARKER (list->end);
+ eassert (MARKERP (MVAR (list, end)));
+ m = XMARKER (MVAR (list, end));
end = build_marker (b, m->charpos, m->bytepos);
XMARKER (end)->insertion_type = m->insertion_type;
- overlay = build_overlay (start, end, Fcopy_sequence (list->plist));
+ overlay = build_overlay (start, end, Fcopy_sequence (MVAR (list, plist)));
if (tail)
tail = tail->next = XOVERLAY (overlay);
else
static void
drop_overlay (struct buffer *b, struct Lisp_Overlay *ov)
{
- eassert (b == XBUFFER (Fmarker_buffer (ov->start)));
- modify_overlay (b, marker_position (ov->start), marker_position (ov->end));
- Fset_marker (ov->start, Qnil, Qnil);
- Fset_marker (ov->end, Qnil, Qnil);
+ eassert (b == XBUFFER (Fmarker_buffer (MVAR (ov, start))));
+ modify_overlay (b, marker_position (MVAR (ov, start)),
+ marker_position (MVAR (ov, end)));
+ Fset_marker (MVAR (ov, start), Qnil, Qnil);
+ Fset_marker (MVAR (ov, end), Qnil, Qnil);
}
{
CHECK_OVERLAY (overlay);
- return Fcopy_sequence (XOVERLAY (overlay)->plist);
+ return Fcopy_sequence (MVAR (XOVERLAY (overlay), plist));
}
\f
(Lisp_Object overlay, Lisp_Object prop)
{
CHECK_OVERLAY (overlay);
- return lookup_char_property (XOVERLAY (overlay)->plist, prop, 0);
+ return lookup_char_property (MVAR (XOVERLAY (overlay), plist), prop, 0);
}
DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
buffer = Fmarker_buffer (OVERLAY_START (overlay));
- for (tail = XOVERLAY (overlay)->plist;
+ for (tail = MVAR (XOVERLAY (overlay), plist);
CONSP (tail) && CONSP (XCDR (tail));
tail = XCDR (XCDR (tail)))
if (EQ (XCAR (tail), prop))
}
/* It wasn't in the list, so add it to the front. */
changed = !NILP (value);
- XOVERLAY (overlay)->plist
- = Fcons (prop, Fcons (value, XOVERLAY (overlay)->plist));
+ MVAR (XOVERLAY (overlay), plist)
+ = Fcons (prop, Fcons (value, MVAR (XOVERLAY (overlay), plist)));
found:
if (! NILP (buffer))
{
/* Return the marker that stands for where OV starts in the buffer. */
-#define OVERLAY_START(OV) (XOVERLAY (OV)->start)
+#define OVERLAY_START(OV) MVAR (XOVERLAY (OV), start)
/* Return the marker that stands for where OV ends in the buffer. */
-#define OVERLAY_END(OV) (XOVERLAY (OV)->end)
+#define OVERLAY_END(OV) MVAR (XOVERLAY (OV), end)
/* Return the plist of overlay OV. */
-#define OVERLAY_PLIST(OV) XOVERLAY ((OV))->plist
+#define OVERLAY_PLIST(OV) MVAR (XOVERLAY (OV), plist)
/* Return the actual buffer position for the marker P.
We assume you know which buffer it's pointing into. */
|| !internal_equal (OVERLAY_END (o1), OVERLAY_END (o2),
depth + 1, props))
return 0;
- o1 = XOVERLAY (o1)->plist;
- o2 = XOVERLAY (o2)->plist;
+ o1 = MVAR (XOVERLAY (o1), plist);
+ o2 = MVAR (XOVERLAY (o2), plist);
goto tail_recurse;
}
if (MARKERP (o1))
#define CHECK_STRING_OR_BUFFER(x) \
CHECK_TYPE (STRINGP (x) || BUFFERP (x), Qbuffer_or_string_p, x)
-\f
-/* In a cons, the markbit of the car is the gc mark bit */
+/* Most code should use this macro to
+ access Lisp fields in struct Lisp_Cons. */
+
+#define CVAR(cons, field) ((cons)->INTERNAL_FIELD (field))
struct Lisp_Cons
{
- /* Please do not use the names of these elements in code other
- than the core lisp implementation. Use XCAR and XCDR below. */
- Lisp_Object car;
+ /* Car of this cons cell. */
+ Lisp_Object INTERNAL_FIELD (car);
+
union
{
- Lisp_Object cdr;
+ /* Cdr of this cons cell. */
+ Lisp_Object INTERNAL_FIELD (cdr);
+
+ /* Used to chain conses on a free list. */
struct Lisp_Cons *chain;
} u;
};
fields are not accessible as lvalues. (What if we want to switch to
a copying collector someday? Cached cons cell field addresses may be
invalidated at arbitrary points.) */
-#define XCAR_AS_LVALUE(c) (XCONS ((c))->car)
-#define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr)
+#define XCAR_AS_LVALUE(c) (CVAR (XCONS (c), car))
+#define XCDR_AS_LVALUE(c) (CVAR (XCONS (c), u.cdr))
/* Use these from normal code. */
#define XCAR(c) LISP_MAKE_RVALUE (XCAR_AS_LVALUE (c))
#define DEFAULT_REHASH_SIZE 1.5
-\f
+/* Most code should use this macro to access
+ Lisp fields in a different misc objects. */
+
+#define MVAR(misc, field) ((misc)->INTERNAL_FIELD (field))
+
/* These structures are used for various misc types. */
struct Lisp_Misc_Any /* Supertype of all Misc types. */
unsigned gcmarkbit : 1;
int spacer : 15;
struct Lisp_Overlay *next;
- Lisp_Object start, end, plist;
+ Lisp_Object INTERNAL_FIELD (start);
+ Lisp_Object INTERNAL_FIELD (end);
+ Lisp_Object INTERNAL_FIELD (plist);
};
/* Hold a C pointer for later use.