templates

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Templates = map[string]string{
	"typescript": `// Auto-generated TypeScript interface
export interface {{.Name}} {
{{range .Fields}}	{{.Name}}: {{.Type}};
{{end}}}
`,

	"csharp": `// Auto-generated C# class
public class {{.Name}} {
{{range .Fields}}	public {{.Type}} {{.Name}} { get; set; }
{{end}}}
`,

	"cpp": `#include <string> 
// Auto-generated C++ struct
struct {{.Name}} {
{{range .Fields}}	{{.Type}} {{.Name}};
{{end}}};
`,

	"python": `# Auto-generated Python class
class {{.Name}}:
	def __init__(self):
{{range .Fields}}		self.{{.Name}}: {{.Type}} = None
{{end}}`,

	"java": `// Auto-generated Java class
public class {{.Name}} {
{{range .Fields}}	private {{.Type}} {{.Name}};

	public {{.Type}} get{{.Name | title}}() {
		return {{.Name}};
	}

	public void set{{.Name | title}}({{.Type}} {{.Name}}) {
		this.{{.Name}} = {{.Name}};
	}
{{end}}}
`,
}

Templates contains pre-defined templates for various languages

View Source
var TypeMappings = map[string]map[string]string{
	"typescript": {
		"string": "string",
		"int":    "number",
		"float":  "number",
		"bool":   "boolean",
	},
	"csharp": {
		"string": "string",
		"int":    "int",
		"float":  "float",
		"bool":   "bool",
	},
	"cpp": {
		"string": "std::string",
		"int":    "int",
		"float":  "float",
		"bool":   "bool",
	},
	"python": {
		"string": "str",
		"int":    "int",
		"float":  "float",
		"bool":   "bool",
	},
	"java": {
		"string": "String",
		"int":    "int",
		"float":  "float",
		"bool":   "boolean",
	},
}

TypeMappings maps generic IR types to language-specific types

Functions

func GetTemplate

func GetTemplate(language string) (*template.Template, error)

GetTemplate retrieves a template string by language

Types

This section is empty.

Jump to

Keyboard shortcuts

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