Merge pull request #770 from asuessenbach/refactor

Refactor functions returning a vector of handles, that might as well …
This commit is contained in:
Andreas Süßenbach 2020-10-12 22:51:36 +02:00 committed by GitHub
commit c3f83db9d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1337 additions and 1370 deletions

File diff suppressed because it is too large Load Diff

View File

@ -74,7 +74,7 @@ private:
struct TypeInfo struct TypeInfo
{ {
std::string compose() const; std::string compose( bool inNamespace = true) const;
bool operator==( TypeInfo const & rhs ) const bool operator==( TypeInfo const & rhs ) const
{ {
@ -280,7 +280,6 @@ private:
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool twoStep, bool twoStep,
bool firstCall, bool firstCall,
bool singular,
size_t from, size_t from,
size_t to ) const; size_t to ) const;
void appendArgumentVector( std::string & str, void appendArgumentVector( std::string & str,
@ -289,9 +288,8 @@ private:
size_t returnParamIndex, size_t returnParamIndex,
size_t templateParamIndex, size_t templateParamIndex,
bool twoStep, bool twoStep,
bool firstCall, bool firstCall ) const;
bool singular ) const; void appendArgumentVulkanType( std::string & str, ParamData const & paramData ) const;
void appendArgumentVulkanType( std::string & str, ParamData const & paramData, bool isLocalVariable ) const;
void appendBitmask( std::string & os, void appendBitmask( std::string & os,
std::string const & bitmaskName, std::string const & bitmaskName,
std::string const & bitmaskType, std::string const & bitmaskType,
@ -309,8 +307,7 @@ private:
size_t templateParamIndex, size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool twoStep, bool twoStep,
bool firstCall, bool firstCall ) const;
bool singular ) const;
void appendCommand( std::string & str, void appendCommand( std::string & str,
std::string const & indentation, std::string const & indentation,
std::string const & name, std::string const & name,
@ -336,16 +333,24 @@ private:
CommandData const & commandData, CommandData const & commandData,
size_t nonConstPointerIndex, size_t nonConstPointerIndex,
bool definition ) const; bool definition ) const;
void appendCommandGetVector( std::string & str, void appendCommandGetVector( std::string & str,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const; size_t returnParamIndex,
void appendCommandGetVectorOfHandles( std::string & str, bool definition ) const;
std::string const & name, void appendCommandGetVectorOfHandles( std::string & str,
CommandData const & commandData, std::string const & name,
std::pair<size_t, size_t> const & vectorParamIndices, CommandData const & commandData,
bool definition ) const; std::map<size_t, size_t> const & vectorParamIndices,
size_t returnParamIndex,
bool definition ) const;
void appendCommandGetVectorOfHandlesIndirect( std::string & str,
std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
size_t returnParamIndex,
bool definition ) const;
void appendCommandSimple( std::string & str, void appendCommandSimple( std::string & str,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
@ -393,8 +398,6 @@ private:
std::string const & enhancedReturnType, std::string const & enhancedReturnType,
bool definition, bool definition,
bool enhanced, bool enhanced,
bool singular,
bool unique,
bool isStructureChain, bool isStructureChain,
bool withAllocatorArgument ) const; bool withAllocatorArgument ) const;
std::string appendFunctionBodyEnhancedLocalReturnVariable( std::string & str, std::string appendFunctionBodyEnhancedLocalReturnVariable( std::string & str,
@ -402,16 +405,9 @@ private:
CommandData const & commandData, CommandData const & commandData,
size_t returnParamIndex, size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool twoStep,
std::string const & enhancedReturnType, std::string const & enhancedReturnType,
bool singular,
bool isStructureChain, bool isStructureChain,
bool withAllocator ) const; bool withAllocator ) const;
void appendFunctionBodyEnhancedLocalReturnVariableVectorSize( std::string & str,
std::vector<ParamData> const & params,
std::pair<size_t, size_t> const & vectorParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool withAllocator ) const;
void appendFunctionBodyEnhancedMultiVectorSizeCheck( std::string & str, void appendFunctionBodyEnhancedMultiVectorSizeCheck( std::string & str,
std::string const & indentation, std::string const & indentation,
std::string const & name, std::string const & name,
@ -424,9 +420,7 @@ private:
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
size_t returnParamIndex, size_t returnParamIndex,
bool twoStep, bool twoStep ) const;
bool singular,
bool unique ) const;
void appendFunctionBodyEnhancedTwoStep( std::string & str, void appendFunctionBodyEnhancedTwoStep( std::string & str,
std::string const & indentation, std::string const & indentation,
std::string const & name, std::string const & name,
@ -434,7 +428,6 @@ private:
size_t returnParamIndex, size_t returnParamIndex,
size_t templateParamIndex, size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool singular,
std::string const & returnName ) const; std::string const & returnName ) const;
void appendFunctionBodyEnhancedVectorOfStructureChain( std::string & str, void appendFunctionBodyEnhancedVectorOfStructureChain( std::string & str,
std::string const & indentation, std::string const & indentation,
@ -443,16 +436,6 @@ private:
size_t returnParamIndex, size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool withAllocator ) const; bool withAllocator ) const;
void appendFunctionBodyEnhancedVectorOfUniqueHandles( std::string & str,
std::string const & indentation,
std::string const & name,
CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool twoStep,
bool singular,
bool withAllocator ) const;
void appendFunctionBodyStandardArgument( std::string & str, void appendFunctionBodyStandardArgument( std::string & str,
TypeInfo const & typeData, TypeInfo const & typeData,
std::string const & name, std::string const & name,
@ -464,20 +447,16 @@ private:
bool skip, bool skip,
bool argEncountered, bool argEncountered,
bool isTemplateParam, bool isTemplateParam,
bool singular,
bool withDefaults, bool withDefaults,
bool withAllocator ) const; bool withAllocator ) const;
void appendFunctionHeaderArgumentEnhancedPointer( std::string & str, void appendFunctionHeaderArgumentEnhancedPointer( std::string & str,
ParamData const & param, ParamData const & param,
std::string const & strippedParameterName, std::string const & strippedParameterName ) const;
bool withDefaults,
bool withAllocator ) const;
void appendFunctionHeaderArgumentEnhancedVector( std::string & str, void appendFunctionHeaderArgumentEnhancedVector( std::string & str,
ParamData const & param, ParamData const & param,
std::string const & strippedParameterName, std::string const & strippedParameterName,
bool hasSizeParam, bool hasSizeParam,
bool isTemplateParam, bool isTemplateParam,
bool singular,
bool withDefaults, bool withDefaults,
bool withAllocator ) const; bool withAllocator ) const;
void appendFunctionHeaderArguments( std::string & str, void appendFunctionHeaderArguments( std::string & str,
@ -486,19 +465,15 @@ private:
size_t templateParamIndex, size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool enhanced, bool enhanced,
bool singular,
bool withDefaults, bool withDefaults,
bool withAllocator ) const; bool withAllocator ) const;
bool appendFunctionHeaderArgumentStandard( std::string & str, ParamData const & param, bool argEncountered ) const; bool appendFunctionHeaderArgumentStandard( std::string & str, ParamData const & param, bool argEncountered ) const;
void appendFunctionHeaderReturnType( std::string & str, void appendFunctionHeaderReturnType( std::string & str,
CommandData const & commandData, CommandData const & commandData,
size_t returnParamIndex, size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
std::string const & enhancedReturnType, std::string const & enhancedReturnType,
bool enhanced, bool enhanced,
bool twoStep, bool twoStep,
bool singular,
bool unique,
bool isStructureChain ) const; bool isStructureChain ) const;
void appendFunctionHeaderTemplate( std::string & str, void appendFunctionHeaderTemplate( std::string & str,
std::string const & indentation, std::string const & indentation,
@ -506,8 +481,6 @@ private:
size_t templateParamIndex, size_t templateParamIndex,
std::string const & enhancedReturnType, std::string const & enhancedReturnType,
bool enhanced, bool enhanced,
bool singular,
bool unique,
bool withDefault, bool withDefault,
bool isStructureChain, bool isStructureChain,
bool withAllocatorArgument ) const; bool withAllocatorArgument ) const;
@ -545,6 +518,7 @@ private:
std::set<std::string> const & childrenTypes ) const; std::set<std::string> const & childrenTypes ) const;
std::string constructArgumentListEnhanced( std::vector<ParamData> const & params, std::string constructArgumentListEnhanced( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams, std::set<size_t> const & skippedParams,
size_t singularParam,
bool definition, bool definition,
bool withAllocators ) const; bool withAllocators ) const;
std::string constructArgumentListStandard( std::vector<ParamData> const & params, std::string constructArgumentListStandard( std::vector<ParamData> const & params,
@ -557,9 +531,10 @@ private:
std::string constructCallArgumentsGetValue( std::string const & handle, std::string constructCallArgumentsGetValue( std::string const & handle,
std::vector<ParamData> const & params, std::vector<ParamData> const & params,
size_t skippedParams ) const; size_t skippedParams ) const;
std::string constructCallArgumentsGetVector( std::vector<ParamData> const & params, std::string constructCallArgumentsGetVector( std::vector<ParamData> const & params,
std::pair<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool singular ) const; size_t returnParamIndex,
bool singular ) const;
std::string constructCallArgumentsStandard( std::string const & handle, std::vector<ParamData> const & params ) const; std::string constructCallArgumentsStandard( std::string const & handle, std::vector<ParamData> const & params ) const;
std::string constructCallArgumentsVectors( std::vector<ParamData> const & params, std::string constructCallArgumentsVectors( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices ) const; std::map<size_t, size_t> const & vectorParamIndices ) const;
@ -586,33 +561,43 @@ private:
CommandData const & commandData, CommandData const & commandData,
size_t nonConstPointerIndex, size_t nonConstPointerIndex,
bool definition ) const; bool definition ) const;
std::string constructCommandGetVector( std::string const & name, std::string constructCommandGetVector( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::pair<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const; size_t returnParamIndex,
std::string constructCommandGetVectorDeprecated( std::string const & name, bool definition ) const;
CommandData const & commandData, std::string constructCommandGetVectorDeprecated( std::string const & name,
std::pair<size_t, size_t> const & vectorParamIndices, CommandData const & commandData,
bool definition ) const; std::map<size_t, size_t> const & vectorParamIndices,
std::string constructCommandGetVectorOfHandles( std::string const & name, size_t returnParamIndex,
CommandData const & commandData, bool definition ) const;
std::pair<size_t, size_t> const & vectorParamIndices, std::string constructCommandGetVectorOfHandles( std::string const & name,
bool definition, CommandData const & commandData,
bool withAllocator ) const; std::map<size_t, size_t> const & vectorParamIndices,
std::string constructCommandGetVectorOfUniqueHandles( std::string const & name, size_t returnParamIndex,
CommandData const & commandData, bool definition,
std::pair<size_t, size_t> const & vectorParamIndices, bool withAllocator ) const;
bool definition, std::string constructCommandGetVectorOfHandlesSingular( std::string const & name,
bool withAllocator ) const; CommandData const & commandData,
std::string std::map<size_t, size_t> const & vectorParamIndices,
constructCommandGetVectorOfUniqueHandlesWithAllocator( std::string const & name, size_t returnParamIndex,
CommandData const & commandData, bool definition ) const;
std::pair<size_t, size_t> const & vectorParamIndices, std::string constructCommandGetVectorOfUniqueHandles( std::string const & name,
bool definition ) const; CommandData const & commandData,
std::string constructCommandGetVectorSingular( std::string const & name, std::map<size_t, size_t> const & vectorParamIndices,
CommandData const & commandData, size_t returnParamIndex,
std::pair<size_t, size_t> const & vectorParamIndices, bool definition,
bool definition ) const; bool withAllocator ) const;
std::string constructCommandGetVectorOfUniqueHandlesSingular( std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
size_t returnParamIndex,
bool definition ) const;
std::string constructCommandGetVectorSingular( std::string const & name,
CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
size_t returnParamIndex,
bool definition ) const;
std::string constructCommandSimple( std::string const & name, std::string constructCommandSimple( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
bool definition, bool definition,
@ -625,64 +610,65 @@ private:
constructCommandStandard( std::string const & name, CommandData const & commandData, bool definition ) const; constructCommandStandard( std::string const & name, CommandData const & commandData, bool definition ) const;
std::string std::string
constructCommandStandardVoid( std::string const & name, CommandData const & commandData, bool definition ) const; constructCommandStandardVoid( std::string const & name, CommandData const & commandData, bool definition ) const;
std::string constructCommandTwoVectors( std::string const & name, std::string constructCommandTwoVectors( std::string const & name,
CommandData const & commandData, CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const;
std::string constructConstexprString( std::pair<std::string, StructureData> const & structData ) const;
std::string constructFunctionBodyEnhanced( std::string const & indentation,
std::string const & name,
CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool twoStep,
std::string const & enhancedReturnType,
bool isStructureChain,
bool withAllocator ) const;
std::string constructFunctionBodyEnhancedSingleStep( std::string const & indentation,
std::string const & name,
CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices ) const;
std::string constructFunctionBodyStandard( std::string const & indentation,
std::string const & commandName,
CommandData const & commandData ) const;
std::string constructFunctionHeaderArgumentsEnhanced( CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool withDefaults,
bool withAllocator ) const;
std::string constructFunctionHeaderArgumentsStandard( CommandData const & commandData, bool withDefaults ) const;
std::string constructNoDiscardEnhanced( CommandData const & commandData ) const;
std::string constructNoDiscardStandard( CommandData const & commandData ) const;
std::string constructReturnType( CommandData const & commandData, std::string const & baseType ) const;
std::string constructSuccessCheck( std::vector<std::string> const & successCodes ) const;
std::string constructSuccessCodeList( std::vector<std::string> const & successCodes ) const;
std::string constructVectorSizeCheck( std::string const & name,
CommandData const & commandData,
std::map<size_t, std::vector<size_t>> const & countToVectorMap,
std::set<size_t> const & skippedParams ) const;
void checkCorrectness();
bool containsArray( std::string const & type ) const;
bool containsUnion( std::string const & type ) const;
size_t determineDefaultStartIndex( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams ) const;
std::string determineEnhancedReturnType( CommandData const & commandData,
size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool isStructureChain ) const;
size_t determineReturnParamIndex( CommandData const & commandData,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool definition ) const; bool twoStep ) const;
std::string constructConstexprString( std::pair<std::string, StructureData> const & structData ) const; std::set<size_t> determineSkippedParams( std::string const & handleType,
std::string constructFunctionBodyEnhanced( std::string const & indentation, std::vector<ParamData> const & params,
std::string const & name,
CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool twoStep,
std::string const & enhancedReturnType,
bool singular,
bool unique,
bool isStructureChain,
bool withAllocator ) const;
std::string constructFunctionBodyEnhancedSingleStep( std::string const & indentation,
std::string const & name,
CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool singular ) const;
std::string constructFunctionBodyStandard( std::string const & indentation,
std::string const & commandName,
CommandData const & commandData ) const;
std::string constructFunctionHeaderArgumentsEnhanced( CommandData const & commandData,
size_t returnParamIndex,
size_t templateParamIndex,
std::map<size_t, size_t> const & vectorParamIndices,
bool singular,
bool withDefaults,
bool withAllocator ) const;
std::string constructFunctionHeaderArgumentsStandard( CommandData const & commandData, bool withDefaults ) const;
std::string constructNoDiscardEnhanced( CommandData const & commandData ) const;
std::string constructNoDiscardStandard( CommandData const & commandData ) const;
std::string constructReturnType( CommandData const & commandData, std::string const & baseType ) const;
std::string constructSuccessCodeList( std::vector<std::string> const & successCodes ) const;
std::string constructVectorSizeCheck( std::string const & name,
CommandData const & commandData,
std::map<size_t, std::vector<size_t>> const & countToVectorMap,
std::set<size_t> const & skippedParams ) const;
void checkCorrectness();
bool containsArray( std::string const & type ) const;
bool containsUnion( std::string const & type ) const;
size_t determineDefaultStartIndex( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams ) const;
std::string determineEnhancedReturnType( CommandData const & commandData,
size_t returnParamIndex,
std::map<size_t, size_t> const & vectorParamIndices, std::map<size_t, size_t> const & vectorParamIndices,
bool isStructureChain ) const; size_t returnParamIndex ) const;
size_t determineReturnParamIndex( CommandData const & commandData, std::string determineSubStruct( std::pair<std::string, StructureData> const & structure ) const;
std::map<size_t, size_t> const & vectorParamIndices, size_t determineTemplateParamIndex( std::vector<ParamData> const & params,
bool twoStep ) const; std::map<size_t, size_t> const & vectorParamIndices ) const;
std::string determineSubStruct( std::pair<std::string, StructureData> const & structure ) const;
size_t determineTemplateParamIndex( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices ) const;
std::vector<size_t> determineConstPointerParamIndices( std::vector<ParamData> const & params ) const; std::vector<size_t> determineConstPointerParamIndices( std::vector<ParamData> const & params ) const;
std::vector<size_t> determineNonConstPointerParamIndices( std::vector<ParamData> const & params ) const; std::vector<size_t> determineNonConstPointerParamIndices( std::vector<ParamData> const & params ) const;
std::map<size_t, size_t> determineVectorParamIndices( std::vector<ParamData> const & params ) const; std::map<size_t, size_t> determineVectorParamIndices( std::vector<ParamData> const & params ) const;
@ -699,6 +685,9 @@ private:
std::string const & prefix ) const; std::string const & prefix ) const;
std::set<std::string> getPlatforms( std::set<std::string> const & extensions ) const; std::set<std::string> getPlatforms( std::set<std::string> const & extensions ) const;
std::pair<std::string, std::string> getPoolTypeAndName( std::string const & type ) const; std::pair<std::string, std::string> getPoolTypeAndName( std::string const & type ) const;
std::string getVectorSize( std::vector<ParamData> const & params,
std::map<size_t, size_t> const & vectorParamIndices,
size_t returnParamIndex ) const;
bool isChainableStructure( std::string const & type ) const; bool isChainableStructure( std::string const & type ) const;
bool isHandleType( std::string const & type ) const; bool isHandleType( std::string const & type ) const;
bool isParam( std::string const & name, std::vector<ParamData> const & params ) const; bool isParam( std::string const & name, std::vector<ParamData> const & params ) const;

File diff suppressed because it is too large Load Diff