// Copyright(c) 2015-2019, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include "XMLHelper.hpp" #include #include #include #include #include constexpr size_t INVALID_INDEX = static_cast( ~0 ); template class Flags { public: using MaskType = typename std::underlying_type::type; constexpr Flags() noexcept : m_mask( 0 ) {} constexpr Flags( BitType bit ) noexcept : m_mask( static_cast( bit ) ) {} constexpr explicit Flags( MaskType flags ) noexcept : m_mask( flags ) {} constexpr Flags & operator|=( Flags const & rhs ) noexcept { m_mask |= rhs.m_mask; return *this; } constexpr bool operator!() const noexcept { return !m_mask; } constexpr bool operator&( BitType const & rhs ) const noexcept { return m_mask & static_cast( rhs ); } constexpr Flags operator&( Flags const & rhs ) const noexcept { return Flags( m_mask & rhs.m_mask ); } constexpr Flags operator|( Flags const & rhs ) const noexcept { return Flags( m_mask | rhs.m_mask ); } private: MaskType m_mask; }; enum class CommandFlavourFlagBits : uint8_t { enhanced = 1 << 0, chained = 1 << 1, singular = 1 << 2, unique = 1 << 3, withAllocator = 1 << 4, noReturn = 1 << 5, keepVoidPtr = 1 << 6 }; using CommandFlavourFlags = Flags; constexpr CommandFlavourFlags operator|( CommandFlavourFlagBits const & lhs, CommandFlavourFlagBits const & rhs ) noexcept { return CommandFlavourFlags( lhs ) | CommandFlavourFlags( rhs ); } class VulkanHppGenerator { public: VulkanHppGenerator( tinyxml2::XMLDocument const & document, std::string const & api ); void generateEnumsHppFile() const; void generateExtensionInspectionFile() const; void generateFormatTraitsHppFile() const; void generateFuncsHppFile() const; void generateHandlesHppFile() const; void generateHashHppFile() const; void generateHppFile() const; void generateMacrosFile() const; void generateRAIIHppFile() const; void generateSharedHppFile() const; void generateStaticAssertionsHppFile() const; void generateStructsHppFile() const; void generateToStringHppFile() const; void generateCppModuleFile() const; void prepareRAIIHandles(); void prepareVulkanFuncs(); struct MacroData { std::string deprecatedComment = {}; std::string calleeMacro = {}; std::vector params = {}; std::string definition = {}; }; private: struct AliasData { std::string name = {}; int xmlLine = {}; }; struct BaseTypeData { TypeInfo typeInfo = {}; int xmlLine = {}; }; struct BitmaskData { std::string require = {}; std::string type = {}; int xmlLine = {}; }; struct EnumValueData { std::string alias = {}; std::string bitpos = {}; std::string name = {}; std::string protect = {}; std::string value = {}; int xmlLine = {}; }; struct EnumData { void addEnumAlias( int line, std::string const & name, std::string const & alias, std::string const & protect, bool supported ); void addEnumValue( int line, std::string const & valueName, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported ); std::string bitwidth = {}; bool isBitmask = false; std::vector unsupportedValues = {}; std::vector values = {}; int xmlLine = {}; }; struct NameData { std::string name = {}; std::vector arraySizes = {}; }; struct ParamData { TypeInfo type = {}; std::string name = {}; std::vector arraySizes = {}; std::string lenExpression = {}; std::vector> lenParams = {}; bool optional = false; std::pair strideParam = {}; int xmlLine = {}; }; struct CommandData { std::vector errorCodes = {}; std::string handle = {}; std::vector params = {}; std::set requiredBy = {}; std::string returnType = {}; std::vector successCodes = {}; int xmlLine = {}; }; struct ConstantData { std::string type = {}; std::string value = {}; int xmlLine = {}; }; struct DefineData { bool deprecated = false; std::string require = {}; int xmlLine = {}; std::string deprecationReason = {}; std::string possibleCallee = {}; std::vector params = {}; std::string possibleDefinition = {}; }; struct DefinesPartition { std::map callees = {}; std::map callers = {}; std::map values = {}; }; struct RemoveData { std::vector commands = {}; std::vector enums = {}; std::vector types = {}; int xmlLine = {}; }; struct RequireData { std::string depends = {}; std::vector commands = {}; std::map enumConstants = {}; std::vector constants = {}; std::vector types = {}; int xmlLine = {}; }; struct ExtensionData { std::string deprecatedBy = {}; bool isDeprecated = false; std::string name = {}; std::string number = {}; std::string obsoletedBy = {}; std::string platform = {}; std::string promotedTo = {}; std::map>> depends = {}; std::vector ratified = {}; std::vector requireData = {}; std::vector supported = {}; std::string type = {}; int xmlLine = 0; }; struct FeatureData { std::string name = {}; std::string number = {}; std::vector removeData = {}; std::vector requireData = {}; int xmlLine = {}; }; struct ExternalTypeData { std::string require = {}; int xmlLine = 0; }; struct ComponentData { std::string bits = {}; std::string name = {}; std::string numericFormat = {}; std::string planeIndex = {}; int xmlLine = {}; }; struct PlaneData { std::string compatible = {}; std::string heightDivisor = {}; std::string widthDivisor = {}; int xmlLine = {}; }; struct FormatData { std::string blockExtent = {}; std::string blockSize = {}; std::string chroma = {}; std::string classAttribute = {}; std::vector components = {}; std::string compressed = {}; std::string packed = {}; std::vector planes = {}; std::string spirvImageFormat = {}; std::string texelsPerBlock = {}; int xmlLine = {}; }; struct FuncPointerArgumentData { std::string name = {}; std::string type = {}; int xmlLine = {}; }; struct FuncPointerData { std::vector arguments = {}; std::string require = {}; int xmlLine = {}; }; struct HandleData { std::set childrenHandles = {}; std::set commands = {}; std::string deleteCommand = {}; std::string deletePool = {}; std::string destructorType = {}; std::string objTypeEnum = {}; std::string parent = {}; std::set secondLevelCommands = {}; bool isDispatchable = {}; int xmlLine = {}; // RAII data std::map::const_iterator destructorIt = {}; std::vector::const_iterator> constructorIts = {}; }; struct PlatformData { std::string protect = {}; int xmlLine = {}; }; struct MemberData { std::string defaultValue = {}; TypeInfo type = {}; std::string name = {}; std::vector arraySizes = {}; std::string bitCount = {}; std::vector lenExpressions = {}; std::vector> lenMembers = {}; bool noAutoValidity = {}; std::vector optional = {}; std::vector selection = {}; std::string selector = {}; std::string value = {}; int xmlLine = {}; }; struct StructureData { bool allowDuplicate = {}; bool isUnion = {}; bool returnedOnly = {}; bool mutualExclusiveLens = {}; std::vector members = {}; std::vector structExtends = {}; std::string subStruct = {}; int xmlLine = {}; }; struct TagData { int xmlLine = {}; }; struct VectorParamData { size_t lenParam = INVALID_INDEX; size_t strideParam = INVALID_INDEX; }; struct MacroVisitor final : tinyxml2::XMLVisitor { // comments, then name, then parameters and definition together, because that's how they appear in the xml! // guaranteed to be 3 elements long std::vector macro; bool Visit( tinyxml2::XMLText const & text ) override { if ( auto const nodeText = text.Value(); nodeText != nullptr ) { macro.emplace_back( nodeText ); } return true; } }; private: void addCommand( std::string const & name, CommandData & commandData ); void addCommandsToHandle( std::vector const & requireData ); void addMissingFlagBits( std::vector & requireData, std::string const & requiredBy ); std::string addTitleAndProtection( std::string const & title, std::string const & strIf, std::string const & strElse = {} ) const; bool allVectorSizesSupported( std::vector const & params, std::map const & vectorParams ) const; void appendDispatchLoaderDynamicCommands( std::vector const & requireData, std::set & listedCommands, std::string const & title, std::string & commandMembers, std::string & initialCommandAssignments, std::string & instanceCommandAssignments, std::string & deviceCommandAssignments ) const; void appendRAIIDispatcherCommands( std::vector const & requireData, std::set & listedCommands, std::string const & title, std::string & contextInitializers, std::string & contextMembers, std::string & deviceAssignments, std::string & deviceMembers, std::string & instanceAssignments, std::string & instanceMembers ) const; void checkBitmaskCorrectness() const; void checkCommandCorrectness() const; void checkCorrectness() const; void checkDefineCorrectness() const; void checkEnumCorrectness() const; void checkEnumCorrectness( std::vector const & requireData ) const; bool checkEquivalentSingularConstructor( std::vector::const_iterator> const & constructorIts, std::map::const_iterator constructorIt, std::vector::const_iterator lenIt ) const; void checkExtensionCorrectness() const; void checkFuncPointerCorrectness() const; void checkHandleCorrectness() const; void checkStructCorrectness() const; void checkStructMemberCorrectness( std::string const & structureName, std::vector const & members, std::set & sTypeValues ) const; std::string combineDataTypes( std::map const & vectorParams, std::vector const & returnParams, bool enumerating, std::vector const & dataTypes, CommandFlavourFlags flavourFlags, bool raii ) const; bool containsArray( std::string const & type ) const; bool containsFuncPointer( std::string const & type ) const; bool containsFloatingPoints( std::vector const & members ) const; bool containsUnion( std::string const & type ) const; std::vector determineChainedReturnParams( std::vector const & params, std::vector const & returnParams ) const; std::vector determineConstPointerParams( std::vector const & params ) const; std::vector determineDataTypes( std::vector const & params, std::map const & vectorParams, std::vector const & returnParams, std::set const & templatedParams ) const; size_t determineDefaultStartIndex( std::vector const & params, std::set const & skippedParams ) const; bool determineEnumeration( std::map const & vectorParams, std::vector const & returnParams ) const; size_t determineInitialSkipCount( std::string const & command ) const; std::vector determineReturnParams( std::vector const & params ) const; std::vector::const_iterator> determineRAIIHandleConstructors( std::string const & handleType, std::map::const_iterator destructorIt ) const; std::map::const_iterator determineRAIIHandleDestructor( std::string const & handleType ) const; std::set determineSingularParams( size_t returnParam, std::map const & vectorParams ) const; std::set determineSkippedParams( std::vector const & params, size_t initialSkipCount, std::map const & vectorParams, std::vector const & returnParam, bool singular ) const; std::string determineSubStruct( std::pair const & structure ) const; std::map determineVectorParams( std::vector const & params ) const; std::set determineVoidPointerParams( std::vector const & params ) const; void distributeSecondLevelCommands( std::set const & specialFunctions ); void filterLenMembers(); std::map::const_iterator findAlias( std::string const & name, std::map const & aliases ) const; std::string findBaseName( std::string aliasName, std::map const & aliases ) const; EnumValueData const * findEnumValueData( std::map::const_iterator enumIt, std::string const & name ) const; std::vector::const_iterator findFeature( std::string const & name ) const; std::vector::const_iterator findParamIt( std::string const & name, std::vector const & paramData ) const; std::vector::const_iterator findStructMemberIt( std::string const & name, std::vector const & memberData ) const; std::vector::const_iterator findStructMemberItByType( std::string const & type, std::vector const & memberData ) const; std::vector::const_iterator findSupportedExtension( std::string const & name ) const; std::string findTag( std::string const & name, std::string const & postfix = "" ) const; std::pair generateAllocatorTemplates( std::vector const & returnParams, std::vector const & returnDataTypes, std::map const & vectorParams, std::vector const & chainedReturnParams, CommandFlavourFlags flavourFlags, bool definition ) const; std::string generateArgumentListEnhanced( std::vector const & params, std::vector const & returnParams, std::map const & vectorParams, std::set const & skippedParams, std::set const & singularParams, std::set const & templatedParams, std::vector const & chainedReturnParams, bool definition, CommandFlavourFlags flavourFlags, bool withDispatcher ) const; std::string generateArgumentListStandard( std::vector const & params, std::set const & skippedParams ) const; std::string generateArgumentTemplates( std::vector const & params, std::vector const & returnParams, std::map const & vectorParams, std::set const & templatedParams, std::vector const & chainedReturnParams, bool raii ) const; std::string generateBaseTypes() const; std::string generateBitmask( std::map::const_iterator bitmaskIt, std::string const & surroundingProtect ) const; std::string generateBitmasksToString() const; std::string generateBitmasksToString( std::vector const & requireData, std::set & listedBitmasks, std::string const & title ) const; std::string generateBitmaskToString( std::map::const_iterator bitmaskIt ) const; std::string generateCallArgumentsEnhanced( CommandData const & commandData, size_t initialSkipCount, bool nonConstPointerAsNullptr, std::set const & singularParams, std::set const & templatedParams, bool raii, bool raiiFactory, CommandFlavourFlags flavourFlags ) const; std::string generateCallArgumentsStandard( std::string const & handle, std::vector const & params ) const; std::string generateCallArgumentEnhanced( std::vector const & params, size_t paramIndex, bool nonConstPointerAsNullptr, std::set const & singularParams, std::set const & templatedParams, CommandFlavourFlags flavourFlags, bool raiiFactory ) const; std::string generateCallArgumentEnhancedConstPointer( ParamData const & param, size_t paramIndex, std::set const & singularParams, std::set const & templatedParams ) const; std::string generateCallArgumentEnhancedNonConstPointer( ParamData const & param, size_t paramIndex, bool nonConstPointerAsNullptr, std::set const & singularParams ) const; std::string generateCallArgumentEnhancedValue( std::vector const & params, size_t paramIndex, std::set const & singularParams, CommandFlavourFlags flavourFlags, bool raiiFactory ) const; std::string generateCallSequence( std::string const & name, CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, size_t initialSkipCount, std::set const & singularParams, std::set const & templatedParams, std::vector const & chainedReturnParams, CommandFlavourFlags flavourFlags, bool raii, bool raiiFactory ) const; std::string generateChainTemplates( std::vector const & returnParams, bool chained ) const; std::string generateCommand( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandDefinitions() const; std::string generateCommandDefinitions( std::vector const & requireData, std::set & listedCommands, std::string const & title ) const; std::string generateCommandDefinitions( std::string const & command, std::string const & handle ) const; std::string generateCommandEnhanced( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::map const & vectorParams, std::vector const & returnParams, CommandFlavourFlags flavourFlags = {} ) const; std::string generateCommandName( std::string const & vulkanCommandName, std::vector const & params, size_t initialSkipCount, CommandFlavourFlags flavourFlags = {} ) const; std::string generateCommandResult( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandResultMultiSuccessNoErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandResultMultiSuccessWithErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandResultMultiSuccessWithErrors1Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandResultMultiSuccessWithErrors2Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector const & returnParamIndices, bool raii ) const; std::string generateCommandResultMultiSuccessWithErrors3Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector const & returnParamIndices, bool raii ) const; std::string generateCommandResultSingleSuccess( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandResultSingleSuccessNoErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors1Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors1ReturnChain( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors1ReturnHandle( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors1ReturnValue( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors1ReturnVoid( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandResultSingleSuccessWithErrors2Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector const & returnParamIndices, bool raii ) const; std::string generateCommandResultWithErrors0Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandSet( bool definition, std::string const & standard, std::vector const & enhanced = {}, std::vector const & unique = {} ) const; std::string generateCommandSet( std::string const & standard, std::string const & enhanced ) const; std::string generateCommandSetInclusive( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector returnParams, std::map vectorParams, bool unique, std::vector const & flags, bool raii, bool raiiFactory, std::vector const & raiiFlags ) const; std::string generateCommandSetExclusive( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandStandard( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; std::string generateCommandVoid( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandValue( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandVoid0Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const; std::string generateCommandVoid1Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const; std::string generateCommandVoid2Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector const & returnParamIndices, bool raii ) const; std::string generateConstexprString( std::string const & structName ) const; std::string generateConstexprDefines() const; std::string generateConstexprUsings() const; std::string generateCppModuleHandleUsings() const; std::string generateCppModuleStructUsings() const; std::string generateCppModuleUniqueHandleUsings() const; std::string generateCppModuleFuncsUsings() const; std::string generateCppModuleEnumUsings() const; std::string generateCppModuleFormatTraitsUsings() const; std::string generateCppModuleExtensionInspectionUsings() const; std::string generateCppModuleUsings() const; std::string generateCppModuleRaiiUsings() const; std::string generateCppModuleSharedHandleUsings() const; std::string generateDataDeclarations( CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, std::set const & templatedParams, CommandFlavourFlags flavourFlags, bool raii, std::vector const & dataTypes, std::string const & dataType, std::string const & returnType, std::string const & returnVariable ) const; std::string generateDataDeclarations1Return( CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, std::set const & templatedParams, CommandFlavourFlags flavourFlags, std::vector const & dataTypes, std::string const & dataType, std::string const & returnType, std::string const & returnVariable ) const; std::string generateDataDeclarations2Returns( CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, CommandFlavourFlags flavourFlags, bool raii, std::vector const & dataTypes, std::string const & returnType, std::string const & returnVariable ) const; std::string generateDataDeclarations3Returns( CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, CommandFlavourFlags flavourFlags, bool raii, std::vector const & dataTypes ) const; std::string generateDataPreparation( CommandData const & commandData, size_t initialSkipCount, std::vector const & returnParams, std::map const & vectorParams, std::set const & templatedParams, CommandFlavourFlags flavourFlags, bool enumerating ) const; std::string generateDataSizeChecks( CommandData const & commandData, std::vector const & returnParams, std::vector const & returnParamTypes, std::map const & vectorParams, std::set const & templatedParams, bool singular ) const; std::string generateDebugReportObjectType( std::string const & objectType ) const; std::string generateDecoratedReturnType( std::string const & name, CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, CommandFlavourFlags flavourFlags, bool raii, std::string const & returnType ) const; std::string generateDispatchLoaderDynamic() const; // uses vkGet*ProcAddress to get function pointers std::string generateDispatchLoaderStatic() const; // uses exported symbols from loader std::string generateDestroyCommand( std::string const & name, CommandData const & commandData ) const; std::string generateDispatchLoaderDynamicCommandAssignment( std::string const & commandName, std::string const & firstArg ) const; std::string generateDispatchLoaderStaticCommands( std::vector const & requireData, std::set & listedCommands, std::string const & title ) const; std::string generateEnum( std::pair const & enumData, std::string const & surroundingProtect ) const; std::string generateEnumInitializer( TypeInfo const & type, std::vector const & arraySizes, std::vector const & values, bool bitmask ) const; std::string generateEnums() const; std::string generateEnums( std::vector const & requireData, std::set & listedEnums, std::string const & title ) const; std::string generateEnumsToString() const; std::string generateEnumsToString( std::vector const & requireData, std::set & listedEnums, std::string const & title ) const; std::string generateEnumToString( std::pair const & enumData ) const; std::pair generateEnumSuffixes( std::string const & name, bool bitmask ) const; std::string generateEnumValueName( std::string const & enumName, std::string const & valueName, bool bitmask ) const; std::string generateExtensionDependencies() const; std::string generateExtensionDependsByVersion( bool definition ) const; template std::string generateExtensionReplacedBy( Predicate p, Extraction e ) const; template std::string generateExtensionReplacedTest( Predicate p ) const; std::string generateExtensionsList( std::string const & type ) const; std::string generateExtensionTypeTest( std::string const & type ) const; std::string generateFormatTraits() const; std::string generateFunctionPointerCheck( std::string const & function, std::set const & requiredBy, bool raii ) const; std::string generateHandle( std::pair const & handle, std::set & listedHandles ) const; std::string generateHandleCommandDeclarations( std::set const & commands ) const; std::string generateHandleDependencies( std::pair const & handle, std::set & listedHandles ) const; std::string generateHandleEmpty( HandleData const & handleData ) const; std::string generateHandleForwardDeclarations() const; std::string generateHandleForwardDeclarations( std::vector const & requireData, std::string const & title ) const; std::string generateHandleHashStructures( std::vector const & requireData, std::string const & title ) const; std::string generateHandleHashStructures() const; std::string generateHandles() const; std::string generateIndexTypeTraits() const; std::string generateLenInitializer( std::vector::const_iterator mit, std::map::const_iterator, std::vector::const_iterator>>::const_iterator litit, bool mutualExclusiveLens ) const; std::string generateName( TypeInfo const & typeInfo ) const; std::string generateNoExcept( std::vector const & errorCodes, std::vector const & returnParams, std::map const & vectorParams, CommandFlavourFlags flavourFlags, bool vectorSizeCheck, bool raii ) const; std::string generateObjectDeleter( std::string const & commandName, CommandData const & commandData, size_t initialSkipCount, size_t returnParam ) const; std::string generateObjectTypeToDebugReportObjectType() const; std::pair generateProtection( std::string const & protect, bool defined = true ) const; std::string generateRAIICommandDefinitions() const; std::string generateRAIICommandDefinitions( std::vector const & requireData, std::set & listedCommands, std::string const & title ) const; std::string generateRAIIDispatchers() const; std::string generateRAIIFactoryReturnStatements( std::vector const & params, std::vector const & successCodes, std::string const & vkType, bool enumerating, std::string const & returnType, std::string const & returnVariable, bool singular ) const; std::string generateRAIIHandle( std::pair const & handle, std::set & listedHandles, std::set const & specialFunctions ) const; std::string generateRAIIHandleCommand( std::string const & command, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommandDeclarations( std::pair const & handle, std::set const & specialFunctions ) const; std::string generateRAIIHandleCommandEnhanced( std::string const & name, CommandData const & commandData, size_t initialSkipCount, std::vector const & returnParams, std::map const & vectorParamIndices, bool definition, CommandFlavourFlags flavourFlags = {} ) const; std::string generateRAIIHandleCommandFactory( std::string const & name, CommandData const & commandData, size_t initialSkipCount, std::vector const & returnParams, std::map const & vectorParams, bool definition, CommandFlavourFlags flavourFlags = {} ) const; std::string generateRAIIHandleCommandFactoryArgumentList( std::vector const & params, std::set const & skippedParams, bool definition, bool singular ) const; std::pair generateRAIIHandleConstructor( std::pair const & handle, std::map::const_iterator constructorIt, std::string const & enter, std::string const & leave ) const; std::string generateRAIIHandleConstructorByCall( std::pair const & handle, std::map::const_iterator constructorIt, std::string const & enter, std::string const & leave, bool isPlural, bool forceSingular ) const; std::pair generateRAIIHandleConstructor1Return2Vector( std::pair const & handle, std::map::const_iterator constructorIt, std::string const & enter, std::string const & leave, size_t returnParam, std::map const & vectorParamIndices ) const; std::pair generateRAIIHandleConstructors( std::pair const & handle ) const; std::string generateRAIIHandleConstructorArgument( ParamData const & param, bool definition, bool singular, bool takesOwnership ) const; std::string generateRAIIHandleConstructorArguments( std::pair const & handle, std::map::const_iterator constructorIt, bool singular, bool takesOwnership ) const; std::string generateRAIIHandleConstructorInitializationList( std::pair const & handle, std::map::const_iterator constructorIt, std::map::const_iterator destructorIt, bool takesOwnership ) const; std::string generateRAIIHandleConstructorParamName( std::string const & type, std::map::const_iterator destructorIt ) const; std::pair generateRAIIHandleConstructorResult( std::pair const & handle, std::map::const_iterator constructorIt, std::string const & enter, std::string const & leave ) const; std::string generateRAIIHandleConstructorTakeOwnership( std::pair const & handle ) const; std::pair generateRAIIHandleConstructorVoid( std::pair const & handle, std::map::const_iterator constructorIt, std::string const & enter, std::string const & leave ) const; std::string generateRAIIHandleContext( std::pair const & handle, std::set const & specialFunctions ) const; std::string generateRAIIHandleDestructorCallArguments( std::string const & handleType, std::map::const_iterator destructorIt ) const; std::tuple generateRAIIHandleDetails( std::pair const & handle ) const; std::string generateRAIIHandleForwardDeclarations( std::vector const & requireData, std::string const & title ) const; std::string generateRAIIHandles() const; std::string generateRAIIHandleSingularConstructorArguments( std::pair const & handle, std::vector const & params, bool singular ) const; template std::string generateReplacedExtensionsList( Predicate p, Extraction e ) const; std::string generateResultAssignment( CommandData const & commandData ) const; std::string generateResultCheck( CommandData const & commandData, std::string const & className, std::string const & classSeparator, std::string commandName, bool enumerating ) const; std::string generateResultCheckExpected( std::vector const & successCodes, std::string const & className, std::string const & commandName ) const; std::string generateResultExceptions() const; std::string generateReturnStatement( std::string const & commandName, CommandData const & commandData, std::string const & returnVariable, std::string const & returnType, std::string const & decoratedReturnType, std::string const & dataType, size_t initialSkipCount, size_t returnParam, CommandFlavourFlags flavourFlags, bool enumerating, bool raii ) const; std::string generateReturnType( std::vector const & returnParams, std::map const & vectorParams, CommandFlavourFlags flavourFlags, bool raii, std::vector const & dataTypes ) const; std::string generateReturnVariable( CommandData const & commandData, std::vector const & returnParams, std::map const & vectorParams, CommandFlavourFlags flavourFlags ) const; std::string generateSizeCheck( std::vector::const_iterator> const & arrayIts, std::string const & structName, bool mutualExclusiveLens ) const; std::string generateStaticAssertions() const; std::string generateStaticAssertions( std::vector const & requireData, std::string const & title, std::set & listedStructs ) const; std::string generateStruct( std::pair const & structure, std::set & listedStructs ) const; std::string generateStructCompareOperators( std::pair const & structure ) const; std::string generateStructConstructors( std::pair const & structData ) const; std::string generateStructConstructorsEnhanced( std::pair const & structData ) const; std::string generateStructConstructorArgument( bool listedArgument, MemberData const & memberData, bool withDefault ) const; std::string generateStructHashStructure( std::pair const & structure, std::set & listedStructs ) const; std::string generateStructHashStructures() const; std::string generateStructHashSum( std::string const & structName, std::vector const & members ) const; std::string generateStructs() const; std::string generateStructure( std::pair const & structure ) const; std::string generateStructExtendsStructs() const; std::string generateStructExtendsStructs( std::vector const & requireData, std::set & listedStructs, std::string const & title ) const; std::string generateStructForwardDeclarations() const; std::string generateStructForwardDeclarations( std::vector const & requireData, std::string const & title, std::set & listedStructs ) const; std::tuple generateStructMembers( std::pair const & structData ) const; std::string generateStructSetter( std::string const & structureName, std::vector const & memberData, size_t index ) const; std::string generateStructSubConstructor( std::pair const & structData ) const; std::string generateSuccessCheck( std::vector const & successCodes ) const; std::string generateSuccessCode( std::string const & code ) const; std::string generateSuccessCodeList( std::vector const & successCodes, bool enumerating ) const; std::string generateThrowResultException() const; std::string generateTypenameCheck( std::vector const & returnParams, std::map const & vectorParams, std::vector const & chainedReturnParams, bool definition, std::vector const & dataTypes, CommandFlavourFlags flavourFlags ) const; std::string generateUnion( std::pair const & structure ) const; std::string generateUniqueHandle( std::pair const & handleData ) const; std::string generateUniqueHandle( std::vector const & requireData, std::string const & title ) const; std::string generateUniqueHandles() const; std::string generateSharedHandle( std::pair const & handleData ) const; std::string generateSharedHandle( std::vector const & requireData, std::string const & title ) const; std::string generateSharedHandleNoDestroy( std::pair const & handleData ) const; std::string generateSharedHandleNoDestroy( std::vector const & requireData, std::string const & title ) const; std::string generateSharedHandles() const; std::string generateSharedHandlesNoDestroy() const; std::string generateVectorSizeCheck( std::string const & name, CommandData const & commandData, size_t initialSkipCount, std::map> const & countToVectorMap, std::set const & skippedParams, bool onlyThrows ) const; CommandData const & getCommandData( std::string const & command ) const; std::pair getParentTypeAndName( std::pair const & handle ) const; std::string getPlatform( std::string const & title ) const; std::pair getPoolTypeAndName( std::string const & type ) const; std::string getProtectFromPlatform( std::string const & platform ) const; std::string getProtectFromTitle( std::string const & title ) const; std::string getProtectFromTitles( std::set const & titles ) const; std::string getProtectFromType( std::string const & type ) const; std::string getVectorSize( std::vector const & params, std::map const & vectorParamIndices, size_t returnParam, std::string const & returnParamType, std::set const & templatedParams ) const; void handleRemoval( RemoveData const & removeData ); bool handleRemovalCommand( std::string const & command, std::vector & requireData ); void handleRemovals(); bool handleRemovalType( std::string const & type, std::vector & requireData ); bool hasLen( MemberData const & md, std::vector const & members ) const; bool hasParentHandle( std::string const & handle, std::string const & parent ) const; bool isDeviceCommand( CommandData const & commandData ) const; bool isExtension( std::string const & name ) const; bool isFeature( std::string const & name ) const; bool isHandleType( std::string const & type ) const; bool isLenByStructMember( std::string const & name, std::vector const & params ) const; bool isLenByStructMember( std::string const & name, ParamData const & param ) const; bool isMultiSuccessCodeConstructor( std::vector::const_iterator> const & constructorIts ) const; bool isParam( std::string const & name, std::vector const & params ) const; bool isStructMember( std::string const & name, std::vector const & memberData ) const; bool isStructureChainAnchor( std::string const & type ) const; bool isSupported( std::set const & requiredBy ) const; bool isSupportedExtension( std::string const & name ) const; bool isSupportedFeature( std::string const & name ) const; bool isTypeRequired( std::string const & type ) const; bool isTypeUsed( std::string const & type ) const; bool needsStructureChainResize( std::map const & vectorParams, std::vector const & chainedReturnParams ) const; std::pair>> needsVectorSizeCheck( std::vector const & params, std::map const & vectorParams, std::vector const & returnParams, std::set const & singularParams, std::set const & skippedParams ) const; void readCommand( tinyxml2::XMLElement const * element ); std::pair readCommandParam( tinyxml2::XMLElement const * element, std::vector const & params ); std::pair readCommandProto( tinyxml2::XMLElement const * element ); void readCommands( tinyxml2::XMLElement const * element ); void readEnums( tinyxml2::XMLElement const * element ); void readEnumsConstants( tinyxml2::XMLElement const * element ); void readEnumsEnum( tinyxml2::XMLElement const * element, std::map::iterator enumIt ); void readExtension( tinyxml2::XMLElement const * element ); void readExtensionRequire( tinyxml2::XMLElement const * element, ExtensionData & extensionData, bool extensionSupported ); void readExtensions( tinyxml2::XMLElement const * element ); void readFeature( tinyxml2::XMLElement const * element ); RemoveData readFeatureRemove( tinyxml2::XMLElement const * element ); RequireData readFeatureRequire( tinyxml2::XMLElement const * element, std::string const & featureName, bool featureSupported ); void readFormat( tinyxml2::XMLElement const * element ); void readFormatComponent( tinyxml2::XMLElement const * element, FormatData & formatData ); void readFormatPlane( tinyxml2::XMLElement const * element, FormatData & formatData ); void readFormats( tinyxml2::XMLElement const * element ); void readFormatSPIRVImageFormat( tinyxml2::XMLElement const * element, FormatData & formatData ); std::string readName( tinyxml2::XMLElement const * elements ); std::pair readNameAndType( tinyxml2::XMLElement const * elements ); void readPlatform( tinyxml2::XMLElement const * element ); void readPlatforms( tinyxml2::XMLElement const * element ); void readRegistry( tinyxml2::XMLElement const * element ); std::string readRequireCommand( tinyxml2::XMLElement const * element, std::string const & requiredBy ); void readRequireEnum( tinyxml2::XMLElement const * element, std::string const & requiredBy, std::string const & platform, bool supported, RequireData & requireData ); std::string readRequireType( tinyxml2::XMLElement const * element, std::string const & requiredBy ); void readSPIRVCapability( tinyxml2::XMLElement const * element ); void readSPIRVCapabilityEnable( tinyxml2::XMLElement const * element ); void readSPIRVCapabilities( tinyxml2::XMLElement const * element ); void readSPIRVExtension( tinyxml2::XMLElement const * element ); void readSPIRVExtensionEnable( tinyxml2::XMLElement const * element ); void readSPIRVExtensions( tinyxml2::XMLElement const * element ); void readStructMember( tinyxml2::XMLElement const * element, std::vector & members, bool isUnion ); void readSync( tinyxml2::XMLElement const * element ); void readSyncAccess( tinyxml2::XMLElement const * element, std::map::const_iterator accessFlagBitsIt, std::map::const_iterator accessFlagBits2It, std::map::const_iterator stageFlagBits2It ); void readSyncAccessEquivalent( tinyxml2::XMLElement const * element, std::map::const_iterator accessFlagBits2It ); void readSyncAccessSupport( tinyxml2::XMLElement const * element, std::map::const_iterator stageFlagBits2It ); void readSyncPipeline( tinyxml2::XMLElement const * element ); void readSyncStage( tinyxml2::XMLElement const * element, std::map::const_iterator stageFlagBitsIt, std::map::const_iterator stageFlagBits2It ); void readSyncStageEquivalent( tinyxml2::XMLElement const * element, std::map::const_iterator stageFlagBits2It ); void readSyncStageSupport( tinyxml2::XMLElement const * element ); void readTag( tinyxml2::XMLElement const * element ); void readTags( tinyxml2::XMLElement const * element ); void readTypeBasetype( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeBitmask( tinyxml2::XMLElement const * element, std::map const & attributes ); DefinesPartition partitionDefines( std::map const & defines ); void readTypeDefine( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeEnum( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeFuncpointer( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeHandle( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeInclude( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeRequires( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeStruct( tinyxml2::XMLElement const * element, bool isUnion, std::map const & attributes ); void readTypes( tinyxml2::XMLElement const * element ); void readTypesType( tinyxml2::XMLElement const * element ); TypeInfo readTypeInfo( tinyxml2::XMLElement const * element ) const; void registerDeleter( std::string const & commandName, CommandData const & commandData ); void rescheduleRAIIHandle( std::string & str, std::pair const & handle, std::set & listedHandles, std::set const & specialFunctions ) const; std::vector selectCommandsByHandle( std::vector const & requireData, std::set const & handleCommands, std::set & listedCommands ) const; bool skipLeadingGrandParent( std::pair const & handle ) const; std::string stripPluralS( std::string const & name ) const; std::string toString( TypeCategory category ); private: std::string m_api; std::map m_baseTypes; std::map m_bitmaskAliases; std::map m_bitmasks; std::map m_commandAliases; std::map m_commands; std::map m_constantAliases; std::map m_constants; std::map m_defines; DefinesPartition m_definesPartition; // partition defined macros into mutually-exclusive sets of callees, callers, and values std::map m_enumAliases; std::map m_enums; std::set m_extendedStructs; // structs which are referenced by the structextends tag std::vector m_extensions; std::map m_externalTypes; std::vector m_features; std::map m_formats; std::map m_funcPointers; std::map m_handleAliases; std::map m_handles; std::map m_includes; std::map m_platforms; std::set m_RAIISpecialFunctions; std::map m_structAliases; std::map m_structs; std::map m_tags; std::map m_types; std::set m_unsupportedExtensions; std::set m_unsupportedFeatures; std::string m_version; std::string m_vulkanLicenseHeader; };