Skip to content

Commit

Permalink
Many more API functions (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
erincatto authored Feb 25, 2024
1 parent 24c3649 commit 0076e58
Show file tree
Hide file tree
Showing 65 changed files with 2,403 additions and 1,343 deletions.
37 changes: 30 additions & 7 deletions include/box2d/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,46 @@
#include <stdint.h>

#if defined(_WIN32) && defined(box2d_EXPORTS)
// building the Box2D DLL
// build the Windows DLL
#define BOX2D_EXPORT __declspec(dllexport)
#elif defined(_WIN32) && defined(BOX2D_DLL)
// using the Box2D DLL
// using the Windows DLL
#define BOX2D_EXPORT __declspec(dllimport)
#elif defined(__GNUC__) && defined(box2d_EXPORTS)
// building the Box2D shared library
#elif defined(box2d_EXPORTS)
// building or using the Box2D shared library
#define BOX2D_EXPORT __attribute__((visibility("default")))
#else
// static library
#define BOX2D_EXPORT
#endif

#if defined(BOX2D_IMPLEMENTATION)
#pragma message("BOX2D_IMPLEMENTATION")
#if defined(_WIN32) && defined(box2d_EXPORTS)
// build the Windows DLL
#define BOX2D_INLINE __declspec(dllexport) extern inline
#elif defined(_WIN32) && defined(BOX2D_DLL)
// using the Windows DLL
#define BOX2D_INLINE __declspec(dllimport)
#elif defined(box2d_EXPORTS)
#define BOX2D_INLINE __attribute__((visibility("default")))
#else
#define BOX2D_INLINE extern inline
#endif
#else
// #pragma message("BOX2D inline")
#define BOX2D_INLINE inline
#endif

#ifdef __cplusplus
#define B2_API extern "C" BOX2D_EXPORT
#define B2_INLINE extern "C" BOX2D_INLINE
#define B2_LITERAL(T) T
#else
#define B2_API BOX2D_EXPORT
#define B2_INLINE BOX2D_INLINE
/// Used for C literals like (b2Vec2){1.0f, 2.0f} where C++ requires b2Vec2{1.0f, 2.0f}
#define B2_LITERAL(T) (T)
#endif

/// Prototype for user allocation function.
Expand All @@ -34,16 +57,16 @@ typedef void* b2AllocFcn(uint32_t size, int32_t alignment);
/// @param mem the memory previously allocated through `b2AllocFcn`
typedef void b2FreeFcn(void* mem);

/// Prototype for the user assert callback. Return 0 to skip the debugger break.
typedef int b2AssertFcn(const char* condition, const char* fileName, int lineNumber);

/// This allows the user to override the allocation functions. These should be
/// set during application startup.
B2_API void b2SetAllocator(b2AllocFcn* allocFcn, b2FreeFcn* freeFcn);

/// Total bytes allocated by Box2D
B2_API uint32_t b2GetByteCount(void);

/// Prototype for the user assert callback. Return 0 to skip the debugger break.
typedef int b2AssertFcn(const char* condition, const char* fileName, int lineNumber);

/// Override the default assert callback.
/// @param assertFcn a non-null assert callback
B2_API void b2SetAssertFcn(b2AssertFcn* assertFcn);
Loading

0 comments on commit 0076e58

Please sign in to comment.