Compare commits

...

3 Commits

Author SHA1 Message Date
Alona EM e4e044e733 Parsable! 2022-01-16 01:25:47 +00:00
Alona EM 6fcfea664f Basic HIDL 2022-01-15 22:50:02 +00:00
Alona EM 5a5199f91f Gah 2022-01-15 22:16:52 +00:00
16 changed files with 9998 additions and 0 deletions

1
hidl/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target/

586
hidl/Cargo.lock generated Normal file
View File

@ -0,0 +1,586 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
[[package]]
name = "ascii-canvas"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6"
dependencies = [
"term",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bit-set"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "debug2"
version = "0.1.0"
source = "git+https://github.com/aDotInTheVoid/debug2/#8b14afb90fc1d9ce470792ea393a9ab821a9e07f"
dependencies = [
"debug2-derive",
]
[[package]]
name = "debug2-derive"
version = "0.1.0"
source = "git+https://github.com/aDotInTheVoid/debug2/#8b14afb90fc1d9ce470792ea393a9ab821a9e07f"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "diff"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499"
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "ena"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3"
dependencies = [
"log",
]
[[package]]
name = "fixedbitset"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "fs-err"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ebd3504ad6116843b8375ad70df74e7bfe83cac77a1f3fe73200c844d43bfe0"
[[package]]
name = "getrandom"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "hidl"
version = "0.1.0"
dependencies = [
"anyhow",
"debug2",
"fs-err",
"lalrpop",
"lalrpop-util",
"serde",
"serde_json",
"serde_yaml",
]
[[package]]
name = "indexmap"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]]
name = "itertools"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]]
name = "lalrpop"
version = "0.19.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15174f1c529af5bf1283c3bc0058266b483a67156f79589fab2a25e23cf8988"
dependencies = [
"ascii-canvas",
"atty",
"bit-set",
"diff",
"ena",
"itertools",
"lalrpop-util",
"petgraph",
"pico-args",
"regex",
"regex-syntax",
"string_cache",
"term",
"tiny-keccak",
"unicode-xid",
]
[[package]]
name = "lalrpop-util"
version = "0.19.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3e58cce361efcc90ba8a0a5f982c741ff86b603495bb15a998412e957dcd278"
dependencies = [
"regex",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
name = "linked-hash-map"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "lock_api"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "new_debug_unreachable"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "parking_lot"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi",
]
[[package]]
name = "petgraph"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
dependencies = [
"fixedbitset",
"indexmap",
]
[[package]]
name = "phf_shared"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7"
dependencies = [
"siphasher",
]
[[package]]
name = "pico-args"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468"
[[package]]
name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "proc-macro2"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [
"getrandom",
"redox_syscall",
]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rustversion"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
[[package]]
name = "ryu"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0"
dependencies = [
"indexmap",
"ryu",
"serde",
"yaml-rust",
]
[[package]]
name = "siphasher"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b"
[[package]]
name = "smallvec"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]]
name = "string_cache"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "923f0f39b6267d37d23ce71ae7235602134b250ace715dd2c90421998ddac0c6"
dependencies = [
"lazy_static",
"new_debug_unreachable",
"parking_lot",
"phf_shared",
"precomputed-hash",
]
[[package]]
name = "syn"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "synstructure"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-xid",
]
[[package]]
name = "term"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
dependencies = [
"dirs-next",
"rustversion",
"winapi",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
dependencies = [
"crunchy",
]
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]

20
hidl/Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "hidl"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.52"
debug2 = { git = "https://github.com/aDotInTheVoid/debug2/" }
fs-err = "2.6.0"
lalrpop-util = { version = "0.19.6", features = ["lexer"] }
serde = { version = "1.0.133", features = ["derive"] }
serde_json = "1.0.75"
serde_yaml = "0.8.23"
[features]
[build-dependencies]
lalrpop = "0.19.6"

6
hidl/build.rs Normal file
View File

@ -0,0 +1,6 @@
fn main() {
lalrpop::Configuration::new()
.generate_in_source_tree()
.process()
.unwrap();
}

77
hidl/hypercosm.hidl Normal file
View File

@ -0,0 +1,77 @@
namespace hypercosm
interface Object {
version 0 0 0
methods {
list_interfaces() -> []string
release()
}
}
interface Root {
version 0 0 0
methods {
list_extenstions() -> []string
ping()
get_object_by_id(id: uuid) -> object
get_object_by_name(name: string) -> object
}
}
extension asset_delivery {
version 0 0 0
interface {
events {
load_assets(assets: []Asset)
unload_assets(assets: []uuid)
}
methods {
fetchById(id: uuid) -> Asset
fetchByName(name: string) -> Asset
fetchByIds(ids: []uuid) -> []Asset
fetchByNames(names: []string) -> []Asset
getId(name: string) -> uuid
}
}
struct Asset {
id: uuid
name: string
data: []u8
}
}
extension world {
version 0 0 0
interface {
events {
add_entitys(entities: []EntityInfo)
update_entitys(entities: []EntityInfo)
remove_entitys(entities: []uuid)
}
}
interface Entity {
methods {
interact()
}
}
struct EntityInfo {
assetId: uuid
entity: Entity
transformation: matrix4x4
flags: EntityFlags
}
enum EntityFlags(vu128) {
None = 0
Interactable = 1
Collidable = 2
}
}

364
hidl/hypercosm.json Normal file
View File

@ -0,0 +1,364 @@
{
"name": "hypercosm",
"interfaces": [
{
"name": "Object",
"version": [
0,
0,
0
],
"methods": [
{
"name": "list_interfaces",
"args": [],
"ret": {
"Array": {
"Primitive": "String"
}
}
},
{
"name": "release",
"args": [],
"ret": null
}
],
"events": []
},
{
"name": "Root",
"version": [
0,
0,
0
],
"methods": [
{
"name": "list_extenstions",
"args": [],
"ret": {
"Array": {
"Primitive": "String"
}
}
},
{
"name": "ping",
"args": [],
"ret": null
},
{
"name": "get_object_by_id",
"args": [
{
"name": "id",
"ty": {
"Primitive": "Uuid"
}
}
],
"ret": {
"Primitive": "Object"
}
},
{
"name": "get_object_by_name",
"args": [
{
"name": "name",
"ty": {
"Primitive": "String"
}
}
],
"ret": {
"Primitive": "Object"
}
}
],
"events": []
}
],
"types": [],
"extensions": [
{
"name": "asset_delivery",
"version": [
0,
0,
0
],
"interface": {
"methods": [
{
"name": "fetchById",
"args": [
{
"name": "id",
"ty": {
"Primitive": "Uuid"
}
}
],
"ret": {
"Custom": "Asset"
}
},
{
"name": "fetchByName",
"args": [
{
"name": "name",
"ty": {
"Primitive": "String"
}
}
],
"ret": {
"Custom": "Asset"
}
},
{
"name": "fetchByIds",
"args": [
{
"name": "ids",
"ty": {
"Array": {
"Primitive": "Uuid"
}
}
}
],
"ret": {
"Array": {
"Custom": "Asset"
}
}
},
{
"name": "fetchByNames",
"args": [
{
"name": "names",
"ty": {
"Array": {
"Primitive": "String"
}
}
}
],
"ret": {
"Array": {
"Custom": "Asset"
}
}
},
{
"name": "getId",
"args": [
{
"name": "name",
"ty": {
"Primitive": "String"
}
}
],
"ret": {
"Primitive": "Uuid"
}
}
],
"events": [
{
"name": "load_assets",
"args": [
{
"name": "assets",
"ty": {
"Array": {
"Custom": "Asset"
}
}
}
],
"ret": null
},
{
"name": "unload_assets",
"args": [
{
"name": "assets",
"ty": {
"Array": {
"Primitive": "Uuid"
}
}
}
],
"ret": null
}
]
},
"interfaces": [],
"types": [
{
"name": "Asset",
"kind": {
"Struct": {
"fields": [
{
"name": "id",
"ty": {
"Primitive": "Uuid"
}
},
{
"name": "name",
"ty": {
"Primitive": "String"
}
},
{
"name": "data",
"ty": {
"Array": {
"IntType": "U8"
}
}
}
]
}
}
}
]
},
{
"name": "world",
"version": [
0,
0,
0
],
"interface": {
"methods": [],
"events": [
{
"name": "add_entitys",
"args": [
{
"name": "entities",
"ty": {
"Array": {
"Custom": "EntityInfo"
}
}
}
],
"ret": null
},
{
"name": "update_entitys",
"args": [
{
"name": "entities",
"ty": {
"Array": {
"Custom": "EntityInfo"
}
}
}
],
"ret": null
},
{
"name": "remove_entitys",
"args": [
{
"name": "entities",
"ty": {
"Array": {
"Primitive": "Uuid"
}
}
}
],
"ret": null
}
]
},
"interfaces": [
{
"name": "Entity",
"version": null,
"methods": [
{
"name": "interact",
"args": [],
"ret": null
}
],
"events": []
}
],
"types": [
{
"name": "EntityInfo",
"kind": {
"Struct": {
"fields": [
{
"name": "assetId",
"ty": {
"Primitive": "Uuid"
}
},
{
"name": "entity",
"ty": {
"Custom": "Entity"
}
},
{
"name": "transformation",
"ty": {
"Primitive": "Matrix4x4"
}
},
{
"name": "flags",
"ty": {
"Custom": "EntityFlags"
}
}
]
}
}
},
{
"name": "EntityFlags",
"kind": {
"Enum": {
"backing": "VU128",
"fields": [
{
"name": "None",
"value": 0
},
{
"name": "Interactable",
"value": 1
},
{
"name": "Collidable",
"value": 2
}
]
}
}
}
]
}
]
}

63
hidl/spec-demo.yaml Normal file
View File

@ -0,0 +1,63 @@
---
name: hypercosm
root:
interfaces:
- name: object
version:
- 1
- 0
- 0
methods:
- name: listInterfaces
ret:
Array: String
- name: release
- name: root
version:
- 0
- 1
- 0
methods:
- name: listExtensions
ret:
Array: String
- name: ping
- name: getObjectById
ret: Object
args:
- - id
- Uuid
- name: getObjectByName
ret: Object
args:
- - name
- String
extenstions:
- name: assetdelivery
version:
- 0
- 1
- 0
module:
interfaces:
- name: assetdelivery
version:
- 0
- 1
- 0
events:
- name: loadAssets
args:
- - name
- String
types:
- name: asset
kind:
Struct:
fields:
- - id
- Uuid
- - name
- String
- - data
- Array: U8

89
hidl/spec-testcosm.yaml Normal file
View File

@ -0,0 +1,89 @@
---
- interface:
name: hypercosm.object.v1.0.0
methods:
- listInterfaces:
- array[string]
- release
- interface:
name: hypercosm.root.v0.1.0
methods:
- listExtensions:
- array[string]
- ping
- getObjectById:
- object
- uuid: id
- getObjectByName:
- object
- string: name
- extension:
- name: hypercosm.assetdelivery.v0.1.0
- interface: # Implicit name; matches extension and visible from root object
events: # Events can come after methods in the YAML but always first for command numbering
- loadAssets:
- void
- array[asset]: asset
- unloadAssets:
- void
- array[uuid]: ids
methods:
- fetchAssetById:
- asset
- uuid: id
- fetchAssetByName:
- asset
- string: name
- fetchAssetsByIds:
- array[asset]
- array[uuid]: ids
- fetchAssetsByNames:
- array[asset]
- array[string]: names
- getId:
- uuid
- string: name
- struct:
- name: asset # First element of a struct is always the name
- uuid: id
- string: name
- array[u8]: data
- extension:
- name: hypercosm.world.v0.1.0
- interface:
events:
- addEntities:
- void
- array[entityInfo]: entities
- updateEntities:
- void
- array[entityInfo]: entities
- removeEntities:
- void
- array[entity]: entities
- struct:
- name: entityInfo
- uuid: assetId # glTF
- entity: entity
- matrix4x4: transformation
- entityFlags: flags
- interface:
name: entity
methods:
- interact
- flags:
- name: entityFlags
- type: vu128
- None: 0
- Interactable
- Collidable
- enum: # Alternate form
- name: entityFlags
- type: vu128
- None: 0
- Interactable: 1
- Collidable: 2

80
hidl/spec.yaml Normal file
View File

@ -0,0 +1,80 @@
---
name: hypercosm
root:
interfaces:
- name: object
version:
- 1
- 0
- 0
methods:
- name: listInterfaces
ret:
Array: String
- name: release
- name: root
version:
- 0
- 1
- 0
methods:
- name: listExtensions
ret:
Array: String
- name: ping
- name: getObjectById
ret: Object
args:
- - id
- Uuid
- name: getObjectByName
ret: Object
args:
- - name
- String
extenstions:
- name: assetdelivery
version:
- 0
- 1
- 0
module:
interfaces:
- name: assetdelivery
version:
- 0
- 1
- 0
events:
- name: loadAssets
args:
- - assets
- Array:
Custom:
asset
- name: unloadAssets
args:
- - ids
- Array: Uuid
methods:
- name: fetchAssetByName
args:
- - name
- String
ret:
Custom:
asset
types:
- name: asset
kind:
Struct:
fields:
- - id
- Uuid
- - name
- String
- - data
- Array: U8

142
hidl/src/ast.rs Normal file
View File

@ -0,0 +1,142 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Namespace {
pub name: String,
pub interfaces: Vec<Interface>,
pub types: Vec<TypeDef>,
pub extensions: Vec<Extension>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Extension {
pub name: String,
pub version: Version,
pub interface: ImplicitInterface,
pub interfaces: Vec<ExtensionInterface>,
pub types: Vec<TypeDef>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Interface {
pub name: String,
pub version: Version,
pub methods: Vec<Func>,
pub events: Vec<Func>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ImplicitInterface {
// Gets version and name from extension
pub methods: Vec<Func>,
pub events: Vec<Func>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ExtensionInterface {
pub name: String,
// May get version from extension
pub version: Option<Version>,
pub methods: Vec<Func>,
pub events: Vec<Func>,
}
pub type Version = (u8, u8, u8);
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Func {
pub name: String,
pub args: Vec<Arg>,
pub ret: Option<Type>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Type {
Primitive(PrimType),
Custom(String),
Array(Box<Type>),
IntType(IntType),
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum PrimType {
String,
Object,
Uuid,
Bytes,
Bool,
Matrix4x4,
F32,
F64,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum IntType {
U8,
U16,
U32,
U64,
U128,
VU8,
VU16,
VU32,
VU64,
VU128,
I8,
I16,
I32,
I64,
I128,
VI8,
VI16,
VI32,
VI64,
VI128,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Arg {
pub name: String,
pub ty: Type,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TypeDef {
pub name: String,
pub kind: TypeKind,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum TypeKind {
Struct(Struct),
Enum(Enum),
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Enum {
pub backing: IntType,
pub fields: Vec<EnumField>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EnumField {
pub name: String,
pub value: Option<i64>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Struct {
pub fields: Vec<StructField>,
}
#[derive(Debug, debug2::Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct StructField {
pub name: String,
pub ty: Type,
}

15
hidl/src/bin/demo.rs Normal file
View File

@ -0,0 +1,15 @@
use anyhow::Result;
use fs_err as fs;
fn main() -> Result<()> {
let tree = fs::read_to_string("hypercosm.hidl")?;
let tree = hidl::grammar::NamespaceParser::new().parse(&tree).unwrap();
debug2::dbg!(&tree);
let json = serde_json::to_string_pretty(&tree)?;
fs::write("hypercosm.json", &json)?;
Ok(())
}

10
hidl/src/bin/load.rs Normal file
View File

@ -0,0 +1,10 @@
use std::fs;
use hidl::IDL;
fn main() {
let file = fs::read_to_string("spec.yaml").unwrap();
let spec: IDL = serde_yaml::from_str(&file).unwrap();
debug2::dbg!(spec);
}

171
hidl/src/grammar.lalrpop Normal file
View File

@ -0,0 +1,171 @@
use crate::ast::*;
grammar();
// Skip over comments
match {
r"\s*" => { },
r"//[^\n\r]*[\n\r]*" => { },
_
}
pub Namespace: Namespace = {
"namespace" <name:Ident>
<interfaces:List<Interface>>
<types:List<TypeDef>>
<extensions:List<Extension>>
=> Namespace{<>}
}
Extension: Extension = {
"extension" <name:Ident> "{"
<version:Version?>
<interface:ImplicitInterface>
<interfaces:List<ExtensionInterface>>
<types:List<TypeDef>>
"}"
=> Extension{name, version: version.unwrap_or_default(), interface, interfaces, types}
}
Interface: Interface = {
"interface" <name:Ident> "{"
<v:Version?>
<e:Events?>
<m:Methods?>
"}" => Interface { name, version: v.unwrap_or_default(), events: e.unwrap_or_default(), methods: m.unwrap_or_default() }
}
ExtensionInterface: ExtensionInterface = {
"interface" <name:Ident> "{"
<version:Version?>
<e:Events?>
<m:Methods?>
"}" => ExtensionInterface { name, version, events: e.unwrap_or_default(), methods: m.unwrap_or_default() }
}
ImplicitInterface: ImplicitInterface = {
"interface" "{"
<e:Events?>
<m:Methods?>
"}" => ImplicitInterface { events: e.unwrap_or_default(), methods: m.unwrap_or_default() }
}
Version: Version = {
"version" <Num> <Num> <Num> => (<>)
}
Events: Vec<Func> = { "events" "{" <List<Func>> "}" => <> }
Methods: Vec<Func> = { "methods" "{" <List<Func>> "}" => <> }
Func: Func = {
<name:Ident> "(" <args: Comma<Arg>> ")" <ret:("->" <Type>)?> => Func{<>}
}
Arg: Arg = {
<name:Ident> ":" <ty:Type> => Arg{<>}
}
// Argument types
Type: Type = {
PrimType => Type::Primitive(<>),
Ident => Type::Custom(<>),
IntType => Type::IntType(<>),
"[]" <Type> => Type::Array(Box::new(<>)),
}
PrimType: PrimType = {
"string" => PrimType::String,
"object" => PrimType::Object,
"uuid" => PrimType::Uuid,
"bytes" => PrimType::Bytes,
"bool" => PrimType::Bool,
"matrix4x4" => PrimType::Matrix4x4,
"f32" => PrimType::F32,
"f64" => PrimType::F64,
}
// These are seperate as only they can back an enum
IntType: IntType = {
"u8" => IntType::U8,
"u16" => IntType::U16,
"u32" => IntType::U32,
"u64" => IntType::U64,
"u128" => IntType::U128,
"vu8" => IntType::VU8,
"vu16" => IntType::VU16,
"vu32" => IntType::VU32,
"vu64" => IntType::VU64,
"vu128" => IntType::VU128,
"i8" => IntType::I8,
"i16" => IntType::I16,
"i32" => IntType::I32,
"i64" => IntType::I64,
"i128" => IntType::I128,
"vi8" => IntType::VI8,
"vi16" => IntType::VI16,
"vi32" => IntType::VI32,
"vi64" => IntType::VI64,
"vi128" => IntType::VI128,
}
// Typedefs
TypeDef: TypeDef = {
"struct" <name:Ident> <s:Struct> => TypeDef{name, kind: TypeKind::Struct(s)},
"enum" <name:Ident> "(" <backing:IntType> ")" <fields:Enum>
=> TypeDef{name, kind: TypeKind::Enum(Enum{fields, backing})},
// Enum => TypeDef::Enum(<>),
}
Struct: Struct = { "{" <fields:List<StructField>> "}" => Struct{<>} }
StructField: StructField = {
<name:Ident> ":" <ty:Type> => StructField{<>}
}
Enum: Vec<EnumField> = { "{" <List<EnumField>> "}" => <> }
EnumField: EnumField = {
<name:Ident> <value:("=" <Int>)?> => EnumField{<>}
}
// Terminals
// Num: u8 = {
// r"[0-9]+" => <>.parse().unwrap()
// }
Num: u8 = {
// TODO: This is a bit hacky, but it works for now
Int => <>.try_into().unwrap(),
}
Int: i64 = {
r"(-)?[0-9]+" => <>.parse().unwrap()
}
Ident: String = { r"[a-zA-Z][a-zA-Z0-9_]*" => <>.to_owned() }
// Combinators
List<T>: Vec<T> = {
<v:(<T>)*> => v
};
Comma<T>: Vec<T> = {
<v:(<T> ",")*> <e:T?> => match e {
None=> v,
Some(e) => {
let mut v = v;
v.push(e);
v
}
}
};

8156
hidl/src/grammar.rs Normal file

File diff suppressed because it is too large Load Diff

160
hidl/src/lib.rs Normal file
View File

@ -0,0 +1,160 @@
use debug2::Debug as Debug2;
use serde::{Deserialize, Serialize};
pub mod ast;
#[allow(clippy::all)]
pub mod grammar;
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct Module {
interfaces: Vec<Interface>,
types: Vec<CustomType>,
}
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct IDL {
name: String,
root: Module,
extenstions: Vec<Extension>,
}
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct Extension {
name: String,
version: Version,
module: Module,
}
type Version = (u8, u8, u8);
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct Interface {
name: String,
version: Version,
methods: Vec<Method>,
events: Vec<Method>,
}
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct Method {
name: String,
ret: Type,
args: Vec<(String, Type)>,
}
#[derive(Debug, Debug2, Clone, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum Type {
NotIntType(NotIntType),
IntType(IntType),
}
#[derive(Debug, Debug2, Clone, Serialize, Deserialize, PartialEq)]
pub enum NotIntType {
/// TODO: Should we special case Array of u8?
Array(Box<Type>),
Custom(String),
String,
Object,
Uuid,
/// Unit type
Void,
}
impl Default for Type {
fn default() -> Self {
Self::NotIntType(NotIntType::Void)
}
}
#[derive(Debug, Debug2, Clone, Serialize, Deserialize, PartialEq)]
pub enum IntType {
U8,
U16,
U32,
U64,
I8,
I16,
I32,
I64,
VU16,
VU8,
VU32,
VU64,
VI8,
VI16,
VI32,
VI64,
}
#[derive(Debug, Debug2, Clone, Serialize, Deserialize, PartialEq)]
pub struct CustomType {
name: String,
kind: CustomTypeKind,
}
#[derive(Debug, Debug2, Clone, Serialize, Deserialize, PartialEq)]
enum CustomTypeKind {
Struct(CustomStruct),
Enum(Enum),
}
#[derive(Debug, Debug2, Clone, Serialize, Deserialize, PartialEq)]
pub struct Enum {
storage: IntType,
values: Vec<(String, i64)>,
}
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct CustomStruct {
fields: Vec<(String, Type)>,
}
#[derive(Debug, Debug2, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct Event {}
fn is_default<T: Default + PartialEq>(t: &T) -> bool {
t == &T::default()
}
mod ty {
use super::IntType::*;
use super::NotIntType::*;
use super::Type::{self, *};
pub fn void() -> Type {
NotIntType(Void)
}
pub fn array(t: Type) -> Type {
NotIntType(Array(Box::new(t)))
}
pub fn string() -> Type {
NotIntType(String)
}
pub fn object() -> Type {
NotIntType(Object)
}
pub fn uuid() -> Type {
NotIntType(Uuid)
}
pub fn u8() -> Type {
IntType(U8)
}
}

58
hidl/src/spec.yaml Normal file
View File

@ -0,0 +1,58 @@
---
name: hypercosm
root:
interfaces:
- name: object
version:
- 1
- 0
- 0
methods:
- name: listInterfaces
ret:
Array: String
- name: release
- name: root
version:
- 0
- 1
- 0
methods:
- name: listExtensions
ret:
Array: String
- name: ping
- name: getObjectById
ret: Object
args:
- - id
- Uuid
- name: getObjectByName
ret: Object
args:
- - name
- String
extenstions:
- name: assetdelivery
version:
- 0
- 1
- 0
module:
interfaces:
- name: assetdelivery
version:
- 0
- 0
- 0
types:
- name: asset
kind:
Struct:
fields:
- - id
- Uuid
- - name
- String
- - data
- Array: U8