diff options
author | Ralph Boehme <slow@samba.org> | 2019-11-19 11:53:50 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2019-11-27 10:25:37 +0000 |
commit | 24905ba82d2f1b9e01df7a6e03d853c5138bc148 (patch) | |
tree | 5dfec989bd670f101680d1517c456ada1d4292a9 /script/generate_param.py | |
parent | 3e81d9460bf4f0640ef7c679cd539e614929343e (diff) | |
download | samba-24905ba82d2f1b9e01df7a6e03d853c5138bc148.tar.gz |
docs-xml: remove explicit "constant"
The constant mark applied to types "string" and "ustring". The previous patches
in this patchset already markes all string options as either constant or
substituted, but it's still possible to add options or change existing ones to
be neither constant nor substituted.
In order to enforce strings to be either constant or substitued, remove the
explicit constant marker. Instead, any option that is not marked as substituted
is implicitly made constant.
This patch doesn't change behaviour and all generated files are the same before
and after this change.
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'script/generate_param.py')
-rw-r--r-- | script/generate_param.py | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/script/generate_param.py b/script/generate_param.py index 55f2b65271b..c29a29df57e 100644 --- a/script/generate_param.py +++ b/script/generate_param.py @@ -135,10 +135,11 @@ def generate_functions(path_in, path_out): if temp is None: raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) output_string += temp - if parameter['constant']: - output_string += "_CONST" - if parameter['substitution']: - output_string += "_SUBSTITUTED" + if parameter['type'] == "string" or parameter['type'] == "ustring": + if parameter['substitution']: + output_string += "_SUBSTITUTED" + else: + output_string += "_CONST" if parameter['parm']: output_string += "_PARM" temp = param_type_dict.get(parameter['type']) @@ -182,8 +183,6 @@ def make_s3_param_proto(path_in, path_out): continue output_string = "" - if parameter['constant']: - output_string += 'const ' param_type = mapping.get(parameter['type']) if param_type is None: raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) @@ -196,20 +195,21 @@ def make_s3_param_proto(path_in, path_out): else: param = "int" - if parameter['type'] == 'string' and parameter['substitution']: - if parameter['context'] == 'G': - output_string += '(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub);\n' - elif parameter['context'] == 'S': - output_string += '(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub, %s);\n' % param - else: - raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) - elif parameter['type'] == 'string' and not parameter['constant']: - if parameter['context'] == 'G': - output_string += '(TALLOC_CTX *ctx);\n' - elif parameter['context'] == 'S': - output_string += '(TALLOC_CTX *ctx, %s);\n' % param + if parameter['type'] == 'string' or parameter['type'] == 'ustring': + if parameter['substitution']: + if parameter['context'] == 'G': + output_string += '(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub);\n' + elif parameter['context'] == 'S': + output_string += '(TALLOC_CTX *ctx, const struct loadparm_substitution *lp_sub, %s);\n' % param + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) else: - raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) + if parameter['context'] == 'G': + output_string = 'const ' + output_string + '(void);\n' + elif parameter['context'] == 'S': + output_string = 'const ' + output_string + '(%s);\n' % param + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) else: if parameter['context'] == 'G': output_string += '(void);\n' @@ -239,8 +239,6 @@ def make_lib_proto(path_in, path_out): continue output_string = "" - if parameter['constant']: - output_string += 'const ' param_type = mapping.get(parameter['type']) if param_type is None: raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) @@ -248,20 +246,21 @@ def make_lib_proto(path_in, path_out): output_string += "lpcfg_%s" % parameter['function'] - if parameter['type'] == 'string' and parameter['substitution']: - if parameter['context'] == 'G': - output_string += '(struct loadparm_context *, const struct loadparm_substitution *lp_sub, TALLOC_CTX *ctx);\n' - elif parameter['context'] == 'S': - output_string += '(struct loadparm_service *, struct loadparm_service *, TALLOC_CTX *ctx);\n' + if parameter['type'] == 'string' or parameter['type'] == 'ustring': + if parameter['substitution']: + if parameter['context'] == 'G': + output_string += '(struct loadparm_context *, const struct loadparm_substitution *lp_sub, TALLOC_CTX *ctx);\n' + elif parameter['context'] == 'S': + output_string += '(struct loadparm_service *, struct loadparm_service *, TALLOC_CTX *ctx);\n' + else: + raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) else: - raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) - elif parameter['type'] == 'string' and not parameter['constant']: - if parameter['context'] == 'G': - output_string += '(struct loadparm_context *, TALLOC_CTX *ctx);\n' - elif parameter['context'] == 'S': - output_string += '(struct loadparm_service *, struct loadparm_service *, TALLOC_CTX *ctx);\n' - else: - raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) + if parameter['context'] == 'G': + output_string = 'const ' + output_string + '(struct loadparm_context *);\n' + elif parameter['context'] == 'S': + output_string = 'const ' + output_string + '(struct loadparm_service *, struct loadparm_service *);\n' + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) else: if parameter['context'] == 'G': output_string += '(struct loadparm_context *);\n' |