Documentation
¶
Index ¶
- Variables
- type CodeGenerationBase
- func (c *CodeGenerationBase) GetFileNameForModel(targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, ...) (string, error)
- func (c *CodeGenerationBase) GetFileNamingStyle(targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, ...) string
- func (c *CodeGenerationBase) GetGlobalAndModelAttributes(targetLang gValues.LanguageType, name string, ...) *cclValues.AttributesCollection
- func (c *CodeGenerationBase) GetGlobalAttribute(targetLang gValues.LanguageType, name string) *cclValues.AttributeUsageInfo
- func (c *CodeGenerationBase) GetGlobalAttributes(targetLang gValues.LanguageType, name string) []*cclValues.AttributeUsageInfo
- func (c *CodeGenerationBase) GetGlobalOrModelAttribute(targetLang gValues.LanguageType, name string, ...) *cclValues.AttributeUsageInfo
- func (c *CodeGenerationBase) GetGlobalOrModelAttributes(targetLang gValues.LanguageType, name string, ...) *cclValues.AttributesCollection
- func (c *CodeGenerationBase) GetModelAndGlobalAttributes(targetLang gValues.LanguageType, name string, ...) *cclValues.AttributesCollection
- func (c *CodeGenerationBase) GetModelOrGlobalAttribute(targetLang gValues.LanguageType, name string, ...) *cclValues.AttributeUsageInfo
- func (c *CodeGenerationBase) GetModelOrGlobalAttributes(targetLang gValues.LanguageType, name string, ...) *cclValues.AttributesCollection
- func (c *CodeGenerationBase) IsSingleFileMode(targetLang gValues.LanguageType) (bool, string)
- func (c *CodeGenerationBase) NeedsBinarySerialization(targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition) bool
- func (c *CodeGenerationBase) NeedsCloneMethods(targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition) bool
- func (c *CodeGenerationBase) NeedsJsonSerialization(targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition) bool
- func (c *CodeGenerationBase) NeedsSerializationType(targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, ...) bool
- func (c *CodeGenerationBase) WriteCodeFile(path string, result *codeBuilder.CodeBuildResult) error
- type CodeGenerationOptions
- type CodeGenerationResult
- type GenerateCode
Constants ¶
This section is empty.
Variables ¶
var CodeGenerators = map[string]GenerateCode{}
var (
ErrLanguageNotSupported = errors.New("language not supported")
)
Functions ¶
This section is empty.
Types ¶
type CodeGenerationBase ¶
type CodeGenerationBase struct {
Options *CodeGenerationOptions
}
func (*CodeGenerationBase) GetFileNameForModel ¶ added in v0.0.3
func (c *CodeGenerationBase) GetFileNameForModel( targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, defaultStyle string, supportedStyles []string, ) (string, error)
GetFileNameForModel returns the file name for the given model based on the naming style. NOTE: this is only the file name, it does not apply any file extension or base path.
func (*CodeGenerationBase) GetFileNamingStyle ¶ added in v0.0.3
func (c *CodeGenerationBase) GetFileNamingStyle( targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, defaultStyle string, ) string
func (*CodeGenerationBase) GetGlobalAndModelAttributes ¶
func (c *CodeGenerationBase) GetGlobalAndModelAttributes( targetLang gValues.LanguageType, name string, currentModel *cclValues.ModelDefinition, ) *cclValues.AttributesCollection
GetGlobalAndModelAttributes retrieves all attributes with the specified name from both global attributes and the current model.
func (*CodeGenerationBase) GetGlobalAttribute ¶
func (c *CodeGenerationBase) GetGlobalAttribute( targetLang gValues.LanguageType, name string, ) *cclValues.AttributeUsageInfo
GetGlobalAttribute retrieves a global attribute with the specified name.
func (*CodeGenerationBase) GetGlobalAttributes ¶
func (c *CodeGenerationBase) GetGlobalAttributes( targetLang gValues.LanguageType, name string, ) []*cclValues.AttributeUsageInfo
GetGlobalAttributes retrieves all global attributes with the specified name.
func (*CodeGenerationBase) GetGlobalOrModelAttribute ¶
func (c *CodeGenerationBase) GetGlobalOrModelAttribute( targetLang gValues.LanguageType, name string, currentModel *cclValues.ModelDefinition, ) *cclValues.AttributeUsageInfo
GetGlobalOrModelAttribute retrieves an attribute with the specified name from global attributes or the current model.
func (*CodeGenerationBase) GetGlobalOrModelAttributes ¶
func (c *CodeGenerationBase) GetGlobalOrModelAttributes( targetLang gValues.LanguageType, name string, currentModel *cclValues.ModelDefinition, ) *cclValues.AttributesCollection
GetGlobalOrModelAttributes retrieves all attributes with the specified name from global attributes or the current model.
func (*CodeGenerationBase) GetModelAndGlobalAttributes ¶
func (c *CodeGenerationBase) GetModelAndGlobalAttributes( targetLang gValues.LanguageType, name string, currentModel *cclValues.ModelDefinition, ) *cclValues.AttributesCollection
GetModelAndGlobalAttributes retrieves all attributes with the specified name from both global attributes and the current model.
func (*CodeGenerationBase) GetModelOrGlobalAttribute ¶
func (c *CodeGenerationBase) GetModelOrGlobalAttribute( targetLang gValues.LanguageType, name string, currentModel *cclValues.ModelDefinition, ) *cclValues.AttributeUsageInfo
GetModelOrGlobalAttribute retrieves an attribute with the specified name from the current model or global attributes.
func (*CodeGenerationBase) GetModelOrGlobalAttributes ¶
func (c *CodeGenerationBase) GetModelOrGlobalAttributes( targetLang gValues.LanguageType, name string, currentModel *cclValues.ModelDefinition, ) *cclValues.AttributesCollection
GetModelOrGlobalAttributes retrieves all attributes with the specified name from the current model or global attributes.
func (*CodeGenerationBase) IsSingleFileMode ¶ added in v0.0.3
func (c *CodeGenerationBase) IsSingleFileMode(targetLang gValues.LanguageType) (bool, string)
IsSingleFileMode checks if the code generation should be done in single file mode and returns the single file name if applicable.
func (*CodeGenerationBase) NeedsBinarySerialization ¶
func (c *CodeGenerationBase) NeedsBinarySerialization( targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, ) bool
NeedsBinarySerialization returns true if the current model or global attributes indicate that binary serialization is needed.
func (*CodeGenerationBase) NeedsCloneMethods ¶
func (c *CodeGenerationBase) NeedsCloneMethods( targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, ) bool
NeedsCloneMethods returns true if the current model or global attributes indicate that clone methods are needed.
func (*CodeGenerationBase) NeedsJsonSerialization ¶
func (c *CodeGenerationBase) NeedsJsonSerialization( targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, ) bool
NeedsJsonSerialization returns true if the current model or global attributes indicate that JSON serialization is needed.
func (*CodeGenerationBase) NeedsSerializationType ¶
func (c *CodeGenerationBase) NeedsSerializationType( targetLang gValues.LanguageType, currentModel *cclValues.ModelDefinition, sType string, ) bool
NeedsSerializationType checks if the specified serialization type is needed based on global attributes and model-specific attributes.
func (*CodeGenerationBase) WriteCodeFile ¶ added in v0.0.3
func (c *CodeGenerationBase) WriteCodeFile(path string, result *codeBuilder.CodeBuildResult) error
WriteCodeFile writes the generated code and debug info (if available) to the specified path.
type CodeGenerationOptions ¶
type CodeGenerationResult ¶
type CodeGenerationResult struct {
OutputFiles []string
// SourceLanguage is the language from which the code was generated.
SourceLanguage gValues.NormalizedLangName
// TargetLanguage is the language to which the code was generated.
TargetLanguage gValues.NormalizedLangName
}
CodeGenerationResult holds the result of a code generation process.
func DoGenerateCode ¶
func DoGenerateCode(options *CodeGenerationOptions) (*CodeGenerationResult, error)
type GenerateCode ¶
type GenerateCode func(options *CodeGenerationOptions) (*CodeGenerationResult, error)