godot/thirdparty/harfbuzz/src/hb-debug.hh

/*
 * Copyright © 2017  Google, Inc.
 *
 *  This is part of HarfBuzz, a text shaping library.
 *
 * Permission is hereby granted, without written agreement and without
 * license or royalty fees, to use, copy, modify, and distribute this
 * software and its documentation for any purpose, provided that the
 * above copyright notice and the following two paragraphs appear in
 * all copies of this software.
 *
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Google Author(s): Behdad Esfahbod
 */

#ifndef HB_DEBUG_HH
#define HB_DEBUG_HH

#include "hb.hh"
#include "hb-atomic.hh"
#include "hb-algs.hh"


#ifndef HB_DEBUG
#define HB_DEBUG
#endif


/*
 * Global runtime options.
 */

struct hb_options_t
{};

hb_options_union_t;
static_assert;

HB_INTERNAL void
_hb_options_init ();

extern HB_INTERNAL hb_atomic_int_t _hb_options;

static inline hb_options_t
hb_options ()
{}


/*
 * Debug output (needs enabling at compile time.)
 */

static inline bool
_hb_debug (unsigned int level,
	   unsigned int max_level)
{}

#define DEBUG_LEVEL_ENABLED(WHAT, LEVEL)
#define DEBUG_ENABLED(WHAT)

static inline void
_hb_print_func (const char *func)
{}

template <int max_level> static inline void
_hb_debug_msg_va (const char *what,
		  const void *obj,
		  const char *func,
		  bool indented,
		  unsigned int level,
		  int level_dir,
		  const char *message,
		  va_list ap) HB_PRINTF_FUNC(7, 0);
template <int max_level> static inline void
_hb_debug_msg_va (const char *what,
		  const void *obj,
		  const char *func,
		  bool indented,
		  unsigned int level,
		  int level_dir,
		  const char *message,
		  va_list ap)
{}
template <> inline void HB_PRINTF_FUNC(7, 0)
_hb_debug_msg_va<0> (const char *what HB_UNUSED,
		     const void *obj HB_UNUSED,
		     const char *func HB_UNUSED,
		     bool indented HB_UNUSED,
		     unsigned int level HB_UNUSED,
		     int level_dir HB_UNUSED,
		     const char *message HB_UNUSED,
		     va_list ap HB_UNUSED) {}

template <int max_level> static inline void
_hb_debug_msg (const char *what,
	       const void *obj,
	       const char *func,
	       bool indented,
	       unsigned int level,
	       int level_dir,
	       const char *message,
	       ...) HB_PRINTF_FUNC(7, 8);
template <int max_level> static inline void HB_PRINTF_FUNC(7, 8)
_hb_debug_msg (const char *what,
	       const void *obj,
	       const char *func,
	       bool indented,
	       unsigned int level,
	       int level_dir,
	       const char *message,
	       ...)
{}
template <> inline void
_hb_debug_msg<0> (const char *what HB_UNUSED,
		  const void *obj HB_UNUSED,
		  const char *func HB_UNUSED,
		  bool indented HB_UNUSED,
		  unsigned int level HB_UNUSED,
		  int level_dir HB_UNUSED,
		  const char *message HB_UNUSED,
		  ...) HB_PRINTF_FUNC(7, 8);
template <> inline void HB_PRINTF_FUNC(7, 8)
_hb_debug_msg<0> (const char *what HB_UNUSED,
		  const void *obj HB_UNUSED,
		  const char *func HB_UNUSED,
		  bool indented HB_UNUSED,
		  unsigned int level HB_UNUSED,
		  int level_dir HB_UNUSED,
		  const char *message HB_UNUSED,
		  ...) {}

#define DEBUG_MSG_LEVEL(WHAT, OBJ, LEVEL, LEVEL_DIR, ...)
#define DEBUG_MSG(WHAT, OBJ, ...)
#define DEBUG_MSG_FUNC(WHAT, OBJ, ...)


/*
 * Printer
 */

template <typename T>
struct hb_printer_t {};

template <>
struct hb_printer_t<bool> {};

template <>
struct hb_printer_t<hb_empty_t> {};


/*
 * Trace
 */

template <typename T>
static inline void _hb_warn_no_return (bool returned)
{}
template <>
/*static*/ inline void _hb_warn_no_return<hb_empty_t> (bool returned HB_UNUSED) {}
template <>
/*static*/ inline void _hb_warn_no_return<void> (bool returned HB_UNUSED) {}

template <int max_level, typename ret_t>
struct hb_auto_trace_t
{};
hb_auto_trace_t<0, ret_t>;

/* For disabled tracing; optimize out everything.
 * https://github.com/harfbuzz/harfbuzz/pull/605 */
template <typename ret_t>
struct hb_no_trace_t {};

#define return_trace(RET)


/*
 * Instances.
 */

#ifndef HB_DEBUG_ARABIC
#define HB_DEBUG_ARABIC
#endif

#ifndef HB_DEBUG_BLOB
#define HB_DEBUG_BLOB
#endif

#ifndef HB_DEBUG_CORETEXT
#define HB_DEBUG_CORETEXT
#endif

#ifndef HB_DEBUG_DIRECTWRITE
#define HB_DEBUG_DIRECTWRITE
#endif

#ifndef HB_DEBUG_FT
#define HB_DEBUG_FT
#endif

#ifndef HB_DEBUG_JUSTIFY
#define HB_DEBUG_JUSTIFY
#endif

#ifndef HB_DEBUG_OBJECT
#define HB_DEBUG_OBJECT
#endif

#ifndef HB_DEBUG_SHAPE_PLAN
#define HB_DEBUG_SHAPE_PLAN
#endif

#ifndef HB_DEBUG_UNISCRIBE
#define HB_DEBUG_UNISCRIBE
#endif

#ifndef HB_DEBUG_WASM
#define HB_DEBUG_WASM
#endif

/*
 * With tracing.
 */

#ifndef HB_DEBUG_APPLY
#define HB_DEBUG_APPLY
#endif
#if HB_DEBUG_APPLY
#define TRACE_APPLY
#else
#define TRACE_APPLY(this)
#endif

#ifndef HB_DEBUG_SANITIZE
#define HB_DEBUG_SANITIZE
#endif
#if HB_DEBUG_SANITIZE
#define TRACE_SANITIZE
#else
#define TRACE_SANITIZE(this)
#endif

#ifndef HB_DEBUG_SERIALIZE
#define HB_DEBUG_SERIALIZE
#endif
#if HB_DEBUG_SERIALIZE
#define TRACE_SERIALIZE
#else
#define TRACE_SERIALIZE(this)
#endif

#ifndef HB_DEBUG_SUBSET
#define HB_DEBUG_SUBSET
#endif
#if HB_DEBUG_SUBSET
#define TRACE_SUBSET
#else
#define TRACE_SUBSET(this)
#endif

#ifndef HB_DEBUG_SUBSET_REPACK
#define HB_DEBUG_SUBSET_REPACK
#endif

#ifndef HB_DEBUG_PAINT
#define HB_DEBUG_PAINT
#endif
#if HB_DEBUG_PAINT
#define TRACE_PAINT
#else
#define TRACE_PAINT(this)
#endif


#ifndef HB_DEBUG_DISPATCH
#define HB_DEBUG_DISPATCH
#endif
#if HB_DEBUG_DISPATCH
#define TRACE_DISPATCH
#else
#define TRACE_DISPATCH(this, format)
#endif


#ifndef HB_BUFFER_MESSAGE_MORE
#define HB_BUFFER_MESSAGE_MORE
#endif


#endif /* HB_DEBUG_HH */