typedefs.h#
Clearer C types and useful platform-agnostic macros.
Authors#
TheSilvered
Macros#
Nst_DBG_TRACK_OBJ_INIT_POS#
Description:
If defined enables tracking of the position in the program where objects are
allocated. This macro should be defined in typedefs.h when compiling.
Note
This macro works only when the program is compiled in debug mode.
Nst_DBG_DISABLE_POOLS#
Description:
If defined disables object pools and instead frees the memory of each object.
This macro should be defined in typedefs.h when compiling.
Note
This macro works only when the program is compiled in debug mode.
Nst_DBG_COUNT_ALLOC#
Description:
If defined enables allocation counting and declares the
Nst_log_alloc_count function. This macro
should be defined in typedefs.h when compiling.
Note
This macro works only when the program is compiled in debug mode.
Nst_DBG_ASSERT_CALLBACK#
Description:
Used in Nst_assert and
Nst_assert_c, in debug mode is abort() by
default.
Nst_DBG_KEEP_DYN_LIBS#
Description:
If defined dynamic libraries are not closed when calling
Nst_quit to allow the checking of stack
traces in memory allocations after the library is closed.
Nst_MSVC#
Description:
Defined when compiling with MSVC.
Nst_CLANG#
Description:
Defined when compiling with Clang.
Nst_GCC#
Description:
Defined when compiling with GCC.
_Nst_ARCH_x64#
Description:
Defined when compiling on 64-bit architectures.
_Nst_ARCH_x86#
Description:
Defined when compiling on 32-bit architectures.
NstEXP#
Description:
Exports a symbol in a dynamic library.
Nst_NORETURN#
Description:
Marks a function that does not finish.
Nst_WIN_FMT#
Description:
Marks an argument as a printf format string on MSVC.
Nst_NIX_FMT#
Synopsis:
#define Nst_NIX_FMT(m, n)
Description:
Marks an argument as a printf format string on GCC or CLANG.
Nst_LITTLE_ENDIAN#
Description:
Represents little-endian systems, check against Nst_BYTEORDER.
Nst_BIG_ENDIAN#
Description:
Represents big-endian systems, check against Nst_BYTEORDER.
Nst_BYTEORDER#
Description:
The endianness of the system, either
Nst_LITTLE_ENDIAN or
Nst_BIG_ENDIAN.
NstC#
Description:
Marks a function for for the standard C declaration (__cdecl).
Nst_UNUSED#
Synopsis:
#define Nst_UNUSED(v)
Description:
Marks the argument of a function as unused, without rasing any compiler warnings.
Nst_assert#
Synopsis:
#define Nst_assert(expr)
Description:
Evaluates Nst_DBG_ASSERT_CALLBACK
and prints an error message when expr is false. The error specifies the
expression that is false, the path and line number of both the C and Nest file
where the assertion failed.
Nst_assert_c#
Synopsis:
#define Nst_assert_c(expr)
Description:
Evaluates Nst_DBG_ASSERT_CALLBACK
and prints an error message when expr is false. The error specifies the
expression that is false, the path and line number of the C file where.
Nst_UNREACHABLE#
Description:
Marks an execution path as unreachable.
Nst_LIKELY#
Synopsis:
#define Nst_LIKELY(expr)
Description:
Marks a condition as likely to be true.
Nst_UNLIKELY#
Synopsis:
#define Nst_UNLIKELY(expr)
Description:
Marks a condition as likely to be false.
Structs#
Nst_Obj#
Synopsis:
typedef struct _Nst_Obj {
struct _Nst_Obj *type;
struct _Nst_Obj *p_next;
isize ref_count;
i32 hash;
u32 flags;
#ifdef Nst_DBG_TRACK_OBJ_INIT_POS
i32 init_line;
i32 init_col;
char *init_path;
#endif // !Nst_DBG_TRACK_OBJ_INIT_POS
} Nst_Obj
Description:
The structure representing a basic Nest object.
Fields:
ref_count: the reference count of the objecttype: the type of the objectp_next: the next object in the type's poolhash: the hash of the object,-1if it has not yet been hashed or is not hashableflags: the flags of the objectinit_line: this field only exists whenNst_DBG_TRACK_OBJ_INIT_POSis defined - the line of the instruction that initialized the objectinit_col: this field only exists whenNst_DBG_TRACK_OBJ_INIT_POSis defined - the column of the instruction that initialized the objectinit_path: this field only exists whenNst_DBG_TRACK_OBJ_INIT_POSis defined - the path to the file where the object was initialized
Type aliases#
i8#
Synopsis:
typedef int8_t i8
Description:
8-bit signed integer.
i16#
Synopsis:
typedef int16_t i16
Description:
16-bit signed integer.
i32#
Synopsis:
typedef int32_t i32
Description:
32-bit signed integer.
i64#
Synopsis:
typedef int64_t i64
Description:
64-bit signed integer.
u8#
Synopsis:
typedef uint8_t u8
Description:
8-bit unsigned integer.
u16#
Synopsis:
typedef uint16_t u16
Description:
16-bit unsigned integer.
uint#
Synopsis:
typedef unsigned int uint
Description:
unsigned int alias.
u32#
Synopsis:
typedef uint32_t u32
Description:
32-bit unsigned integer.
u64#
Synopsis:
typedef uint64_t u64
Description:
64-bit unsigned integer.
f32#
Synopsis:
typedef float f32
Description:
float alias.
f64#
Synopsis:
typedef double f64
Description:
double alias.
usize#
Synopsis:
typedef size_t usize
Description:
size_t alias.
isize#
Synopsis:
typedef ptrdiff_t isize
Description:
ptrdiff_t alias.
Nst_ObjRef#
Synopsis:
typedef Nst_Obj Nst_ObjRef
Description:
Using Nst_ObjRef * instead of
Nst_Obj * signals that an object reference is
being passed or owned. Depending on context it has different meanings:
- When used as the type of a function argument it signals that a reference is taken from the argument itself.
- When used as the type of the return value of a function it signals that the function returns a new reference to the object.
- When used in a struct it signals that the struct owns a reference to the object.
Nst_NestCallable#
Synopsis:
typedef Nst_ObjRef *(*Nst_NestCallable)(usize, Nst_Obj **)
Description:
The signature of a C function callable by Nest.
Nst_Destructor#
Synopsis:
typedef void (*Nst_Destructor)(void *)
Description:
The signature of a generic destructor.