diff --git a/Documentation/build.sh b/Documentation/build.sh index 9c05d371..79483efa 100755 --- a/Documentation/build.sh +++ b/Documentation/build.sh @@ -37,7 +37,7 @@ python genPropertiesReference.py \ > /tmp/ofx-doc-build.out 2>&1 egrep -v "$EXPECTED_ERRS" /tmp/ofx-doc-build.out || true -# Build the Doxygen docs +# Build the Doxygen docs into $TOP/Documentation/doxygen_build EXPECTED_ERRS="malformed hyperlink target|Duplicate explicit|Definition list ends|unable to resolve|could not be resolved" cd ../include doxygen ofx.doxy > /tmp/ofx-doc-build.out 2>&1 diff --git a/Documentation/genPropertiesReference.py b/Documentation/genPropertiesReference.py index 13451b79..d594ddc4 100755 --- a/Documentation/genPropertiesReference.py +++ b/Documentation/genPropertiesReference.py @@ -2,67 +2,86 @@ badlyNamedProperties = ["kOfxImageEffectFrameVarying", "kOfxImageEffectPluginRenderThreadSafety"] -def getPropertiesFromDir(sourcePath, recursive, props): +def getPropertiesFromFile(path): + """Get all OpenFX property definitions from C header file. - if os.path.isdir(sourcePath): - files=sorted(os.listdir(sourcePath)) - for f in files: - absF = sourcePath + '/' + f - if not recursive and os.path.isdir(absF): + Uses a heuristic to identify property #define lines: + anything starting with '#define' and containing 'Prop' in the name. + """ + props = set() + with open(path) as f: + try: + lines = f.readlines() + except UnicodeDecodeError as e: + logging.error(f'error reading {path}: {e}') + raise e + for l in lines: + # Detect lines that correspond to a property definition, e.g: + # #define kOfxPropLala "OfxPropLala" + splits=l.split() + if len(splits) < 3: continue - else: - getPropertiesFromDir(absF,recursive,props) - elif os.path.isfile(sourcePath): - ext = os.path.splitext(sourcePath)[1] - if ext.lower() in ('.c', '.cxx', '.cpp', '.h', '.hxx', '.hpp'): - with open(sourcePath) as f: - try: - lines = f.readlines() - except UnicodeDecodeError as e: - print('WARNING: error in', sourcePath, ':') - raise e - for l in lines: - # Detect lines that correspond to a property definition, e.g: - # #define kOfxPropLala "OfxPropLala" - splits=l.split(' ') - if len(splits) != 3: - continue - if splits[0] != '#define': - continue - if 'Prop' in splits[1] and splits[1] != 'kOfxPropertySuite': - #if l.startswith('#define kOfx') and 'Prop' in l: - props.append(splits[1]) - else: - raise ValueError('No such file or directory: %s' % sourcePath) + if splits[0] != '#define': + continue + # ignore these + nonProperties = ('kOfxPropertySuite', + # prop values, not props + 'kOfxImageEffectPropColourManagementNone', + 'kOfxImageEffectPropColourManagementBasic', + 'kOfxImageEffectPropColourManagementCore', + 'kOfxImageEffectPropColourManagementFull', + 'kOfxImageEffectPropColourManagementOCIO', + ) + if splits[1] in nonProperties: + continue + # these are props, as well as anything with Prop in the name + badlyNamedProperties = ("kOfxImageEffectFrameVarying", + "kOfxImageEffectPluginRenderThreadSafety") + if 'Prop' in splits[1] \ + or any(s in splits[1] for s in badlyNamedProperties): + props.add(splits[1]) + return props + +def getPropertiesFromDir(dir): + """ + Recursively get all property definitions from source files in a dir. + """ + + extensions = {'.c', '.h', '.cxx', '.hxx', '.cpp', '.hpp'} + + props = set() + for root, _dirs, files in os.walk(dir): + for file in files: + # Get the file extension + file_extension = os.path.splitext(file)[1] + + if file_extension in extensions: + file_path = os.path.join(root, file) + props |= getPropertiesFromFile(file_path) + return list(props) def main(argv): - recursive=False sourcePath='' outputFile='' try: - opts, args = getopt.getopt(argv,"i:o:r",["sourcePath=","outputFile","recursive"]) + opts, args = getopt.getopt(argv,"i:o:r",["sourcePath=","outputFile"]) for opt,value in opts: if opt == "-i": sourcePath = value elif opt == "-o": outputFile = value - elif opt == "-r": - recursive=True except getopt.GetoptError: sys.exit(1) - props=badlyNamedProperties - getPropertiesFromDir(sourcePath, recursive, props) + props = getPropertiesFromDir(sourcePath) - re='/^#define k[\w_]*Ofx[\w_]*Prop/' with open(outputFile, 'w') as f: f.write('.. _propertiesReference:\n') f.write('Properties Reference\n') f.write('=====================\n') - props.sort() - for p in props: + for p in sorted(props): f.write('.. doxygendefine:: ' + p + '\n\n') if __name__ == "__main__": diff --git a/Documentation/sources/Reference/ofxPropertiesReference.rst b/Documentation/sources/Reference/ofxPropertiesReference.rst index c38454c2..ef8ff53e 100644 --- a/Documentation/sources/Reference/ofxPropertiesReference.rst +++ b/Documentation/sources/Reference/ofxPropertiesReference.rst @@ -1,6 +1,8 @@ .. _propertiesReference: Properties Reference ===================== +.. doxygendefine:: kOfxImageClipPropColourspace + .. doxygendefine:: kOfxImageClipPropConnected .. doxygendefine:: kOfxImageClipPropContinuousSamples @@ -13,6 +15,8 @@ Properties Reference .. doxygendefine:: kOfxImageClipPropOptional +.. doxygendefine:: kOfxImageClipPropPreferredColourspaces + .. doxygendefine:: kOfxImageClipPropUnmappedComponents .. doxygendefine:: kOfxImageClipPropUnmappedPixelDepth @@ -21,6 +25,8 @@ Properties Reference .. doxygendefine:: kOfxImageEffectHostPropIsBackground +.. doxygendefine:: kOfxImageEffectHostPropNativeOrigin + .. doxygendefine:: kOfxImageEffectInstancePropEffectDuration .. doxygendefine:: kOfxImageEffectInstancePropSequentialRender @@ -41,6 +47,12 @@ Properties Reference .. doxygendefine:: kOfxImageEffectPropClipPreferencesSlaveParam +.. doxygendefine:: kOfxImageEffectPropColourManagementAvailableConfigs + +.. doxygendefine:: kOfxImageEffectPropColourManagementConfig + +.. doxygendefine:: kOfxImageEffectPropColourManagementStyle + .. doxygendefine:: kOfxImageEffectPropComponents .. doxygendefine:: kOfxImageEffectPropContext @@ -53,6 +65,8 @@ Properties Reference .. doxygendefine:: kOfxImageEffectPropCudaStreamSupported +.. doxygendefine:: kOfxImageEffectPropDisplayColourspace + .. doxygendefine:: kOfxImageEffectPropFieldToRender .. doxygendefine:: kOfxImageEffectPropFrameRange @@ -71,12 +85,22 @@ Properties Reference .. doxygendefine:: kOfxImageEffectPropMetalRenderSupported +.. doxygendefine:: kOfxImageEffectPropOCIOConfig + +.. doxygendefine:: kOfxImageEffectPropOCIODisplay + +.. doxygendefine:: kOfxImageEffectPropOCIOView + .. doxygendefine:: kOfxImageEffectPropOpenCLCommandQueue .. doxygendefine:: kOfxImageEffectPropOpenCLEnabled +.. doxygendefine:: kOfxImageEffectPropOpenCLImage + .. doxygendefine:: kOfxImageEffectPropOpenCLRenderSupported +.. doxygendefine:: kOfxImageEffectPropOpenCLSupported + .. doxygendefine:: kOfxImageEffectPropOpenGLEnabled .. doxygendefine:: kOfxImageEffectPropOpenGLRenderSupported @@ -285,6 +309,8 @@ Properties Reference .. doxygendefine:: kOfxParamPropShowTimeMarker +.. doxygendefine:: kOfxParamPropStringFilePathExists + .. doxygendefine:: kOfxParamPropStringMode .. doxygendefine:: kOfxParamPropType diff --git a/include/ofx-props.yml b/include/ofx-props.yml new file mode 100644 index 00000000..34b06b9d --- /dev/null +++ b/include/ofx-props.yml @@ -0,0 +1,1225 @@ +######################################################################## +# All OpenFX properties. +######################################################################## + +# List all properties by property-set, and then metadata for each +# property. + +propertySets: + General: + - kOfxPropTime + ImageEffectHost: + - kOfxPropAPIVersion + - kOfxPropType + - kOfxPropName + - kOfxPropLabel + - kOfxPropVersion + - kOfxPropVersionLabel + - kOfxImageEffectHostPropIsBackground + - kOfxImageEffectPropSupportsOverlays + - kOfxImageEffectPropSupportsMultiResolution + - kOfxImageEffectPropSupportsTiles + - kOfxImageEffectPropTemporalClipAccess + - kOfxImageEffectPropSupportedComponents + - kOfxImageEffectPropSupportedContexts + - kOfxImageEffectPropSupportsMultipleClipDepths + - kOfxImageEffectPropSupportsMultipleClipPARs + - kOfxImageEffectPropSetableFrameRate + - kOfxImageEffectPropSetableFielding + - kOfxParamHostPropSupportsCustomInteract + - kOfxParamHostPropSupportsStringAnimation + - kOfxParamHostPropSupportsChoiceAnimation + - kOfxParamHostPropSupportsBooleanAnimation + - kOfxParamHostPropSupportsCustomAnimation + - kOfxParamHostPropMaxParameters + - kOfxParamHostPropMaxPages + - kOfxParamHostPropPageRowColumnCount + - kOfxPropHostOSHandle + - kOfxParamHostPropSupportsParametricAnimation + - kOfxImageEffectInstancePropSequentialRender + - kOfxImageEffectPropOpenGLRenderSupported + - kOfxImageEffectPropRenderQualityDraft + - kOfxImageEffectHostPropNativeOrigin + EffectDescriptor: + - kOfxPropType + - kOfxPropLabel + - kOfxPropShortLabel + - kOfxPropLongLabel + - kOfxPropVersion + - kOfxPropVersionLabel + - kOfxPropPluginDescription + - kOfxImageEffectPropSupportedContexts + - kOfxImageEffectPluginPropGrouping + - kOfxImageEffectPluginPropSingleInstance + - kOfxImageEffectPluginRenderThreadSafety + - kOfxImageEffectPluginPropHostFrameThreading + - kOfxImageEffectPluginPropOverlayInteractV1 + - kOfxImageEffectPropSupportsMultiResolution + - kOfxImageEffectPropSupportsTiles + - kOfxImageEffectPropTemporalClipAccess + - kOfxImageEffectPropSupportedPixelDepths + - kOfxImageEffectPluginPropFieldRenderTwiceAlways + - kOfxImageEffectPropSupportsMultipleClipDepths + - kOfxImageEffectPropSupportsMultipleClipPARs + - kOfxImageEffectPluginRenderThreadSafety + - kOfxImageEffectPropClipPreferencesSlaveParam + - kOfxImageEffectPropOpenGLRenderSupported + - kOfxPluginPropFilePath + ImageEffectHost: + - kOfxPropAPIVersion + - kOfxPropType + - kOfxPropName + - kOfxPropLabel + - kOfxPropVersion + - kOfxPropVersionLabel + - kOfxImageEffectHostPropIsBackground + - kOfxImageEffectPropSupportsOverlays + - kOfxImageEffectPropSupportsMultiResolution + - kOfxImageEffectPropSupportsTiles + - kOfxImageEffectPropTemporalClipAccess + - kOfxImageEffectPropSupportedComponents + - kOfxImageEffectPropSupportedContexts + - kOfxImageEffectPropSupportsMultipleClipDepths + - kOfxImageEffectPropSupportsMultipleClipPARs + - kOfxImageEffectPropSetableFrameRate + - kOfxImageEffectPropSetableFielding + - kOfxParamHostPropSupportsCustomInteract + - kOfxParamHostPropSupportsStringAnimation + - kOfxParamHostPropSupportsChoiceAnimation + - kOfxParamHostPropSupportsBooleanAnimation + - kOfxParamHostPropSupportsCustomAnimation + - kOfxParamHostPropMaxParameters + - kOfxParamHostPropMaxPages + - kOfxParamHostPropPageRowColumnCount + - kOfxPropHostOSHandle + - kOfxParamHostPropSupportsParametricAnimation + - kOfxImageEffectInstancePropSequentialRender + - kOfxImageEffectPropOpenGLRenderSupported + - kOfxImageEffectPropRenderQualityDraft + - kOfxImageEffectHostPropNativeOrigin + EffectDescriptor: + - kOfxPropType + - kOfxPropLabel + - kOfxPropShortLabel + - kOfxPropLongLabel + - kOfxPropVersion + - kOfxPropVersionLabel + - kOfxPropPluginDescription + - kOfxImageEffectPropSupportedContexts + - kOfxImageEffectPluginPropGrouping + - kOfxImageEffectPluginPropSingleInstance + - kOfxImageEffectPluginRenderThreadSafety + - kOfxImageEffectPluginPropHostFrameThreading + - kOfxImageEffectPluginPropOverlayInteractV1 + - kOfxImageEffectPropSupportsMultiResolution + - kOfxImageEffectPropSupportsTiles + - kOfxImageEffectPropTemporalClipAccess + - kOfxImageEffectPropSupportedPixelDepths + - kOfxImageEffectPluginPropFieldRenderTwiceAlways + - kOfxImageEffectPropSupportsMultipleClipDepths + - kOfxImageEffectPropSupportsMultipleClipPARs + - kOfxImageEffectPluginRenderThreadSafety + - kOfxImageEffectPropClipPreferencesSlaveParam + - kOfxImageEffectPropOpenGLRenderSupported + - kOfxPluginPropFilePath + EffectInstance: + - kOfxPropType + - kOfxImageEffectPropContext + - kOfxPropInstanceData + - kOfxImageEffectPropProjectSize + - kOfxImageEffectPropProjectOffset + - kOfxImageEffectPropProjectExtent + - kOfxImageEffectPropProjectPixelAspectRatio + - kOfxImageEffectInstancePropEffectDuration + - kOfxImageEffectInstancePropSequentialRender + - kOfxImageEffectPropSupportsTiles + - kOfxImageEffectPropOpenGLRenderSupported + - kOfxImageEffectPropFrameRate + - kOfxPropIsInteractive + + ClipDescriptor: + - kOfxPropType + - kOfxPropName + - kOfxPropLabel + - kOfxPropShortLabel + - kOfxPropLongLabel + - kOfxImageEffectPropSupportedComponents + - kOfxImageEffectPropTemporalClipAccess + - kOfxImageClipPropOptional + - kOfxImageClipPropFieldExtraction + - kOfxImageClipPropIsMask + - kOfxImageEffectPropSupportsTiles + + ClipInstance: + + - kOfxPropType + - kOfxPropName + - kOfxPropLabel + - kOfxPropShortLabel + - kOfxPropLongLabel + - kOfxImageEffectPropSupportedComponents + - kOfxImageEffectPropTemporalClipAccess + - kOfxImageClipPropColourspace + - kOfxImageClipPropPreferredColourspaces + - kOfxImageClipPropOptional + - kOfxImageClipPropFieldExtraction + - kOfxImageClipPropIsMask + - kOfxImageEffectPropSupportsTiles + - kOfxImageEffectPropPixelDepth + - kOfxImageEffectPropComponents + - kOfxImageClipPropUnmappedPixelDepth + - kOfxImageClipPropUnmappedComponents + - kOfxImageEffectPropPreMultiplication + - kOfxImagePropPixelAspectRatio + - kOfxImageEffectPropFrameRate + - kOfxImageEffectPropFrameRange + - kOfxImageClipPropFieldOrder + - kOfxImageClipPropConnected + - kOfxImageEffectPropUnmappedFrameRange + - kOfxImageEffectPropUnmappedFrameRate + - kOfxImageClipPropContinuousSamples + + Image: + + - kOfxPropType + - kOfxImageEffectPropPixelDepth + - kOfxImageEffectPropComponents + - kOfxImageEffectPropPreMultiplication + - kOfxImageEffectPropRenderScale + - kOfxImagePropPixelAspectRatio + - kOfxImagePropData + - kOfxImagePropBounds + - kOfxImagePropRegionOfDefinition + - kOfxImagePropRowBytes + - kOfxImagePropField + - kOfxImagePropUniqueIdentifier + + ParameterSet: + - kOfxPropParamSetNeedsSyncing + + ParamsCommon_DEF: + - kOfxPropType + - kOfxPropName + - kOfxPropLabel + - kOfxPropShortLabel + - kOfxPropLongLabel + - kOfxParamPropType + - kOfxParamPropSecret + - kOfxParamPropHint + - kOfxParamPropScriptName + - kOfxParamPropParent + - kOfxParamPropEnabled + - kOfxParamPropDataPtr + - kOfxPropIcon + ParamsAllButGroupPage_DEF: + - kOfxParamPropInteractV1 + - kOfxParamPropInteractSize + - kOfxParamPropInteractSizeAspect + - kOfxParamPropInteractMinimumSize + - kOfxParamPropInteractPreferedSize + - kOfxParamPropHasHostOverlayHandle + - kOfxParamPropUseHostOverlayHandle + ParamsValue_DEF: + - kOfxParamPropDefault + - kOfxParamPropAnimates + - kOfxParamPropIsAnimating + - kOfxParamPropIsAutoKeying + - kOfxParamPropPersistant + - kOfxParamPropEvaluateOnChange + - kOfxParamPropPluginMayWrite + - kOfxParamPropCacheInvalidation + - kOfxParamPropCanUndo + ParamsNumeric_DEF: + - kOfxParamPropMin + - kOfxParamPropMax + - kOfxParamPropDisplayMin + - kOfxParamPropDisplayMax + ParamsDouble_DEF: + - kOfxParamPropIncrement + - kOfxParamPropDigits + + ParamsGroup: + - kOfxParamPropGroupOpen + - ParamsCommon_REF + + ParamDouble1D: + - kOfxParamPropShowTimeMarker + - kOfxParamPropDoubleType + - ParamsCommon_REF + - ParamsAllButGroupPage_REF + - ParamsValue_REF + - ParamsNumeric_REF + - ParamsDouble_REF + + ParamsDouble2D3D: + - kOfxParamPropDoubleType + + ParamsNormalizedSpatial: + - kOfxParamPropDefaultCoordinateSystem + + ParamsInt2D3D: + - kOfxParamPropDimensionLabel + + ParamsString: + - kOfxParamPropStringMode + - kOfxParamPropStringFilePathExists + + ParamsChoice: + - kOfxParamPropChoiceOption + - kOfxParamPropChoiceOrder + + ParamsCustom: + - kOfxParamPropCustomInterpCallbackV1 + + ParamsPage: + - kOfxParamPropPageChild + + ParamsParametric: + - kOfxParamPropAnimates + - kOfxParamPropIsAnimating + - kOfxParamPropIsAutoKeying + - kOfxParamPropPersistant + - kOfxParamPropEvaluateOnChange + - kOfxParamPropPluginMayWrite + - kOfxParamPropCacheInvalidation + - kOfxParamPropCanUndo + - kOfxParamPropParametricDimension + - kOfxParamPropParametricUIColour + - kOfxParamPropParametricInteractBackground + - kOfxParamPropParametricRange + + InteractDescriptor: + - kOfxInteractPropHasAlpha + - kOfxInteractPropBitDepth + + InteractInstance: + - kOfxPropEffectInstance + - kOfxPropInstanceData + - kOfxInteractPropPixelScale + - kOfxInteractPropBackgroundColour + - kOfxInteractPropHasAlpha + - kOfxInteractPropBitDepth + - kOfxInteractPropSlaveToParam + - kOfxInteractPropSuggestedColour + + Misc: + - kOfxImageEffectFrameVarying + - kOfxImageEffectPluginPropOverlayInteractV2 + - kOfxImageEffectPropColourManagementAvailableConfigs + - kOfxImageEffectPropColourManagementConfig + - kOfxImageEffectPropColourManagementStyle + - kOfxImageEffectPropCudaEnabled + - kOfxImageEffectPropCudaRenderSupported + - kOfxImageEffectPropCudaStream + - kOfxImageEffectPropCudaStreamSupported + - kOfxImageEffectPropDisplayColourspace + - kOfxImageEffectPropFieldToRender + - kOfxImageEffectPropFrameStep + - kOfxImageEffectPropInAnalysis + - kOfxImageEffectPropInteractiveRenderStatus + - kOfxImageEffectPropMetalCommandQueue + - kOfxImageEffectPropMetalEnabled + - kOfxImageEffectPropMetalRenderSupported + - kOfxImageEffectPropOCIOConfig + - kOfxImageEffectPropOCIODisplay + - kOfxImageEffectPropOCIOView + - kOfxImageEffectPropOpenCLCommandQueue + - kOfxImageEffectPropOpenCLEnabled + - kOfxImageEffectPropOpenCLImage + - kOfxImageEffectPropOpenCLRenderSupported + - kOfxImageEffectPropOpenCLSupported + - kOfxImageEffectPropOpenGLEnabled + - kOfxImageEffectPropOpenGLTextureIndex + - kOfxImageEffectPropOpenGLTextureTarget + - kOfxImageEffectPropPluginHandle + - kOfxImageEffectPropRegionOfDefinition + - kOfxImageEffectPropRegionOfInterest + - kOfxImageEffectPropRenderWindow + - kOfxImageEffectPropSequentialRenderStatus + - kOfxInteractPropDrawContext + - kOfxInteractPropPenPosition + - kOfxInteractPropPenPressure + - kOfxInteractPropPenViewportPosition + - kOfxInteractPropViewportSize + - kOfxOpenGLPropPixelDepth + - kOfxParamHostPropSupportsStrChoice + - kOfxParamHostPropSupportsStrChoiceAnimation + - kOfxParamPropChoiceEnum + - kOfxParamPropCustomValue + - kOfxParamPropInterpolationAmount + - kOfxParamPropInterpolationTime + - kOfxPluginPropParamPageOrder + - kOfxPropChangeReason + - kOfxPropKeyString + - kOfxPropKeySym + + + +# Properties by name. +# Notes: +# type=bool means an int property with value 1 or 0 for true or false. +# type=enum means a string property with values from the "values" list +# default: only include here if not "" for strings or 0 for numeric or null for ptr. +# hostOptional: is it optional for a host to support this prop? Only include if true. +# pluginOptional: is it optional for a plugin to support this prop? Only include if true. +# dimension: 0 means "any dimension OK" +properties: + kOfxPropType: + type: string + dimension: 1 + writable: host + kOfxPropName: + type: string + dimension: 1 + writable: host + kOfxPropTime: + type: double + dimension: 1 + writable: all + + # Param props + kOfxParamPropSecret: + type: bool + dimension: 1 + writable: all + kOfxParamPropHint: + type: string + dimension: 1 + writable: all + kOfxParamPropScriptName: + type: string + dimension: 1 + writable: all + kOfxParamPropParent: + type: string + dimension: 1 + writable: all + kOfxParamPropEnabled: + type: bool + dimension: 1 + writable: all + optional: true + kOfxParamPropDataPtr: + type: pointer + dimension: 1 + writable: all + kOfxParamPropType: + type: string + dimension: 1 + writable: host + kOfxPropLabel: + type: string + dimension: 1 + writable: plugin + kOfxPropShortLabel: + type: string + dimension: 1 + writable: plugin + hostOptional: true + kOfxPropLongLabel: + type: string + dimension: 1 + writable: plugin + hostOptional: true + kOfxPropIcon: + type: string + dimension: 2 + writable: plugin + hostOptional: true + + # host props + kOfxPropAPIVersion: + type: int + dimension: 0 + writable: host + kOfxPropLabel: + type: string + dimension: 1 + writable: host + kOfxPropVersion: + type: int + dimension: 0 + writable: host + kOfxPropVersionLabel: + type: string + dimension: 1 + writable: host + + # ImageEffect props: + kOfxPropPluginDescription: + type: string + dimension: 1 + writable: plugin + kOfxImageEffectPropSupportedContexts: + type: string + dimension: 0 + writable: plugin + kOfxImageEffectPluginPropGrouping: + type: string + dimension: 1 + writable: plugin + kOfxImageEffectPluginPropSingleInstance: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPluginRenderThreadSafety: + type: string + dimension: 1 + writable: plugin + kOfxImageEffectPluginPropHostFrameThreading: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPluginPropOverlayInteractV1: + type: pointer + dimension: 1 + writable: plugin + kOfxImageEffectPropSupportsMultiResolution: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPropSupportsTiles: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPropTemporalClipAccess: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPropSupportedPixelDepths: + type: string + dimension: 0 + writable: plugin + kOfxImageEffectPluginPropFieldRenderTwiceAlways: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPropSupportsMultipleClipDepths: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPropSupportsMultipleClipPARs: + type: int + dimension: 1 + writable: plugin + kOfxImageEffectPropClipPreferencesSlaveParam: + type: string + dimension: 0 + writable: plugin + kOfxImageEffectInstancePropSequentialRender: + type: int + dimension: 1 + writable: plugin + kOfxPluginPropFilePath: + type: enum + dimension: 1 + values: ['false', 'true', 'needed'] + writable: plugin + kOfxImageEffectPropOpenGLRenderSupported: + type: enum + dimension: 1 + values: ['false', 'true', 'needed'] + writable: plugin + kOfxImageEffectPropCudaRenderSupported: + type: enum + dimension: 1 + values: ['false', 'true', 'needed'] + writable: plugin + kOfxImageEffectPropCudaStreamSupported: + type: enum + dimension: 1 + values: ['false', 'true', 'needed'] + writable: plugin + kOfxImageEffectPropMetalRenderSupported: + type: enum + dimension: 1 + values: ['false', 'true', 'needed'] + writable: plugin + kOfxImageEffectPropOpenCLRenderSupported: + type: enum + dimension: 1 + values: ['false', 'true', 'needed'] + writable: plugin + + # Clip props + kOfxImageClipPropColourspace: + type: string + dimension: 1 + writable: all + kOfxImageClipPropConnected: + type: bool + dimension: 1 + writable: host + kOfxImageClipPropContinuousSamples: + type: bool + dimension: 1 + writable: all + kOfxImageClipPropFieldExtraction: + type: enum + dimension: 1 + writable: plugin + values: ['kOfxImageFieldNone', + 'kOfxImageFieldLower', + 'kOfxImageFieldUpper', + 'kOfxImageFieldBoth', + 'kOfxImageFieldSingle', + 'kOfxImageFieldDoubled'] + kOfxImageClipPropFieldOrder: + type: enum + dimension: 1 + writable: all + values: ['kOfxImageFieldNone', + 'kOfxImageFieldLower', + 'kOfxImageFieldUpper'] + kOfxImageClipPropIsMask: + type: bool + dimension: 1 + writable: plugin + kOfxImageClipPropOptional: + type: bool + dimension: 1 + writable: plugin + kOfxImageClipPropPreferredColourspaces: + type: string + dimension: 0 + writable: plugin + kOfxImageClipPropUnmappedComponents: + type: enum + dimension: 1 + writable: host + values: + - kOfxImageComponentNone + - kOfxImageComponentRGBA + - kOfxImageComponentRGB + - kOfxImageComponentAlpha + kOfxImageClipPropUnmappedPixelDepth: + type: enum + dimension: 1 + writable: host + values: + - kOfxBitDepthNone + - kOfxBitDepthByte + - kOfxBitDepthShort + - kOfxBitDepthHalf + - kOfxBitDepthFloat + + # Image Effect + kOfxImageEffectFrameVarying: + type: bool + dimension: 1 + writable: plugin + kOfxImageEffectHostPropIsBackground: + type: bool + dimension: 1 + writable: host + kOfxImageEffectHostPropNativeOrigin: + type: enum + dimension: 1 + writable: host + values: + kOfxImageEffectHostPropNativeOriginBottomLeft + kOfxImageEffectHostPropNativeOriginTopLeft + kOfxImageEffectHostPropNativeOriginCenter + kOfxImageEffectInstancePropEffectDuration: + type: double + dimension: 1 + writable: host + kOfxImageEffectPluginPropOverlayInteractV1: + type: pointer + dimension: 1 + writable: all + kOfxImageEffectPluginPropOverlayInteractV2: + type: pointer + dimension: 1 + writable: all + kOfxImageEffectPropColourManagementAvailableConfigs: + type: string + dimension: 0 + writable: all + kOfxImageEffectPropColourManagementStyle: + type: enum + dimension: 1 + writable: all + values: + - kOfxImageEffectPropColourManagementNone + - kOfxImageEffectPropColourManagementBasic + - kOfxImageEffectPropColourManagementCore + - kOfxImageEffectPropColourManagementFull + - kOfxImageEffectPropColourManagementOCIO + kOfxImageEffectPropComponents: + type: enum + dimension: 1 + writable: host + values: + - kOfxImageComponentNone + - kOfxImageComponentRGBA + - kOfxImageComponentRGB + - kOfxImageComponentAlpha + kOfxImageEffectPropContext: + type: enum + dimension: 1 + writable: host + values: + - kOfxImageEffectContextGenerator + - kOfxImageEffectContextFilter + - kOfxImageEffectContextTransition + - kOfxImageEffectContextPaint + - kOfxImageEffectContextGeneral + - kOfxImageEffectContextRetimer + kOfxImageEffectPropCudaEnabled: + type: bool + dimension: 1 + writable: all + kOfxImageEffectPropCudaStream: + type: pointer + dimension: 1 + writable: host + kOfxImageEffectPropDisplayColourspace: + type: string + dimension: 1 + writable: host + kOfxImageEffectPropFieldToRender: + type: enum + dimension: 1 + writable: host + values: + - kOfxImageFieldNone + - kOfxImageFieldBoth + - kOfxImageFieldLower + - kOfxImageFieldUpper + kOfxImageEffectPropFrameRange: + type: double + dimension: 2 + writable: host + kOfxImageEffectPropFrameRate: + type: double + dimension: 1 + writable: all + kOfxImageEffectPropFrameStep: + type: double + dimension: 1 + writable: host + kOfxImageEffectPropInAnalysis: + type: bool + dimension: 1 + writable: all + deprecated: "1.4" + kOfxImageEffectPropInteractiveRenderStatus: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropMetalCommandQueue: + type: pointer + dimension: 1 + writable: host + kOfxImageEffectPropMetalEnabled: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropOCIOConfig: + type: string + dimension: 1 + writable: host + kOfxImageEffectPropOCIODisplay: + type: string + dimension: 1 + writable: host + kOfxImageEffectPropOCIOView: + type: string + dimension: 1 + writable: host + kOfxImageEffectPropOpenCLCommandQueue: + type: pointer + dimension: 1 + writable: host + kOfxImageEffectPropOpenCLEnabled: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropOpenCLImage: + type: int + dimension: 1 + kOfxImageEffectPropOpenCLSupported: + type: enum + dimension: 1 + values: + - "false" + - "true" + kOfxImageEffectPropOpenGLEnabled: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropOpenGLTextureIndex: + type: int + dimension: 1 + writable: host + kOfxImageEffectPropOpenGLTextureTarget: + type: int + dimension: 1 + writable: host + kOfxImageEffectPropPixelDepth: + type: enum + dimension: 1 + writable: host + values: + - kOfxBitDepthNone + - kOfxBitDepthByte + - kOfxBitDepthShort + - kOfxBitDepthHalf + - kOfxBitDepthFloat + kOfxImageEffectPropPluginHandle: + type: pointer + dimension: 1 + writable: host + kOfxImageEffectPropPreMultiplication: + type: enum + dimension: 1 + writable: all + values: + - kOfxImageOpaque + - kOfxImagePreMultiplied + - kOfxImageUnPreMultiplied + kOfxImageEffectPropProjectExtent: + type: double + dimension: 2 + writable: host + kOfxImageEffectPropProjectOffset: + type: double + dimension: 2 + writable: host + kOfxImageEffectPropProjectPixelAspectRatio: + type: double + dimension: 1 + writable: host + kOfxImageEffectPropProjectSize: + type: double + dimension: 2 + writable: host + kOfxImageEffectPropRegionOfDefinition: + type: int + dimension: 4 + writable: host + kOfxImageEffectPropRegionOfInterest: + type: int + dimension: 4 + writable: host + kOfxImageEffectPropRenderQualityDraft: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropRenderScale: + type: double + dimension: 2 + writable: host + kOfxImageEffectPropRenderWindow: + type: int + dimension: 4 + writable: host + kOfxImageEffectPropSequentialRenderStatus: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropSetableFielding: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropSetableFrameRate: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropSupportedComponents: + type: enum + dimension: 0 + writable: host + values: + - kOfxImageComponentNone + - kOfxImageComponentRGBA + - kOfxImageComponentRGB + - kOfxImageComponentAlpha + kOfxImageEffectPropSupportsOverlays: + type: bool + dimension: 1 + writable: host + kOfxImageEffectPropUnmappedFrameRange: + type: double + dimension: 2 + writable: host + kOfxImageEffectPropUnmappedFrameRate: + type: double + dimension: 1 + writable: host + kOfxImageEffectPropColourManagementConfig: + type: string + dimension: 1 + writable: host + kOfxImagePropBounds: + type: int + dimension: 4 + writable: host + kOfxImagePropData: + type: pointer + dimension: 1 + writable: host + kOfxImagePropField: + type: enum + dimension: 1 + writable: host + values: + - kOfxImageFieldNone + - kOfxImageFieldBoth + - kOfxImageFieldLower + - kOfxImageFieldUpper + kOfxImagePropPixelAspectRatio: + type: double + dimension: 1 + writable: all + kOfxImagePropRegionOfDefinition: + type: int + dimension: 4 + writable: host + kOfxImagePropRowBytes: + type: int + dimension: 1 + writable: host + kOfxImagePropUniqueIdentifier: + type: string + dimension: 1 + writable: host + + # Interact/Drawing + kOfxInteractPropBackgroundColour: + type: double + dimension: 3 + writable: host + kOfxInteractPropBitDepth: + type: int + dimension: 1 + writable: host + kOfxInteractPropDrawContext: + type: pointer + dimension: 1 + writable: host + kOfxInteractPropHasAlpha: + type: bool + dimension: 1 + writable: host + kOfxInteractPropPenPosition: + type: double + dimension: 2 + writable: host + kOfxInteractPropPenPressure: + type: double + dimension: 1 + writable: host + kOfxInteractPropPenViewportPosition: + type: int + dimension: 2 + writable: host + kOfxInteractPropPixelScale: + type: double + dimension: 2 + writable: host + kOfxInteractPropSlaveToParam: + type: string + dimension: 0 + writable: all + kOfxInteractPropSuggestedColour: + type: double + dimension: 3 + writable: host + kOfxInteractPropViewportSize: + type: int + dimension: 2 + writable: host + deprecated: "1.3" + + kOfxOpenGLPropPixelDepth: + type: enum + dimension: 0 + writable: host + values: + - kOfxBitDepthNone + - kOfxBitDepthByte + - kOfxBitDepthShort + - kOfxBitDepthHalf + - kOfxBitDepthFloat + kOfxParamHostPropMaxPages: + type: int + dimension: 1 + writable: host + kOfxParamHostPropMaxParameters: + type: int + dimension: 1 + writable: host + kOfxParamHostPropPageRowColumnCount: + type: int + dimension: 2 + writable: host + kOfxParamHostPropSupportsBooleanAnimation: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsChoiceAnimation: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsCustomAnimation: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsCustomInteract: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsParametricAnimation: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsStrChoice: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsStrChoiceAnimation: + type: bool + dimension: 1 + writable: host + kOfxParamHostPropSupportsStringAnimation: + type: bool + dimension: 1 + writable: host + + + # Param + kOfxParamPropAnimates: + type: bool + dimension: 1 + writable: host + kOfxParamPropCacheInvalidation: + type: enum + dimension: 1 + writable: all + values: + - kOfxParamInvalidateValueChange + - kOfxParamInvalidateValueChangeToEnd + - kOfxParamInvalidateAll + kOfxParamPropCanUndo: + type: bool + dimension: 1 + writable: plugin + kOfxParamPropChoiceEnum: + type: bool + dimension: 1 + writable: host + added: "1.5" + kOfxParamPropChoiceOption: + type: string + dimension: 0 + writable: plugin + kOfxParamPropChoiceOrder: + type: int + dimension: 0 + writable: plugin + kOfxParamPropCustomInterpCallbackV1: + type: pointer + dimension: 1 + writable: plugin + kOfxParamPropCustomValue: + type: string + dimension: 2 + writable: plugin + # This is special because its type and dims vary depending on the param + kOfxParamPropDefault: + type: [int, double, string, bytes] + dimension: 0 + writable: plugin + kOfxParamPropDefaultCoordinateSystem: + type: enum + dimension: 1 + writable: plugin + values: + - kOfxParamCoordinatesCanonical + - kOfxParamCoordinatesNormalised + kOfxParamPropDigits: + type: int + dimension: 1 + writable: plugin + kOfxParamPropDimensionLabel: + type: string + dimension: 1 + writable: plugin + kOfxParamPropDisplayMax: + type: [int, double] + dimension: 0 + writable: plugin + kOfxParamPropDisplayMin: + type: [int, double] + dimension: 0 + writable: plugin + kOfxParamPropDoubleType: + type: enum + dimension: 1 + writable: plugin + values: + - kOfxParamDoubleTypePlain + - kOfxParamDoubleTypeAngle + - kOfxParamDoubleTypeScale + - kOfxParamDoubleTypeTime + - kOfxParamDoubleTypeAbsoluteTime + - kOfxParamDoubleTypeX + - kOfxParamDoubleTypeXAbsolute + - kOfxParamDoubleTypeY + - kOfxParamDoubleTypeYAbsolute + - kOfxParamDoubleTypeXY + - kOfxParamDoubleTypeXYAbsolute + kOfxParamPropEvaluateOnChange: + type: bool + dimension: 1 + writable: plugin + kOfxParamPropGroupOpen: + type: bool + dimension: 1 + writable: plugin + kOfxParamPropHasHostOverlayHandle: + type: bool + dimension: 1 + writable: host + kOfxParamPropIncrement: + type: double + dimension: 1 + writable: plugin + kOfxParamPropInteractMinimumSize: + type: double + dimension: 2 + writable: plugin + kOfxParamPropInteractPreferedSize: + type: int + dimension: 2 + writable: plugin + kOfxParamPropInteractSize: + type: double + dimension: 2 + writable: plugin + kOfxParamPropInteractSizeAspect: + type: double + dimension: 1 + writable: plugin + kOfxParamPropInteractV1: + type: pointer + dimension: 1 + writable: plugin + kOfxParamPropInterpolationAmount: + type: double + dimension: 1 + writable: plugin + kOfxParamPropInterpolationTime: + type: double + dimension: 2 + writable: plugin + kOfxParamPropIsAnimating: + type: bool + dimension: 1 + writable: host + kOfxParamPropIsAutoKeying: + type: bool + dimension: 1 + writable: host + kOfxParamPropMax: + type: [int, double] + dimension: 0 + writable: plugin + kOfxParamPropMin: + type: [int, double] + dimension: 0 + writable: plugin + kOfxParamPropPageChild: + type: string + dimension: 0 + writable: plugin + kOfxParamPropParametricDimension: + type: int + dimension: 1 + writable: plugin + kOfxParamPropParametricInteractBackground: + type: pointer + dimension: 1 + writable: plugin + kOfxParamPropParametricRange: + type: double + dimension: 2 + writable: plugin + kOfxParamPropParametricUIColour: + type: double + dimension: 0 + writable: plugin + kOfxParamPropPersistant: + type: int + dimension: 1 + writable: plugin + kOfxParamPropPluginMayWrite: + type: int + dimension: 1 + writable: plugin + deprecated: "1.4" + kOfxParamPropShowTimeMarker: + type: bool + dimension: 1 + writable: plugin + kOfxParamPropStringMode: + type: enum + dimension: 1 + writable: plugin + values: + - kOfxParamStringIsSingleLine + - kOfxParamStringIsMultiLine + - kOfxParamStringIsFilePath + - kOfxParamStringIsDirectoryPath + - kOfxParamStringIsLabel + - kOfxParamStringIsRichTextFormat + kOfxParamPropUseHostOverlayHandle: + type: bool + dimension: 1 + writable: host + kOfxParamPropStringFilePathExists: + type: bool + dimension: 1 + writable: plugin + kOfxPluginPropParamPageOrder: + type: string + dimension: 0 + writable: plugin + kOfxPropChangeReason: + type: enum + dimension: 1 + writable: host + values: + - kOfxChangeUserEdited + - kOfxChangePluginEdited + - kOfxChangeTime + kOfxPropEffectInstance: + type: pointer + dimension: 1 + writable: host + kOfxPropHostOSHandle: + type: pointer + dimension: 1 + writable: host + kOfxPropInstanceData: + type: pointer + dimension: 1 + writable: plugin + kOfxPropIsInteractive: + type: bool + dimension: 1 + writable: host + kOfxPropKeyString: + type: string + dimension: 1 + writable: host + kOfxPropKeySym: + type: int + dimension: 1 + writable: host + kOfxPropParamSetNeedsSyncing: + type: bool + dimension: 1 + writable: plugin diff --git a/include/ofxInteract.h b/include/ofxInteract.h index 3acc6d33..6b5e061a 100644 --- a/include/ofxInteract.h +++ b/include/ofxInteract.h @@ -111,7 +111,7 @@ This is used to indicate the status of the 'pen' in an interact. If a pen has on */ #define kOfxInteractPropPenPressure "OfxInteractPropPenPressure" -/** @brief Indicates whether the dits per component in the interact's openGL frame buffer +/** @brief Indicates the bits per component in the interact's openGL frame buffer - Type - int X 1 - Property Set - interact instance and descriptor (read only) diff --git a/include/ofxKeySyms.h b/include/ofxKeySyms.h index 01397f6a..2535b7d1 100644 --- a/include/ofxKeySyms.h +++ b/include/ofxKeySyms.h @@ -31,7 +31,7 @@ the UTF8 value. /** @brief This property encodes a single keypresses that generates a unicode code point. The value is stored as a UTF8 string. - Type - C string X 1, UTF8 - - Property Set - an read only in argument for the actions ::kOfxInteractActionKeyDown, ::kOfxInteractActionKeyUp and ::kOfxInteractActionKeyRepeat. + - Property Set - a read-only in argument for the actions ::kOfxInteractActionKeyDown, ::kOfxInteractActionKeyUp and ::kOfxInteractActionKeyRepeat. - Valid Values - a UTF8 string representing a single character, or the empty string. This property represents the UTF8 encode value of a single key press by a user in an OFX interact. diff --git a/include/ofxParam.h b/include/ofxParam.h index af834e0f..772d3f91 100644 --- a/include/ofxParam.h +++ b/include/ofxParam.h @@ -717,7 +717,7 @@ Setting this will also reset ::kOfxParamPropDisplayMin. - Property Set - plugin parameter descriptor (read/write) and instance (read/write), - Default - the largest possible value corresponding to the parameter type (eg: INT_MAX for an integer, DBL_MAX for a double parameter) -Setting this will also reset :;kOfxParamPropDisplayMax. +Setting this will also reset ::kOfxParamPropDisplayMax. */ #define kOfxParamPropMax "OfxParamPropMax" diff --git a/include/ofxParametricParam.h b/include/ofxParametricParam.h index 2d52fdd0..4fa073d9 100644 --- a/include/ofxParametricParam.h +++ b/include/ofxParametricParam.h @@ -61,7 +61,7 @@ This indicates the dimension of the parametric param. - Property Set - parametric param descriptor (read/write) and instance (read only) - default - unset, - Value Values - three values for each dimension (see ::kOfxParamPropParametricDimension) - being interpretted as R, G and B of the colour for each curve drawn in the UI. + being interpreted as R, G and B of the colour for each curve drawn in the UI. This sets the colour of a parametric param curve drawn a host user interface. A colour triple is needed for each dimension of the oparametric param. diff --git a/scripts/gen-props.py b/scripts/gen-props.py new file mode 100644 index 00000000..940bc902 --- /dev/null +++ b/scripts/gen-props.py @@ -0,0 +1,292 @@ +# Copyright OpenFX and contributors to the OpenFX project. +# SPDX-License-Identifier: BSD-3-Clause + +import os +import difflib +import argparse +import yaml +import logging +from pathlib import Path +from collections.abc import Iterable + +# Set up basic configuration for logging +logging.basicConfig( + level=logging.INFO, # Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL + format='%(levelname)s: %(message)s', # Format of the log messages + datefmt='%Y-%m-%d %H:%M:%S' # Date format +) + +def getPropertiesFromFile(path): + """Get all OpenFX property definitions from C header file. + + Uses a heuristic to identify property #define lines: + anything starting with '#define' and containing 'Prop' in the name. + """ + props = set() + with open(path) as f: + try: + lines = f.readlines() + except UnicodeDecodeError as e: + logging.error(f'error reading {path}: {e}') + raise e + for l in lines: + # Detect lines that correspond to a property definition, e.g: + # #define kOfxPropLala "OfxPropLala" + splits=l.split() + if len(splits) < 3: + continue + if splits[0] != '#define': + continue + # ignore these + nonProperties = ('kOfxPropertySuite', + # prop values, not props + 'kOfxImageEffectPropColourManagementNone', + 'kOfxImageEffectPropColourManagementBasic', + 'kOfxImageEffectPropColourManagementCore', + 'kOfxImageEffectPropColourManagementFull', + 'kOfxImageEffectPropColourManagementOCIO', + ) + if splits[1] in nonProperties: + continue + # these are props, as well as anything with Prop in the name + badlyNamedProperties = ("kOfxImageEffectFrameVarying", + "kOfxImageEffectPluginRenderThreadSafety") + if 'Prop' in splits[1] \ + or any(s in splits[1] for s in badlyNamedProperties): + props.add(splits[1]) + return props + +def getPropertiesFromDir(dir): + """ + Recursively get all property definitions from source files in a dir. + """ + + extensions = {'.c', '.h', '.cxx', '.hxx', '.cpp', '.hpp'} + + props = set() + for root, _dirs, files in os.walk(dir): + for file in files: + # Get the file extension + file_extension = os.path.splitext(file)[1] + + if file_extension in extensions: + file_path = os.path.join(root, file) + props |= getPropertiesFromFile(file_path) + return list(props) + +def get_def(name: str, defs): + if name.endswith('_REF'): + defname = name.replace("_REF", "_DEF") + return defs[defname] + else: + return [name] + +def expand_set_props(props_by_set): + """Expand refs in props_by_sets. + YAML can't interpolate a list, so we do it here, using + our own method: + - A prop set may end with _DEF in which case it's just a definition + containing a list of prop names. + - A prop *name* may be _REF which means to interpolate the + corresponding DEF list into this set's props. + Returns a new props_by_set with DEFs removed and all lists interpolated. + """ + # First get all the list defs + defs = {} + sets = {} + for key, value in props_by_set.items(): + if key.endswith('_DEF'): + defs[key] = value # should be a list to be interpolated + else: + sets[key] = value + for key in sets: + sets[key] = [item for element in sets[key] \ + for item in get_def(element, defs)] + return sets + + +def find_missing(all_props, props_metadata): + """Find and print all mismatches between prop defs and metadata. + + Returns 0 if no errors. + """ + errs = 0 + for p in sorted(all_props): + if not props_metadata.get(p): + logging.error(f"No YAML metadata found for {p}") + errs += 1 + for p in sorted(props_metadata): + if p not in all_props: + logging.error(f"No prop definition found for '{p}' in source/include") + matches = difflib.get_close_matches(p, all_props, 3, 0.9) + if matches: + logging.info(f" Did you mean: {matches}") + errs += 1 + return errs + +def check_props_by_set(props_by_set, props_metadata): + """Find and print all mismatches between prop set specs, props, and metadata. + + * Each prop name in props_by_set should have a match in props_metadata + Returns 0 if no errors. + """ + errs = 0 + for pset in sorted(props_by_set): + for prop in sorted(props_by_set[pset]): + if not props_metadata.get(prop): + logging.error(f"No props metadata found for {pset}.{prop}") + errs += 1 + return errs + +def check_props_used_by_set(props_by_set, props_metadata): + """Find and print all mismatches between prop set specs, props, and metadata. + + * Each prop name in props_metadata should be used in at least one set. + Returns 0 if no errors. + """ + errs = 0 + for prop in props_metadata: + found = 0 + for pset in props_by_set: + for set_prop in props_by_set[pset]: + if set_prop == prop: + found += 1 + if not found: + logging.error(f"Prop {prop} not used in any prop set in YML file") + return errs + +def gen_props_metadata(props_metadata, outfile_path: Path): + """Generate a header file with metadata for each prop""" + with open(outfile_path, 'w') as outfile: + outfile.write(""" +#include +#include +#include "ofxImageEffect.h" +#include "ofxGPURender.h" +#include "ofxColour.h" +#include "ofxDrawSuite.h" +#include "ofxParametricParam.h" +#include "ofxKeySyms.h" +#include "ofxOld.h" + +enum class PropType { + Int, + Double, + Enum, + Bool, + String, + Bytes, + Pointer +}; + +enum class Writable { + Host, + Plugin, + All +}; + +struct PropsMetadata { + std::string name; + std::vector types; + int dimension; + Writable writable; + bool host_optional; + std::vector values; // for enums +}; + +""") + outfile.write("const std::vector props_metadata {\n") + for p in props_metadata: + try: + md = props_metadata[p] + types = md.get('type') + if isinstance(types, str): # make it always a list + types = (types,) + prop_type_defs = "{" + ",".join(f'PropType::{t.capitalize()}' for t in types) + "}" + writable = "Writable::" + md.get('writable', "unknown").capitalize() + host_opt = md.get('hostOptional', 'false') + if host_opt in ('True', 'true', 1): + host_opt = 'true' + if host_opt in ('False', 'false', 0): + host_opt = 'false' + if md['type'] == 'enum': + values = "{" + ",".join(f'"{v}"' for v in md['values']) + "}" + else: + values = "{}" + outfile.write(f"{{ {p}, {prop_type_defs}, {md['dimension']}, " + f"{writable}, {host_opt}, {values} }},\n") + except Exception as e: + logging.error(f"Error: {p} is missing metadata? {e}") + raise(e) + outfile.write("};\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""" + with open(outfile_path, 'w') as outfile: + outfile.write(""" +#include +#include +#include +#include "ofxImageEffect.h" +#include "ofxGPURender.h" +#include "ofxColour.h" +#include "ofxDrawSuite.h" +#include "ofxParametricParam.h" +#include "ofxKeySyms.h" +#include "ofxOld.h" + +""") + outfile.write("const std::map> prop_sets {\n") + for pset in sorted(props_by_set.keys()): + propnames = ",".join(props_by_set[pset]) + outfile.write(f"{{ \"{pset}\", {{ {propnames} }} }},\n") + outfile.write("};\n") + +def main(args): + script_dir = os.path.dirname(os.path.abspath(__file__)) + include_dir = Path(script_dir).parent / 'include' + all_props = getPropertiesFromDir(include_dir) + logging.info(f'Got {len(all_props)} props from "include" dir') + + with open(include_dir / 'ofx-props.yml', 'r') as props_file: + props_data = yaml.safe_load(props_file) + props_by_set = props_data['propertySets'] + props_by_set = expand_set_props(props_by_set) + props_metadata = props_data['properties'] + + if args.verbose: + print("\n=== Checking ofx-props.yml: should map 1:1 to props found in source/header files") + errs = find_missing(all_props, props_metadata) + if not errs and args.verbose: + print(" ✔️ ALL OK") + + if args.verbose: + print("\n=== Checking ofx-props.yml: every prop in a set should have metadata in the YML file") + errs = check_props_by_set(props_by_set, props_metadata) + if not errs and args.verbose: + print(" ✔️ ALL OK") + + if args.verbose: + print("\n=== Checking ofx-props.yml: every prop should be used in in at least one set in the YML file") + errs = check_props_used_by_set(props_by_set, props_metadata) + if not errs and args.verbose: + print(" ✔️ ALL OK") + + 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') + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Check OpenFX properties and generate ancillary data structures") + + # Define arguments here + parser.add_argument('-v', '--verbose', action='store_true', help='Enable verbose mode') + + # Parse the arguments + args = parser.parse_args() + + # Call the main function with parsed arguments + main(args)