Unify detection logic for raii- and non-raii-command-generation (#1499)

This commit is contained in:
Andreas Süßenbach 2023-02-02 14:09:45 +01:00 committed by GitHub
parent 83adc3fa57
commit e651117495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 796 additions and 1208 deletions

File diff suppressed because it is too large Load Diff

View File

@ -60,10 +60,11 @@ private:
enum class CommandFlavourFlagBits : uint8_t enum class CommandFlavourFlagBits : uint8_t
{ {
chained = 1 << 0, enhanced = 1 << 0,
singular = 1 << 1, chained = 1 << 1,
unique = 1 << 2, singular = 1 << 2,
withAllocator = 1 << 3 unique = 1 << 3,
withAllocator = 1 << 4
}; };
using CommandFlavourFlags = Flags<CommandFlavourFlagBits>; using CommandFlavourFlags = Flags<CommandFlavourFlagBits>;
@ -554,7 +555,7 @@ private:
CommandFlavourFlags flavourFlags, CommandFlavourFlags flavourFlags,
bool raii ) const; bool raii ) const;
std::string generateChainTemplates( std::vector<size_t> const & returnParams, bool chained ) const; std::string generateChainTemplates( std::vector<size_t> const & returnParams, bool chained ) const;
std::string generateCommand( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) 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() const;
std::string std::string
generateCommandDefinitions( std::vector<RequireData> const & requireData, std::set<std::string> & listedCommands, std::string const & title ) const; generateCommandDefinitions( std::vector<RequireData> const & requireData, std::set<std::string> & listedCommands, std::string const & title ) const;
@ -571,70 +572,80 @@ private:
size_t initialSkipCount, size_t initialSkipCount,
std::set<std::string> const & tags, std::set<std::string> const & tags,
CommandFlavourFlags flavourFlags = {} ) const; CommandFlavourFlags flavourFlags = {} ) const;
std::string std::string generateCommandResult( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const;
generateCommandResultMultiSuccessNoErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; std::string generateCommandResultMultiSuccessNoErrors(
std::string generateCommandResultMultiSuccessNoErrors0Return( std::string const & name, std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const;
CommandData const & commandData, std::string generateCommandResultMultiSuccessWithErrors(
size_t initialSkipCount, std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const;
bool definition ) const;
std::string generateCommandResultMultiSuccessNoErrors2Return(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector<size_t> const & returnParams ) const;
std::string
generateCommandResultMultiSuccessWithErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const;
std::string generateCommandResultMultiSuccessWithErrors1Return( std::string generateCommandResultMultiSuccessWithErrors1Return(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const;
std::string generateCommandResultMultiSuccessWithErrors2Return( std::string generateCommandResultMultiSuccessWithErrors2Return( std::string const & name,
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector<size_t> const & returnParamIndices ) const; CommandData const & commandData,
std::string generateCommandResultMultiSuccessWithErrors3Return( size_t initialSkipCount,
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector<size_t> const & returnParamIndices ) const; bool definition,
std::vector<size_t> const & returnParamIndices,
bool raii ) const;
std::string generateCommandResultMultiSuccessWithErrors3Return( std::string const & name,
CommandData const & commandData,
size_t initialSkipCount,
bool definition,
std::vector<size_t> const & returnParamIndices,
bool raii ) const;
std::string std::string
generateCommandResultSingleSuccessNoErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; generateCommandResultSingleSuccess( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const;
std::string std::string generateCommandResultSingleSuccessNoErrors(
generateCommandResultSingleSuccessWithErrors( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; 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 generateCommandResultSingleSuccessWithErrors1Return(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnChain( std::string generateCommandResultSingleSuccessWithErrors1ReturnChain(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnHandle( std::string generateCommandResultSingleSuccessWithErrors1ReturnHandle(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnHandle1Vector( std::string const & name,
CommandData const & commandData,
size_t initialSkipCount,
bool definition,
size_t returnParam,
std::pair<size_t, VectorParamData> const & vectorParamIndex ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnHandle2Vector( std::string const & name,
CommandData const & commandData,
size_t initialSkipCount,
bool definition,
size_t returnParam,
std::map<size_t, VectorParamData> const & vectorParamIndices ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnValue( std::string generateCommandResultSingleSuccessWithErrors1ReturnValue(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnValue2Vectors( std::string const & name,
CommandData const & commandData,
size_t initialSkipCount,
bool definition,
size_t returnParam,
std::map<size_t, VectorParamData> const & vectorParamIndices ) const;
std::string generateCommandResultSingleSuccessWithErrors1ReturnVoid( std::string generateCommandResultSingleSuccessWithErrors1ReturnVoid(
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam, bool raii ) const;
std::string generateCommandResultSingleSuccessWithErrors2Return( std::string generateCommandResultSingleSuccessWithErrors2Return( std::string const & name,
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector<size_t> const & returnParamIndices ) const; CommandData const & commandData,
std::string size_t initialSkipCount,
generateCommandResultWithErrors0Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; bool definition,
std::vector<size_t> 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 generateCommandSet( bool definition,
std::string const & standard, std::string const & standard,
std::vector<std::string> const & enhanced = {}, std::vector<std::string> const & enhanced = {},
std::vector<std::string> const & unique = {} ) const; std::vector<std::string> const & unique = {} ) const;
std::string generateCommandSet( std::string const & standard, std::string const & enhanced ) const; std::string generateCommandSet( std::string const & standard, std::string const & enhanced ) const;
std::string generateCommandStandard( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; std::string generateCommandSetInclusive( std::string const & name,
std::string generateCommandValue( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; CommandData const & commandData,
std::string generateCommandVoid0Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const; size_t initialSkipCount,
bool definition,
std::vector<size_t> returnParams,
std::map<size_t, VectorParamData> vectorParams,
bool unique,
std::vector<CommandFlavourFlags> const & flags,
bool raii,
bool raiiFactory,
std::vector<CommandFlavourFlags> const & raiiFlags ) const;
std::string std::string
generateCommandVoid1Return( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, size_t returnParam ) const; generateCommandSetExclusive( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, bool raii ) const;
std::string generateCommandVoid2Return( std::string generateCommandStandard( std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition ) const;
std::string const & name, CommandData const & commandData, size_t initialSkipCount, bool definition, std::vector<size_t> const & returnParamIndices ) 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<size_t> const & returnParamIndices,
bool raii ) const;
std::string generateConstexprString( std::string const & structName ) const; std::string generateConstexprString( std::string const & structName ) const;
std::string generateDataDeclarations( CommandData const & commandData, std::string generateDataDeclarations( CommandData const & commandData,
std::vector<size_t> const & returnParams, std::vector<size_t> const & returnParams,
@ -732,82 +743,24 @@ private:
std::set<std::string> const & specialFunctions ) const; std::set<std::string> const & specialFunctions ) const;
std::string generateRAIIHandleCommand( std::string const & command, size_t initialSkipCount, bool definition ) const; std::string generateRAIIHandleCommand( std::string const & command, size_t initialSkipCount, bool definition ) const;
std::string generateRAIIHandleCommandDeclarations( std::pair<std::string, HandleData> const & handle, std::set<std::string> const & specialFunctions ) const; std::string generateRAIIHandleCommandDeclarations( std::pair<std::string, HandleData> const & handle, std::set<std::string> const & specialFunctions ) const;
std::string generateRAIIHandleCommandEnhanced( std::map<std::string, CommandData>::const_iterator commandIt, std::string generateRAIIHandleCommandEnhanced( std::string const & name,
size_t initialSkipCount, CommandData const & commandData,
std::vector<size_t> const & returnParams, size_t initialSkipCount,
std::map<size_t, VectorParamData> const & vectorParamIndices, std::vector<size_t> const & returnParams,
bool definition, std::map<size_t, VectorParamData> const & vectorParamIndices,
CommandFlavourFlags flavourFlags = {} ) const; bool definition,
std::string generateRAIIHandleCommandFactory( std::map<std::string, CommandData>::const_iterator commandIt, CommandFlavourFlags flavourFlags = {} ) const;
size_t initialSkipCount, std::string generateRAIIHandleCommandFactory( std::string const & name,
std::vector<size_t> const & returnParams, CommandData const & commandData,
std::map<size_t, VectorParamData> const & vectorParams, size_t initialSkipCount,
bool definition, std::vector<size_t> const & returnParams,
CommandFlavourFlags flavourFlags = {} ) const; std::map<size_t, VectorParamData> const & vectorParams,
bool definition,
CommandFlavourFlags flavourFlags = {} ) const;
std::string generateRAIIHandleCommandFactoryArgumentList( std::vector<ParamData> const & params, std::string generateRAIIHandleCommandFactoryArgumentList( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams, std::set<size_t> const & skippedParams,
bool definition, bool definition,
bool singular ) const; bool singular ) const;
std::string generateRAIIHandleCommandResult( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const;
std::string generateRAIIHandleCommandResultMultiSuccessNoErrors( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition ) const;
std::string generateRAIIHandleCommandResultMultiSuccessNoErrors2Return( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
std::vector<size_t> const & returnParams ) const;
std::string generateRAIIHandleCommandResultMultiSuccessWithErrors( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition ) const;
std::string generateRAIIHandleCommandResultMultiSuccessWithErrors1Return( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam ) const;
std::string generateRAIIHandleCommandResultMultiSuccessWithErrors2Return( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
std::vector<size_t> const & returnParamIndices ) const;
std::string generateRAIIHandleCommandResultMultiSuccessWithErrors3Return( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
std::vector<size_t> const & returnParamIndices ) const;
std::string generateRAIIHandleCommandResultSingleSuccessNoErrors( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1Return( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnHandle( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnValue( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnValue2Vectors( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam,
std::map<size_t, VectorParamData> const & vectorParams ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnVoid( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
size_t returnParam ) const;
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors2Return( std::map<std::string, CommandData>::const_iterator commandIt,
size_t initialSkipCount,
bool definition,
std::vector<size_t> const & returnParamIndices ) const;
std::string generateRAIIHandleCommandValue( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const;
std::string generateRAIIHandleCommandVoid( std::map<std::string, CommandData>::const_iterator commandIt, size_t initialSkipCount, bool definition ) const;
std::pair<std::string, std::string> generateRAIIHandleConstructor( std::pair<std::string, HandleData> const & handle, std::pair<std::string, std::string> generateRAIIHandleConstructor( std::pair<std::string, HandleData> const & handle,
std::map<std::string, CommandData>::const_iterator constructorIt, std::map<std::string, CommandData>::const_iterator constructorIt,
std::string const & enter, std::string const & enter,