forked from rojo-rbx/rojo
Simplify usage of attributes. (#574)
* Support implicit values for primitive attributes This commit adds support for strings, numbers, and booleans to be implicitly typed in attribute maps, reducing the redundancy of needing to specify their types. I also quietly adjusted one of the tests to use a more stable class/property pair. Since SourceAssetId is locked to Roblox, it could potentially disappear at any time. * Apply formatting. * Address feedback * Backwards compatible format usage. * Axe UnresolvedValueMap in favor of $attributes Attributes can be defined directly on instances, with support for unambiguous types. * Adjust test. * to_string() -> into() * Made attribute test more concise. * small cleanup * Update src/resolution.rs * Update src/resolution.rs * Update src/resolution.rs * Update src/resolution.rs Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
---
|
||||
source: tests/tests/build.rs
|
||||
assertion_line: 99
|
||||
expression: contents
|
||||
---
|
||||
<roblox version="4">
|
||||
@@ -11,12 +10,24 @@ expression: contents
|
||||
<Item class="Folder" referent="1">
|
||||
<Properties>
|
||||
<string name="Name">Explicit</string>
|
||||
<BinaryString name="AttributesSerialize">AgAAAAUAAABIZWxsbwIFAAAAV29ybGQGAAAAVmVjdG9yEQAAgD8AAABAAABAQA==</BinaryString>
|
||||
<BinaryString name="AttributesSerialize">DQAAAAQAAABCb29sAwEKAAAAQnJpY2tDb2xvcg4BAAAABgAAAENvbG9yMw8AAAAAAAAAAAAAAAANAAAAQ29sb3JTZXF1ZW5jZRkCAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAAAAAACAPwAAgD8AAIA/AACAPwcAAABGbG9hdDMyBQAAAAAHAAAARmxvYXQ2NAYAAAAAAAAAAAsAAABOdW1iZXJSYW5nZRsAAAAAAAAAAA4AAABOdW1iZXJTZXF1ZW5jZRcCAAAAAAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAABAAAAFJlY3QcAAAAAAAAAAAAAAAAAAAAAAQAAABVRGltCQAAAAAAAAAABQAAAFVEaW0yCgAAAAAAAAAAAAAAAAAAAAAHAAAAVmVjdG9yMhAAAAAAAAAAAAcAAABWZWN0b3IzEQAAAAAAAAAAAAAAAA==</BinaryString>
|
||||
</Properties>
|
||||
</Item>
|
||||
<Item class="Folder" referent="2">
|
||||
<Properties>
|
||||
<string name="Name">ImplicitAttributes</string>
|
||||
<string name="Name">Implicit</string>
|
||||
<BinaryString name="AttributesSerialize">AwAAAAQAAABCb29sAwEGAAAATnVtYmVyBgAAAAAAAOA/BgAAAFN0cmluZwIEAAAAVGVzdA==</BinaryString>
|
||||
</Properties>
|
||||
</Item>
|
||||
<Item class="Folder" referent="3">
|
||||
<Properties>
|
||||
<string name="Name">LegacyExplicit</string>
|
||||
<BinaryString name="AttributesSerialize">AgAAAAUAAABIZWxsbwIFAAAAV29ybGQGAAAAVmVjdG9yEQAAgD8AAABAAABAQA==</BinaryString>
|
||||
</Properties>
|
||||
</Item>
|
||||
<Item class="Folder" referent="4">
|
||||
<Properties>
|
||||
<string name="Name">LegacyImplicit</string>
|
||||
<BinaryString name="AttributesSerialize">AgAAAAMAAABIZXkCBwAAAEdyYW5kbWEGAAAAVmVjdG9yEQAAgEAAAKBAAADAQA==</BinaryString>
|
||||
</Properties>
|
||||
</Item>
|
||||
|
||||
@@ -3,7 +3,85 @@
|
||||
"tree": {
|
||||
"$className": "Folder",
|
||||
|
||||
"Implicit": {
|
||||
"$className": "Folder",
|
||||
"$attributes": {
|
||||
"Bool": true,
|
||||
"Number": 0.5,
|
||||
"String": "Test"
|
||||
}
|
||||
},
|
||||
|
||||
"Explicit": {
|
||||
"$className": "Folder",
|
||||
"$attributes": {
|
||||
"Bool": {
|
||||
"Bool": true
|
||||
},
|
||||
"Float32": {
|
||||
"Float32": 0
|
||||
},
|
||||
"Float64": {
|
||||
"Float64": 0
|
||||
},
|
||||
"UDim": {
|
||||
"UDim": [0, 0]
|
||||
},
|
||||
"UDim2": {
|
||||
"UDim2": [[0, 0], [0, 0]]
|
||||
},
|
||||
"BrickColor": {
|
||||
"BrickColor": 1
|
||||
},
|
||||
"Color3": {
|
||||
"Color3": [0, 0, 0]
|
||||
},
|
||||
"Vector2": {
|
||||
"Vector2": [0, 0]
|
||||
},
|
||||
"Vector3": {
|
||||
"Vector3": [0, 0, 0]
|
||||
},
|
||||
"NumberSequence": {
|
||||
"NumberSequence": {
|
||||
"keypoints": [
|
||||
{
|
||||
"time": 0,
|
||||
"value": 0,
|
||||
"envelope": 0
|
||||
},
|
||||
{
|
||||
"time": 1,
|
||||
"value": 0,
|
||||
"envelope": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"ColorSequence": {
|
||||
"ColorSequence": {
|
||||
"keypoints": [
|
||||
{
|
||||
"time": 0,
|
||||
"color": [1, 1, 1]
|
||||
},
|
||||
{
|
||||
"time": 1,
|
||||
"color": [1, 1, 1]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"NumberRange": {
|
||||
"NumberRange": [0, 0]
|
||||
},
|
||||
"Rect": {
|
||||
"Rect": [[0, 0], [0, 0]]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"LegacyExplicit": {
|
||||
"$className": "Folder",
|
||||
"$properties": {
|
||||
"Attributes": {
|
||||
@@ -19,7 +97,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
"ImplicitAttributes": {
|
||||
"LegacyImplicit": {
|
||||
"$className": "Folder",
|
||||
"$properties": {
|
||||
"Attributes": {
|
||||
|
||||
Reference in New Issue
Block a user