Skip to content

Commit

Permalink
Merge pull request #77 from NLnetLabs/rotodoc
Browse files Browse the repository at this point in the history
Bump ariadne, some more docs and a clippy fix
  • Loading branch information
tertsdiepraam authored Nov 15, 2024
2 parents 730f285 + 3ff25c1 commit f312e3c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ categories = ["network-programming"]
# ariadne is set to git because of some unpublished contributions made on
# Aug 5 2024. It should revert to crates.io when a version later than 4.1.0
# is released
ariadne = { version = "0.4.0", git = "https://github.com/zesterer/ariadne.git", rev = "4e5987cd55d954858da4a4130255eca1bf0bee5f" }
ariadne = "0.5.0"
clap = { version = "4.4.6", features = ["derive"] }
env_logger = "0.10"
log = "0.4"
Expand Down
25 changes: 11 additions & 14 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,20 +778,17 @@ impl<'c> FuncGen<'c> {
let (dest, _) = self.operand(to);
let (src, _) = self.operand(from);

match clone {
Some(clone) => {
let pointer_ty = self.module.isa.pointer_type();
let clone = self.ins().iconst(
pointer_ty,
*clone as *mut u8 as usize as i64,
);
self.builder.ins().call_indirect(
self.clone_signature,
clone,
&[src, dest],
);
}
None => {}
if let Some(clone) = clone {
let pointer_ty = self.module.isa.pointer_type();
let clone = self.ins().iconst(
pointer_ty,
*clone as *mut u8 as usize as i64,
);
self.builder.ins().call_indirect(
self.clone_signature,
clone,
&[src, dest],
);
}
self.builder.emit_small_memory_copy(
self.module.isa.frontend_config(),
Expand Down
7 changes: 3 additions & 4 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ impl std::fmt::Display for RotoReport {

let report = Report::build(
ReportKind::Error,
file,
error.location.start,
(file, error.location.start..error.location.end),
)
.with_message(format!("Parse error: {}", error))
.with_label(label)
Expand All @@ -158,10 +157,10 @@ impl std::fmt::Display for RotoReport {

let file = self.filename(self.spans.get(error.location));

let span = self.spans.get(error.location);
let report = Report::build(
ReportKind::Error,
file,
self.spans.get(error.location).start,
(file, span.start..span.end),
)
.with_message(format!(
"Type error: {}",
Expand Down
26 changes: 21 additions & 5 deletions src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,19 @@ impl Runtime {
rt.register_copy_type::<i16>(int_docs!(i16))?;
rt.register_copy_type::<i32>(int_docs!(i32))?;
rt.register_copy_type::<i64>(int_docs!(i64))?;
rt.register_copy_type::<Asn>("An ASN: an Autonomous System Number")?;
rt.register_copy_type::<Asn>(
"An ASN: an Autonomous System Number\n\
\n\
An AS number can contain a number of 32-bits and is therefore similar to a [`u32`](u32). \
However, AS numbers cannot be manipulated with arithmetic operations. An AS number \
is constructed with the `AS` prefix followed by a number.\n\
\n\
```roto\n\
AS0\n\
AS1010\n\
AS4294967295\n\
```\n\
")?;
rt.register_copy_type::<IpAddr>(
"An IP address\n\nCan be either IPv4 or IPv6.\n\
\n\
Expand All @@ -572,9 +584,10 @@ impl Runtime {
",
)?;
rt.register_copy_type::<Prefix>(
"An IP address prefix: an IP address and a prefix length\n\n\
"An IP address prefix: the combination of an IP address and a prefix length\n\n\
A prefix can be constructed with the `/` operator or with the \
`Prefix.new` function.\n\
[`Prefix.new`](Prefix.new) function. This operator takes an [`IpAddr`](IpAddr) \
and a [`u8`](u8) as operands.\n
\n\
```roto\n\
1.1.1.0 / 8\n\
Expand All @@ -585,10 +598,13 @@ impl Runtime {

/// Construct a new prefix
///
/// A prefix can also be constructed with a prefix literal.
/// A prefix can also be constructed with the `/` operator.
///
/// ```roto
/// Prefix.new(192.169.0.0)
/// Prefix.new(192.169.0.0, 16)
///
/// # or equivalently
/// 192.169.0.0 / 16
/// ```
#[roto_static_method(rt, Prefix, new)]
fn prefix_new(ip: *mut IpAddr, len: u8) -> Prefix {
Expand Down

0 comments on commit f312e3c

Please sign in to comment.