Skip to content

Commit 89f0cfb

Browse files
committed
Isolate goto_model loading to its own function in a file dedicated to API
1 parent a7b397d commit 89f0cfb

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

cpp_api/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22

3-
add_executable(bmc_api call_bmc.cpp)
3+
add_executable(bmc_api call_bmc.cpp api.cpp)
44

55
target_link_libraries(bmc_api goto-programs util langapi ansi-c)

cpp_api/api.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <goto-programs/goto_model.h>
2+
#include <goto-programs/initialize_goto_model.h>
3+
4+
#include <util/message.h>
5+
6+
goto_modelt load_model_from_files(
7+
const std::vector<std::string> &files,
8+
const optionst &options)
9+
{
10+
null_message_handlert null_msg_hnd;
11+
return initialize_goto_model(files, null_msg_hnd, options);
12+
}

cpp_api/api.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <vector>
2+
3+
#include <goto-programs/goto_model.h>
4+
5+
goto_modelt load_model_from_files(
6+
const std::vector<std::string> &files,
7+
const optionst &options);

cpp_api/call_bmc.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <util/message.h>
1515
#include <util/options.h>
1616

17+
#include "api.h"
18+
1719
int main(int argc, char *argv[])
1820
{
1921
try {
@@ -35,13 +37,7 @@ int main(int argc, char *argv[])
3537
// Initialise C language mode
3638
register_language(new_ansi_c_language);
3739

38-
std::cout << "[DEBUG] arguments is ";
39-
for (auto opt : arguments) {
40-
std::cout << " [] " << opt << std::endl;
41-
}
42-
43-
// Assume that argv[] is a list of files passed
44-
goto_modelt model = initialize_goto_model(arguments, null_msg_hnd, opts);
40+
auto model = load_model_from_files(arguments, opts);
4541

4642
std::cout << "Successfully initialised goto_model" << std::endl;
4743
return 0;

0 commit comments

Comments
 (0)