Skip to content

Commit

Permalink
1.73 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 13, 2023
1 parent ef3f205 commit 6a6111e
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 46 deletions.
3 changes: 2 additions & 1 deletion bin/src/modules/asc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Module for ArmaScriptCompiler {
}

#[derive(Default, Serialize)]
struct ASCConfig {
pub struct ASCConfig {
#[serde(rename = "inputDirs")]
input_dirs: Vec<String>,
#[serde(rename = "outputDir")]
Expand All @@ -225,6 +225,7 @@ struct ASCConfig {
}

impl ASCConfig {
#[must_use]
pub const fn new() -> Self {
Self {
input_dirs: vec![],
Expand Down
8 changes: 1 addition & 7 deletions bin/src/modules/hook/libraries/hemtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,39 @@ impl RhaiHemtt {
}
}

#[allow(clippy::needless_pass_by_ref_mut)]
#[export_module]
pub mod project_functions {
#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn version(hemtt: &mut RhaiHemtt) -> Version {
hemtt.version.clone()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn project(hemtt: &mut RhaiHemtt) -> RhaiProject {
hemtt.project.clone()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn mode(hemtt: &mut RhaiHemtt) -> String {
hemtt.folder.clone()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn is_dev(hemtt: &mut RhaiHemtt) -> bool {
hemtt.folder == "dev"
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn is_launch(hemtt: &mut RhaiHemtt) -> bool {
hemtt.folder == "launch"
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn is_build(hemtt: &mut RhaiHemtt) -> bool {
hemtt.folder == "build"
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn is_release(hemtt: &mut RhaiHemtt) -> bool {
hemtt.folder == "release"
Expand Down
4 changes: 1 addition & 3 deletions bin/src/modules/hook/libraries/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ impl RhaiProject {
}
}

#[allow(clippy::needless_pass_by_ref_mut)]
#[export_module]
pub mod project_functions {
use crate::modules::hook::libraries::project::RhaiProject;

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn name(project: &mut RhaiProject) -> String {
project.name.clone()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn prefix(project: &mut RhaiProject) -> String {
project.prefix.clone()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn version(project: &mut RhaiProject) -> Version {
project.version.clone()
Expand Down
4 changes: 2 additions & 2 deletions bin/src/modules/hook/libraries/rfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub mod file_functions {
std::fs::remove_file(path).map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[allow(clippy::needless_pass_by_ref_mut)]
#[rhai_fn(global, return_raw)]
pub fn read(file: &mut ReadFile) -> Result<String, Box<EvalAltResult>> {
let mut buf = String::new();
Expand All @@ -47,7 +47,7 @@ pub mod file_functions {
.map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[allow(clippy::needless_pass_by_ref_mut)]
#[rhai_fn(global, return_raw)]
pub fn write(file: &mut WriteFile, data: &str) -> Result<(), Box<EvalAltResult>> {
file.0
Expand Down
6 changes: 1 addition & 5 deletions bin/src/modules/hook/libraries/rfs/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,32 @@ use rhai::plugin::{
PluginFunction, RhaiResult, TypeId,
};

#[allow(clippy::needless_pass_by_ref_mut)]
#[allow(clippy::ptr_arg)]
#[export_module]
pub mod path_functions {
use std::path::PathBuf;

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn join(path: &mut PathBuf, other: &str) -> PathBuf {
path.join(other)
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn exists(path: &mut PathBuf) -> bool {
path.exists()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn is_dir(path: &mut PathBuf) -> bool {
path.is_dir()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn is_file(path: &mut PathBuf) -> bool {
path.is_file()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, name = "to_string", name = "to_debug", pure)]
pub fn to_string(path: &mut PathBuf) -> String {
path.display().to_string()
Expand Down
7 changes: 1 addition & 6 deletions bin/src/modules/hook/libraries/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ use rhai::plugin::{
RhaiResult, TypeId,
};

#[allow(clippy::needless_pass_by_ref_mut)]
#[export_module]
pub mod version_functions {
use hemtt_common::version::Version;

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn to_string(version: &mut Version) -> String {
version.to_string()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn to_string_short(version: &mut Version) -> String {
format!(
Expand All @@ -24,25 +23,21 @@ pub mod version_functions {
)
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn major(version: &mut Version) -> i64 {
i64::from(version.major())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn minor(version: &mut Version) -> i64 {
i64::from(version.minor())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn patch(version: &mut Version) -> i64 {
i64::from(version.patch())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure)]
pub fn build(version: &mut Version) -> i64 {
version.build().map(i64::from).unwrap_or_default()
Expand Down
12 changes: 4 additions & 8 deletions bin/src/modules/hook/libraries/vfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,33 @@ pub struct ReadFile(Rc<RefCell<Box<dyn SeekAndRead + Send>>>);
#[derive(Clone)]
pub struct WriteFile(Rc<RefCell<Box<dyn Write + Send>>>);

#[allow(clippy::needless_pass_by_ref_mut)]
#[export_module]
pub mod file_functions {
use std::{cell::RefCell, rc::Rc};

use rhai::EvalAltResult;
use vfs::VfsPath;

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, return_raw)]
#[rhai_fn(global, pure, return_raw)]
pub fn open_file(path: &mut VfsPath) -> Result<ReadFile, Box<EvalAltResult>> {
path.open_file()
.map(|f| ReadFile(Rc::new(RefCell::new(f))))
.map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, return_raw)]
#[rhai_fn(global, pure, return_raw)]
pub fn create_file(path: &mut VfsPath) -> Result<WriteFile, Box<EvalAltResult>> {
path.create_file()
.map(|f| WriteFile(Rc::new(RefCell::new(f))))
.map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, return_raw)]
#[rhai_fn(global, pure, return_raw)]
pub fn remove_file(path: &mut VfsPath) -> Result<(), Box<EvalAltResult>> {
path.remove_file().map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, return_raw)]
pub fn read(file: &mut ReadFile) -> Result<String, Box<EvalAltResult>> {
let mut buf = String::new();
Expand All @@ -52,7 +49,6 @@ pub mod file_functions {
.map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, return_raw)]
pub fn write(file: &mut WriteFile, data: &str) -> Result<(), Box<EvalAltResult>> {
file.0
Expand Down
8 changes: 1 addition & 7 deletions bin/src/modules/hook/libraries/vfs/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,37 @@ use rhai::plugin::{
PluginFunction, RhaiResult, TypeId,
};

#[allow(clippy::needless_pass_by_ref_mut)]
#[export_module]
pub mod path_functions {
use rhai::EvalAltResult;
use vfs::VfsPath;

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure, return_raw)]
pub fn join(path: &mut VfsPath, other: &str) -> Result<VfsPath, Box<EvalAltResult>> {
path.join(other).map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure, return_raw)]
pub fn exists(path: &mut VfsPath) -> Result<bool, Box<EvalAltResult>> {
path.exists().map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure, return_raw)]
pub fn is_dir(path: &mut VfsPath) -> Result<bool, Box<EvalAltResult>> {
path.is_dir().map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, pure, return_raw)]
pub fn is_file(path: &mut VfsPath) -> Result<bool, Box<EvalAltResult>> {
path.is_file().map_err(|e| e.to_string().into())
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, name = "to_string", name = "to_debug", pure)]
pub fn to_string(path: &mut VfsPath) -> String {
path.as_str().to_string()
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, return_raw)]
pub fn copy(path: &mut VfsPath, other: VfsPath) -> Result<bool, Box<EvalAltResult>> {
let res = if path.is_dir().map_err(|e| e.to_string())? {
Expand All @@ -53,7 +48,6 @@ pub mod path_functions {
res.map_or_else(|| Ok(true), Err)
}

#[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))]
#[rhai_fn(global, name = "move", return_raw)]
pub fn _move(path: &mut VfsPath, other: VfsPath) -> Result<bool, Box<EvalAltResult>> {
let res = if path.is_dir().map_err(|e| e.to_string())? {
Expand Down
2 changes: 1 addition & 1 deletion bin/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod rapifier;
mod sign;

#[cfg(not(target_os = "macos"))]
pub use asc::ArmaScriptCompiler;
pub use asc::{ASCConfig, ArmaScriptCompiler};
pub use binarize::Binarize;
pub use file_patching::FilePatching;
pub use files::Files;
Expand Down
2 changes: 1 addition & 1 deletion bin/src/modules/rapifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Module for Rapifier {
}
let mut messages = Vec::new();
let mut res = Ok(());
for entry in ctx.workspace().join(&addon.folder())?.walk_dir()? {
for entry in ctx.workspace().join(addon.folder())?.walk_dir()? {
if entry.metadata()?.file_type == VfsFileType::File
&& can_preprocess(entry.as_str())
{
Expand Down
6 changes: 1 addition & 5 deletions libs/preprocessor/src/processor/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,14 @@ impl Processor {
Self::expect_nothing_to_newline(stream)?;
Ok(())
}
("pragma", _) => {
("pragma", _) | (_, false) => {
// TODO: hemtt pragma
self.skip_to_after_newline(stream, None);
Ok(())
}
(_, true) => Err(Error::Code(Box::new(UnknownDirective {
token: Box::new(command),
}))),
(_, false) => {
self.skip_to_after_newline(stream, None);
Ok(())
}
}
}

Expand Down

0 comments on commit 6a6111e

Please sign in to comment.