mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-08-04 19:08:32 +00:00
make query_group macro procedural
Switch to a procedural implementation of the `query_group!` macro, residing in the `components/salsa_macros` subcrate. Allow the user to override the invoked function via `salsa::invoke(...)` and the name of the generated query type via `salsa::query_type(...)`. In all tests, replace the `salsa::query_group! { ... }` invocations with the new attribute-style `#[salsa::query_group]` macro, and change them to the new naming scheme for query types (`...Query`). Update README, examples, and documentation.
This commit is contained in:
parent
cd454e986e
commit
93c30a953d
35 changed files with 768 additions and 782 deletions
|
@ -5,41 +5,26 @@ use salsa::Snapshot;
|
|||
use std::cell::Cell;
|
||||
use std::sync::Arc;
|
||||
|
||||
salsa::query_group! {
|
||||
pub(crate) trait ParDatabase: Knobs + salsa::ParallelDatabase {
|
||||
fn input(key: char) -> usize {
|
||||
type Input;
|
||||
storage input;
|
||||
}
|
||||
#[salsa::query_group]
|
||||
pub(crate) trait ParDatabase: Knobs + salsa::ParallelDatabase {
|
||||
#[salsa::input]
|
||||
fn input(&self, key: char) -> usize;
|
||||
|
||||
fn sum(key: &'static str) -> usize {
|
||||
type Sum;
|
||||
}
|
||||
fn sum(&self, key: &'static str) -> usize;
|
||||
|
||||
/// Invokes `sum`
|
||||
fn sum2(key: &'static str) -> usize {
|
||||
type Sum2;
|
||||
}
|
||||
/// Invokes `sum`
|
||||
fn sum2(&self, key: &'static str) -> usize;
|
||||
|
||||
/// Invokes `sum` but doesn't really care about the result.
|
||||
fn sum2_drop_sum(key: &'static str) -> usize {
|
||||
type Sum2Drop;
|
||||
}
|
||||
/// Invokes `sum` but doesn't really care about the result.
|
||||
fn sum2_drop_sum(&self, key: &'static str) -> usize;
|
||||
|
||||
/// Invokes `sum2`
|
||||
fn sum3(key: &'static str) -> usize {
|
||||
type Sum3;
|
||||
}
|
||||
/// Invokes `sum2`
|
||||
fn sum3(&self, key: &'static str) -> usize;
|
||||
|
||||
/// Invokes `sum2_drop_sum`
|
||||
fn sum3_drop_sum(key: &'static str) -> usize {
|
||||
type Sum3Drop;
|
||||
}
|
||||
/// Invokes `sum2_drop_sum`
|
||||
fn sum3_drop_sum(&self, key: &'static str) -> usize;
|
||||
|
||||
fn snapshot_me() -> () {
|
||||
type SnapshotMe;
|
||||
}
|
||||
}
|
||||
fn snapshot_me(&self) -> ();
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
|
@ -252,13 +237,13 @@ impl Knobs for ParDatabaseImpl {
|
|||
salsa::database_storage! {
|
||||
pub struct DatabaseImplStorage for ParDatabaseImpl {
|
||||
impl ParDatabase {
|
||||
fn input() for Input;
|
||||
fn sum() for Sum;
|
||||
fn sum2() for Sum2;
|
||||
fn sum2_drop_sum() for Sum2Drop;
|
||||
fn sum3() for Sum3;
|
||||
fn sum3_drop_sum() for Sum3Drop;
|
||||
fn snapshot_me() for SnapshotMe;
|
||||
fn input() for InputQuery;
|
||||
fn sum() for SumQuery;
|
||||
fn sum2() for Sum2Query;
|
||||
fn sum2_drop_sum() for Sum2DropSumQuery;
|
||||
fn sum3() for Sum3Query;
|
||||
fn sum3_drop_sum() for Sum3DropSumQuery;
|
||||
fn snapshot_me() for SnapshotMeQuery;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue