rbxapijson

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 7 Imported by: 15

Documentation

Overview

The rbxapijson package implements the rbxapi package as a codec for the Roblox API dump in JSON format.

Note that this package is an implementation of a non-standardized format. Therefore, this package's API is subject to change as the format changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, root *Root) (err error)

Encode encodes root, writing the results to w in the API dump JSON format.

Types

type Callback

type Callback struct {
	Name       string
	Parameters []Parameter
	ReturnType Type
	Security   string
	Tags       `json:",omitempty"`
}

Callback represents a class member of the Callback member type.

func (*Callback) Copy

func (member *Callback) Copy() rbxapi.Member

Copy returns a deep copy of the member descriptor.

Copy implements the rbxapi.Member interface.

func (*Callback) GetMemberType

func (member *Callback) GetMemberType() string

GetMemberType returns a string indicating the the type of member.

GetMemberType implements the rbxapi.Member interface.

func (*Callback) GetName

func (member *Callback) GetName() string

GetName returns the name of the member.

GetName implements the rbxapi.Member interface.

func (*Callback) GetParameters

func (member *Callback) GetParameters() rbxapi.Parameters

GetParameters returns the list of parameters describing the arguments passed to the callback. These parameters cannot have default values.

GetParameters implements the rbxapi.Callback interface.

func (*Callback) GetReturnType

func (member *Callback) GetReturnType() rbxapi.Type

GetReturnType returns the type of value that is returned by the callback.

GetReturnType implements the rbxapi.Callback interface.

func (*Callback) GetSecurity

func (member *Callback) GetSecurity() string

GetSecurity returns the security context of the member's access.

GetSecurity implements the rbxapi.Callback interface.

func (*Callback) Patch

func (member *Callback) Patch(actions []patch.Action)

type Class

type Class struct {
	Name           string
	Superclass     string
	MemoryCategory string
	Members        []rbxapi.Member
	Tags           `json:",omitempty"`
}

Class represents a class descriptor.

func (*Class) Copy

func (class *Class) Copy() rbxapi.Class

Copy returns a deep copy of the class descriptor.

Copy implements the rbxapi.Class interface.

func (*Class) GetMember

func (class *Class) GetMember(name string) rbxapi.Member

GetMember returns the first member descriptor of the given name, or nil if no member of the given name is present.

GetMember implements the rbxapi.Class interface.

func (*Class) GetMembers

func (class *Class) GetMembers() []rbxapi.Member

GetMembers returns a list of member descriptors belonging to the class.

GetMembers implements the rbxapi.Class interface.

func (*Class) GetName

func (class *Class) GetName() string

GetName returns the class name.

GetName implements the rbxapi.Class interface.

func (*Class) GetSuperclass

func (class *Class) GetSuperclass() string

GetSuperclass returns the name of the class that this class inherits from.

GetSuperclass implements the rbxapi.Class interface.

func (*Class) MarshalJSON

func (class *Class) MarshalJSON() (b []byte, err error)

MarshalJSON implements the json.Marshaller interface.

func (*Class) Patch

func (class *Class) Patch(actions []patch.Action)

func (*Class) UnmarshalJSON

func (class *Class) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements the json.Unmarshaller interface.

type Diff

type Diff struct {
	Prev, Next *Root
}

Diff is a patch.Differ that finds differences between two Root values.

func (*Diff) Diff

func (d *Diff) Diff() (actions []patch.Action)

type DiffCallback

type DiffCallback struct {
	Class      *Class
	Prev, Next *Callback
}

Diff is a patch.Differ that finds differences between two Callback values.

func (*DiffCallback) Diff

func (d *DiffCallback) Diff() (actions []patch.Action)

type DiffClass

type DiffClass struct {
	Prev, Next *Class
	// ExcludeMembers indicates whether members should be diffed.
	ExcludeMembers bool
}

Diff is a patch.Differ that finds differences between two Class values.

func (*DiffClass) Diff

func (d *DiffClass) Diff() (actions []patch.Action)

type DiffEnum

type DiffEnum struct {
	Prev, Next *Enum
	// ExcludeEnumItems indicates whether enum items should be diffed.
	ExcludeEnumItems bool
}

Diff is a patch.Differ that finds differences between two Enum values.

func (*DiffEnum) Diff

func (d *DiffEnum) Diff() (actions []patch.Action)

type DiffEnumItem

type DiffEnumItem struct {
	Enum       *Enum
	Prev, Next *EnumItem
}

Diff is a patch.Differ that finds differences between two EnumItem values.

func (*DiffEnumItem) Diff

func (d *DiffEnumItem) Diff() (actions []patch.Action)

type DiffEvent

type DiffEvent struct {
	Class      *Class
	Prev, Next *Event
}

Diff is a patch.Differ that finds differences between two Event values.

func (*DiffEvent) Diff

func (d *DiffEvent) Diff() (actions []patch.Action)

type DiffFunction

type DiffFunction struct {
	Class      *Class
	Prev, Next *Function
}

Diff is a patch.Differ that finds differences between two Function values.

func (*DiffFunction) Diff

func (d *DiffFunction) Diff() (actions []patch.Action)

type DiffProperty

type DiffProperty struct {
	Class      *Class
	Prev, Next *Property
}

Diff is a patch.Differ that finds differences between two Property values.

func (*DiffProperty) Diff

func (d *DiffProperty) Diff() (actions []patch.Action)

type Enum

type Enum struct {
	Name  string
	Items []*EnumItem
	Tags  `json:",omitempty"`
}

Enum represents an enum descriptor.

func (*Enum) Copy

func (enum *Enum) Copy() rbxapi.Enum

Copy returns a deep copy of the enum descriptor.

Copy implements the rbxapi.Enum interface.

func (*Enum) GetEnumItem

func (enum *Enum) GetEnumItem(name string) rbxapi.EnumItem

GetEnumItem returns the first item of the given name, or nil if no item of the given name is present.

GetEnumItem implements the rbxapi.Enum interface.

func (*Enum) GetEnumItems

func (enum *Enum) GetEnumItems() []rbxapi.EnumItem

GetEnumItems returns a list of items of the enum.

GetEnumItems implements the rbxapi.Enum interface.

func (*Enum) GetName

func (enum *Enum) GetName() string

GetName returns the name of the enum.

GetName implements the rbxapi.Enum interface.

func (*Enum) Patch

func (enum *Enum) Patch(actions []patch.Action)

type EnumItem

type EnumItem struct {
	Name  string
	Value int
	Tags  `json:",omitempty"`
}

EnumItem represents an enum item descriptor.

func (*EnumItem) Copy

func (item *EnumItem) Copy() rbxapi.EnumItem

Copy returns a deep copy of the enum item descriptor.

Copy implements the rbxapi.EnumItem interface.

func (*EnumItem) GetName

func (item *EnumItem) GetName() string

GetName returns the name of the enum item.

GetName implements the rbxapi.EnumItem interface.

func (*EnumItem) GetValue

func (item *EnumItem) GetValue() int

GetValue returns the value of the enum item.

GetValue implements the rbxapi.EnumItem interface.

func (*EnumItem) Patch

func (item *EnumItem) Patch(actions []patch.Action)

type Event

type Event struct {
	Name       string
	Parameters []Parameter
	Security   string
	Tags       `json:",omitempty"`
}

Event represents a class member of the Event member type.

func (*Event) Copy

func (member *Event) Copy() rbxapi.Member

Copy returns a deep copy of the member descriptor.

Copy implements the rbxapi.Member interface.

func (*Event) GetMemberType

func (member *Event) GetMemberType() string

GetMemberType returns a string indicating the the type of member.

GetMemberType implements the rbxapi.Member interface.

func (*Event) GetName

func (member *Event) GetName() string

GetName returns the name of the member.

GetName implements the rbxapi.Member interface.

func (*Event) GetParameters

func (member *Event) GetParameters() rbxapi.Parameters

GetParameters returns the list of parameters describing the arguments received from the event. These parameters cannot have default values.

GetParameters implements the rbxapi.Event interface.

func (*Event) GetSecurity

func (member *Event) GetSecurity() string

GetSecurity returns the security context of the member's access.

GetSecurity implements the rbxapi.Event interface.

func (*Event) Patch

func (member *Event) Patch(actions []patch.Action)

type Function

type Function struct {
	Name       string
	Parameters []Parameter
	ReturnType Type
	Security   string
	Tags       `json:",omitempty"`
}

Function represents a class member of the Function member type.

func (*Function) Copy

func (member *Function) Copy() rbxapi.Member

Copy returns a deep copy of the member descriptor.

Copy implements the rbxapi.Member interface.

func (*Function) GetMemberType

func (member *Function) GetMemberType() string

GetMemberType returns a string indicating the the type of member.

GetMemberType implements the rbxapi.Member interface.

func (*Function) GetName

func (member *Function) GetName() string

GetName returns the name of the member.

GetName implements the rbxapi.Member interface.

func (*Function) GetParameters

func (member *Function) GetParameters() rbxapi.Parameters

GetParameters returns the list of parameters describing the arguments passed to the function. These parameters may have default values.

GetParameters implements the rbxapi.Function interface.

func (*Function) GetReturnType

func (member *Function) GetReturnType() rbxapi.Type

GetReturnType returns the type of value returned by the function.

GetReturnType implements the rbxapi.Function interface.

func (*Function) GetSecurity

func (member *Function) GetSecurity() string

GetSecurity returns the security context of the member's access.

GetSecurity implements the rbxapi.Function interface.

func (*Function) Patch

func (member *Function) Patch(actions []patch.Action)

type Parameter

type Parameter struct {
	Type       Type
	Name       string
	HasDefault bool
	Default    string
}

Parameter represents a parameter of a function, event, or callback member.

func (Parameter) Copy

func (param Parameter) Copy() rbxapi.Parameter

Copy returns a deep copy of the parameter.

Copy implements the rbxapi.Parameter interface.

func (Parameter) GetDefault

func (param Parameter) GetDefault() (value string, ok bool)

GetDefault returns a string representing the default value of the parameter, and whether a default value is present.

GetDefault implements the rbxapi.Parameter interface.

func (Parameter) GetName

func (param Parameter) GetName() string

GetName returns the name describing the parameter.

GetName implements the rbxapi.Parameter interface.

func (Parameter) GetType

func (param Parameter) GetType() rbxapi.Type

GetType returns the type of the parameter value.

GetType implements the rbxapi.Parameter interface.

func (*Parameter) MarshalJSON

func (param *Parameter) MarshalJSON() (b []byte, err error)

MarshalJSON implements the json.Marshaller interface.

func (*Parameter) UnmarshalJSON

func (param *Parameter) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements the json.Unmarshaller interface.

type Parameters

type Parameters struct {
	List *[]Parameter
}

func (Parameters) Copy

func (params Parameters) Copy() rbxapi.Parameters

func (Parameters) GetLength

func (params Parameters) GetLength() int

func (Parameters) GetParameter

func (params Parameters) GetParameter(index int) rbxapi.Parameter

func (Parameters) GetParameters

func (params Parameters) GetParameters() []rbxapi.Parameter

type Property

type Property struct {
	Name          string
	ValueType     Type
	Category      string
	ReadSecurity  string
	WriteSecurity string
	CanLoad       bool
	CanSave       bool
	Tags          `json:",omitempty"`
}

Property represents a class member of the Property member type.

func (*Property) Copy

func (member *Property) Copy() rbxapi.Member

Copy returns a deep copy of the member descriptor.

Copy implements the rbxapi.Member interface.

func (*Property) GetMemberType

func (member *Property) GetMemberType() string

GetMemberType returns a string indicating the the type of member.

GetMemberType implements the rbxapi.Member interface.

func (*Property) GetName

func (member *Property) GetName() string

GetName returns the name of the member.

GetName implements the rbxapi.Member interface.

func (*Property) GetSecurity

func (member *Property) GetSecurity() (read, write string)

GetSecurity returns the security context associated with the property's read and write access.

GetSecurity implements the rbxapi.Property interface.

func (*Property) GetValueType

func (member *Property) GetValueType() rbxapi.Type

GetValueType returns the type of value stored in the property.

GetValueType implements the rbxapi.Property interface.

func (*Property) Patch

func (member *Property) Patch(actions []patch.Action)

type Root

type Root struct {
	Classes []*Class
	Enums   []*Enum
}

Root represents the top-level structure of an API.

func Decode

func Decode(r io.Reader) (root *Root, err error)

Decode parses an API dump from r in JSON format.

func (*Root) Copy

func (root *Root) Copy() rbxapi.Root

Copy returns a deep copy of the API structure.

Copy implements the rbxapi.Root interface.

func (*Root) GetClass

func (root *Root) GetClass(name string) rbxapi.Class

GetClass returns the first class descriptor of the given name, or nil if no class of the given name is present.

GetClass implements the rbxapi.Root interface.

func (*Root) GetClasses

func (root *Root) GetClasses() []rbxapi.Class

GetClasses returns a list of class descriptors present in the API.

GetClasses implements the rbxapi.Root interface.

func (*Root) GetEnum

func (root *Root) GetEnum(name string) rbxapi.Enum

GetEnum returns the first enum descriptor of the given name, or nil if no enum of the given name is present.

GetEnum implements the rbxapi.Root interface.

func (*Root) GetEnums

func (root *Root) GetEnums() []rbxapi.Enum

GetEnums returns a list of enum descriptors present in the API.

GetEnums implements the rbxapi.Root interface.

func (*Root) MarshalJSON

func (root *Root) MarshalJSON() (b []byte, err error)

MarshalJSON implements the json.Marshaller interface.

func (*Root) Patch

func (root *Root) Patch(actions []patch.Action)

Patch transforms the API structure by applying a list of patch actions.

Patch implements the patch.Patcher interface.

func (*Root) UnmarshalJSON

func (root *Root) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements the json.Unmarshaller interface.

type Tags

type Tags []string

Tags contains the list of tags of a descriptor.

func (Tags) GetTag

func (tags Tags) GetTag(tag string) bool

GetTag returns whether the given tag is present in the descriptor.

GetTag implements the rbxapi.Taggable interface.

func (Tags) GetTags

func (tags Tags) GetTags() []string

GetTags returns a list of all tags present in the descriptor.

GetTags implements the rbxapi.Taggable interface.

func (*Tags) SetTag

func (tags *Tags) SetTag(tag ...string)

SetTag adds one or more tags to the list. Duplicate tags are removed.

func (*Tags) UnsetTag

func (tags *Tags) UnsetTag(tag ...string)

UnsetTag removes one or more tags from the list. Duplicate tags are removed.

type Type

type Type struct {
	Category string
	Name     string
}

Type represents a value type.

func (Type) Copy

func (typ Type) Copy() rbxapi.Type

Copy returns a deep copy of the type.

Copy implements the rbxapi.Type interface.

func (Type) GetCategory

func (typ Type) GetCategory() string

GetCategory returns the category of the type.

GetCategory implements the rbxapi.Type interface.

func (Type) GetName

func (typ Type) GetName() string

GetName returns the name of the type.

GetName implements the rbxapi.Type interface.

func (Type) String

func (typ Type) String() string

String returns a string representation of the entire type.

String implements the rbxapi.Type interface.

type VersionError

type VersionError interface {
	error
	// VersionError returns the unsupported version.
	VersionError() int
}

VersionError is an error indicating that the version of the JSON format is unsupported.

Jump to

Keyboard shortcuts

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