Prepare for replacement of modified version used in input_server addons. Adapt existing callers. The "this" argument is required, and the CALLED macro can only set it to one single value for an entire file currently. So, in any case where at least one standalone function or static method uses CALLED, the macro has to use a NULL pointer for all calls. Change-Id: I42fdcbeaf6dd039d4c4369818220ad85e0b8087e Reviewed-on: https://review.haiku-os.org/c/haiku/+/10041 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
/*
|
|
* Copyright 2008 Stephan Aßmus <[email protected]>
|
|
* Distributed under the terms of the MIT/X11 license.
|
|
*/
|
|
#ifndef FUNCTION_TRACER_H
|
|
#define FUNCTION_TRACER_H
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
class FunctionTracer {
|
|
public:
|
|
typedef int (*PrintFunction)(const char * fmt, ...);
|
|
|
|
FunctionTracer(PrintFunction printFunction, const void* pointer, const char* functionName,
|
|
int32& depth)
|
|
: fFunctionName(functionName),
|
|
fPrepend(),
|
|
fFunctionDepth(depth),
|
|
fPrintFunction(printFunction)
|
|
{
|
|
fFunctionDepth++;
|
|
if (pointer != NULL)
|
|
fPrepend.SetToFormat("%p ->", pointer);
|
|
fPrepend.Append(' ', fFunctionDepth * 2);
|
|
|
|
fPrintFunction("%s%s {\n", fPrepend.String(), fFunctionName.String());
|
|
}
|
|
|
|
~FunctionTracer()
|
|
{
|
|
fPrintFunction("%s}\n", fPrepend.String());
|
|
fFunctionDepth--;
|
|
}
|
|
|
|
private:
|
|
BString fFunctionName;
|
|
BString fPrepend;
|
|
int32& fFunctionDepth;
|
|
#if __GNUC__ < 3
|
|
// gcc2 doesn't support function attributes on function pointers
|
|
PrintFunction fPrintFunction;
|
|
#else
|
|
PrintFunction _PRINTFLIKE(1, 2) fPrintFunction;
|
|
#endif
|
|
};
|
|
|
|
} // namespace BPrivate
|
|
|
|
using BPrivate::FunctionTracer;
|
|
|
|
#endif // FUNCTION_TRACER_H
|