aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorPaul Pogonyshev2016-03-26 11:19:43 +0300
committerEli Zaretskii2016-03-26 11:19:43 +0300
commit6f3243db55e61847784178ea812f28ddf003544a (patch)
treee2bbb4e4c3a49ab661524135c6b1a610580431b8 /src/bytecode.c
parent368b9bb45f125061506d43af4bd4791ab2cfd7b9 (diff)
downloademacs-6f3243db55e61847784178ea812f28ddf003544a.tar.gz
emacs-6f3243db55e61847784178ea812f28ddf003544a.zip
Implement 'func-arity'
* src/eval.c (Ffunc_arity, lambda_arity): New functions. * src/bytecode.c (get_byte_code_arity): New function. * src/lisp.h (get_byte_code_arity): Add prototype. * doc/lispref/functions.texi (What Is a Function): Document 'func-arity'. * etc/NEWS: Mention 'func-arity'. * test/src/fns-tests.el (fns-tests-func-arity): New test set.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 9ae2e820d51..4ff15d2912a 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1987,6 +1987,24 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1987 return result; 1987 return result;
1988} 1988}
1989 1989
1990/* `args_template' has the same meaning as in exec_byte_code() above. */
1991Lisp_Object
1992get_byte_code_arity (Lisp_Object args_template)
1993{
1994 if (INTEGERP (args_template))
1995 {
1996 ptrdiff_t at = XINT (args_template);
1997 bool rest = (at & 128) != 0;
1998 int mandatory = at & 127;
1999 ptrdiff_t nonrest = at >> 8;
2000
2001 return Fcons (make_number (mandatory),
2002 rest ? Qmany : make_number (nonrest));
2003 }
2004 else
2005 error ("Unknown args template!");
2006}
2007
1990void 2008void
1991syms_of_bytecode (void) 2009syms_of_bytecode (void)
1992{ 2010{