Default is the default constructor for structs. It is merely the string "struct".
const Default = starlark.String("struct")
func Make(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
Make is the implementation of a built-in function that instantiates an immutable struct from the specified keyword arguments.
An application can add 'struct' to the Starlark environment like so:
globals := starlark.StringDict{ "struct": starlark.NewBuiltin("struct", starlarkstruct.Make), }
func MakeModule(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
MakeModule may be used as the implementation of a Starlark built-in function, module(name, **kwargs). It returns a new module with the specified name and members.
A Module is a named collection of values, typically a suite of functions imported by a load statement.
It differs from Struct primarily in that its string representation does not enumerate its fields.
type Module struct { Name string Members starlark.StringDict }
func (m *Module) Attr(name string) (starlark.Value, error)
func (m *Module) AttrNames() []string
func (m *Module) Freeze()
func (m *Module) Hash() (uint32, error)
func (m *Module) String() string
func (m *Module) Truth() starlark.Bool
func (m *Module) Type() string
Struct is an immutable Starlark type that maps field names to values. It is not iterable and does not support len.
A struct has a constructor, a distinct value that identifies a class of structs, and which appears in the struct's string representation.
Operations such as x+y fail if the constructors of the two operands are not equal.
The default constructor, Default, is the string "struct", but clients may wish to 'brand' structs for their own purposes. The constructor value appears in the printed form of the value, and is accessible using the Constructor method.
Use Attr to access its fields and AttrNames to enumerate them.
type Struct struct {
// contains filtered or unexported fields
}
func FromKeywords(constructor starlark.Value, kwargs []starlark.Tuple) *Struct
FromKeywords returns a new struct instance whose fields are specified by the key/value pairs in kwargs. (Each kwargs[i][0] must be a starlark.String.)
func FromStringDict(constructor starlark.Value, d starlark.StringDict) *Struct
FromStringDict returns a new struct instance whose elements are those of d. The constructor parameter specifies the constructor; use Default for an ordinary struct.
func (s *Struct) Attr(name string) (starlark.Value, error)
Attr returns the value of the specified field.
func (s *Struct) AttrNames() []string
AttrNames returns a new sorted list of the struct fields.
func (x *Struct) Binary(op syntax.Token, y starlark.Value, side starlark.Side) (starlark.Value, error)
func (x *Struct) CompareSameType(op syntax.Token, y_ starlark.Value, depth int) (bool, error)
func (s *Struct) Constructor() starlark.Value
Constructor returns the constructor used to create this struct.
func (s *Struct) Freeze()
func (s *Struct) Hash() (uint32, error)
func (s *Struct) String() string
func (s *Struct) ToStringDict(d starlark.StringDict)
ToStringDict adds a name/value entry to d for each field of the struct.
func (s *Struct) Truth() starlark.Bool
func (s *Struct) Type() string