Skip to content

Commit 373890f

Browse files
authored
Dual 514-515 compat (+ reformatting) (#85)
1 parent fdacde2 commit 373890f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+828
-1106
lines changed

.cargo/config .cargo/config.toml

File renamed without changes.

.rustfmt.toml

+39
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1+
edition = "2021"
12
hard_tabs = true
3+
fn_params_layout = "Tall"
4+
force_explicit_abi = true
5+
match_block_trailing_comma = false
6+
max_width = 150
7+
merge_derives = true
8+
newline_style = "Unix"
9+
remove_nested_parens = true
10+
reorder_imports = true
11+
reorder_modules = true
12+
use_field_init_shorthand = true
13+
use_small_heuristics = "Default"
14+
# Unstable formatting options below; remove if you REALLY don't wanna use `cargo +nightly fmt`
15+
unstable_features = true
16+
binop_separator = "Front"
17+
brace_style = "SameLineWhere"
18+
condense_wildcard_suffixes = true
19+
control_brace_style = "AlwaysSameLine"
20+
empty_item_single_line = true
21+
format_code_in_doc_comments = true
22+
format_macro_bodies = true
23+
format_macro_matchers = true
24+
format_strings = true
25+
group_imports = "Preserve"
26+
imports_granularity = "Crate"
27+
imports_indent = "Block"
28+
imports_layout = "Mixed"
29+
indent_style = "Block"
30+
match_arm_blocks = true
31+
normalize_comments = true
32+
overflow_delimited_expr = true
33+
reorder_impl_items = true
34+
space_after_colon = true
35+
space_before_colon = false
36+
spaces_around_ranges = false
37+
trailing_comma = "Never"
38+
trailing_semicolon = true
39+
type_punctuation_density = "Wide"
40+
wrap_comments = true

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[workspace]
2-
members = [
3-
"auxcov",
4-
"auxtools",
5-
"auxtools-impl",
6-
"debug_server",
7-
"instruction_hooking",
8-
"tests/auxtest",
9-
"tests/byond_get",
10-
"tests/test_runner",
11-
]
2+
members = ["auxcov", "auxtools", "auxtools-impl", "debug_server", "instruction_hooking", "tests/auxtest", "tests/byond_get", "tests/test_runner"]
3+
resolver = "2"
4+
5+
[workspace.package]
6+
authors = ["Sophie Wallace <[email protected]>", "Lucy <[email protected]>"]
7+
edition = "2021"
8+
license = "MIT"
9+
repository = "https://github.com/wilox/auxtools"
10+
rust-version = "1.76"
11+
version = "0.1.0"
1212

1313
[profile.release]
1414
opt-level = 3

auxcov/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
name = "auxcov"
33
version = "1.0.0"
44
authors = ["Jordan Dominion <[email protected]>"]
5-
edition = "2018"
65
publish = false
6+
edition.workspace = true
7+
rust-version.workspace = true
8+
repository.workspace = true
9+
license.workspace = true
710

811
[lib]
912
crate-type = ["cdylib", "lib"]

auxcov/src/codecov.rs

+31-48
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
use std::cell::RefCell;
2-
use std::collections::{BTreeMap, HashMap, HashSet};
3-
use std::convert::TryInto;
4-
use std::fs::create_dir_all;
5-
use std::io::Error;
6-
use std::panic::catch_unwind;
7-
use std::path::{Path, PathBuf};
8-
use std::rc::Rc;
9-
10-
use auxtools::raw_types::strings::StringId;
11-
use auxtools::*;
1+
use std::{
2+
cell::RefCell,
3+
collections::{BTreeMap, HashMap, HashSet},
4+
convert::TryInto,
5+
fs::create_dir_all,
6+
io::Error,
7+
panic::catch_unwind,
8+
path::{Path, PathBuf},
9+
rc::Rc
10+
};
11+
12+
use auxtools::{raw_types::strings::StringId, *};
1213
use dmasm::Instruction;
13-
1414
use grcov::{output_cobertura, CovResult, FunctionMap, ResultTuple};
15-
use instruction_hooking::disassemble_env::DisassembleEnv;
16-
use instruction_hooking::InstructionHook;
15+
use instruction_hooking::{disassemble_env::DisassembleEnv, InstructionHook};
1716

1817
struct TrackerContext {
1918
output_file_name: String,
2019
proc_id_map: Vec<Option<Rc<RefCell<Vec<u64>>>>>,
21-
filename_map: HashMap<String, Rc<RefCell<Vec<u64>>>>,
20+
filename_map: HashMap<String, Rc<RefCell<Vec<u64>>>>
2221
}
2322

2423
pub struct Tracker {
2524
hittable_lines: HashMap<String, HashSet<u32>>,
2625
contexts: Vec<TrackerContext>,
27-
total_procs: u32,
26+
total_procs: u32
2827
}
2928

3029
impl Tracker {
@@ -51,7 +50,7 @@ impl Tracker {
5150
let string_ref_result = StringRef::from_raw(&file.0);
5251
match string_ref_result {
5352
Ok(string_ref) => current_file_option = Some(string_ref),
54-
Err(_) => current_file_option = None,
53+
Err(_) => current_file_option = None
5554
}
5655
}
5756
Instruction::DbgLine(line) => {
@@ -64,10 +63,7 @@ impl Tracker {
6463
continue;
6564
}
6665

67-
hittable_lines
68-
.entry(file_name)
69-
.or_insert(HashSet::new())
70-
.insert(line);
66+
hittable_lines.entry(file_name).or_insert(HashSet::new()).insert(line);
7167
}
7268
}
7369
_ => {}
@@ -79,23 +75,19 @@ impl Tracker {
7975
Tracker {
8076
hittable_lines,
8177
contexts: Vec::new(),
82-
total_procs: i,
78+
total_procs: i
8379
}
8480
}
8581

8682
pub fn init_context(&mut self, output_file_name: String) -> bool {
87-
if self
88-
.contexts
89-
.iter()
90-
.any(|context| context.output_file_name == *output_file_name)
91-
{
83+
if self.contexts.iter().any(|context| context.output_file_name == *output_file_name) {
9284
return false;
9385
}
9486

9587
let mut context: TrackerContext = TrackerContext {
9688
output_file_name,
9789
proc_id_map: Vec::new(),
98-
filename_map: HashMap::new(),
90+
filename_map: HashMap::new()
9991
};
10092

10193
context.proc_id_map.reserve(self.total_procs as usize);
@@ -126,11 +118,7 @@ impl Tracker {
126118
}
127119

128120
// returns true if we need to pause
129-
pub fn process_dbg_line(
130-
&mut self,
131-
ctx: &raw_types::procs::ExecutionContext,
132-
proc_instance: &raw_types::procs::ProcInstance,
133-
) {
121+
pub fn process_dbg_line(&mut self, ctx: &raw_types::procs::ExecutionContext, proc_instance: &raw_types::procs::ProcInstance) {
134122
if ctx.line == 0 || !ctx.filename.valid() {
135123
return;
136124
}
@@ -146,8 +134,7 @@ impl Tracker {
146134
context.process_dbg_line(filename_id, proc_map_index, line, Some(file_name));
147135
}
148136
None => {
149-
let processed_file_name =
150-
context.process_dbg_line(filename_id, proc_map_index, line, None);
137+
let processed_file_name = context.process_dbg_line(filename_id, proc_map_index, line, None);
151138
if let Some((file_name, valid)) = processed_file_name {
152139
if !valid {
153140
break;
@@ -213,7 +200,8 @@ impl Tracker {
213200

214201
impl Drop for Tracker {
215202
fn drop(&mut self) {
216-
let _result = self.finalize(); // dropping the result here because what can ya do?
203+
let _result = self.finalize(); // dropping the result here because what can ya
204+
// do?
217205
}
218206
}
219207

@@ -236,7 +224,7 @@ impl TrackerContext {
236224
filename_id: StringId,
237225
proc_map_index: usize,
238226
line: usize,
239-
known_file_name: Option<&String>,
227+
known_file_name: Option<&String>
240228
) -> Option<(String, bool)> {
241229
let needs_extending = self.proc_id_map.len() < proc_map_index + 1;
242230

@@ -324,8 +312,7 @@ impl TrackerContext {
324312
hit_map[i] = current_hits + 1;
325313

326314
let hit_map_rc = Rc::new(RefCell::new(hit_map));
327-
self.filename_map
328-
.insert(file_name.clone(), hit_map_rc.clone());
315+
self.filename_map.insert(file_name.clone(), hit_map_rc.clone());
329316
self.proc_id_map[proc_map_index] = Some(hit_map_rc);
330317
}
331318
}
@@ -348,15 +335,11 @@ impl TrackerContext {
348335
}
349336

350337
let path = PathBuf::from(file_name);
351-
(
352-
path.clone(),
353-
path,
354-
CovResult {
355-
lines: new_map,
356-
branches: BTreeMap::default(),
357-
functions: FunctionMap::default(),
358-
},
359-
)
338+
(path.clone(), path, CovResult {
339+
lines: new_map,
340+
branches: BTreeMap::default(),
341+
functions: FunctionMap::default()
342+
})
360343
})
361344
.collect();
362345

auxcov/src/lib.rs

+11-22
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@
22
33
mod codecov;
44

5-
use codecov::Tracker;
6-
use instruction_hooking::INSTRUCTION_HOOKS;
7-
85
use std::any::{Any, TypeId};
96

107
use auxtools::*;
8+
use codecov::Tracker;
9+
use instruction_hooking::INSTRUCTION_HOOKS;
1110

1211
fn with_tracker_option<F>(f: F, create: bool)
1312
where
14-
F: FnOnce(&mut Tracker),
13+
F: FnOnce(&mut Tracker)
1514
{
1615
unsafe {
1716
let hooks = INSTRUCTION_HOOKS.get_mut();
1817

1918
let tracker_tid = TypeId::of::<Tracker>();
20-
let tracker_option = hooks
21-
.iter_mut()
22-
.find(|hook| (*hook).as_ref().type_id() == tracker_tid);
19+
let tracker_option = hooks.iter_mut().find(|hook| (*hook).as_ref().type_id() == tracker_tid);
2320

2421
match tracker_option {
2522
Some(existing_hook) => {
@@ -39,7 +36,8 @@ where
3936
}
4037
}
4138

42-
// INSTRUCTION_HOOKS are cleared on shutdown so we don't need to worry about that.
39+
// INSTRUCTION_HOOKS are cleared on shutdown so we don't need to worry about
40+
// that.
4341
#[hook("/proc/start_code_coverage")]
4442
fn start_code_coverage(coverage_file: Value) {
4543
let coverage_file_string_result = coverage_file.as_string();
@@ -54,14 +52,11 @@ fn start_code_coverage(coverage_file: Value) {
5452
|tracker| {
5553
init_result = tracker.init_context(coverage_file_string.clone());
5654
},
57-
true,
55+
true
5856
);
5957

6058
if !init_result {
61-
return Err(runtime!(
62-
"A code coverage context for {} already exists!",
63-
coverage_file_string
64-
));
59+
return Err(runtime!("A code coverage context for {} already exists!", coverage_file_string));
6560
}
6661

6762
Ok(Value::null())
@@ -83,21 +78,15 @@ fn stop_code_coverage(coverage_file: Value) {
8378
result = match inner_result {
8479
Ok(had_entry) => {
8580
if !had_entry {
86-
Err(runtime!(
87-
"A code coverage context for {} does not exist!",
88-
coverage_file_string
89-
))
81+
Err(runtime!("A code coverage context for {} does not exist!", coverage_file_string))
9082
} else {
9183
Ok(Value::null())
9284
}
9385
}
94-
Err(error) => Err(runtime!(
95-
"A error occurred while trying to save the coverage file: {}",
96-
error
97-
)),
86+
Err(error) => Err(runtime!("A error occurred while trying to save the coverage file: {}", error))
9887
}
9988
},
100-
false,
89+
false
10190
);
10291

10392
result

auxtools-impl/Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
name = "auxtools-impl"
33
description = "procedural macros for use with the auxtools crate"
44
version = "0.1.0"
5-
authors = ["Aspen <[email protected]>", "Sophie Wallace <[email protected]>"]
6-
license = "MIT"
7-
repository = "https://github.com/willox/auxtools"
8-
edition = "2018"
5+
authors.workspace = true
6+
edition.workspace = true
7+
rust-version.workspace = true
8+
repository.workspace = true
9+
license.workspace = true
910

1011
[lib]
1112
proc-macro = true

0 commit comments

Comments
 (0)