summaryrefslogtreecommitdiff
path: root/dist/api_config.py
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2015-03-12 13:50:54 -0400
committerKeith Bostic <keith@wiredtiger.com>2015-03-12 13:50:54 -0400
commit3e384a74e6e02793e983a232a7bb64d6d358eeff (patch)
tree6dd9e8f021e2d36bfa69f62e5972ad405487427d /dist/api_config.py
parent4bdadc781d442f2ecd230418805239c5f79adf40 (diff)
downloadmongo-3e384a74e6e02793e983a232a7bb64d6d358eeff.tar.gz
Add support for calling functions to validate configuration values,
reference #1536, #1739.
Diffstat (limited to 'dist/api_config.py')
-rw-r--r--dist/api_config.py15
1 files changed, 9 insertions, 6 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('.', '_'),