v.io: v.io/v23/vdlroot/vdltool Index | Files

package vdltool

import "v.io/v23/vdlroot/vdltool"

Package vdltool defines types used by the vdl tool itself, including the format of vdl.config files. nolint:golint

Index

Package Files

vdltool.vdl.go

Variables

var GenLanguageAll = [...]GenLanguage{GenLanguageGo, GenLanguageJava, GenLanguageJavascript, GenLanguageSwift}

GenLanguageAll holds all labels for GenLanguage.

var GoKindAll = [...]GoKind{GoKindStruct, GoKindBool, GoKindNumber, GoKindString, GoKindArray, GoKindSlice, GoKindMap, GoKindPointer, GoKindIface}

GoKindAll holds all labels for GoKind.

var GoZeroModeAll = [...]GoZeroMode{GoZeroModeUnknown, GoZeroModeCanonical, GoZeroModeUnique}

GoZeroModeAll holds all labels for GoZeroMode.

type Config Uses

type Config struct {
    // GenLanguages restricts the set of code generation languages.  If the set is
    // empty, all supported languages are allowed to be generated.
    GenLanguages map[GenLanguage]struct{}
    // Language-specific configurations.
    Go         GoConfig
    Java       JavaConfig
    Javascript JavascriptConfig
    Swift      SwiftConfig
}

Config specifies the configuration for the vdl tool. This is typically represented in optional "vdl.config" files in each vdl source package. Each vdl.config file implicitly imports this package. E.g. you may refer to vdltool.Config in the "vdl.config" file without explicitly importing vdltool.

func (Config) VDLIsZero Uses

func (x Config) VDLIsZero() bool

func (*Config) VDLRead Uses

func (x *Config) VDLRead(dec vdl.Decoder) error

func (Config) VDLReflect Uses

func (Config) VDLReflect(struct {
    Name string `vdl:"vdltool.Config"`
})

func (Config) VDLWrite Uses

func (x Config) VDLWrite(enc vdl.Encoder) error

type GenLanguage Uses

type GenLanguage int

GenLanguage enumerates the known code generation languages.

const (
    GenLanguageGo GenLanguage = iota
    GenLanguageJava
    GenLanguageJavascript
    GenLanguageSwift
)

func GenLanguageFromString Uses

func GenLanguageFromString(label string) (x GenLanguage, err error)

GenLanguageFromString creates a GenLanguage from a string label. nolint:deadcode,unused

func (*GenLanguage) Set Uses

func (x *GenLanguage) Set(label string) error

Set assigns label to x.

func (GenLanguage) String Uses

func (x GenLanguage) String() string

String returns the string label of x.

func (GenLanguage) VDLIsZero Uses

func (x GenLanguage) VDLIsZero() bool

func (*GenLanguage) VDLRead Uses

func (x *GenLanguage) VDLRead(dec vdl.Decoder) error

func (GenLanguage) VDLReflect Uses

func (GenLanguage) VDLReflect(struct {
    Name string `vdl:"vdltool.GenLanguage"`
    Enum struct{ Go, Java, Javascript, Swift string }
})

func (GenLanguage) VDLWrite Uses

func (x GenLanguage) VDLWrite(enc vdl.Encoder) error

type GoConfig Uses

type GoConfig struct {
    // WireToNativeTypes specifies the mapping from a VDL wire type to its Go
    // native type representation.  This is rarely used and easy to configure
    // incorrectly; usage is currently restricted to packages that are explicitly
    // whitelisted.
    //
    // WireToNativeTypes are meant for scenarios where there is an idiomatic Go
    // type used in your code, but you need a standard VDL representation for wire
    // compatibility.  E.g. the VDL time package defines Duration and Time for
    // wire compatibility, but we want the generated code to use the standard Go
    // time package.
    //
    // The key of the map is the name of the VDL type (aka WireType), which must
    // be defined in the vdl package associated with the vdl.config file.
    //
    // The code generator assumes the existence of a pair of conversion functions
    // converting between the wire and native types, and will automatically call
    // vdl.RegisterNative with these function names.
    //
    // Assuming the name of the WireType is Foo:
    //   func fooToNative(x Foo, n *Native) error
    //   func fooFromNative(x *Foo, n Native) error
    WireToNativeTypes map[string]GoType
}

GoConfig specifies go specific configuration.

func (GoConfig) VDLIsZero Uses

func (x GoConfig) VDLIsZero() bool

func (*GoConfig) VDLRead Uses

func (x *GoConfig) VDLRead(dec vdl.Decoder) error

func (GoConfig) VDLReflect Uses

func (GoConfig) VDLReflect(struct {
    Name string `vdl:"vdltool.GoConfig"`
})

func (GoConfig) VDLWrite Uses

func (x GoConfig) VDLWrite(enc vdl.Encoder) error

type GoImport Uses

type GoImport struct {
    // Path is the package path that uniquely identifies the imported package.
    Path string
    // Name is the name of the package identified by Path.  Due to Go conventions,
    // it is typically just the basename of Path, but may be set to something
    // different if the imported package doesn't follow Go conventions.
    Name string
}

GoImport describes Go import information.

func (GoImport) VDLIsZero Uses

func (x GoImport) VDLIsZero() bool

func (*GoImport) VDLRead Uses

func (x *GoImport) VDLRead(dec vdl.Decoder) error

func (GoImport) VDLReflect Uses

func (GoImport) VDLReflect(struct {
    Name string `vdl:"vdltool.GoImport"`
})

func (GoImport) VDLWrite Uses

func (x GoImport) VDLWrite(enc vdl.Encoder) error

type GoKind Uses

type GoKind int

GoKind describes the kind of Go type.

const (
    GoKindStruct GoKind = iota
    GoKindBool
    GoKindNumber
    GoKindString
    GoKindArray
    GoKindSlice
    GoKindMap
    GoKindPointer
    GoKindIface
)

func GoKindFromString Uses

func GoKindFromString(label string) (x GoKind, err error)

GoKindFromString creates a GoKind from a string label. nolint:deadcode,unused

func (*GoKind) Set Uses

func (x *GoKind) Set(label string) error

Set assigns label to x.

func (GoKind) String Uses

func (x GoKind) String() string

String returns the string label of x.

func (GoKind) VDLIsZero Uses

func (x GoKind) VDLIsZero() bool

func (*GoKind) VDLRead Uses

func (x *GoKind) VDLRead(dec vdl.Decoder) error

func (GoKind) VDLReflect Uses

func (GoKind) VDLReflect(struct {
    Name string `vdl:"vdltool.GoKind"`
    Enum struct{ Struct, Bool, Number, String, Array, Slice, Map, Pointer, Iface string }
})

func (GoKind) VDLWrite Uses

func (x GoKind) VDLWrite(enc vdl.Encoder) error

type GoType Uses

type GoType struct {
    // Kind is the kind of Type.
    Kind GoKind
    // Type is the Go type to use in generated code, instead of the VDL type.
    Type string
    // Zero specifies zero value setting and checking behavior.
    Zero GoZero
    // ToNative and FromNative overrides the names of the native conversion
    // functions.  If unspecified, the default functions are of the form:
    //   WireTypeToNative(wire WireType, native *NativeType) error
    //   WireTypeFromNative(wire *WireType, native NativeType) error
    ToNative   string
    FromNative string
    // Imports are the Go imports referenced by the Type, ToNative and FromNative
    // fields.  In each field, use the standard local package name, and specify
    // the import package here.  E.g. to specify the native type time.Time:
    //   GoType{
    //     Kind:    Struct,
    //     Type:    "time.Time",
    //     Zero:    {Mode: Canonical, IsZero: ".IsZero()"},
    //     Imports: {{Path: "time", Name: "time"}},
    //   }
    Imports []GoImport
}

GoType describes the Go type information associated with a VDL type. See v.io/x/ref/lib/vdl/testdata/native for examples.

func (GoType) VDLIsZero Uses

func (x GoType) VDLIsZero() bool

func (*GoType) VDLRead Uses

func (x *GoType) VDLRead(dec vdl.Decoder) error

func (GoType) VDLReflect Uses

func (GoType) VDLReflect(struct {
    Name string `vdl:"vdltool.GoType"`
})

func (GoType) VDLWrite Uses

func (x GoType) VDLWrite(enc vdl.Encoder) error

type GoZero Uses

type GoZero struct {
    Mode GoZeroMode
    // IsZero specifies a field, method or function that returns true iff the
    // native value represents the VDL zero value.
    //
    // If IsZero starts with a dot (.), it is assumed to be a field or method.
    // The field type or method return type must be bool.  Generated code will
    // apply the IsZero string verbatim to expressions of the native type.
    //
    // If IsZero doesn't start with a dot(.), it is assumed to be a function whose
    // return type must be bool.  Generated code will call the function with a
    // single argument that is an expression of the native type.
    //
    // TODO(toddw): The function form of IsZero isn't implemented.
    IsZero string
}

GoZero describes Go zero value behavior.

REQUIRED: Either Mode == Unique or IsZero is set. We will not perform native/wire conversions to check zero values.

func (GoZero) VDLIsZero Uses

func (x GoZero) VDLIsZero() bool

func (*GoZero) VDLRead Uses

func (x *GoZero) VDLRead(dec vdl.Decoder) error

func (GoZero) VDLReflect Uses

func (GoZero) VDLReflect(struct {
    Name string `vdl:"vdltool.GoZero"`
})

func (GoZero) VDLWrite Uses

func (x GoZero) VDLWrite(enc vdl.Encoder) error

type GoZeroMode Uses

type GoZeroMode int

GoZeroMode describes the relationship between the Go zero value of the native type, and the VDL zero value.

const (
    GoZeroModeUnknown GoZeroMode = iota
    GoZeroModeCanonical
    GoZeroModeUnique
)

func GoZeroModeFromString Uses

func GoZeroModeFromString(label string) (x GoZeroMode, err error)

GoZeroModeFromString creates a GoZeroMode from a string label. nolint:deadcode,unused

func (*GoZeroMode) Set Uses

func (x *GoZeroMode) Set(label string) error

Set assigns label to x.

func (GoZeroMode) String Uses

func (x GoZeroMode) String() string

String returns the string label of x.

func (GoZeroMode) VDLIsZero Uses

func (x GoZeroMode) VDLIsZero() bool

func (*GoZeroMode) VDLRead Uses

func (x *GoZeroMode) VDLRead(dec vdl.Decoder) error

func (GoZeroMode) VDLReflect Uses

func (GoZeroMode) VDLReflect(struct {
    Name string `vdl:"vdltool.GoZeroMode"`
    Enum struct{ Unknown, Canonical, Unique string }
})

func (GoZeroMode) VDLWrite Uses

func (x GoZeroMode) VDLWrite(enc vdl.Encoder) error

type JavaConfig Uses

type JavaConfig struct {
    // WireToNativeTypes specifies the mapping from a VDL wire type to its Java
    // native type representation.  This is rarely used and easy to configure
    // incorrectly; usage is currently restricted to packages that are explicitly
    // whitelisted.
    //
    // WireToNativeTypes are meant for scenarios where there is an idiomatic Java
    // type used in your code, but you need a standard VDL representation for wire
    // compatibility.  E.g. the VDL time package defines Duration and Time for
    // wire compatibility, but we want the generated code to use the org.joda.time
    // package.
    //
    // The key of the map is the name of the VDL type (aka WireType), which must
    // be defined in the vdl package associated with the vdl.config file.
    //
    // The code generator assumes that the conversion functions will be registered
    // in java vdl package.
    WireToNativeTypes map[string]string
    // WireTypeRenames specifies the mapping from a VDL wire type name to its
    // Java native type name.
    //
    // WireTypeRenames are meant for scenarios where the VDL wire name
    // conflicts in some way with the Java native names, e.g., a VDL Integer
    // type could be named VInteger for clarity.
    //
    // When combined with WireToNativeTypes, this feature allows us to attach
    // functions to VDL types.  For example, we may rename AccessList VDL type
    // into WireAccessList and then map WireAccessList to our Java native type
    // AccessList which defines functions on the VDL data.
    //
    // The key of the map is the name of the VDL wire type, which must be
    // defined in the vdl package associated with the vdl.config file.
    WireTypeRenames map[string]string
}

JavaConfig specifies java specific configuration.

func (JavaConfig) VDLIsZero Uses

func (x JavaConfig) VDLIsZero() bool

func (*JavaConfig) VDLRead Uses

func (x *JavaConfig) VDLRead(dec vdl.Decoder) error

func (JavaConfig) VDLReflect Uses

func (JavaConfig) VDLReflect(struct {
    Name string `vdl:"vdltool.JavaConfig"`
})

func (JavaConfig) VDLWrite Uses

func (x JavaConfig) VDLWrite(enc vdl.Encoder) error

type JavascriptConfig Uses

type JavascriptConfig struct {
}

JavascriptConfig specifies javascript specific configuration.

func (JavascriptConfig) VDLIsZero Uses

func (x JavascriptConfig) VDLIsZero() bool

func (*JavascriptConfig) VDLRead Uses

func (x *JavascriptConfig) VDLRead(dec vdl.Decoder) error

func (JavascriptConfig) VDLReflect Uses

func (JavascriptConfig) VDLReflect(struct {
    Name string `vdl:"vdltool.JavascriptConfig"`
})

func (JavascriptConfig) VDLWrite Uses

func (x JavascriptConfig) VDLWrite(enc vdl.Encoder) error

type SwiftConfig Uses

type SwiftConfig struct {
    // WireToNativeTypes specifies the mapping from a VDL wire type to its Swift
    // native type representation.  This is rarely used and easy to configure
    // incorrectly; usage is currently restricted to packages that are explicitly
    // whitelisted.
    //
    // WireToNativeTypes are meant for scenarios where there is an idiomatic Swift
    // type used in your code, but you need a standard VDL representation for wire
    // compatibility.  E.g. the VDL time package defines Duration and Time for
    // wire compatibility, but we want the generated code to use NSDate or NSTimeInterval
    //
    // The key of the map is the name of the VDL type (aka WireType), which must
    // be defined in the vdl package associated with the vdl.config file.
    //
    // The code generator assumes that the conversion functions will be registered
    // in Swift vdl package.
    WireToNativeTypes map[string]string
}

SwiftConfig specifies swift specific configuration for this package. Note that despite the SwiftConfig options for a given package (which should be very rare in practice), we still need to know the name of the swift module that this package relates to to properly understand import boundaries between projects/frameworks/modules.

We do this by defining a file called "swiftmodule" that contains JUST the name of the Swift module at the root of your VDL packages. For example, if you have the VDL files for your Xcode project/target called UberForCats at /Users/aaron/uberforcats/vdl, then create /Users/aaron/uberforcats/vdl/com.uberforcats/swiftmodule and have it just contain "UberForCats". We then will treat any VDL files contained in that directory and any subdirectories as part of the UberForCats Swift module, ultimately letting the compiler and will automatically do the right thing if others import your package. If you don't do this then nobody will be able to import your VDL types in Swift, and you might end up with extra long class/pkg names (ComuberforcatsServicesProfit instead of ServicesProfit for $VDLROOT/com.uberforcats/services/profit).

If you are creating multiple Swift modules for a given $VDLROOT then just place swiftmodule files at the logical boundaries. For eample, we do this for v.io/v23 to be exported to the VanadiumCore framework, but everything under v.io/v23/services lives in the VanadiumServices framework.

func (SwiftConfig) VDLIsZero Uses

func (x SwiftConfig) VDLIsZero() bool

func (*SwiftConfig) VDLRead Uses

func (x *SwiftConfig) VDLRead(dec vdl.Decoder) error

func (SwiftConfig) VDLReflect Uses

func (SwiftConfig) VDLReflect(struct {
    Name string `vdl:"vdltool.SwiftConfig"`
})

func (SwiftConfig) VDLWrite Uses

func (x SwiftConfig) VDLWrite(enc vdl.Encoder) error

Package vdltool imports 2 packages (graph) and is imported by 14 packages. Updated 2020-10-29. Refresh now. Tools for package owners.