Documents the C Interface.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9abdbecd17
commit
2e8a7f5fbb
|
@ -1,13 +1,16 @@
|
|||
#include "Core.hpp"
|
||||
#include "../src/SignalHandling.hpp"
|
||||
|
||||
/// @file
|
||||
|
||||
std::string ExceptionHandler::_ArbutilsLastException = "";
|
||||
/// @brief Returns a null-terminated C string to the last exception found.
|
||||
export const char* Arbutils_C_GetLastException() { return ExceptionHandler::GetLastException(); }
|
||||
|
||||
#if !WINDOWS
|
||||
static ArbUt::SignalHandling sh;
|
||||
/// @brief Sets a callback to a function to run when a signal occurs.
|
||||
export void Arbutils_C_SetSignalCallback(void (*callback)(const char*)) { sh.SetCallback(callback); }
|
||||
export void Arbutils_C_RaiseSignal() { raise(SIGSEGV); }
|
||||
#else
|
||||
export void Arbutils_C_SetSignalCallback(void (*)(const char*)) { }
|
||||
export void Arbutils_C_RaiseSignal() { raise(SIGSEGV); }
|
||||
|
|
|
@ -8,14 +8,21 @@
|
|||
|
||||
#define ArbutilsException 3;
|
||||
|
||||
/// @brief Handler class for storing C++ exceptions, and passing them over a C interface.
|
||||
class ExceptionHandler {
|
||||
static std::string _ArbutilsLastException;
|
||||
|
||||
public:
|
||||
/// @brief Stores the last found exception. Overrides previously last found exception.
|
||||
/// @param e The last found exception as Arbutils exception.
|
||||
static void SetLastException(const ArbUt::Exception& e) {
|
||||
_ArbutilsLastException = std::string(e.what()) + "\n" + e.GetStacktrace();
|
||||
}
|
||||
/// @brief Stores the last found exception. Overrides previously last found exception.
|
||||
/// @param e The last found exception as std exception.
|
||||
static void SetLastException(const std::exception& e) { _ArbutilsLastException = std::string(e.what()); }
|
||||
/// @brief Returns the last found exception as null-terminated C string.
|
||||
/// @return A null-terminated c string detailing the last found exception.
|
||||
static const char* GetLastException() { return _ArbutilsLastException.c_str(); }
|
||||
};
|
||||
|
||||
|
|
|
@ -1,25 +1,38 @@
|
|||
#include "../src/Random.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
/// @file
|
||||
|
||||
/// @brief Constructs a random class.
|
||||
export ArbUt::Random* Arbutils_Random_Construct() { return new ArbUt::Random(); }
|
||||
/// @brief Constructs a random class with a specific seed.
|
||||
export ArbUt::Random* Arbutils_Random_ConstructWithSeed(uint_fast32_t seed) { return new ArbUt::Random(seed); }
|
||||
|
||||
/// @brief Call the destructor on a random object.
|
||||
export void Arbutils_Random_Destruct(ArbUt::Random* p) { delete p; }
|
||||
|
||||
/// @brief Returns a random float between 0.0 and 1.0 using a random object.
|
||||
export float Arbutils_Random_GetFloat(ArbUt::Random* p) { return p->GetFloat(); }
|
||||
/// @brief Returns a random double between 0.0 and 1.0 using a random object.
|
||||
export double Arbutils_Random_GetDouble(ArbUt::Random* p) { return p->GetDouble(); }
|
||||
/// @brief Returns a random a random 32 bit integer using a random object.
|
||||
export int32_t Arbutils_Random_Get(ArbUt::Random* p) { return p->Get(); }
|
||||
/// @brief Gets a random 32 bit integer with a given max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
|
||||
export uint8_t Arbutils_Random_GetWithMax(ArbUt::Random* p, int32_t max, int32_t& out) { Try(out = p->Get(max);) }
|
||||
/// @brief Gets a random 32 bit integer with a given min and max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
|
||||
export uint8_t Arbutils_Random_GetInLimits(ArbUt::Random* p, int32_t min, int32_t max, int32_t& out) {
|
||||
Try(out = p->Get(min, max);)
|
||||
}
|
||||
|
||||
/// @brief Returns a random a random 32 bit unsigned integer using a random object.
|
||||
export uint32_t Arbutils_Random_GetUnsigned(ArbUt::Random* p) { return p->GetUnsigned(); }
|
||||
/// @brief Gets a random 32 bit unsigned integer with a given max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
|
||||
export uint8_t Arbutils_Random_GetUnsignedWithMax(ArbUt::Random* p, uint32_t max, uint32_t& out) {
|
||||
Try(out = p->GetUnsigned(max);)
|
||||
}
|
||||
/// @brief Gets a random 32 bit unsigned integer with a given min and max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
|
||||
export uint8_t Arbutils_Random_GetUnsignedInLimits(ArbUt::Random* p, uint32_t min, uint32_t max, uint32_t& out) {
|
||||
Try(out = p->GetUnsigned(min, max);)
|
||||
}
|
||||
|
||||
/// @brief Returns the seed of the random object.
|
||||
export uint_fast32_t Arbutils_Random_GetSeed(ArbUt::Random* p) { return p->GetSeed(); }
|
10
Doxyfile
10
Doxyfile
|
@ -844,7 +844,8 @@ WARN_LOGFILE =
|
|||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = src/
|
||||
INPUT = src/ \
|
||||
CInterface/
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
|
@ -872,7 +873,8 @@ INPUT_ENCODING = UTF-8
|
|||
# *.vhdl, *.ucf, *.qsf and *.ice.
|
||||
|
||||
FILE_PATTERNS = *.cpp \
|
||||
*.hpp
|
||||
*.hpp \
|
||||
*.h
|
||||
|
||||
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
||||
# be searched for input files as well.
|
||||
|
@ -914,7 +916,7 @@ EXCLUDE_PATTERNS =
|
|||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories use the pattern */test/*
|
||||
|
||||
EXCLUDE_SYMBOLS = _*
|
||||
EXCLUDE_SYMBOLS = ^_* ArbUt::_*
|
||||
|
||||
# The EXAMPLE_PATH tag can be used to specify one or more files or directories
|
||||
# that contain example code fragments that are included (see the \include
|
||||
|
@ -2172,7 +2174,7 @@ EXPAND_AS_DEFINED =
|
|||
# The default value is: YES.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
SKIP_FUNCTION_MACROS = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to external references
|
||||
|
|
Loading…
Reference in New Issue