golang

package
v0.0.0-...-e433cde Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: BSD-4-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MRPC_PATH   string = "github.com/mslmio/mrpc-go"
	INT128_PATH string = "github.com/mslmio/int128-go"
)

Fixed paths.

View Source
const (
	BYTE_KIND int = iota
	UINT8_KIND
	UINT16_KIND
	UINT32_KIND
	UINT64_KIND
	UINT128_KIND
	INT8_KIND
	INT16_KIND
	INT32_KIND
	INT64_KIND
	INT128_KIND
	FLOAT32_KIND
	FLOAT64_KIND
	BOOL_KIND
	STRING_KIND
	UUID_KIND
)

Base types.

Variables

This section is empty.

Functions

func NewGen

func NewGen(
	env *typecheck.Data,
) *golangGen

Return a new Golang code generator.

Types

type API

type API struct {
	Doc        string     // Documentation, if any.
	Recv       *Field     // Receiver.
	Name       string     // The name of the API.
	Type       *FuncSig   // API signature.
	Parent     Decl       // The declaration to which the API belongs to.
	Stream     StreamType // Streaming type.
	Package    *Package   // The package to which the API belongs to.
	ParentPath string     // The parent path of the API.
	Path       string     // The full path of the API.
	Public     bool       // Set if the API is exposed.
}

APIs.

func (*API) String

func (a *API) String() string

type Array

type Array struct {
	Elem Type
}

Array type.

func (*Array) String

func (arr *Array) String() string

type Base

type Base struct {
	Kind int
}

Base type.

var (
	BYTE    *Base = &Base{BYTE_KIND}
	UINT8   *Base = &Base{UINT8_KIND}
	UINT16  *Base = &Base{UINT16_KIND}
	UINT32  *Base = &Base{UINT32_KIND}
	UINT64  *Base = &Base{UINT64_KIND}
	UINT128 *Base = &Base{UINT128_KIND}
	INT8    *Base = &Base{INT8_KIND}
	INT16   *Base = &Base{INT16_KIND}
	INT32   *Base = &Base{INT32_KIND}
	INT64   *Base = &Base{INT64_KIND}
	INT128  *Base = &Base{INT128_KIND}
	FLOAT32 *Base = &Base{FLOAT32_KIND}
	FLOAT64 *Base = &Base{FLOAT64_KIND}
	BOOL    *Base = &Base{BOOL_KIND}
	STRING  *Base = &Base{STRING_KIND}
	UUID    *Base = &Base{UUID_KIND}
)

func (*Base) String

func (b *Base) String() string

type Client

type Client struct {
	Doc      string   // Documentation, if any.
	Name     string   // The name of the client.
	Protocol string   // The protocol for the client.
	APIs     []*API   // A list of APIs for the client.
	Package  *Package // The package to which the client belongs to.
}

Client declaration.

Clients are implemented through the `struct` type.

func (*Client) String

func (c *Client) String() string

type Decl

type Decl interface {
	codegen.Node
	// contains filtered or unexported methods
}

All declaration nodes implement this interface.

type Def

type Def struct {
	Name string
}

Defined type.

func (*Def) String

func (d *Def) String() string

type Field

type Field struct {
	Doc  string   // Documentation, if any.
	Name string   // The name of the field.
	Type Type     // The type of the field.
	Tags []string // Tag used for the field.
}

Fields.

func (*Field) String

func (f *Field) String() string

type File

type File struct {
	Package *Package  // The package to which the file belongs to.
	Imports []*Import // Packages imported by the file.
	Decls   []Decl    // A list of declarations in the file.
	// contains filtered or unexported fields
}

This file includes any messages or servers exported by the protocol file.

func (*File) Gen

func (f *File) Gen() string

func (*File) Path

func (f *File) Path() string

func (*File) String

func (f *File) String() string

type FuncSig

type FuncSig struct {
	Param  *Field
	Return *Field
}

Function signature.

func (*FuncSig) String

func (f *FuncSig) String() string

type Import

type Import struct {
	Doc  string // Documentation, if any.
	Name string // The name of the import, if any.
	Path string // The corresponding path.
}

Golang import.

func (*Import) String

func (i *Import) String() string

type Map

type Map struct {
	Key   Type
	Value Type
}

Map type.

func (*Map) String

func (m *Map) String() string

type Message

type Message struct {
	Doc     string   // Documentation, if any.
	Name    string   // The name of the message.
	Fields  []*Field // A list of fields.
	Package *Package // The package to which the message belongs to.
	Path    string   // The full path of the message.
}

Message declaration.

Messages are translated to the `struct` data type in Golang.

func (*Message) String

func (m *Message) String() string

type Oneof

type Oneof struct {
	Doc    string
	Name   string
	Fields []*OneofField
}

Oneof declaration.

func (*Oneof) String

func (o *Oneof) String() string

type OneofField

type OneofField struct {
	Doc       string
	Name      string
	FieldName string
	Tag       string
	Type      Type
}

Oneof field.

type Package

type Package struct {
	Doc     string     // Documentation, if any.
	Name    string     // The name of the package.
	Path    string     // The corresponding path.
	Files   []*File    // A list of files.
	Imports []*Package // A list of packages imported.
}

`Package` defines the main Golang package file for the Mrpc protocol file.

func (*Package) String

func (p *Package) String() string

type Pointer

type Pointer struct {
	Base Type
}

Pointer type.

func (*Pointer) String

func (p *Pointer) String() string

type Server

type Server struct {
	Doc      string   // Documentation, if any.
	Name     string   // The name of the server.
	Protocol string   // The protocol for the server.
	APIs     []*API   // A list of APIs for the server.
	Package  *Package // The package to which the server belongs to.
	Path     string   // The full path of the server.
}

Server declaration.

Servers are implemented through the `interface` type.

func (*Server) String

func (s *Server) String() string

type StreamType

type StreamType int

Streaming types.

const (
	NONE StreamType = iota
	SERVER
	CLIENT
	BOTH
)

type Type

type Type interface {
	codegen.Node
	// contains filtered or unexported methods
}

All type nodes implement this interface.

Jump to

Keyboard shortcuts

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