Open Anaminus opened 2 years ago
Descriptor extensions can be used for configuration. e.g. AttrConfig. To support this well, inheritance should have a merging strategy that enables each component to be inherited individually.
For merging the descriptor portion, the set of descriptor fields is defined as all fields that aren't $rbxmkConfig
. If none of these fields are present, then the descriptor portion is considered not present, and instead inherits from the upper descriptor as usual.
The $rbxmkConfig
field is merged top to bottom. That is, if a queried value does not exist on the current RootDesc, then try again with the upper RootDesc, and so on.
To block inheritance, false
can be passed as before, but this will block all fields. To block just descriptor fields, a RootDesc.new()
can be used. To block just config fields, RootDesc.config()
can be used.
RootDesc.config(config: table): RootDesc
The config constructor returns a RootDesc with only the config fields specified by config.
Handle desc extensions separately from desc format by implementing a generic json patching system.
Types:
JsonValue: nil|boolean|number|string|Array|Dictionary
JsonOperation: {op: string, from: string?, path: string, value: JsonValue?}
JsonPatch: {JsonOperation}
Formats:
patch.json
format encodes JsonPatch
.json
format encodes JsonValue
instead of union of values.Libraries:
json
json.diff(prev: JsonValue, next: JsonValue): JsonPatch
json.patch(value: JsonValue, patch: JsonPatch): JsonValue
json.string(value: JsonValue, indent: string?): string
rbxmk.encodeFormat("json", value)
.json.fromString(string: string): JsonValue
rbxmk.decodeFormat("json", string)
.Desc
gains several members:
Desc.Extensions: JsonValue
Desc:DiffExtensions(next: JsonValue): JsonPatch
Desc:PatchExtensions(patch: JsonPatch)
Certain fields of Desc.Extensions are interpreted in certain ways:
rbxmk.globalDesc.Extensions = {
Elements = ..., -- Extends elements in Desc.
Config = ..., -- Additional non-element-specific config.
Behaviors = ..., -- Instance behaviors.
}
Flags:
--desc-extend
: Accepts a json
formatted file that sets the extensions portion of the global Desc.--desc-patch
: Now requires .desc-action.json
extension of given file, which is interpreted as before. Now also accepts .patch.json
extension, which is interpreted as patch to extension portion of global Desc.
$rbxmkExtensions
field in the descriptor root, for forward-compatibility with Roblox's API dump format.$rbxmkConfig
field in the descriptor root.Example descriptor file:
Example patch that enhances a property with a default value:
Example patch that modifies global BrickColor data: