Skip to content

Commit

Permalink
docs(examples): update docs for new introduced proc-macros (#139)
Browse files Browse the repository at this point in the history
* docs(examples): update docs for new introduced proc-macros

* chore(zink): more details for the codegen library

* bump(zink): 0.1.4
  • Loading branch information
clearloop authored Oct 8, 2023
1 parent b8d6dd4 commit ddc8a41
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.1.3"
version = "0.1.4"
authors = ["clearloop"]
edition = "2021"
license = "GPL-3.0-only"
Expand Down Expand Up @@ -47,13 +47,13 @@ wasmparser = "0.107.0"
wat = "1.0.66"

# Local Dependencies.
zinkup = { path = "cli", version = "=0.1.3" }
zinkup = { path = "cli", version = "=0.1.4" }
opcodes = { package = "evm-opcodes", path = "codegen/opcodes", version = "=0.0.3", features = ["data"] }
zingen = { path = "codegen", version = "=0.1.3" }
zinkc = { path = "compiler", version = "=0.1.3" }
zink = { path = "zink", version = "=0.1.3" }
zink-codegen = { path = "zink/codegen", version = "=0.1.3" }
zint = { path = "zint", version = "=0.1.3" }
zingen = { path = "codegen", version = "=0.1.4" }
zinkc = { path = "compiler", version = "=0.1.4" }
zink = { path = "zink", version = "=0.1.4" }
zink-codegen = { path = "zink/codegen", version = "=0.1.4" }
zint = { path = "zint", version = "=0.1.4" }

[profile]
dev = { panic = "abort"}
Expand Down
1 change: 1 addition & 0 deletions Conta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ packages = [
"zingen",
"zint",
"zinkc",
"zink-codegen",
"zink",
"zinkup"
]
2 changes: 1 addition & 1 deletion cli/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Compile {
/// The path of the wasm file.
#[clap(value_name = "INPUT")]
input: PathBuf,
/// Write output to <filename>
/// Write output to \<filename\>
#[clap(short, long)]
output: Option<PathBuf>,
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/visitor/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl CodeGen {
/// The select instruction selects one of its first two operands based
/// on whether its third oprand is zero or not.
///
/// STACK: [val1, val2, cond] -> [val1] if cond is non-zero, [val2] otherwise.
/// STACK: [val1, val2, cond] -> \[val1\] if cond is non-zero, \[val2\] otherwise.
pub fn _select(&mut self) -> Result<()> {
tracing::trace!("select");
let func = Func::Select;
Expand Down
8 changes: 1 addition & 7 deletions docs/examples/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ extern crate zink;
use zink::Event;

/// A `Ping` event.
///
/// TODO: generate this with proc-macro.
#[derive(Event)]
struct Ping;

/// TODO: generate this with proc-macro.
impl Event for Ping {
const NAME: &'static [u8] = b"Ping";
}

#[no_mangle]
pub extern "C" fn log1() {
Ping.log1(b"pong");
Expand Down
31 changes: 15 additions & 16 deletions docs/examples/storage.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# Storage

```rust
use zink::storage::{sload, sstore};

/// TODO: generate this storage interface with proc macro.
struct Counter;

// The number `0` in this struct is for the storage key,
// it will be convreted to `0x000..0000`.
impl Counter {
fn get() -> i64 {
unsafe { sload(0) }
}

fn set(value: i64) {
unsafe { sstore(0, value) }
}
}
// for the panic handler.
#[cfg(not(test))]
extern crate zink;

use zink::Storage;

/// It gets expanded to 'Counter' struct
/// that implements zink::Storage trait
/// (::set and ::get)
///
/// Storage key is taken based on macro order
/// (e.g this macro is first and only in this project,
/// so it will take 0x0 contract storage key)
#[zink::storage]
pub type Counter = i32;

/// Set value to storage and get it
#[no_mangle]
Expand Down
10 changes: 8 additions & 2 deletions zink/codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
[package]
name = "zink-codegen"
version = "0.1.3"
edition = "2021"
description = "Code generation for zink APIs."
documentation = "https://docs.rs/zink-codegen"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true

[lib]
proc-macro = true
Expand Down

0 comments on commit ddc8a41

Please sign in to comment.