Mercurial > hg > xemacs-beta
comparison src/elhash.c @ 5084:6afe991b8135
Add a PARSE_KEYWORDS macro, use it in #'make-hash-table.
lisp/ChangeLog addition:
2010-03-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el (cl-parsing-keywords):
* cl-macs.el (cl-do-arglist):
Use the new invalid-keyword-argument error here.
src/ChangeLog addition:
2010-03-01 Aidan Kehoe <kehoea@parhasard.net>
* lisp.h (PARSE_KEYWORDS): New macro, for parsing keyword
arguments from C subrs.
* elhash.c (Fmake_hash_table): Use it.
* general-slots.h (Q_allow_other_keys): Add this symbol.
* eval.c (non_nil_allow_other_keys_p):
(invalid_keyword_argument):
New functions, called from the keyword argument parsing code.
* data.c (init_errors_once_early):
Add the new invalid-keyword-argument error here.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 01 Mar 2010 21:05:33 +0000 |
parents | 16112448d484 |
children | 7be849cb8828 |
comparison
equal
deleted
inserted
replaced
5083:88f955fa5a7f | 5084:6afe991b8135 |
---|---|
82 #include "bytecode.h" | 82 #include "bytecode.h" |
83 #include "elhash.h" | 83 #include "elhash.h" |
84 #include "opaque.h" | 84 #include "opaque.h" |
85 | 85 |
86 Lisp_Object Qhash_tablep; | 86 Lisp_Object Qhash_tablep; |
87 static Lisp_Object Qhashtable, Qhash_table; | 87 static Lisp_Object Qhashtable, Qhash_table, Qmake_hash_table; |
88 static Lisp_Object Qweakness, Qvalue, Qkey_or_value, Qkey_and_value; | 88 static Lisp_Object Qweakness, Qvalue, Qkey_or_value, Qkey_and_value; |
89 static Lisp_Object Vall_weak_hash_tables; | 89 static Lisp_Object Vall_weak_hash_tables; |
90 static Lisp_Object Qrehash_size, Qrehash_threshold; | 90 static Lisp_Object Qrehash_size, Qrehash_threshold; |
91 static Lisp_Object Q_size, Q_test, Q_weakness, Q_rehash_size, Q_rehash_threshold; | 91 static Lisp_Object Q_size, Q_test, Q_weakness, Q_rehash_size, Q_rehash_threshold; |
92 | 92 |
991 | 991 |
992 arguments: (&key TEST SIZE REHASH-SIZE REHASH-THRESHOLD WEAKNESS) | 992 arguments: (&key TEST SIZE REHASH-SIZE REHASH-THRESHOLD WEAKNESS) |
993 */ | 993 */ |
994 (int nargs, Lisp_Object *args)) | 994 (int nargs, Lisp_Object *args)) |
995 { | 995 { |
996 int i = 0; | 996 #ifdef NO_NEED_TO_HANDLE_21_4_CODE |
997 Lisp_Object test = Qnil; | 997 PARSE_KEYWORDS (Qmake_hash_table, nargs, args, 0, 5, |
998 Lisp_Object size = Qnil; | 998 (test, size, rehash_size, rehash_threshold, weakness), |
999 Lisp_Object rehash_size = Qnil; | 999 NULL, weakness = Qunbound), 0); |
1000 Lisp_Object rehash_threshold = Qnil; | 1000 #else |
1001 Lisp_Object weakness = Qnil; | 1001 PARSE_KEYWORDS (Qmake_hash_table, nargs, args, 0, 6, |
1002 | 1002 (test, size, rehash_size, rehash_threshold, weakness, |
1003 while (i + 1 < nargs) | 1003 type), (type = Qunbound, weakness = Qunbound), 0); |
1004 { | 1004 |
1005 Lisp_Object keyword = args[i++]; | 1005 if (EQ (weakness, Qunbound)) |
1006 Lisp_Object value = args[i++]; | 1006 { |
1007 | 1007 if (EQ (weakness, Qunbound) && !EQ (type, Qunbound)) |
1008 if (EQ (keyword, Q_test)) test = value; | 1008 { |
1009 else if (EQ (keyword, Q_size)) size = value; | 1009 weakness = type; |
1010 else if (EQ (keyword, Q_rehash_size)) rehash_size = value; | 1010 } |
1011 else if (EQ (keyword, Q_rehash_threshold)) rehash_threshold = value; | 1011 else |
1012 else if (EQ (keyword, Q_weakness)) weakness = value; | 1012 { |
1013 else if (EQ (keyword, Q_type))/*obsolete*/ weakness = value; | 1013 weakness = Qnil; |
1014 else invalid_constant ("Invalid hash table property keyword", keyword); | 1014 } |
1015 } | 1015 } |
1016 | 1016 #endif |
1017 if (i < nargs) | |
1018 sferror ("Hash table property requires a value", args[i]); | |
1019 | 1017 |
1020 #define VALIDATE_VAR(var) \ | 1018 #define VALIDATE_VAR(var) \ |
1021 if (!NILP (var)) hash_table_##var##_validate (Q##var, var, ERROR_ME); | 1019 if (!NILP (var)) hash_table_##var##_validate (Q##var, var, ERROR_ME); |
1022 | 1020 |
1023 VALIDATE_VAR (test); | 1021 VALIDATE_VAR (test); |
1852 #endif | 1850 #endif |
1853 | 1851 |
1854 DEFSYMBOL_MULTIWORD_PREDICATE (Qhash_tablep); | 1852 DEFSYMBOL_MULTIWORD_PREDICATE (Qhash_tablep); |
1855 DEFSYMBOL (Qhash_table); | 1853 DEFSYMBOL (Qhash_table); |
1856 DEFSYMBOL (Qhashtable); | 1854 DEFSYMBOL (Qhashtable); |
1855 DEFSYMBOL (Qmake_hash_table); | |
1857 DEFSYMBOL (Qweakness); | 1856 DEFSYMBOL (Qweakness); |
1858 DEFSYMBOL (Qvalue); | 1857 DEFSYMBOL (Qvalue); |
1859 DEFSYMBOL (Qkey_or_value); | 1858 DEFSYMBOL (Qkey_or_value); |
1860 DEFSYMBOL (Qkey_and_value); | 1859 DEFSYMBOL (Qkey_and_value); |
1861 DEFSYMBOL (Qrehash_size); | 1860 DEFSYMBOL (Qrehash_size); |