diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-03-12 13:50:54 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2015-03-12 13:50:54 -0400 |
commit | 3e384a74e6e02793e983a232a7bb64d6d358eeff (patch) | |
tree | 6dd9e8f021e2d36bfa69f62e5972ad405487427d /dist | |
parent | 4bdadc781d442f2ecd230418805239c5f79adf40 (diff) | |
download | mongo-3e384a74e6e02793e983a232a7bb64d6d358eeff.tar.gz |
Add support for calling functions to validate configuration values,
reference #1536, #1739.
Diffstat (limited to 'dist')
-rw-r--r-- | dist/api_config.py | 15 | ||||
-rw-r--r-- | dist/api_data.py | 6 | ||||
-rw-r--r-- | dist/s_string.ok | 1 |
3 files changed, 14 insertions, 8 deletions
diff --git a/dist/api_config.py b/dist/api_config.py index 83a57ad4e0d..5608933defb 100644 --- a/dist/api_config.py +++ b/dist/api_config.py @@ -165,9 +165,12 @@ w = textwrap.TextWrapper(width=64, break_on_hyphens=False) w.wordsep_re = w.wordsep_simple_re = re.compile(r'(,)') def checkstr(c): - '''Generate the JSON string used by __wt_config_check to validate the - config string''' + '''Generate the function reference and JSON string used by __wt_config_check + to validate the config string''' checks = c.flags + cfunc = str(checks.get('func', '')) + if not cfunc: + cfunc = 'NULL'; cmin = str(checks.get('min', '')) cmax = str(checks.get('max', '')) choices = checks.get('choices', []) @@ -180,9 +183,9 @@ def checkstr(c): result.append('choices=' + '[' + ','.join('\\"' + s + '\\"' for s in choices) + ']') if result: - return '"' + ','.join(result) + '"' + return cfunc + ', "' + ','.join(result) + '"' else: - return 'NULL' + return cfunc + ', NULL' def get_default(c): t = gettype(c) @@ -206,7 +209,7 @@ def add_subconfig(c): tfile.write(''' static const WT_CONFIG_CHECK confchk_%(name)s_subconfigs[] = { \t%(check)s -\t{ NULL, NULL, NULL, NULL } +\t{ NULL, NULL, NULL, NULL, NULL } }; ''' % { 'name' : c.name, @@ -230,7 +233,7 @@ for name in sorted(api_data.methods.keys()): tfile.write(''' static const WT_CONFIG_CHECK confchk_%(name)s[] = { \t%(check)s -\t{ NULL, NULL, NULL, NULL } +\t{ NULL, NULL, NULL, NULL, NULL } }; ''' % { 'name' : name.replace('.', '_'), diff --git a/dist/api_data.py b/dist/api_data.py index feb51011309..c7ba43b8a09 100644 --- a/dist/api_data.py +++ b/dist/api_data.py @@ -163,11 +163,13 @@ file_config = format_meta + [ Config('huffman_key', 'none', r''' configure Huffman encoding for keys. Permitted values are \c "none", \c "english", \c "utf8<file>" or \c "utf16<file>". - See @ref huffman for more information'''), + See @ref huffman for more information''', + func='__wt_huffman_confchk'), Config('huffman_value', 'none', r''' configure Huffman encoding for values. Permitted values are \c "none", \c "english", \c "utf8<file>" or \c "utf16<file>". - See @ref huffman for more information'''), + See @ref huffman for more information''', + func='__wt_huffman_confchk'), Config('internal_key_truncate', 'true', r''' configure internal key truncation, discarding unnecessary trailing bytes on internal keys (ignored for custom diff --git a/dist/s_string.ok b/dist/s_string.ok index 15b572bd933..4b3a7db760b 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -495,6 +495,7 @@ compat concat cond conf +confchk config conn connectionp |