diff --git a/ruby-parser-cpp/src/decoder.rs b/ruby-parser-cpp/src/decoder.rs index 45fec87..541f00f 100644 --- a/ruby-parser-cpp/src/decoder.rs +++ b/ruby-parser-cpp/src/decoder.rs @@ -1,4 +1,5 @@ #[allow(unused_imports)] +use std::os::raw::{c_char}; use crate::{blob_type, bytes::ByteListBlob, string::StringBlob}; use lib_ruby_parser::source::{DecoderResult, InputError}; @@ -73,7 +74,7 @@ pub extern "C" fn lib_ruby_parser__test__always_ok_decoder(output: *const u8) -> drop(String::from(encoding)); drop(Vec::::from(input)); // and return given output - let output = unsafe { std::ffi::CStr::from_ptr(state as *const i8) } + let output = unsafe { std::ffi::CStr::from_ptr(state as *const c_char) } .to_str() .unwrap(); DecoderResultBlob::from(DecoderResult::Ok(output.as_bytes().to_vec())) @@ -97,7 +98,7 @@ pub extern "C" fn lib_ruby_parser__test__always_err_decoder(output: *const u8) - drop(String::from(encoding)); drop(Vec::::from(input)); // and return given output - let output = unsafe { std::ffi::CStr::from_ptr(state as *const i8) } + let output = unsafe { std::ffi::CStr::from_ptr(state as *const c_char) } .to_str() .unwrap(); DecoderResultBlob::from(DecoderResult::Err(InputError::DecodingError( diff --git a/ruby-parser-cpp/src/diagnostic.rs b/ruby-parser-cpp/src/diagnostic.rs index 706f06a..f638357 100644 --- a/ruby-parser-cpp/src/diagnostic.rs +++ b/ruby-parser-cpp/src/diagnostic.rs @@ -1,3 +1,4 @@ +use std::os::raw::{c_char}; use crate::blob_type; #[allow(unused_imports)] use crate::message::DiagnosticMessageBlob; @@ -42,7 +43,7 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_diagnostic_list(diagnostic_list: *mut Vec pub extern "C" fn LIB_RUBY_PARSER_render_diagnostic( diagnostic: *const Diagnostic, input: *const DecodedInput, -) -> *mut i8 { +) -> *mut c_char { let diagnostic = unsafe { diagnostic.as_ref().unwrap() }; let input = unsafe { input.as_ref().unwrap() }; let rendered = diagnostic.render(input).unwrap(); diff --git a/ruby-parser-cpp/src/loc.rs b/ruby-parser-cpp/src/loc.rs index 0fb6179..4cd0ae3 100644 --- a/ruby-parser-cpp/src/loc.rs +++ b/ruby-parser-cpp/src/loc.rs @@ -1,3 +1,4 @@ +use std::os::raw::{c_char}; use crate::blob_type; use lib_ruby_parser::source::DecodedInput; #[allow(unused_imports)] @@ -27,7 +28,7 @@ pub extern "C" fn lib_ruby_parser__test__make_some_loc(begin: usize, end: usize) pub extern "C" fn LIB_RUBY_PARSER_loc_source( loc: *const Loc, input: *const DecodedInput, -) -> *mut i8 { +) -> *mut c_char { let loc = unsafe { loc.as_ref().unwrap() }; let input = unsafe { input.as_ref().unwrap() }; let source = loc.source(input).unwrap(); diff --git a/ruby-parser-cpp/src/string.rs b/ruby-parser-cpp/src/string.rs index 50e41e9..0cb5d52 100644 --- a/ruby-parser-cpp/src/string.rs +++ b/ruby-parser-cpp/src/string.rs @@ -1,4 +1,5 @@ use crate::blob_type; +use std::os::raw::{c_char}; blob_type!(StringBlob, String); blob_type!(MaybeStringBlob, Option); @@ -10,7 +11,7 @@ pub extern "C" fn LIB_RUBY_PARSER_new_string_owned(ptr: *mut u8, len: usize) -> } #[no_mangle] -pub extern "C" fn LIB_RUBY_PARSER_new_string_from_cstr(ptr: *const i8) -> StringBlob { +pub extern "C" fn LIB_RUBY_PARSER_new_string_from_cstr(ptr: *const c_char) -> StringBlob { let s = unsafe { std::ffi::CStr::from_ptr(ptr) }; StringBlob::from(s.to_str().unwrap_or_default().to_owned()) } diff --git a/ruby-parser-cpp/src/token.rs b/ruby-parser-cpp/src/token.rs index aadb14e..5cbd8f2 100644 --- a/ruby-parser-cpp/src/token.rs +++ b/ruby-parser-cpp/src/token.rs @@ -1,3 +1,4 @@ +use std::os::raw::{c_char}; use crate::blob_type; #[allow(unused_imports)] use lib_ruby_parser::{Bytes, LexState, Lexer, Loc, Token}; @@ -29,7 +30,7 @@ pub extern "C" fn lib_ruby_parser__test__make_token_eq( } #[no_mangle] -pub extern "C" fn LIB_RUBY_PARSER_token_name(token: *const Token) -> *mut i8 { +pub extern "C" fn LIB_RUBY_PARSER_token_name(token: *const Token) -> *mut c_char { let token = unsafe { token.as_ref().unwrap() }; let token_name = token.token_name(); std::ffi::CString::new(token_name).unwrap().into_raw()