From 0d2bec95e8a3cc2e3432fa3f857fa56a4ad7c39c Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 10 Jul 2020 09:30:10 +0200 Subject: [PATCH] C Interface for random class. --- CInterface/Random.cpp | 20 ++++++++++++++++++++ CMakeLists.txt | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 CInterface/Random.cpp diff --git a/CInterface/Random.cpp b/CInterface/Random.cpp new file mode 100644 index 0000000..5b1e23f --- /dev/null +++ b/CInterface/Random.cpp @@ -0,0 +1,20 @@ +#include "../src/Random.hpp" + +ArbUt::Random* Arbutils_Random_Construct() { return new ArbUt::Random(); } +ArbUt::Random* Arbutils_Random_ConstructWithSeed(uint_fast32_t seed) { return new ArbUt::Random(seed); } + +void Arbutils_Random_Destruct(ArbUt::Random* p) { delete p; } + +float Arbutils_Random_GetFloat(ArbUt::Random* p) { return p->GetFloat(); } +double Arbutils_Random_GetDouble(ArbUt::Random* p) { return p->GetDouble(); } +int32_t Arbutils_Random_Get(ArbUt::Random* p) { return p->Get(); } +int32_t Arbutils_Random_GetWithMax(ArbUt::Random* p, int32_t max) { return p->Get(max); } +int32_t Arbutils_Random_GetInLimits(ArbUt::Random* p, int32_t min, int32_t max) { return p->Get(min, max); } + +uint32_t Arbutils_Random_GetUnsigned(ArbUt::Random* p) { return p->GetUnsigned(); } +uint32_t Arbutils_Random_GetUnsignedWithMax(ArbUt::Random* p, uint32_t max) { return p->GetUnsigned(max); } +uint32_t Arbutils_Random_GetUnsignedInLimits(ArbUt::Random* p, uint32_t min, uint32_t max) { + return p->GetUnsigned(min, max); +} + +uint_fast32_t Arbutils_Random_GetSeed(ArbUt::Random* p) { return p->GetSeed(); } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b3ef40..2473c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,10 @@ if (WINDOWS) ADD_DEFINITIONS(-D WINDOWS=1) endif (WINDOWS) -file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp") +file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp" "CInterface/*.cpp") set(LIBTYPE STATIC) if (SHARED) - set(LIBTYPE SHARED src/StringView.hpp src/String/BasicStringView.hpp src/String/StringViewLiteral.hpp) + set(LIBTYPE SHARED src/StringView.hpp src/String/BasicStringView.hpp src/String/StringViewLiteral.hpp CInterface/Random.cpp) endif(SHARED) add_library(Arbutils ${LIBTYPE} ${SRC_FILES})