Documentation ¶
Overview ¶
The diff package provides operations for diffing and patching rbxdump structures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v0.2.0
type Action struct { // Type is the kind of transformation performed by the action. Type Type // Element is the type of element to which the action applies. Element Element // Primary is the name of the primary element. Primary string // Secondary is the name of the secondary element. Applies only to Property, // Function, Event, Callback, and EnumItem elements. Secondary string `json:",omitempty"` // Fields describes fields of the element. If Type is Add, this describes // the initial values. If Type is Change, this describes the new values. Fields rbxdump.Fields `json:",omitempty"` }
Action describes a single unit of difference between two dump structures.
func (Action) ToFielder ¶ added in v0.9.0
ToFielder returns a new element corresponding to the action's element type, as a Fielder. The Name field is set according to the action's identifiers. Returns nil if the type is invalid.
func (Action) ToMember ¶ added in v0.9.0
ToMember returns a new member element corresponding to the action's element type, as a Member. The Name field is set according to the action's identifiers. Returns nil if the type is not a member.
func (Action) ToPrimaryFielder ¶ added in v0.9.0
ToPrimaryFielder is similar to ToFielder, but returns a new element corresponding to the action's primary element type.
func (*Action) UnmarshalJSON ¶ added in v0.7.0
type Diff ¶
type Diff struct {
Prev, Next *rbxdump.Root
// If true, then each change action will have exactly one field. Otherwise,
// an action will have all changed fields grouped together.
SeparateFields bool
}
Diff is a Differ that finds differences between two rbxdump.Root values.
type DiffClass ¶
type DiffClass struct {
Prev, Next *rbxdump.Class
// ExcludeMembers indicates whether members should be diffed.
ExcludeMembers bool
// If true, then each change action will have exactly one field. Otherwise,
// an action will have all changed fields grouped together.
SeparateFields bool
}
DiffClass is a Differ that finds differences between two rbxdump.Class values.
type DiffEnum ¶
type DiffEnum struct {
Prev, Next *rbxdump.Enum
// ExcludeEnumItems indicates whether enum items should be diffed.
ExcludeEnumItems bool
// If true, then each change action will have exactly one field. Otherwise,
// an action will have all changed fields grouped together.
SeparateFields bool
}
DiffEnum is a Differ that finds differences between two rbxdump.Enum values.
type DiffEnumItem ¶
type DiffEnumItem struct { // Enum is the name of the outer structure of the Prev value. Enum string Prev, Next *rbxdump.EnumItem // If true, then each change action will have exactly one field. Otherwise, // an action will have all changed fields grouped together. SeparateFields bool }
DiffEnumItem is a Differ that finds differences between two rbxdump.EnumItem values.
func (DiffEnumItem) Diff ¶
func (d DiffEnumItem) Diff() (actions []Action)
Diff implements the Differ interface.
type DiffMember ¶ added in v0.2.0
type DiffMember struct { // Class is the name of the outer structure of the Prev value. Class string Prev, Next rbxdump.Member // If true, then each change action will have exactly one field. Otherwise, // an action will have all changed fields grouped together. SeparateFields bool }
DiffMember is a Differ that finds differences between two rbxdump.Member values.
func (DiffMember) Diff ¶ added in v0.2.0
func (d DiffMember) Diff() (actions []Action)
Diff implements the Differ interface.
type Differ ¶ added in v0.2.0
type Differ interface {
Diff() []Action
}
Differ is implemented by any value that has a Diff method, which returns the differences between two structures as a list of Actions.
type Element ¶ added in v0.2.0
type Element int
Element indicates the type of element to which an Action applies.
const ( Invalid Element Class Property Function Event Callback Enum EnumItem )
func FromElement ¶ added in v0.2.0
FromElement returns the Element corresponding to the given rbxdump element type or a pointer to such. Returns Invalid for any other type.
func (Element) MarshalJSON ¶ added in v0.3.2
func (*Element) UnmarshalJSON ¶ added in v0.3.2
type Inverter ¶ added in v0.8.0
Inverter is implemented by any value that has an Inverse method, which receives a list of Actions and produces an inverse list of Actions. That is, for a list of actions P that patches structure A into B, the inverse of P will patch structure B back into A.
type Patch ¶ added in v0.2.0
Patch is used to transform the embedded rbxdump.Root by applying a list of Actions.
type PatchCallback ¶ added in v0.2.0
PatchCallback is used to transform the embedded rbxdump.Callback by applying a list of Actions.
func (*PatchCallback) Patch ¶ added in v0.2.0
func (member *PatchCallback) Patch(actions []Action)
Patch implements the Patcher interface.
type PatchClass ¶ added in v0.2.0
PatchClass is used to transform the embedded rbxdump.Class by applying a list of Actions.
func (*PatchClass) Patch ¶ added in v0.2.0
func (class *PatchClass) Patch(actions []Action)
Patch implements the Patcher interface.
type PatchEnum ¶ added in v0.2.0
PatchEnum is used to transform the embedded rbxdump.Enum by applying a list of Actions.
type PatchEnumItem ¶ added in v0.2.0
PatchEnumItem is used to transform the embedded rbxdump.EnumItem by applying a list of Actions.
func (*PatchEnumItem) Patch ¶ added in v0.2.0
func (item *PatchEnumItem) Patch(actions []Action)
Patch implements the Patcher interface.
type PatchEvent ¶ added in v0.2.0
PatchEvent is used to transform the embedded rbxdump.Event by applying a list of Actions.
func (*PatchEvent) Patch ¶ added in v0.2.0
func (member *PatchEvent) Patch(actions []Action)
Patch implements the Patcher interface.
type PatchFunction ¶ added in v0.2.0
PatchFunction is used to transform the embedded rbxdump.Function by applying a list of Actions.
func (*PatchFunction) Patch ¶ added in v0.2.0
func (member *PatchFunction) Patch(actions []Action)
Patch implements the Patcher interface.
type PatchProperty ¶ added in v0.2.0
PatchProperty is used to transform the embedded rbxdump.Property by applying a list of Actions.
func (*PatchProperty) Patch ¶ added in v0.2.0
func (member *PatchProperty) Patch(actions []Action)
Patch implements the Patcher interface.
type Patcher ¶ added in v0.2.0
type Patcher interface {
Patch([]Action)
}
Patcher is implemented by any value that has a Patch method, which applies a given list of Actions to a structure. Actions with information that is irrelevant, incomplete, or invalid can be ignored.
Ideally, when the API's "origin" and "target" are compared with a Differ, and the returned list of Actions are passed to a Patcher, the end result is that origin is transformed to match target exactly.
Implementations must ensure that values contained within action Fields are copied, so that they are not shared between structures.