Skip to content

Commit

Permalink
luau: adapt to mlua 0.10 API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Oct 26, 2024
1 parent 3b2ff62 commit 268cb45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
30 changes: 10 additions & 20 deletions src/cmd/luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ fn sequential_mode(
let main_bytecode = if debug_enabled {
Vec::new()
} else {
luau_compiler.compile(main_script)
luau_compiler.compile(main_script)?
};

let mut record = csv::StringRecord::new();
Expand Down Expand Up @@ -803,12 +803,7 @@ fn sequential_mode(
}

if cmd_map {
map_computedvalue(
computed_value.as_ref(),
&mut record,
flag_remap,
new_column_count,
)?;
map_computedvalue(&computed_value, &mut record, flag_remap, new_column_count)?;

// check if the script is trying to insert a record with
// qsv_insertrecord(). We do this by checking if the global
Expand Down Expand Up @@ -895,7 +890,7 @@ fn sequential_mode(
beginend_insertrecord(luau, &mut insertrecord, headers_count, &mut wtr)?;

let end_string = match end_value {
Value::String(string) => string.to_string_lossy().to_string(),
Value::String(string) => string.to_string_lossy(),
Value::Number(number) => number.to_string(),
Value::Integer(number) => number.to_string(),
Value::Boolean(boolean) => (if boolean { "true" } else { "false" }).to_string(),
Expand Down Expand Up @@ -1029,7 +1024,7 @@ fn random_access_mode(

// in random access mode, setting "_INDEX" allows us to change the current record
// for the NEXT read
let mut pos = globals.get::<_, isize>(QSV_V_INDEX).unwrap_or_default();
let mut pos = globals.get::<isize>(QSV_V_INDEX).unwrap_or_default();
let mut curr_record = if pos > 0 && pos <= row_count as isize {
pos as u64
} else {
Expand All @@ -1041,7 +1036,7 @@ fn random_access_mode(
let main_bytecode = if debug_enabled {
Vec::new()
} else {
luau_compiler.compile(main_script)
luau_compiler.compile(main_script)?
};
let mut record = csv::StringRecord::new();
let mut error_count = 0_usize;
Expand Down Expand Up @@ -1153,12 +1148,7 @@ fn random_access_mode(
}

if cmd_map {
map_computedvalue(
computed_value.as_ref(),
&mut record,
flag_remap,
new_column_count,
)?;
map_computedvalue(&computed_value, &mut record, flag_remap, new_column_count)?;

// check if the MAIN script is trying to insert a record
match luau.globals().raw_get(QSV_INSERTRECORD_TBL) {
Expand Down Expand Up @@ -1209,7 +1199,7 @@ fn random_access_mode(
}
}

pos = globals.get::<_, isize>(QSV_V_INDEX).unwrap_or_default();
pos = globals.get::<isize>(QSV_V_INDEX).unwrap_or_default();
if pos < 0 || pos as u64 > row_count {
break 'main;
}
Expand Down Expand Up @@ -1244,7 +1234,7 @@ fn random_access_mode(
beginend_insertrecord(luau, &mut insertrecord, headers_count, &mut wtr)?;

let end_string = match end_value {
Value::String(string) => string.to_string_lossy().to_string(),
Value::String(string) => string.to_string_lossy(),
Value::Number(number) => number.to_string(),
Value::Integer(number) => number.to_string(),
Value::Boolean(boolean) => (if boolean { "true" } else { "false" }).to_string(),
Expand Down Expand Up @@ -1287,7 +1277,7 @@ fn map_computedvalue(
) -> Result<(), CliError> {
match computed_value {
Value::String(string) => {
if let Ok(utf8) = simdutf8::basic::from_utf8(string.as_bytes()) {
if let Ok(utf8) = simdutf8::basic::from_utf8(&string.as_bytes()) {
record.push_field(utf8);
} else {
record.push_field(&string.to_string_lossy());
Expand Down Expand Up @@ -1897,7 +1887,7 @@ fn setup_helpers(
let qsv_binary = env::current_exe().unwrap();

let mut cmd = std::process::Command::new(qsv_binary);
let qsv_args = args.to_str().unwrap_or_default().to_string();
let qsv_args = args.to_string_lossy();
let args_vec: Vec<&str> = qsv_args.split_whitespace().collect();
log::info!("Invoking qsv_cmd: {qsv_args}");
let result = cmd.args(args_vec).output();
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub fn version() -> String {
match luau.load("return _VERSION").eval() {
Ok(version_info) => {
if let mlua::Value::String(luaustring_val) = version_info {
let string_val = luaustring_val.to_str().unwrap_or("Luau - invalid version");
let string_val = luaustring_val.to_string_lossy();
if string_val == "Luau" {
enabled_features.push_str("Luau - version not specified;");
} else {
Expand Down

0 comments on commit 268cb45

Please sign in to comment.