From 23973af0db04c300f45ba021289d7b2befee6385 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Wed, 28 Aug 2024 18:10:05 -0400 Subject: [PATCH] Props metadata: fixes, namespacing, sorting Signed-off-by: Gary Oberbrunner --- include/ofx-props.yml | 8 +++++--- scripts/gen-props.py | 18 +++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/ofx-props.yml b/include/ofx-props.yml index 34b06b9d..6edf6e70 100644 --- a/include/ofx-props.yml +++ b/include/ofx-props.yml @@ -617,9 +617,9 @@ properties: dimension: 1 writable: host values: - kOfxImageEffectHostPropNativeOriginBottomLeft - kOfxImageEffectHostPropNativeOriginTopLeft - kOfxImageEffectHostPropNativeOriginCenter + - kOfxImageEffectHostPropNativeOriginBottomLeft + - kOfxImageEffectHostPropNativeOriginTopLeft + - kOfxImageEffectHostPropNativeOriginCenter kOfxImageEffectInstancePropEffectDuration: type: double dimension: 1 @@ -739,9 +739,11 @@ properties: kOfxImageEffectPropOpenCLImage: type: int dimension: 1 + writable: host kOfxImageEffectPropOpenCLSupported: type: enum dimension: 1 + writable: all values: - "false" - "true" diff --git a/scripts/gen-props.py b/scripts/gen-props.py index 940bc902..9c4ba19e 100644 --- a/scripts/gen-props.py +++ b/scripts/gen-props.py @@ -169,6 +169,7 @@ def gen_props_metadata(props_metadata, outfile_path: Path): #include "ofxKeySyms.h" #include "ofxOld.h" +namespace OpenFX { enum class PropType { Int, Double, @@ -191,12 +192,12 @@ def gen_props_metadata(props_metadata, outfile_path: Path): int dimension; Writable writable; bool host_optional; - std::vector values; // for enums + std::vector values; // for enums }; """) outfile.write("const std::vector props_metadata {\n") - for p in props_metadata: + for p in sorted(props_metadata): try: md = props_metadata[p] types = md.get('type') @@ -210,7 +211,8 @@ def gen_props_metadata(props_metadata, outfile_path: Path): if host_opt in ('False', 'false', 0): host_opt = 'false' if md['type'] == 'enum': - values = "{" + ",".join(f'"{v}"' for v in md['values']) + "}" + assert isinstance(md['values'], list) + values = "{" + ",".join(f'{v}' for v in md['values']) + "}" else: values = "{}" outfile.write(f"{{ {p}, {prop_type_defs}, {md['dimension']}, " @@ -218,7 +220,7 @@ def gen_props_metadata(props_metadata, outfile_path: Path): except Exception as e: logging.error(f"Error: {p} is missing metadata? {e}") raise(e) - outfile.write("};\n") + outfile.write("};\n} // namespace OpenFX\n") def gen_props_by_set(props_by_set, outfile_path: Path): """Generate a header file with definitions of all prop sets, including their props""" @@ -235,12 +237,13 @@ def gen_props_by_set(props_by_set, outfile_path: Path): #include "ofxKeySyms.h" #include "ofxOld.h" +namespace OpenFX { """) - outfile.write("const std::map> prop_sets {\n") + outfile.write("const std::map> prop_sets {\n") for pset in sorted(props_by_set.keys()): - propnames = ",".join(props_by_set[pset]) + propnames = ",\n ".join(sorted(props_by_set[pset])) outfile.write(f"{{ \"{pset}\", {{ {propnames} }} }},\n") - outfile.write("};\n") + outfile.write("};\n} // namespace OpenFX\n") def main(args): script_dir = os.path.dirname(os.path.abspath(__file__)) @@ -275,6 +278,7 @@ def main(args): if args.verbose: print("=== Generating gen_props_metadata.hxx") gen_props_metadata(props_metadata, include_dir / 'gen_props_metadata.hxx') + if args.verbose: print("=== Generating props by set header gen_props_by_set.hxx") gen_props_by_set(props_by_set, include_dir / 'gen_props_by_set.hxx')