Skip to content

Commit 6acfa25

Browse files
committed
move function to utils file
1 parent 938651f commit 6acfa25

7 files changed

Lines changed: 28 additions & 16 deletions

File tree

src/pages/Attributes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "../DevTools.hpp"
44
#include <misc/cpp/imgui_stdlib.h>
55
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
6+
#include "../platform/utils.hpp"
67

78
using namespace geode::prelude;
89

src/platform/Mac.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#ifdef GEODE_IS_MACOS
44

5-
#include "platform.hpp"
5+
#include "utils.hpp"
66

77
#include <Geode/utils/string.hpp>
88
#include <array>
@@ -12,6 +12,7 @@
1212
#include <dlfcn.h>
1313
#include <cxxabi.h>
1414
#include <algorithm>
15+
#include <fmt/core.h>
1516

1617
#include <mach-o/dyld_images.h>
1718
#include <mach-o/dyld.h>

src/platform/Win32.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class $modify(CCEGLView) {
4646
}
4747
};
4848

49+
#include "utils.hpp"
50+
4951
std::string formatAddressIntoOffsetImpl(uintptr_t addr) {
5052
HMODULE mod;
5153

src/platform/platform.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,3 @@ void GLRenderCtx::end() {
110110
glFlush();
111111
}
112112

113-
std::string formatAddressIntoOffset(uintptr_t addr) {
114-
static std::unordered_map<uintptr_t, std::string> formatted;
115-
auto it = formatted.find(addr);
116-
if (it != formatted.end()) {
117-
return it->second;
118-
} else {
119-
auto const txt = formatAddressIntoOffsetImpl(addr);
120-
formatted.insert({ addr, txt });
121-
return txt;
122-
}
123-
}

src/platform/platform.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,3 @@ class GLRenderCtx final {
2626
bool begin();
2727
void end();
2828
};
29-
30-
std::string formatAddressIntoOffsetImpl(uintptr_t addr);
31-
32-
std::string formatAddressIntoOffset(uintptr_t addr);

src/platform/utils.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "utils.hpp"
2+
3+
#include <unordered_map>
4+
5+
std::string formatAddressIntoOffset(uintptr_t addr) {
6+
static std::unordered_map<uintptr_t, std::string> formatted;
7+
auto it = formatted.find(addr);
8+
if (it != formatted.end()) {
9+
return it->second;
10+
} else {
11+
auto const txt = formatAddressIntoOffsetImpl(addr);
12+
formatted.insert({ addr, txt });
13+
return txt;
14+
}
15+
}

src/platform/utils.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <stdint.h>
5+
6+
std::string formatAddressIntoOffset(uintptr_t addr);
7+
8+
std::string formatAddressIntoOffsetImpl(uintptr_t addr);

0 commit comments

Comments
 (0)