Let's just use 1 PD_API header

This commit is contained in:
2026-01-25 20:57:14 +01:00
parent 337c016824
commit fb46f4d36a
63 changed files with 289 additions and 459 deletions

View File

@@ -24,8 +24,8 @@ SOFTWARE.
#include <pd/core/bit_util.hpp>
namespace PD::BitUtil {
PD_CORE_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
PD_CORE_API u32 GetPow2(u32 v) {
PD_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
PD_API u32 GetPow2(u32 v) {
v--;
v |= v >> 1;
v |= v >> 2;

View File

@@ -25,7 +25,7 @@ SOFTWARE.
#include <pd/core/color.hpp>
namespace PD {
PD_CORE_API std::string Color::Hex(bool rgba) const {
PD_API std::string Color::Hex(bool rgba) const {
/** Need to int cast (so it is used as num and not char...) */
std::stringstream s;
s << "#";

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace IO {
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
PD_API std::vector<u8> LoadFile2Mem(const std::string& path) {
std::ifstream iff(path, std::ios::binary);
if (!iff) {
return std::vector<u8>();
@@ -39,7 +39,7 @@ PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
return res;
}
PD_CORE_API std::string LoadFile2Str(const std::string& path) {
PD_API std::string LoadFile2Str(const std::string& path) {
std::ifstream iff(path, std::ios::binary);
if (!iff) {
return "";
@@ -53,7 +53,7 @@ PD_CORE_API std::string LoadFile2Str(const std::string& path) {
return ret;
}
PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
PD_API u32 HashMemory(const std::vector<u8>& data) {
u32 hash = 4477;
for (auto& it : data) {
hash = (hash * 33) + it;
@@ -61,7 +61,7 @@ PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
return hash;
}
PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
PD_API void DecompressRLE(std::vector<u8>& data) {
if ((data.size() % 2) != 0) {
return;
}
@@ -72,7 +72,7 @@ PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
}
}
PD_CORE_API void CompressRLE(std::vector<u8>& data) {
PD_API void CompressRLE(std::vector<u8>& data) {
if (data.empty()) {
/** No exceptions enabled :( */
return;

14
source/core/mat.cpp Executable file → Normal file
View File

@@ -25,7 +25,7 @@ SOFTWARE.
#include <pd/core/mat.hpp>
namespace PD {
PD_CORE_API Mat4 Mat4::RotateX(float a) {
PD_API Mat4 Mat4::RotateX(float a) {
float c = std::cos(a);
float s = std::sin(a);
Mat4 ret = Identity();
@@ -36,7 +36,7 @@ PD_CORE_API Mat4 Mat4::RotateX(float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::RotateY(float a) {
PD_API Mat4 Mat4::RotateY(float a) {
float c = std::cos(a);
float s = std::sin(a);
Mat4 ret = Identity();
@@ -47,7 +47,7 @@ PD_CORE_API Mat4 Mat4::RotateY(float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::RotateZ(float a) {
PD_API Mat4 Mat4::RotateZ(float a) {
float c = std::cos(a);
float s = std::sin(a);
Mat4 ret = Identity();
@@ -58,7 +58,7 @@ PD_CORE_API Mat4 Mat4::RotateZ(float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
PD_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
float s = std::sin(a);
float c = std::cos(a);
float t = 1.f - c;
@@ -81,7 +81,7 @@ PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
float _fov = std::tan(fov / 2.f);
Mat4 ret;
ret(0, 0) = 1.f / (aspect * _fov);
@@ -98,8 +98,8 @@ PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
return ret;
}
PD_CORE_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
const fvec3& up) {
PD_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
const fvec3& up) {
auto f = fvec3(center - pos).Normalize();
auto s = f.Cross(up).Normalize();
auto u = s.Cross(f);

20
source/core/strings.cpp Executable file → Normal file
View File

@@ -24,8 +24,8 @@ SOFTWARE.
#include <pd/core/strings.hpp>
namespace PD::Strings {
PD_CORE_API bool StringEndsWith(const std::string& str,
const std::vector<std::string>& exts) {
PD_API bool StringEndsWith(const std::string& str,
const std::vector<std::string>& exts) {
// Changed order to not do an substr on empty string
if (str.empty()) {
return false;
@@ -44,7 +44,7 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
return false;
}
PD_CORE_API std::wstring MakeWstring(const std::string& s) {
PD_API std::wstring MakeWstring(const std::string& s) {
// Manually convert to wstring as they removed wstring_convert :(
std::wstring result;
size_t i = 0;
@@ -85,7 +85,7 @@ PD_CORE_API std::wstring MakeWstring(const std::string& s) {
return result;
}
PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
PD_API const std::string FormatNanos(unsigned long long nanos) {
// Based on some code of my minecraft plugins
if (nanos < 1000) {
return std::format("{}ns", nanos);
@@ -106,7 +106,7 @@ PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
return "";
}
PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
PD_API const std::string FormatMillis(unsigned long long millis) {
// Original Code can be found in some of my mv plugins
if (millis < 1000) {
return std::format("{}ms", millis);
@@ -121,7 +121,7 @@ PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
return "";
}
PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
PD_API const std::string FormatBytes(unsigned long long bytes) {
static const std::vector<std::string> endings = {
"B", "KB", "MB", "GB", "TB", "Unk",
};
@@ -137,8 +137,8 @@ PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
return std::format("{:.1f} {}", b, endings[i]);
}
PD_CORE_API const std::string GetFileName(const std::string& path,
const std::string& saperators) {
PD_API const std::string GetFileName(const std::string& path,
const std::string& saperators) {
auto pos = path.find_last_of(saperators);
if (pos != path.npos) {
return path.substr(pos + 1);
@@ -147,7 +147,7 @@ PD_CORE_API const std::string GetFileName(const std::string& path,
return path;
}
PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
PD_API const std::string PathRemoveExtension(const std::string& path) {
auto pos = path.find_last_of('.');
if (pos != path.npos) {
return path.substr(0, pos);
@@ -156,7 +156,7 @@ PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
return path;
}
PD_CORE_API u32 FastHash(const std::string& s) {
PD_API u32 FastHash(const std::string& s) {
u32 hash = 5381;
for (auto& it : s) {
hash = (hash * 33) + static_cast<u8>(it);

View File

@@ -26,25 +26,25 @@ SOFTWARE.
#include <pd/drivers/drivers.hpp>
namespace PD {
PD_CORE_API Timer::Timer(bool autostart) {
PD_API Timer::Timer(bool autostart) {
pIsRunning = autostart;
Reset();
}
PD_CORE_API void Timer::Reset() {
PD_API void Timer::Reset() {
pStart = OS::GetTime();
pNow = pStart;
}
PD_CORE_API void Timer::Update() {
PD_API void Timer::Update() {
if (pIsRunning) {
pNow = OS::GetTime();
}
}
PD_CORE_API void Timer::Pause() { pIsRunning = false; }
PD_CORE_API void Timer::Rseume() { pIsRunning = true; }
PD_CORE_API bool Timer::IsRunning() const { return pIsRunning; }
PD_CORE_API u64 Timer::Get() { return pNow - pStart; }
PD_CORE_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
PD_API void Timer::Pause() { pIsRunning = false; }
PD_API void Timer::Rseume() { pIsRunning = true; }
PD_API bool Timer::IsRunning() const { return pIsRunning; }
PD_API u64 Timer::Get() { return pNow - pStart; }
PD_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
} // namespace PD

View File

@@ -25,12 +25,12 @@ SOFTWARE.
#include <pd/drivers/drivers.hpp>
namespace PD::TT {
PD_CORE_API void Beg(const std::string& id) {
PD_API void Beg(const std::string& id) {
auto trace = OS::GetTraceRef(id);
trace->SetStart(PD::OS::GetNanoTime());
}
PD_CORE_API void End(const std::string& id) {
PD_API void End(const std::string& id) {
auto trace = OS::GetTraceRef(id);
trace->SetEnd(PD::OS::GetNanoTime());
}