aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Brinkhoff2017-04-03 08:42:18 +0200
committerLars Brinkhoff2017-04-10 20:35:13 +0200
commit3ccd0ff1064a2836c379b13c2d5f4b11c5da1f88 (patch)
tree29393d7ce726f222d0f82ddfbb1363b0364168e7 /src
parentdd42ca427cf8a890678f574de43685ae70416491 (diff)
downloademacs-3ccd0ff1064a2836c379b13c2d5f4b11c5da1f88.tar.gz
emacs-3ccd0ff1064a2836c379b13c2d5f4b11c5da1f88.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/chartab.c2
-rw-r--r--src/data.c9
-rw-r--r--src/doc.c4
-rw-r--r--src/eval.c9
-rw-r--r--src/fns.c5
-rw-r--r--src/font.h6
-rw-r--r--src/lisp.h6
-rw-r--r--src/lread.c2
-rw-r--r--src/print.c2
9 files changed, 24 insertions, 21 deletions
diff --git a/src/chartab.c b/src/chartab.c
index fa5a8e41164..8392c0c07dc 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -185,7 +185,7 @@ Lisp_Object
185copy_char_table (Lisp_Object table) 185copy_char_table (Lisp_Object table)
186{ 186{
187 Lisp_Object copy; 187 Lisp_Object copy;
188 int size = XCHAR_TABLE (table)->header.size & PSEUDOVECTOR_SIZE_MASK; 188 int size = PVSIZE (table);
189 int i; 189 int i;
190 190
191 copy = Fmake_vector (make_number (size), Qnil); 191 copy = Fmake_vector (make_number (size), Qnil);
diff --git a/src/data.c b/src/data.c
index 903e809d235..141b26ccf35 100644
--- a/src/data.c
+++ b/src/data.c
@@ -270,7 +270,7 @@ for example, (type-of 1) returns `integer'. */)
270 case PVEC_RECORD: 270 case PVEC_RECORD:
271 { 271 {
272 Lisp_Object t = AREF (object, 0); 272 Lisp_Object t = AREF (object, 0);
273 if (RECORDP (t) && 1 < (ASIZE (t) & PSEUDOVECTOR_SIZE_MASK)) 273 if (RECORDP (t) && 1 < PVSIZE (t))
274 /* Return the type name field of the class! */ 274 /* Return the type name field of the class! */
275 return AREF (t, 1); 275 return AREF (t, 1);
276 else 276 else
@@ -902,7 +902,7 @@ Value, if non-nil, is a list (interactive SPEC). */)
902 } 902 }
903 else if (COMPILEDP (fun)) 903 else if (COMPILEDP (fun))
904 { 904 {
905 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE) 905 if (PVSIZE (fun) > COMPILED_INTERACTIVE)
906 return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE)); 906 return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE));
907 } 907 }
908 else if (AUTOLOADP (fun)) 908 else if (AUTOLOADP (fun))
@@ -2306,7 +2306,7 @@ or a byte-code object. IDX starts at 0. */)
2306 if (VECTORP (array)) 2306 if (VECTORP (array))
2307 size = ASIZE (array); 2307 size = ASIZE (array);
2308 else if (COMPILEDP (array) || RECORDP (array)) 2308 else if (COMPILEDP (array) || RECORDP (array))
2309 size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK; 2309 size = PVSIZE (array);
2310 else 2310 else
2311 wrong_type_argument (Qarrayp, array); 2311 wrong_type_argument (Qarrayp, array);
2312 2312
@@ -2349,8 +2349,7 @@ bool-vector. IDX starts at 0. */)
2349 } 2349 }
2350 else if (RECORDP (array)) 2350 else if (RECORDP (array))
2351 { 2351 {
2352 ptrdiff_t size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK; 2352 if (idxval < 0 || idxval >= PVSIZE (array))
2353 if (idxval < 0 || idxval >= size)
2354 args_out_of_range (array, idx); 2353 args_out_of_range (array, idx);
2355 ASET (array, idxval, newelt); 2354 ASET (array, idxval, newelt);
2356 } 2355 }
diff --git a/src/doc.c b/src/doc.c
index 1e7e3fcf6a6..dd674e3bc05 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -342,7 +342,7 @@ string is passed through `substitute-command-keys'. */)
342 doc = make_number (XSUBR (fun)->doc); 342 doc = make_number (XSUBR (fun)->doc);
343 else if (COMPILEDP (fun)) 343 else if (COMPILEDP (fun))
344 { 344 {
345 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING) 345 if (PVSIZE (fun) <= COMPILED_DOC_STRING)
346 return Qnil; 346 return Qnil;
347 else 347 else
348 { 348 {
@@ -500,7 +500,7 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
500 { 500 {
501 /* This bytecode object must have a slot for the 501 /* This bytecode object must have a slot for the
502 docstring, since we've found a docstring for it. */ 502 docstring, since we've found a docstring for it. */
503 if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) 503 if (PVSIZE (fun) > COMPILED_DOC_STRING)
504 ASET (fun, COMPILED_DOC_STRING, make_number (offset)); 504 ASET (fun, COMPILED_DOC_STRING, make_number (offset));
505 else 505 else
506 { 506 {
diff --git a/src/eval.c b/src/eval.c
index 16d1cf810ea..af0912fd14f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1881,8 +1881,7 @@ then strings and vectors are not accepted. */)
1881 have an element whose index is COMPILED_INTERACTIVE, which is 1881 have an element whose index is COMPILED_INTERACTIVE, which is
1882 where the interactive spec is stored. */ 1882 where the interactive spec is stored. */
1883 else if (COMPILEDP (fun)) 1883 else if (COMPILEDP (fun))
1884 return ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE 1884 return (PVSIZE (fun) > COMPILED_INTERACTIVE ? Qt : if_prop);
1885 ? Qt : if_prop);
1886 1885
1887 /* Strings and vectors are keyboard macros. */ 1886 /* Strings and vectors are keyboard macros. */
1888 if (STRINGP (fun) || VECTORP (fun)) 1887 if (STRINGP (fun) || VECTORP (fun))
@@ -2922,7 +2921,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2922 } 2921 }
2923 else if (COMPILEDP (fun)) 2922 else if (COMPILEDP (fun))
2924 { 2923 {
2925 ptrdiff_t size = ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK; 2924 ptrdiff_t size = PVSIZE (fun);
2926 if (size <= COMPILED_STACK_DEPTH) 2925 if (size <= COMPILED_STACK_DEPTH)
2927 xsignal1 (Qinvalid_function, fun); 2926 xsignal1 (Qinvalid_function, fun);
2928 syms_left = AREF (fun, COMPILED_ARGLIST); 2927 syms_left = AREF (fun, COMPILED_ARGLIST);
@@ -3103,7 +3102,7 @@ lambda_arity (Lisp_Object fun)
3103 } 3102 }
3104 else if (COMPILEDP (fun)) 3103 else if (COMPILEDP (fun))
3105 { 3104 {
3106 ptrdiff_t size = ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK; 3105 ptrdiff_t size = PVSIZE (fun);
3107 if (size <= COMPILED_STACK_DEPTH) 3106 if (size <= COMPILED_STACK_DEPTH)
3108 xsignal1 (Qinvalid_function, fun); 3107 xsignal1 (Qinvalid_function, fun);
3109 syms_left = AREF (fun, COMPILED_ARGLIST); 3108 syms_left = AREF (fun, COMPILED_ARGLIST);
@@ -3148,7 +3147,7 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
3148 3147
3149 if (COMPILEDP (object)) 3148 if (COMPILEDP (object))
3150 { 3149 {
3151 ptrdiff_t size = ASIZE (object) & PSEUDOVECTOR_SIZE_MASK; 3150 ptrdiff_t size = PVSIZE (object);
3152 if (size <= COMPILED_STACK_DEPTH) 3151 if (size <= COMPILED_STACK_DEPTH)
3153 xsignal1 (Qinvalid_function, object); 3152 xsignal1 (Qinvalid_function, object);
3154 if (CONSP (AREF (object, COMPILED_BYTECODE))) 3153 if (CONSP (AREF (object, COMPILED_BYTECODE)))
diff --git a/src/fns.c b/src/fns.c
index 2f07c2ccfb7..10d35b6112a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -107,7 +107,7 @@ To get the number of bytes, use `string-bytes'. */)
107 else if (BOOL_VECTOR_P (sequence)) 107 else if (BOOL_VECTOR_P (sequence))
108 XSETFASTINT (val, bool_vector_size (sequence)); 108 XSETFASTINT (val, bool_vector_size (sequence));
109 else if (COMPILEDP (sequence) || RECORDP (sequence)) 109 else if (COMPILEDP (sequence) || RECORDP (sequence))
110 XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK); 110 XSETFASTINT (val, PVSIZE (sequence));
111 else if (CONSP (sequence)) 111 else if (CONSP (sequence))
112 { 112 {
113 intptr_t i = 0; 113 intptr_t i = 0;
@@ -484,8 +484,7 @@ shared with the original. */)
484 484
485 if (RECORDP (arg)) 485 if (RECORDP (arg))
486 { 486 {
487 ptrdiff_t size = ASIZE (arg) & PSEUDOVECTOR_SIZE_MASK; 487 return Frecord (PVSIZE (arg), XVECTOR (arg)->contents);
488 return Frecord (size, XVECTOR (arg)->contents);
489 } 488 }
490 489
491 if (CHAR_TABLE_P (arg)) 490 if (CHAR_TABLE_P (arg))
diff --git a/src/font.h b/src/font.h
index a469b20e4f4..53e3fc21a3d 100644
--- a/src/font.h
+++ b/src/font.h
@@ -424,7 +424,7 @@ FONTP (Lisp_Object x)
424INLINE bool 424INLINE bool
425FONT_SPEC_P (Lisp_Object x) 425FONT_SPEC_P (Lisp_Object x)
426{ 426{
427 return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_SPEC_MAX; 427 return FONTP (x) && PVSIZE (x) == FONT_SPEC_MAX;
428} 428}
429 429
430/* Like FONT_SPEC_P, but can be used in the garbage collector. */ 430/* Like FONT_SPEC_P, but can be used in the garbage collector. */
@@ -438,7 +438,7 @@ GC_FONT_SPEC_P (Lisp_Object x)
438INLINE bool 438INLINE bool
439FONT_ENTITY_P (Lisp_Object x) 439FONT_ENTITY_P (Lisp_Object x)
440{ 440{
441 return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_ENTITY_MAX; 441 return FONTP (x) && PVSIZE (x) == FONT_ENTITY_MAX;
442} 442}
443 443
444/* Like FONT_ENTITY_P, but can be used in the garbage collector. */ 444/* Like FONT_ENTITY_P, but can be used in the garbage collector. */
@@ -452,7 +452,7 @@ GC_FONT_ENTITY_P (Lisp_Object x)
452INLINE bool 452INLINE bool
453FONT_OBJECT_P (Lisp_Object x) 453FONT_OBJECT_P (Lisp_Object x)
454{ 454{
455 return FONTP (x) && (ASIZE (x) & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX; 455 return FONTP (x) && PVSIZE (x) == FONT_OBJECT_MAX;
456} 456}
457 457
458/* Like FONT_OBJECT_P, but can be used in the garbage collector. */ 458/* Like FONT_OBJECT_P, but can be used in the garbage collector. */
diff --git a/src/lisp.h b/src/lisp.h
index 5e7d41bc5d5..678e261c1da 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1401,6 +1401,12 @@ ASIZE (Lisp_Object array)
1401 return size; 1401 return size;
1402} 1402}
1403 1403
1404INLINE ptrdiff_t
1405PVSIZE (Lisp_Object pv)
1406{
1407 return ASIZE (pv) & PSEUDOVECTOR_SIZE_MASK;
1408}
1409
1404INLINE bool 1410INLINE bool
1405VECTORP (Lisp_Object x) 1411VECTORP (Lisp_Object x)
1406{ 1412{
diff --git a/src/lread.c b/src/lread.c
index 513f63e4315..3b2e123dd39 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3402,7 +3402,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj
3402 else if (CHAR_TABLE_P (subtree) || SUB_CHAR_TABLE_P (subtree) 3402 else if (CHAR_TABLE_P (subtree) || SUB_CHAR_TABLE_P (subtree)
3403 || COMPILEDP (subtree) || HASH_TABLE_P (subtree) 3403 || COMPILEDP (subtree) || HASH_TABLE_P (subtree)
3404 || RECORDP (subtree)) 3404 || RECORDP (subtree))
3405 length = ASIZE (subtree) & PSEUDOVECTOR_SIZE_MASK; 3405 length = PVSIZE (subtree);
3406 else if (VECTORP (subtree)) 3406 else if (VECTORP (subtree))
3407 length = ASIZE (subtree); 3407 length = ASIZE (subtree);
3408 else 3408 else
diff --git a/src/print.c b/src/print.c
index 76f263994e6..872103bd4c2 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1966,7 +1966,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1966 1966
1967 case PVEC_RECORD: 1967 case PVEC_RECORD:
1968 { 1968 {
1969 ptrdiff_t n, size = ASIZE (obj) & PSEUDOVECTOR_SIZE_MASK; 1969 ptrdiff_t n, size = PVSIZE (obj);
1970 int i; 1970 int i;
1971 1971
1972 /* Don't print more elements than the specified maximum. */ 1972 /* Don't print more elements than the specified maximum. */