Skip to content

Commit

Permalink
Merge branch 'master' into dynamic-reflection-pog
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot authored Sep 3, 2024
2 parents 2413092 + c5f705e commit 99171cb
Show file tree
Hide file tree
Showing 93 changed files with 17,167 additions and 4,158 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.lua linguist-language=Luau
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ on:
- master

jobs:
validate:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: ok-nick/[email protected]

- name: Validate Crate Versions
run: lune run validate-crate-versions

build:

runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ Cargo.lock

# Editor-specific folders and files
/.vscode
sourcemap.json
sourcemap.json

# macOS Finder files
.DS_Store
81 changes: 81 additions & 0 deletions .lune/semver.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
--!strict
local SemVer = {}
SemVer.__index = SemVer

export type SemVer = {
major: number,
minor: number?,
patch: number?,
}

local function compare(a: number, b: number): number
if a > b then
return 1
elseif a < b then
return -1
end

return 0
end

function SemVer.__tostring(self: SemVer): string
return string.format("%i.%i.%i", self.major, self.minor or 0, self.patch or 0)
end

--[[
Constructs a new SemVer from the provided parts.
]]
function SemVer.new(major: number, minor: number?, patch: number?): SemVer
return (setmetatable({
major = major,
minor = minor,
patch = patch,
}, SemVer) :: any) :: SemVer
end

--[[
Parses `version` into a SemVer.
]]
function SemVer.parse(version: string)
local major, minor, patch, _ = version:match("^(%d+)%.(%d+)%.(%d+)(.*)$")
local realVersion = {
major = tonumber(major),
minor = tonumber(minor),
patch = tonumber(patch),
}
if realVersion.major == nil then
error(`could not parse major version from '{version}'`, 2)
end
if minor and realVersion.minor == nil then
error(`could not parse minor version from '{version}'`, 2)
end
if patch and realVersion.patch == nil then
error(`could not parse patch version from '{version}'`, 2)
end

return (setmetatable(realVersion, SemVer) :: any) :: SemVer
end

--[[
Compares two SemVers and returns their status compared to one another.
If `1` is returned, a is 'newer' than b.
If `-1` is returned, a is 'older' than b.
If `0` is returned, they are identical.
]]
function SemVer.compare(a: SemVer, b: SemVer)
local major = compare(a.major, b.major)
local minor = compare(a.minor or 0, b.minor or 0)

if major ~= 0 then
return major
end

if minor ~= 0 then
return minor
end

return compare(a.patch or 0, b.patch or 0)
end

return SemVer
107 changes: 107 additions & 0 deletions .lune/validate-crate-versions.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
--!strict
--#selene: allow(incorrect_standard_library_use)

local IGNORE_CRATE_LIST = {
"rbx_util",
"rbx_reflector",
}

local fs = require("@lune/fs")
local serde = require("@lune/serde")
local stdio = require("@lune/stdio")
local process = require("@lune/process")

local SemVer = require("semver")

type WorkspaceCargo = {
workspace: {
members: { string },
},
}

type CrateCargo = {
package: {
name: string,
version: string,
},
dependencies: { [string]: Dependency },
["dev-dependencies"]: { [string]: Dependency }?,
}

type Dependency = string | { version: string?, path: string?, features: { string }, optional: boolean? }

local function warn(...)
stdio.write(`[{stdio.color("yellow")}WARN{stdio.color("reset")}] `)
print(...)
end

local function processDependencies(dependency_list: { [string]: Dependency }, output: { [string]: Dependency })
for name, dependency in dependency_list do
if typeof(dependency) == "string" then
continue
end
if dependency.path then
output[name] = dependency
end
end
end

local workspace: WorkspaceCargo = serde.decode("toml", fs.readFile("Cargo.toml"))

local crate_info = {}

for _, crate_name in workspace.workspace.members do
if table.find(IGNORE_CRATE_LIST, crate_name) then
continue
end
local cargo: CrateCargo = serde.decode("toml", fs.readFile(`{crate_name}/Cargo.toml`))
local dependencies = {}
local dev_dependencies = {}
processDependencies(cargo.dependencies, dependencies)
if cargo.package["dev-dependencies"] then
processDependencies(cargo["dev-dependencies"] :: any, dev_dependencies)
end
crate_info[crate_name] = {
version = SemVer.parse(cargo.package.version),
dependencies = dependencies,
dev_dependencies = dev_dependencies,
}
end

table.freeze(crate_info)

local all_ok = true

for crate_name, cargo in crate_info do
for name, dependency in cargo.dependencies do
if typeof(dependency) == "string" then
error("invariant: string dependency made it into path list")
end
if not crate_info[name] then
warn(`Dependency {name} of crate {crate_name} has a path but is not local to this workspace.`)
all_ok = false
continue
end
if not dependency.version then
warn(`Dependency {name} of crate {crate_name} has a path but no version specified. Please fix this.`)
all_ok = false
continue
end
local dependency_version = SemVer.parse(dependency.version :: string)
local cmp = SemVer.compare(crate_info[name].version, dependency_version)
if cmp == 0 then
continue
else
all_ok = false
warn(
`Dependency {name} of crate {crate_name} has a version mismatch. Current version: {dependency_version}. Should be: {crate_info[name].version}`
)
end
end
end

if all_ok then
process.exit(0)
else
process.exit(1)
end
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @Dekkonot
docs/ @Dekkonot
.github/ @Dekkonot
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = [
"generate_reflection",
"rbx_binary",
"rbx_dom_weak",
"rbx_reflector",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Roblox Lua implementation of DOM APIs, allowing Instance reflection from inside
| Int64 | `Player.UserId` |||||
| NumberRange | `ParticleEmitter.Lifetime` |||||
| NumberSequence | `Beam.Transparency` |||||
| OptionalCoordinateFrame | `Model.WorldPivotData` || |||
| OptionalCFrame | `Model.WorldPivotData` || |||
| PhysicalProperties | `Part.CustomPhysicalProperties` |||||
| ProtectedString | `ModuleScript.Source` |||||
| Ray | `RayValue.Value` |||||
Expand Down
1 change: 1 addition & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ rojo = "rojo-rbx/[email protected]"
run-in-roblox = "rojo-rbx/[email protected]"
selene = "Kampfkarren/[email protected]"
stylua = "JohnnyMorganz/[email protected]"
lune = "lune-org/[email protected]"
35 changes: 27 additions & 8 deletions docs/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This document describes the Attribute binary format. In this format there is no
- [Data Types](#data-types)
- [String](#string)
- [Bool](#bool)
- [Int32](#int32)
- [Float32](#float32)
- [Float64](#float64)
- [UDim](#udim)
Expand All @@ -17,6 +18,7 @@ This document describes the Attribute binary format. In this format there is no
- [Vector2](#vector2)
- [Vector3](#vector3)
- [CFrame](#cframe)
- [EnumItem](#EnumItem)
- [NumberSequence](#numbersequence)
- [ColorSequence](#colorsequence)
- [NumberRange](#numberrange)
Expand Down Expand Up @@ -69,12 +71,16 @@ The `Bool` type is stored as a single byte. If the byte is `0x00`, the bool is `

It is worth noting that Roblox Studio will interpret any non-zero value as `true`.

### Int32
**Type ID `0x04`**
The `Int32` type is stored as a little-endian 32-bit integer.

### Float32
**Type ID `0x05`**

The `Float32` type is stored as a [single-precision float](https://en.wikipedia.org/wiki/Single-precision_floating-point_format), also known as an `f32` or `single`, or sometimes even simply `float`.

This type is accepted by Roblox Studio but will not ever be generated by it.
This type is accepted by Roblox Studio, though will almost never be generated by it. In some cases the Roblox Studio Properties widget may cause this type to appear.

### Float64
**Type ID `0x06`**
Expand Down Expand Up @@ -180,6 +186,18 @@ A `CFrame` with the value `CFrame.new(1, 2, 3) * CFrame.Angles(0, 45, 0)` looks

Demonstrating the axis-aligned rotation matrix case, a `CFrame` with the value `CFrame.new(1, 2, 3)` looks like this: `00 00 80 3f 00 00 00 40 00 00 40 40 02`.

### EnumItem
**Type ID `0x15`**

The `EnumItem` type is composed of two parts:

| Field Name | Format | Value |
|:-----------|:--------------------|:-------------------------------------------------------|
| Enum Name | [`String`](#string) | The name of the [`Enum`][Enum_Type] of this `EnumItem` |
| Value | `u32` | The `Value` field of the `EnumItem` |

[Enum_Type]: https://create.roblox.com/docs/reference/engine/datatypes/Enum

### NumberSequence
**Type ID `0x17`**

Expand All @@ -201,7 +219,8 @@ A `NumberSequenceKeypoint` is stored as a struct composed of three `f32`s:
A NumberSequence with the keypoints `0, 0, 0`, `0.5, 1, 0`, and `1, 1, 0.5` would look like this: `03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3f 00 00 80 3f 00 00 00 3f 00 00 80 3f 00 00 80 3f`

### ColorSequence
**Type ID `0x17`**
**Type ID `0x19`**

The `ColorSequence` type is stored as a struct composed of a `u32` and an array of `ColorSequenceKeypoint`s:

| Field Name | Format | Value |
Expand Down Expand Up @@ -250,12 +269,12 @@ A Rect with the value `10, 20, 30, 40` would look like this: `00 00 20 41 00 00

The `Font` type is a struct composed of a `u16`, `u8` and two `String`s

| Field Name | Format | Value |
|:-------------|:----------------------|:---------------------------------------|
| Weight | `u16` | The weight of the font |
| Style | `u8` | The style of the font |
| Family | [String](#string) | The font family content URI |
| CachedFaceId | [String](#string) | The cached content URI of the TTF file |
| Field Name | Format | Value |
|:-------------|:------------------------|:---------------------------------------|
| Weight | `u16` | The weight of the font |
| Style | `u8` | The style of the font |
| Family | [`String`](#string) | The font family content URI |
| CachedFaceId | [`String`](#string) | The cached content URI of the TTF file |

The `Weight` and `Style` values refer to the `FontWeight` and `FontStyle` enums respectively. They are stored as unsigned little-endian

Expand Down
32 changes: 0 additions & 32 deletions generate_reflection/Cargo.toml

This file was deleted.

27 changes: 0 additions & 27 deletions generate_reflection/README.md

This file was deleted.

Loading

0 comments on commit 99171cb

Please sign in to comment.