cclGenerators

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CodeGenerators = map[string]GenerateCode{}
View Source
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 CodeGenerationOptions struct {
	CCLDefinition     *cclValues.SourceCodeDefinition
	OutputPath        string
	TargetLanguage    string
	PackageName       string
	GenerateDebugInfo bool
}

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL