Skip to content

Commit

Permalink
feat(*): add initial function call tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Dec 24, 2023
1 parent 8c9340a commit 9ce7ad7
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/zenkit-capi/Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <zenkit/Logger.hh>

#define ZKC_WRAP_NEW(x) new (decltype(x))(std::move(x))
#define ZKC_LOG_TRACE(...) zenkit::Logger::log(zenkit::LogLevel::TRACE, "<Native>", __VA_ARGS__)
#define ZKC_LOG_ERROR(...) zenkit::Logger::log(zenkit::LogLevel::ERROR, "<Native>", __VA_ARGS__)
#define ZKC_LOG_WARN(...) zenkit::Logger::log(zenkit::LogLevel::WARNING, "<Native>", __VA_ARGS__)
#define ZKC_LOG_WARN_NULL(fn) \
Expand Down
9 changes: 9 additions & 0 deletions src/Boxes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// SPDX-License-Identifier: MIT
#include "zenkit-capi/Boxes.h"

#include "Internal.hh"

ZkVec3f ZkOrientedBoundingBox_getCenter(ZkOrientedBoundingBox const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_getCenter");
return {};
Expand All @@ -12,6 +15,7 @@ ZkVec3f ZkOrientedBoundingBox_getCenter(ZkOrientedBoundingBox const* slf) {
}

ZkVec3f ZkOrientedBoundingBox_getAxis(ZkOrientedBoundingBox const* slf, ZkSize i) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_getAxis");
return {};
Expand All @@ -26,6 +30,7 @@ ZkVec3f ZkOrientedBoundingBox_getAxis(ZkOrientedBoundingBox const* slf, ZkSize i
}

ZkVec3f ZkOrientedBoundingBox_getHalfWidth(ZkOrientedBoundingBox const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_getHalfWidth");
return {};
Expand All @@ -35,6 +40,7 @@ ZkVec3f ZkOrientedBoundingBox_getHalfWidth(ZkOrientedBoundingBox const* slf) {
}

ZkSize ZkOrientedBoundingBox_getChildCount(ZkOrientedBoundingBox const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_getChildCount");
return {};
Expand All @@ -44,6 +50,7 @@ ZkSize ZkOrientedBoundingBox_getChildCount(ZkOrientedBoundingBox const* slf) {
}

ZkOrientedBoundingBox const* ZkOrientedBoundingBox_getChild(ZkOrientedBoundingBox const* slf, ZkSize i) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_getChildCount");
return {};
Expand All @@ -60,6 +67,7 @@ ZkOrientedBoundingBox const* ZkOrientedBoundingBox_getChild(ZkOrientedBoundingBo
void ZkOrientedBoundingBox_enumerateChildren(ZkOrientedBoundingBox const* slf,
ZkOrientedBoundingBoxEnumerator cb,
void* ctx) {
ZKC_TRACE_FN();
if (slf == nullptr || cb == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_enumerateChildren");
return;
Expand All @@ -71,6 +79,7 @@ void ZkOrientedBoundingBox_enumerateChildren(ZkOrientedBoundingBox const* slf,
}

ZkAxisAlignedBoundingBox ZkOrientedBoundingBox_toAabb(ZkOrientedBoundingBox const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkOrientedBoundingBox_toAabb");
return {};
Expand Down
13 changes: 13 additions & 0 deletions src/CutsceneLibrary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// SPDX-License-Identifier: MIT
#include "zenkit-capi/CutsceneLibrary.h"

#include "Internal.hh"

ZkCutsceneLibrary* ZkCutsceneLibrary_load(ZkRead* buf) {
ZKC_TRACE_FN();
if (buf == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneLibrary_load");
return nullptr;
Expand All @@ -19,6 +22,7 @@ ZkCutsceneLibrary* ZkCutsceneLibrary_load(ZkRead* buf) {
}

ZkCutsceneLibrary* ZkCutsceneLibrary_loadPath(ZkString path) {
ZKC_TRACE_FN();
if (path == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneLibrary_loadPath");
return nullptr;
Expand All @@ -37,6 +41,7 @@ ZkCutsceneLibrary* ZkCutsceneLibrary_loadPath(ZkString path) {
}

ZkCutsceneLibrary* ZkCutsceneLibrary_loadVfs(ZkVfs const* vfs, ZkString name) {
ZKC_TRACE_FN();
if (vfs == nullptr || name == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneLibrary_loadVfs");
return nullptr;
Expand All @@ -50,10 +55,12 @@ ZkCutsceneLibrary* ZkCutsceneLibrary_loadVfs(ZkVfs const* vfs, ZkString name) {
}

void ZkCutsceneLibrary_del(ZkCutsceneLibrary* slf) {
ZKC_TRACE_FN();
delete slf;
}

ZkCutsceneBlock const* ZkCutsceneLibrary_getBlock(ZkCutsceneLibrary const* slf, ZkString name) {
ZKC_TRACE_FN();
if (slf == nullptr || name == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneLibrary_getBlock");
return nullptr;
Expand All @@ -63,6 +70,7 @@ ZkCutsceneBlock const* ZkCutsceneLibrary_getBlock(ZkCutsceneLibrary const* slf,
}

void ZkCutsceneLibrary_enumerateBlocks(ZkCutsceneLibrary const* slf, ZkCutsceneBlockEnumerator cb, void* ctx) {
ZKC_TRACE_FN();
if (slf == nullptr || cb == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneLibrary_enumerateBlocks");
return;
Expand All @@ -74,6 +82,7 @@ void ZkCutsceneLibrary_enumerateBlocks(ZkCutsceneLibrary const* slf, ZkCutsceneB
}

ZkString ZkCutsceneBlock_getName(ZkCutsceneBlock const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneBlock_getName");
return nullptr;
Expand All @@ -83,6 +92,7 @@ ZkString ZkCutsceneBlock_getName(ZkCutsceneBlock const* slf) {
}

ZkCutsceneMessage const* ZkCutsceneBlock_getMessage(ZkCutsceneBlock const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneBlock_getMessage");
return nullptr;
Expand All @@ -92,6 +102,7 @@ ZkCutsceneMessage const* ZkCutsceneBlock_getMessage(ZkCutsceneBlock const* slf)
}

uint32_t ZkCutsceneMessage_getType(ZkCutsceneMessage const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneMessage_getType");
return 0;
Expand All @@ -101,6 +112,7 @@ uint32_t ZkCutsceneMessage_getType(ZkCutsceneMessage const* slf) {
}

ZkString ZkCutsceneMessage_getText(ZkCutsceneMessage const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneMessage_getText");
return nullptr;
Expand All @@ -110,6 +122,7 @@ ZkString ZkCutsceneMessage_getText(ZkCutsceneMessage const* slf) {
}

ZkString ZkCutsceneMessage_getName(ZkCutsceneMessage const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkCutsceneMessage_getName");
return nullptr;
Expand Down
4 changes: 3 additions & 1 deletion src/Internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,6 @@ inline bool zk_any_nullptr(T*... args) {
ZKC_LOG_ERROR("%s() failed: index out of range", __func__); \
return; \
} \
} while (false)
} while (false)

#define ZKC_TRACE_FN() ZKC_LOG_TRACE("%s()", __func__)\
29 changes: 29 additions & 0 deletions src/Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// SPDX-License-Identifier: MIT
#include "zenkit-capi/Material.h"

#include "Internal.hh"

#include <zenkit/Archive.hh>

ZkMaterial* ZkMaterial_load(ZkRead* buf) {
ZKC_TRACE_FN();
if (buf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_load");
return nullptr;
Expand All @@ -24,6 +27,7 @@ ZkMaterial* ZkMaterial_load(ZkRead* buf) {
}

ZkMaterial* ZkMaterial_loadPath(ZkString path) {
ZKC_TRACE_FN();
if (path == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_loadPath");
return nullptr;
Expand All @@ -44,10 +48,12 @@ ZkMaterial* ZkMaterial_loadPath(ZkString path) {
}

void ZkMaterial_del(ZkMaterial* slf) {
ZKC_TRACE_FN();
delete slf;
}

ZkString ZkMaterial_getName(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getName");
return nullptr;
Expand All @@ -57,6 +63,7 @@ ZkString ZkMaterial_getName(ZkMaterial const* slf) {
}

ZkMaterialGroup ZkMaterial_getGroup(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getGroup");
return ZkMaterialGroup_UNDEFINED;
Expand All @@ -66,6 +73,7 @@ ZkMaterialGroup ZkMaterial_getGroup(ZkMaterial const* slf) {
}

ZkColor ZkMaterial_getColor(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getColor");
return {};
Expand All @@ -75,6 +83,7 @@ ZkColor ZkMaterial_getColor(ZkMaterial const* slf) {
}

float ZkMaterial_getSmoothAngle(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getSmoothAngle");
return 0;
Expand All @@ -84,6 +93,7 @@ float ZkMaterial_getSmoothAngle(ZkMaterial const* slf) {
}

ZkString ZkMaterial_getTexture(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getTexture");
return nullptr;
Expand All @@ -93,6 +103,7 @@ ZkString ZkMaterial_getTexture(ZkMaterial const* slf) {
}

ZkVec2f ZkMaterial_getTextureScale(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getTextureScale");
return {};
Expand All @@ -102,6 +113,7 @@ ZkVec2f ZkMaterial_getTextureScale(ZkMaterial const* slf) {
}

float ZkMaterial_getTextureAnimationFps(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getTextureAnimationFps");
return 0;
Expand All @@ -111,6 +123,7 @@ float ZkMaterial_getTextureAnimationFps(ZkMaterial const* slf) {
}

ZkAnimationMapping ZkMaterial_getTextureAnimationMapping(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getTextureAnimationMapping");
return ZkAnimationMapping_NONE;
Expand All @@ -120,6 +133,7 @@ ZkAnimationMapping ZkMaterial_getTextureAnimationMapping(ZkMaterial const* slf)
}

ZkVec2f ZkMaterial_getTextureAnimationMappingDirection(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getTextureAnimationMappingDirection");
return {};
Expand All @@ -129,6 +143,7 @@ ZkVec2f ZkMaterial_getTextureAnimationMappingDirection(ZkMaterial const* slf) {
}

ZkBool ZkMaterial_getDisableCollision(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getDisableCollision");
return false;
Expand All @@ -138,6 +153,7 @@ ZkBool ZkMaterial_getDisableCollision(ZkMaterial const* slf) {
}

ZkBool ZkMaterial_getDisableLightmap(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getDisableLightmap");
return false;
Expand All @@ -147,6 +163,7 @@ ZkBool ZkMaterial_getDisableLightmap(ZkMaterial const* slf) {
}

ZkBool ZkMaterial_getDontCollapse(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getDontCollapse");
return false;
Expand All @@ -156,6 +173,7 @@ ZkBool ZkMaterial_getDontCollapse(ZkMaterial const* slf) {
}

ZkString ZkMaterial_getDetailObject(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getDetailObject");
return nullptr;
Expand All @@ -165,6 +183,7 @@ ZkString ZkMaterial_getDetailObject(ZkMaterial const* slf) {
}

float ZkMaterial_getDetailObjectScale(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getDetailObjectScale");
return 1;
Expand All @@ -174,6 +193,7 @@ float ZkMaterial_getDetailObjectScale(ZkMaterial const* slf) {
}

ZkBool ZkMaterial_getForceOccluder(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getForceOccluder");
return false;
Expand All @@ -183,6 +203,7 @@ ZkBool ZkMaterial_getForceOccluder(ZkMaterial const* slf) {
}

ZkBool ZkMaterial_getEnvironmentMapping(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getEnvironmentMapping");
return false;
Expand All @@ -192,6 +213,7 @@ ZkBool ZkMaterial_getEnvironmentMapping(ZkMaterial const* slf) {
}

float ZkMaterial_getEnvironmentMappingStrength(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getEnvironmentMappingStrength");
return 0;
Expand All @@ -201,6 +223,7 @@ float ZkMaterial_getEnvironmentMappingStrength(ZkMaterial const* slf) {
}

ZkWaveMode ZkMaterial_getWaveMode(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getWaveMode");
return ZkWaveMode_NONE;
Expand All @@ -210,6 +233,7 @@ ZkWaveMode ZkMaterial_getWaveMode(ZkMaterial const* slf) {
}

ZkWaveSpeed ZkMaterial_getWaveSpeed(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getWaveSpeed");
return ZkWaveSpeed_NORMAL;
Expand All @@ -219,6 +243,7 @@ ZkWaveSpeed ZkMaterial_getWaveSpeed(ZkMaterial const* slf) {
}

float ZkMaterial_getWaveAmplitude(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getWaveAmplitude");
return 0;
Expand All @@ -228,6 +253,7 @@ float ZkMaterial_getWaveAmplitude(ZkMaterial const* slf) {
}

float ZkMaterial_getWaveGridSize(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getWaveGridSize");
return 1;
Expand All @@ -237,6 +263,7 @@ float ZkMaterial_getWaveGridSize(ZkMaterial const* slf) {
}

ZkBool ZkMaterial_getIgnoreSun(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getIgnoreSun");
return false;
Expand All @@ -246,6 +273,7 @@ ZkBool ZkMaterial_getIgnoreSun(ZkMaterial const* slf) {
}

ZkAlphaFunction ZkMaterial_getAlphaFunction(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getAlphaFunction");
return ZkAlphaFunction_DEFAULT;
Expand All @@ -255,6 +283,7 @@ ZkAlphaFunction ZkMaterial_getAlphaFunction(ZkMaterial const* slf) {
}

ZkVec2f ZkMaterial_getDefaultMapping(ZkMaterial const* slf) {
ZKC_TRACE_FN();
if (slf == nullptr) {
ZKC_LOG_WARN_NULL("ZkMaterial_getDefaultMapping");
return {};
Expand Down
Loading

0 comments on commit 9ce7ad7

Please sign in to comment.