Gama C Library
Gama C API Documentation
debug.h File Reference

Provides macros and functions for debugging output in Gama. More...

#include "3d/position.h"
#include "color.h"
#include "position.h"
#include <stdio.h>
#include "3d/mesh.h"

Go to the source code of this file.

Macros

#define gmdi(fn, obj)
 Macro to print debug information for an object without a newline.
#define gmdn(fn, obj)
 Macro to print debug information for an object with a newline.
#define gmd(fn, obj, e)
 Generic macro to print debug information for an object.

Functions

int gmd_color (char *s, size_t n, gmColor c)
 Formats a gmColor into a human-readable string for debugging.
int gmd_pos3 (char *s, size_t n, gm3Pos p)
 Formats a gm3Pos (3D position) into a human-readable string for debugging.
int gmd_pos2 (char *s, size_t n, gmPos p)
 Formats a gmPos (2D position) into a human-readable string for debugging.
int gmd_mesh (char *s, size_t n, gm3Mesh m)
 Formats a gm3Mesh into a human-readable string for debugging.

Detailed Description

Provides macros and functions for debugging output in Gama.

This file offers utilities to print the state of various Gama data structures to the console, aiding in debugging and development.

Macro Definition Documentation

◆ gmd

#define gmd ( fn,
obj,
e )
Value:
do { \
char __gmd_str[200]; \
/* Use sizeof the buffer, not sizeof the number 200 */ \
gmd_##fn(__gmd_str, sizeof(__gmd_str), obj); \
printf("<%s>%s", __gmd_str, e); \
} while (0)

Generic macro to print debug information for an object.

This macro calls a specific gmd_ formatting function, prints the result to stdout, and appends an optional end string.

Parameters
fnThe debug formatting function to use (e.g., color, pos2, pos3, mesh).
objThe object to print debug information for.
eAn optional string to append after the debug output (e.g., "\n").

◆ gmdi

#define gmdi ( fn,
obj )
Value:
gmd(fn, obj, "")
#define gmd(fn, obj, e)
Generic macro to print debug information for an object.
Definition debug.h:40

Macro to print debug information for an object without a newline.

Parameters
fnThe debug formatting function (e.g., color, pos2, pos3, mesh).
objThe object to print.

◆ gmdn

#define gmdn ( fn,
obj )
Value:
gmd(fn, obj, "\n")

Macro to print debug information for an object with a newline.

Parameters
fnThe debug formatting function (e.g., color, pos2, pos3, mesh).
objThe object to print.

Function Documentation

◆ gmd_color()

int gmd_color ( char * s,
size_t n,
gmColor c )

Formats a gmColor into a human-readable string for debugging.

Parameters
sThe buffer to write the formatted string into.
nThe size of the buffer.
cThe gmColor to format.
Returns
The number of characters written to the buffer.

◆ gmd_mesh()

int gmd_mesh ( char * s,
size_t n,
gm3Mesh m )

Formats a gm3Mesh into a human-readable string for debugging.

Parameters
sThe buffer to write the formatted string into.
nThe size of the buffer.
mThe gm3Mesh to format.
Returns
The number of characters written to the buffer.

◆ gmd_pos2()

int gmd_pos2 ( char * s,
size_t n,
gmPos p )

Formats a gmPos (2D position) into a human-readable string for debugging.

Parameters
sThe buffer to write the formatted string into.
nThe size of the buffer.
pThe gmPos to format.
Returns
The number of characters written to the buffer.

◆ gmd_pos3()

int gmd_pos3 ( char * s,
size_t n,
gm3Pos p )

Formats a gm3Pos (3D position) into a human-readable string for debugging.

Parameters
sThe buffer to write the formatted string into.
nThe size of the buffer.
pThe gm3Pos to format.
Returns
The number of characters written to the buffer.