Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #87 from golemcloud/vigoo/improvements
Browse files Browse the repository at this point in the history
Various improvements
  • Loading branch information
vigoo authored Oct 9, 2024
2 parents 9785eae + ab01a23 commit 5edd641
Show file tree
Hide file tree
Showing 11 changed files with 1,052 additions and 953 deletions.
971 changes: 471 additions & 500 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ opt-level = 's'

[workspace.dependencies]
fs_extra = "1.3.0"
golem-wasm-ast = "1.0.0"
golem-wasm-ast = "1.0.1"
tempfile = "3.12.0"
tokio = "1.38.0"
139 changes: 3 additions & 136 deletions wasm-rpc-stubgen/tests-integration/tests/stub_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
//! Tests in this module are verifying the STUB WASM created by the stub generator
//! regardless of how the actual wasm generator is implemented. (Currently generates Rust code and compiles it)
use golem_wasm_ast::analysis::analysed_type::*;
use golem_wasm_ast::analysis::{
AnalysedExport, AnalysedFunctionParameter, AnalysedInstance, AnalysedResourceId,
AnalysedResourceMode, AnalysedType, AnalysisContext, NameOptionTypePair, NameTypePair,
TypeBool, TypeChr, TypeEnum, TypeF32, TypeF64, TypeFlags, TypeHandle, TypeList, TypeOption,
TypeRecord, TypeResult, TypeS16, TypeS32, TypeS64, TypeS8, TypeStr, TypeTuple, TypeU16,
TypeU32, TypeU64, TypeU8, TypeVariant,
AnalysedResourceMode, AnalysedType, AnalysisContext, NameTypePair, TypeHandle, TypeOption,
TypeRecord, TypeStr,
};
use golem_wasm_ast::component::Component;
use golem_wasm_ast::IgnoreAllButMetadata;
Expand Down Expand Up @@ -328,138 +327,6 @@ async fn all_wit_types() {
);
}

// TODO: move these helpers to golem-wasm-ast

fn field(name: &str, typ: AnalysedType) -> NameTypePair {
NameTypePair {
name: name.to_string(),
typ,
}
}

fn case(name: &str, typ: AnalysedType) -> NameOptionTypePair {
NameOptionTypePair {
name: name.to_string(),
typ: Some(typ),
}
}

fn unit_case(name: &str) -> NameOptionTypePair {
NameOptionTypePair {
name: name.to_string(),
typ: None,
}
}

fn bool() -> AnalysedType {
AnalysedType::Bool(TypeBool)
}

fn s8() -> AnalysedType {
AnalysedType::S8(TypeS8)
}

fn s16() -> AnalysedType {
AnalysedType::S16(TypeS16)
}

fn s32() -> AnalysedType {
AnalysedType::S32(TypeS32)
}

fn s64() -> AnalysedType {
AnalysedType::S64(TypeS64)
}

fn u8() -> AnalysedType {
AnalysedType::U8(TypeU8)
}

fn u16() -> AnalysedType {
AnalysedType::U16(TypeU16)
}

fn u32() -> AnalysedType {
AnalysedType::U32(TypeU32)
}

fn u64() -> AnalysedType {
AnalysedType::U64(TypeU64)
}

fn f32() -> AnalysedType {
AnalysedType::F32(TypeF32)
}

fn f64() -> AnalysedType {
AnalysedType::F64(TypeF64)
}

fn chr() -> AnalysedType {
AnalysedType::Chr(TypeChr)
}

fn str() -> AnalysedType {
AnalysedType::Str(TypeStr)
}

fn list(inner: AnalysedType) -> AnalysedType {
AnalysedType::List(TypeList {
inner: Box::new(inner),
})
}

fn option(inner: AnalysedType) -> AnalysedType {
AnalysedType::Option(TypeOption {
inner: Box::new(inner),
})
}

fn flags(names: &[&str]) -> AnalysedType {
AnalysedType::Flags(TypeFlags {
names: names.iter().map(|n| n.to_string()).collect(),
})
}

fn r#enum(cases: &[&str]) -> AnalysedType {
AnalysedType::Enum(TypeEnum {
cases: cases.iter().map(|n| n.to_string()).collect(),
})
}

fn tuple(items: Vec<AnalysedType>) -> AnalysedType {
AnalysedType::Tuple(TypeTuple { items })
}

fn result(ok: AnalysedType, err: AnalysedType) -> AnalysedType {
AnalysedType::Result(TypeResult {
ok: Some(Box::new(ok)),
err: Some(Box::new(err)),
})
}

fn result_ok(ok: AnalysedType) -> AnalysedType {
AnalysedType::Result(TypeResult {
ok: Some(Box::new(ok)),
err: None,
})
}

fn result_err(err: AnalysedType) -> AnalysedType {
AnalysedType::Result(TypeResult {
ok: None,
err: Some(Box::new(err)),
})
}

fn record(fields: Vec<NameTypePair>) -> AnalysedType {
AnalysedType::Record(TypeRecord { fields })
}

fn variant(cases: Vec<NameOptionTypePair>) -> AnalysedType {
AnalysedType::Variant(TypeVariant { cases })
}

fn assert_has_rpc_resource_constructor(exported_interface: &AnalysedInstance, name: &str) {
let fun = exported_interface
.functions
Expand Down
3 changes: 2 additions & 1 deletion wasm-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ async-trait = { version = "0.1.77", optional = true }
bigdecimal = { version = "0.4.5", optional = true }
bincode = { version = "2.0.0-rc.3", optional = true }
git-version = "0.3.9"
golem-wasm-ast = { version = "1.0.0", optional = true }
golem-wasm-ast = { workspace = true, optional = true }
poem-openapi = { version = "5.0", optional = true }
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
prost = { version = "0.12", optional = true }
uuid = "1.10.0"
wasmtime = { version = "=21.0.1", features = [
"component-model",
], optional = true }
Expand Down
Loading

0 comments on commit 5edd641

Please sign in to comment.