Skip to content

Commit

Permalink
Remove cty dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Dec 19, 2022
1 parent 61d30e5 commit f1ea6cb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 41 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ include = ["/rust/src", "/rust/build.rs", "/src", "/include"]
path = "rust/src/lib.rs"

[dependencies]
cty = "0.2.2"
num_enum = "0.5.7"

[build-dependencies]
Expand Down
12 changes: 6 additions & 6 deletions rust/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Instruction {

#[link(name = "rabbitizer", kind = "static")]
extern "C" {
fn RabbitizerInstrId_getOpcodeName(unique_id: instr_id_enum::InstrId) -> *const cty::c_char;
fn RabbitizerInstrId_getOpcodeName(unique_id: instr_id_enum::InstrId) -> *const core::ffi::c_char;
}

extern "C" {
Expand Down Expand Up @@ -86,14 +86,14 @@ extern "C" {
fn RabbitizerInstruction_getSizeForBuffer(
self_: *const Instruction,
immOverrideLength: utils::SizeT,
extraLJust: cty::c_int,
extraLJust: core::ffi::c_int,
) -> utils::SizeT;
fn RabbitizerInstruction_disassemble(
self_: *const Instruction,
dst: *mut cty::c_char,
immOverride: *const cty::c_char,
dst: *mut core::ffi::c_char,
immOverride: *const core::ffi::c_char,
immOverrideLength: utils::SizeT,
extraLJust: cty::c_int,
extraLJust: core::ffi::c_int,
) -> utils::SizeT;
}

Expand Down Expand Up @@ -683,7 +683,7 @@ impl Instruction {
let mut buffer: Vec<u8> = vec![0; buffer_size.try_into().unwrap()];
let disassembled_size = RabbitizerInstruction_disassemble(
self,
buffer.as_mut_ptr() as *mut cty::c_char,
buffer.as_mut_ptr() as *mut core::ffi::c_char,
imm_override_ptr,
imm_override_len,
extra_l_just.try_into().unwrap(),
Expand Down
6 changes: 3 additions & 3 deletions rust/src/opereand_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ extern "C" {
fn RabbitizerOperandType_disassemble(
operand: operand_type_enum::OperandType,
instr: *const instruction::Instruction,
dst: *mut cty::c_char,
immOverride: *const cty::c_char,
dst: *mut core::ffi::c_char,
immOverride: *const core::ffi::c_char,
immOverrideLength: utils::SizeT,
) -> utils::SizeT;
}
Expand All @@ -30,7 +30,7 @@ impl operand_type_enum::OperandType {
let disassembled_size = RabbitizerOperandType_disassemble(
*self,
&instr,
buffer.as_mut_ptr() as *mut cty::c_char,
buffer.as_mut_ptr() as *mut core::ffi::c_char,
imm_override_ptr,
imm_override_len,
);
Expand Down
58 changes: 29 additions & 29 deletions rust/src/registers_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
use crate::registers_enum;

extern "C" {
pub static mut RabbitizerRegister_GprO32_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_GprN32_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop0_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1O32_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1N32_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1N64_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1Control_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop2_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspGpr_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspCop0_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspCop2_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspCop2Control_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspVector_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_R5900VF_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_R5900VI_Names: [[*const cty::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_GprO32_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_GprN32_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop0_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1O32_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1N32_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1N64_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop1Control_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_Cop2_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspGpr_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspCop0_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspCop2_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspCop2Control_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_RspVector_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_R5900VF_Names: [[*const core::ffi::c_char; 2usize]; 0usize];
pub static mut RabbitizerRegister_R5900VI_Names: [[*const core::ffi::c_char; 2usize]; 0usize];

/*
pub fn RabbitizerRegister_getNameGpr(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameCop0(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameCop1(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameCop1Control(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameCop2(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameRspGpr(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameRspCop0(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameRspCop2(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameRspCop2Control(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameRspVector(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameR5900VF(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameR5900VI(reg_value: u8) -> *const cty::c_char;
pub fn RabbitizerRegister_getNameGpr(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameCop0(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameCop1(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameCop1Control(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameCop2(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameRspGpr(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameRspCop0(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameRspCop2(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameRspCop2Control(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameRspVector(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameR5900VF(reg_value: u8) -> *const core::ffi::c_char;
pub fn RabbitizerRegister_getNameR5900VI(reg_value: u8) -> *const core::ffi::c_char;
*/
}

Expand Down
4 changes: 2 additions & 2 deletions rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
pub type SizeT = usize;


pub fn c_string_from_str(str: Option<&str>) -> (*const cty::c_char, SizeT) {
pub fn c_string_from_str(str: Option<&str>) -> (*const core::ffi::c_char, SizeT) {
if let Some(str) = str {
(str.as_ptr() as *const cty::c_char, str.len().try_into().unwrap())
(str.as_ptr() as *const core::ffi::c_char, str.len().try_into().unwrap())
} else {
(std::ptr::null(), 0)
}
Expand Down

0 comments on commit f1ea6cb

Please sign in to comment.