Skip to content

Commit 304e156

Browse files
committed
[REFACTOR] Rename bridge module to cprover_api from ffi.
This should give a better name to the module to allow for better integration inside user code, along with a name that better documents the module itself.
1 parent 4af9c8a commit 304e156

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/libcprover-rust/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use cxx::{CxxString, CxxVector};
22

33
#[cxx::bridge]
4-
pub mod ffi {
4+
pub mod cprover_api {
55

66
unsafe extern "C++" {
77
include!("libcprover-cpp/api.h");
@@ -58,7 +58,7 @@ mod tests {
5858

5959
#[test]
6060
fn it_works() {
61-
let client = ffi::new_api_session();
61+
let client = cprover_api::new_api_session();
6262
let result = client.get_api_version();
6363

6464
let_cxx_string!(expected_version = "0.1");
@@ -69,21 +69,21 @@ mod tests {
6969
fn translate_vector_of_rust_string_to_cpp() {
7070
let vec: Vec<String> = vec!["other/example.c".to_owned(), "/tmp/example2.c".to_owned()];
7171

72-
let vect = ffi::translate_vector_of_string(vec);
72+
let vect = cprover_api::translate_vector_of_string(vec);
7373
assert_eq!(vect.len(), 2);
7474
}
7575

7676
#[test]
7777
fn it_can_load_model_from_file() {
78-
let binding = ffi::new_api_session();
78+
let binding = cprover_api::new_api_session();
7979
let client = match binding.as_ref() {
8080
Some(api_ref) => api_ref,
8181
None => panic!("Failed to acquire API session handle"),
8282
};
8383

8484
let vec: Vec<String> = vec!["other/example.c".to_owned()];
8585

86-
let vect = ffi::translate_vector_of_string(vec);
86+
let vect = cprover_api::translate_vector_of_string(vec);
8787
assert_eq!(vect.len(), 1);
8888

8989
// Invoke load_model_from_files and see if the model
@@ -104,7 +104,7 @@ mod tests {
104104
// This is also why a print instruction is commented out (as a guide for someone
105105
// else in case they want to inspect the output).
106106
let validation_msg = "Validating consistency of goto-model supplied to API session";
107-
let msgs = ffi::get_messages();
107+
let msgs = cprover_api::get_messages();
108108
let msgs_assert = translate_response_buffer(msgs).clone();
109109

110110
assert!(msgs_assert.contains(&String::from(validation_msg)));
@@ -114,11 +114,11 @@ mod tests {
114114

115115
#[test]
116116
fn it_can_verify_the_loaded_model() {
117-
let client = ffi::new_api_session();
117+
let client = cprover_api::new_api_session();
118118

119119
let vec: Vec<String> = vec!["other/example.c".to_owned()];
120120

121-
let vect = ffi::translate_vector_of_string(vec);
121+
let vect = cprover_api::translate_vector_of_string(vec);
122122

123123
if let Err(_) = client.load_model_from_files(vect) {
124124
eprintln!("Failed to load model from files: {:?}", vect);
@@ -138,23 +138,23 @@ mod tests {
138138

139139
let verification_msg = "VERIFICATION FAILED";
140140

141-
let msgs = ffi::get_messages();
141+
let msgs = cprover_api::get_messages();
142142
let msgs_assert = translate_response_buffer(msgs).clone();
143143

144144
assert!(msgs_assert.contains(&String::from(verification_msg)));
145145
}
146146

147147
#[test]
148148
fn it_can_drop_unused_functions_from_model() {
149-
let binding = ffi::new_api_session();
149+
let binding = cprover_api::new_api_session();
150150
let client = match binding.as_ref() {
151151
Some(api_ref) => api_ref,
152152
None => panic!("Failed to acquire API session handle"),
153153
};
154154

155155
let vec: Vec<String> = vec!["other/example.c".to_owned()];
156156

157-
let vect = ffi::translate_vector_of_string(vec);
157+
let vect = cprover_api::translate_vector_of_string(vec);
158158
assert_eq!(vect.len(), 1);
159159

160160
if let Err(_) = client.load_model_from_files(vect) {
@@ -171,7 +171,7 @@ mod tests {
171171
let instrumentation_msg = "Performing instrumentation pass: dropping unused functions";
172172
let instrumentation_msg2 = "Dropping 8 of 11 functions (3 used)";
173173

174-
let msgs = ffi::get_messages();
174+
let msgs = cprover_api::get_messages();
175175
let msgs_assert = translate_response_buffer(msgs).clone();
176176

177177
assert!(msgs_assert.contains(&String::from(instrumentation_msg)));

0 commit comments

Comments
 (0)