Commit 3ccd0ff1 authored by Lars Brinkhoff's avatar Lars Brinkhoff

Add PVSIZE function to return the size of a pseudovector.

* src/lisp.h (PVSIZE): New function.

* src/chartab.c (copy_char_table):
* src/data.c (Ftype_of, Finteractive_form, Faref, Faset):
* src/doc.c (Fdocumentation, store_function_docstring):
* src/eval.c (Fcommandp, funcall_lambda, lambda_arity, Ffetch_bytecode):
* src/fns.c (Flength, Fcopy_sequence):
* src/font.h (FONT_SPEC_P, FONT_ENTITY_P, FONT_OBJECT_P):
* src/lread.c (substitute_object_recurse):
* src/src/print.c (print_object):
  Use it.
parent dd42ca42
......@@ -185,7 +185,7 @@ Lisp_Object
copy_char_table (Lisp_Object table)
{
Lisp_Object copy;
int size = XCHAR_TABLE (table)->header.size & PSEUDOVECTOR_SIZE_MASK;
int size = PVSIZE (table);
int i;
copy = Fmake_vector (make_number (size), Qnil);
......
......@@ -270,7 +270,7 @@ for example, (type-of 1) returns `integer'. */)
case PVEC_RECORD:
{
Lisp_Object t = AREF (object, 0);
if (RECORDP (t) && 1 < (ASIZE (t) & PSEUDOVECTOR_SIZE_MASK))
if (RECORDP (t) && 1 < PVSIZE (t))
/* Return the type name field of the class! */
return AREF (t, 1);
else
......@@ -902,7 +902,7 @@ Value, if non-nil, is a list (interactive SPEC). */)
}
else if (COMPILEDP (fun))
{
if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE)
if (PVSIZE (fun) > COMPILED_INTERACTIVE)
return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE));
}
else if (AUTOLOADP (fun))
......@@ -2306,7 +2306,7 @@ or a byte-code object. IDX starts at 0. */)
if (VECTORP (array))
size = ASIZE (array);
else if (COMPILEDP (array) || RECORDP (array))
size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK;
size = PVSIZE (array);
else
wrong_type_argument (Qarrayp, array);
......@@ -2349,8 +2349,7 @@ bool-vector. IDX starts at 0. */)
}
else if (RECORDP (array))
{
ptrdiff_t size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK;
if (idxval < 0 || idxval >= size)
if (idxval < 0 || idxval >= PVSIZE (array))
args_out_of_range (array, idx);
ASET (array, idxval, newelt);
}
......
......@@ -342,7 +342,7 @@ string is passed through `substitute-command-keys'. */)
doc = make_number (XSUBR (fun)->doc);
else if (COMPILEDP (fun))
{
if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
if (PVSIZE (fun) <= COMPILED_DOC_STRING)
return Qnil;
else
{
......@@ -500,7 +500,7 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
{
/* This bytecode object must have a slot for the
docstring, since we've found a docstring for it. */
if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
if (PVSIZE (fun) > COMPILED_DOC_STRING)
ASET (fun, COMPILED_DOC_STRING, make_number (offset));
else
{
......
......@@ -1881,8 +1881,7 @@ then strings and vectors are not accepted. */)
have an element whose index is COMPILED_INTERACTIVE, which is
where the interactive spec is stored. */
else if (COMPILEDP (fun))
return ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE
? Qt : if_prop);
return (PVSIZE (fun) > COMPILED_INTERACTIVE ? Qt : if_prop);
/* Strings and vectors are keyboard macros. */
if (STRINGP (fun) || VECTORP (fun))
......@@ -2922,7 +2921,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
}
else if (COMPILEDP (fun))
{
ptrdiff_t size = ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK;
ptrdiff_t size = PVSIZE (fun);
if (size <= COMPILED_STACK_DEPTH)
xsignal1 (Qinvalid_function, fun);
syms_left = AREF (fun, COMPILED_ARGLIST);
......@@ -3103,7 +3102,7 @@ lambda_arity (Lisp_Object fun)
}
else if (COMPILEDP (fun))
{
ptrdiff_t size = ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK;
ptrdiff_t size = PVSIZE (fun);
if (size <= COMPILED_STACK_DEPTH)
xsignal1 (Qinvalid_function, fun);
syms_left = AREF (fun, COMPILED_ARGLIST);
......@@ -3148,7 +3147,7 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
if (COMPILEDP (object))
{
ptrdiff_t size = ASIZE (object) & PSEUDOVECTOR_SIZE_MASK;
ptrdiff_t size = PVSIZE (object);
if (size <= COMPILED_STACK_DEPTH)
xsignal1 (Qinvalid_function, object);
if (CONSP (AREF (object, COMPILED_BYTECODE)))
......
......@@ -107,7 +107,7 @@ To get the number of bytes, use `string-bytes'. */)
else if (BOOL_VECTOR_P (sequence))
XSETFASTINT (val, bool_vector_size (sequence));
else if (COMPILEDP (sequence) || RECORDP (sequence))
XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK);
XSETFASTINT (val, PVSIZE (sequence));
else if (CONSP (sequence))
{
intptr_t i = 0;
......@@ -484,8 +484,7 @@ shared with the original. */)
if (RECORDP (arg))
{
ptrdiff_t size = ASIZE (arg) & PSEUDOVECTOR_SIZE_MASK;
return Frecord (size, XVECTOR (arg)->contents);
return Frecord (PVSIZE (arg), XVECTOR (arg)->contents);
}
if (CHAR_TABLE_P (arg))
......
......@@ -424,7 +424,7 @@ FONTP (Lisp_Object x)
INLINE bool
FONT_SPEC_P (Lisp_Object x)
{
return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX;
return FONTP (x) && PVSIZE (x) == FONT_SPEC_MAX;
}
/* Like FONT_SPEC_P, but can be used in the garbage collector. */
......@@ -438,7 +438,7 @@ GC_FONT_SPEC_P (Lisp_Object x)
INLINE bool
FONT_ENTITY_P (Lisp_Object x)
{
return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX;
return FONTP (x) && PVSIZE (x) == FONT_ENTITY_MAX;
}
/* Like FONT_ENTITY_P, but can be used in the garbage collector. */
......@@ -452,7 +452,7 @@ GC_FONT_ENTITY_P (Lisp_Object x)
INLINE bool
FONT_OBJECT_P (Lisp_Object x)
{
return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX;
return FONTP (x) && PVSIZE (x) == FONT_OBJECT_MAX;
}
/* Like FONT_OBJECT_P, but can be used in the garbage collector. */
......
......@@ -1401,6 +1401,12 @@ ASIZE (Lisp_Object array)
return size;
}
INLINE ptrdiff_t
PVSIZE (Lisp_Object pv)
{
return ASIZE (pv) & PSEUDOVECTOR_SIZE_MASK;
}
INLINE bool
VECTORP (Lisp_Object x)
{
......
......@@ -3402,7 +3402,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj
else if (CHAR_TABLE_P (subtree) || SUB_CHAR_TABLE_P (subtree)
|| COMPILEDP (subtree) || HASH_TABLE_P (subtree)
|| RECORDP (subtree))
length = ASIZE (subtree) & PSEUDOVECTOR_SIZE_MASK;
length = PVSIZE (subtree);
else if (VECTORP (subtree))
length = ASIZE (subtree);
else
......
......@@ -1966,7 +1966,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
case PVEC_RECORD:
{
ptrdiff_t n, size = ASIZE (obj) & PSEUDOVECTOR_SIZE_MASK;
ptrdiff_t n, size = PVSIZE (obj);
int i;
/* Don't print more elements than the specified maximum. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment