MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / buildExport

Function buildExport

src/api_builder/build_export.cpp:8–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <sstream>
7
8void buildExport(const std::string& mode, const std::string& input, const std::string& output)
9{
10 bool isLinux = mode == "linux";
11
12 std::ofstream outfile(output.c_str());
13
14 std::string jsBuff = loadFile(input);
15
16 json_value *root = json_parse(jsBuff.c_str(), jsBuff.size());
17 if (root) {
18 json_value *function_root = get_object_key(root, "functions");
19
20 assert(function_root->type == json_array);
21
22 if (isLinux) {
23 outfile << "{\nglobal:\n";
24 }
25
26 for (auto& it: jsonArrayIterator(function_root))
27 {
28 std::string funcname = get_object_string_key(it, "functionname");
29 if (!funcname.empty()) {
30 if (isLinux) { // Linux
31 outfile << "\t" << funcname << ";\n";
32 } else { // OS X
33 outfile << "_" << funcname << "\n";
34 }
35 }
36 }
37
38 if (isLinux) {
39 outfile << "local: *;\n};\n";
40 }
41
42 json_value_free(root);
43 } else {
44 die("Unable to parse JSON file");
45 }
46}

Callers 1

mainFunction · 0.85

Calls 9

loadFileFunction · 0.85
json_parseFunction · 0.85
get_object_keyFunction · 0.85
jsonArrayIteratorClass · 0.85
get_object_string_keyFunction · 0.85
json_value_freeFunction · 0.85
dieFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected