Skip to content

Commit

Permalink
fix: macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-olivier committed Jul 14, 2024
1 parent 94ca9dc commit 3b4a96b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
18 changes: 16 additions & 2 deletions src/dylib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ void replace_occurrences(std::string &input, const std::string &keyword, const s
}
}

void add_space_after_comma(std::string &input) {
std::string result;

for (char c : input) {
if (c == ',') {
result += ", ";
} else {
result += c;
}
}

input = result;
}

static dylib::native_handle_type open_lib(const char *path) noexcept {
#if (defined(_WIN32) || defined(_WIN64))
return LoadLibraryA(path);
Expand Down Expand Up @@ -137,8 +151,8 @@ dylib::~dylib() {

#if !(defined(_WIN32) || defined(_WIN64))
std::string format_symbol(std::string input) {
replace_occurrences(result, "std::__1::", "std::");
replace_occurrences(result, "std::__cxx11::", "std::");
replace_occurrences(input, "std::__1::", "std::");
replace_occurrences(input, "std::__cxx11::", "std::");

input.erase(
std::remove_if(
Expand Down
15 changes: 1 addition & 14 deletions src/win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,7 @@
#include <algorithm>

void replace_occurrences(std::string &input, const std::string &keyword, const std::string &replacement);

void add_space_after_comma(std::string &input) {
std::string result;

for (char c : input) {
if (c == ',') {
result += ", ";
} else {
result += c;
}
}

input = result;
}
void add_space_after_comma(std::string &input);

std::string format_symbol(std::string input) {
replace_occurrences(input, "(class ", "(");
Expand Down
5 changes: 4 additions & 1 deletion tests/tests.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <gtest/gtest.h>
#include <utility>

#include "dylib.hpp"

#include <iostream>
#if !(defined(_WIN32) || defined(_WIN64))
#include <dlfcn.h>
#endif

TEST(example, example_test) {
testing::internal::CaptureStdout();
Expand Down

0 comments on commit 3b4a96b

Please sign in to comment.