| 6 | #include <sstream> |
| 7 | |
| 8 | void 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 | } |
no test coverage detected