File: tracing_category.cpp

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (34 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "tracing_category.h"

#include "tracing/tracing.h"

namespace scripting {
namespace api {

ADE_OBJ(l_TracingCategory, tracing::Category, "tracing_category", "A category for tracing engine performance");

ADE_FUNC(trace,
	l_TracingCategory,
	"function() => void body",
	"Traces the run time of the specified function that will be invoked in this call.",
	nullptr,
	nullptr)
{
	tracing::Category* category = nullptr;
	luacpp::LuaFunction func;
	if (!ade_get_args(L, "ou", l_TracingCategory.GetPtr(&category), &func)) {
		return ADE_RETURN_NIL;
	}

	if (!func.isValid()) {
		LuaError(L, "Invalid function reference passed!");
		return ADE_RETURN_NIL;
	}

	TRACE_SCOPE(*category);
	func(L);
	return ADE_RETURN_NIL;
}

} // namespace api
} // namespace scripting