diff --git a/lib/hak-cmn.h b/lib/hak-cmn.h index 1ef77e6..778774e 100644 --- a/lib/hak-cmn.h +++ b/lib/hak-cmn.h @@ -840,22 +840,24 @@ typedef void* (*hak_mmgr_realloc_t) (hak_mmgr_t* mmgr, void* ptr, hak_oow_t n); typedef void (*hak_mmgr_free_t) (hak_mmgr_t* mmgr, void* ptr); /** - * The hak_mmgr_t type defines the memory management interface. - * As the type is merely a structure, it is just used as a single container - * for memory management functions with a pointer to user-defined data. - * The user-defined data pointer \a ctx is passed to each memory management - * function whenever it is called. You can allocate, reallocate, and free - * a memory chunk. + * The hak_mmgr_t type defines a memory management interface. It is a structure + * that serves as a container for function pointers to allocation, reallocation, + * and deallocation routines, along with a user-defined context pointer. * - * For example, a hak_xxx_open() function accepts a pointer of the hak_mmgr_t - * type and the xxx object uses it to manage dynamic data within the object. + * The \a ctx field stores a user-defined data pointer, which is passed to each + * memory management function whenever it is invoked. This allows the user to + * associate custom state or configuration with their memory manager. + * + * For example, a hak_xxx_open() function may accept a pointer to a hak_mmgr_t + * instance, enabling the xxx object to manage its dynamic memory through the + * provided allocation functions. */ struct hak_mmgr_t { hak_mmgr_alloc_t allocmem; /**< allocation function */ hak_mmgr_realloc_t reallocmem; /**< resizing function */ hak_mmgr_free_t freemem; /**< disposal function */ - void* ctx; /**< user-defined data pointer */ + void* ctx; /**< user-defined data pointer */ }; /** diff --git a/lib/hak-opt.h b/lib/hak-opt.h index 2fae883..e4337b9 100644 --- a/lib/hak-opt.h +++ b/lib/hak-opt.h @@ -107,7 +107,7 @@ extern "C" { * - \b ? indicates a bad option stored in the \a opt->opt field. * - \b : indicates a bad parameter for an option stored in the \a opt->opt field. * - * @return an option character on success, HAK_CHAR_EOF on no more options. + * \return an option character on success, HAK_CHAR_EOF on no more options. */ HAK_EXPORT hak_uci_t hak_getuopt ( int argc, /* argument count */ diff --git a/lib/hak-xma.h b/lib/hak-xma.h index e344d65..f15de84 100644 --- a/lib/hak-xma.h +++ b/lib/hak-xma.h @@ -25,7 +25,7 @@ #ifndef _HAK_XMA_H_ #define _HAK_XMA_H_ -/** @file +/** \file * This file defines an extravagant memory allocator. Why? It may be so. * The memory allocator allows you to maintain memory blocks from a * larger memory chunk allocated with an outer memory allocator. @@ -34,7 +34,7 @@ * * See the example below. Note it omits error handling. * - * @code + * \code * #include * #include * #include @@ -68,13 +68,13 @@ * hak_xma_close (xma); // destroy the memory allocator * return 0; * } - * @endcode + * \endcode */ #include #define HAK_XMA_ENABLE_STAT -/** @struct hak_xma_t +/** \struct hak_xma_t * The hak_xma_t type defines a simple memory allocator over a memory zone. * It can obtain a relatively large zone of memory and manage it. */ @@ -139,11 +139,11 @@ extern "C" { /** * The hak_xma_open() function creates a memory allocator. It obtains a memory - * zone of the @a zonesize bytes with the memory manager @a mmgr. It also makes - * available the extension area of the @a xtnsize bytes that you can get the + * zone of the \a zonesize bytes with the memory manager \a mmgr. It also makes + * available the extension area of the \a xtnsize bytes that you can get the * pointer to with hak_xma_getxtn(). * - * @return pointer to a memory allocator on success, #HAK_NULL on failure + * \return pointer to a memory allocator on success, #HAK_NULL on failure */ HAK_EXPORT hak_xma_t* hak_xma_open ( hak_mmgr_t* mmgr, /**< memory manager */ @@ -178,9 +178,9 @@ static HAK_INLINE void* hak_xma_getxtn (hak_xma_t* xma) { return (void*)(xma + 1 * The hak_xma_init() initializes a memory allocator. If you have the hak_xma_t * structure statically declared or already allocated, you may pass the pointer * to this function instead of calling hak_xma_open(). It obtains a memory zone - * of @a zonesize bytes with the memory manager @a mmgr. Unlike hak_xma_open(), + * of \a zonesize bytes with the memory manager \a mmgr. Unlike hak_xma_open(), * it does not accept the extension size, thus not creating an extention area. - * @return 0 on success, -1 on failure + * \return 0 on success, -1 on failure */ HAK_EXPORT int hak_xma_init ( hak_xma_t* xma, /**< memory allocator */ @@ -198,8 +198,8 @@ HAK_EXPORT void hak_xma_fini ( ); /** - * The hak_xma_alloc() function allocates @a size bytes. - * @return pointer to a memory block on success, #HAK_NULL on failure + * The hak_xma_alloc() function allocates \a size bytes. + * \return pointer to a memory block on success, #HAK_NULL on failure */ HAK_EXPORT void* hak_xma_alloc ( hak_xma_t* xma, /**< memory allocator */ @@ -212,8 +212,8 @@ HAK_EXPORT void* hak_xma_calloc ( ); /** - * The hak_xma_alloc() function resizes the memory block @a b to @a size bytes. - * @return pointer to a resized memory block on success, #HAK_NULL on failure + * The hak_xma_alloc() function resizes the memory block \a b to \a size bytes. + * \return pointer to a resized memory block on success, #HAK_NULL on failure */ HAK_EXPORT void* hak_xma_realloc ( hak_xma_t* xma, /**< memory allocator */ @@ -222,7 +222,7 @@ HAK_EXPORT void* hak_xma_realloc ( ); /** - * The hak_xma_alloc() function frees the memory block @a b. + * The hak_xma_alloc() function frees the memory block \a b. */ HAK_EXPORT void hak_xma_free ( hak_xma_t* xma, /**< memory allocator */ @@ -231,7 +231,7 @@ HAK_EXPORT void hak_xma_free ( /** * The hak_xma_dump() function dumps the contents of the memory zone - * with the output function @a dumper provided. The debug build shows + * with the output function \a dumper provided. The debug build shows * more statistical counters. */ HAK_EXPORT void hak_xma_dump ( diff --git a/lib/hak.h b/lib/hak.h index 446df87..2c6173e 100644 --- a/lib/hak.h +++ b/lib/hak.h @@ -94,6 +94,7 @@ enum hak_errnum_t HAK_EUNDEFVAR /**< runtime error - undefined variable access */ }; typedef enum hak_errnum_t hak_errnum_t; +/**/ enum hak_synerrnum_t { @@ -947,6 +948,7 @@ struct hak_class_t */ #define HAK_CLASSOF(hak,oop) \ (HAK_OOP_GET_TAG(oop)? ((hak_oop_t)(*(hak)->tagged_classes[HAK_OOP_GET_TAG(oop)])): HAK_OBJ_GET_CLASS(oop)) +/**/ /** @@ -956,6 +958,7 @@ struct hak_class_t */ #define HAK_BYTESOF(hak,oop) \ (HAK_OOP_IS_NUMERIC(oop)? HAK_SIZEOF(hak_oow_t): HAK_OBJ_BYTESOF(oop)) +/**/ /** @@ -963,6 +966,7 @@ struct hak_class_t */ #define HAK_ISTYPEOF(hak,oop,type) \ (!HAK_OOP_IS_NUMERIC(oop) && HAK_OBJ_GET_FLAGS_TYPE(oop) == (type)) +/**/ /* ========================================================================= * HEAP @@ -1270,6 +1274,9 @@ typedef struct hak_lxc_t hak_lxc_t; #define HAK_CCI_BUF_LEN (2048) #endif +/** + * The hak_io_cciarg_t defines the input stream to the compiler. + */ typedef struct hak_io_cciarg_t hak_io_cciarg_t; struct hak_io_cciarg_t { @@ -1336,7 +1343,11 @@ struct hak_io_cciarg_t hak_lxc_t lxc; /*-----------------------------------------------------------------*/ }; +/**/ +/** + * The hak_io_udiarg_t defines the user-defined input stream handler. + */ typedef struct hak_io_udiarg_t hak_io_udiarg_t; struct hak_io_udiarg_t { @@ -1384,7 +1395,11 @@ struct hak_io_udiarg_t int eof_reached; }; +/**/ +/** + * The hak_io_udiarg_t defines the user-defined output stream handler. + */ typedef struct hak_io_udoarg_t hak_io_udoarg_t; struct hak_io_udoarg_t { @@ -1415,6 +1430,7 @@ struct hak_io_udoarg_t */ hak_oow_t xlen; }; +/**/ /** * The hak_io_impl_t type defines a callback function prototype @@ -1425,6 +1441,7 @@ typedef int (*hak_io_impl_t) ( hak_io_cmd_t cmd, void* arg /* one of hak_io_cciarg_t*, hak_io_udiarg_t*, hak_io_udoarg_t* */ ); +/**/ /* ========================================================================= * CALLBACK MANIPULATION @@ -2106,27 +2123,39 @@ HAK_EXPORT const hak_bch_t* hak_obj_type_to_bcstr ( hak_obj_type_t type ); +/** + * The hak_open() function creates a hak object. + */ HAK_EXPORT hak_t* hak_open ( hak_mmgr_t* mmgr, hak_oow_t xtnsize, const hak_vmprim_t* vmprim, hak_errnum_t* errnum ); +/**/ +/** + * The hak_openstdwithmmgr() function creates a hak objuect with the default primitve functions. + */ HAK_EXPORT hak_t* hak_openstdwithmmgr ( hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_errnum_t* errnum ); +/**/ HAK_EXPORT hak_t* hak_openstd ( hak_oow_t xtnsize, hak_errnum_t* errnum ); +/** + * The hak_close() function destroys a hak object. + */ HAK_EXPORT void hak_close ( - hak_t* vm + hak_t* hak ); +/**/ HAK_EXPORT int hak_init ( hak_t* hak, diff --git a/t/fun-01.hak b/t/fun-01.hak index 374ec1b..94babdf 100644 --- a/t/fun-01.hak +++ b/t/fun-01.hak @@ -149,7 +149,7 @@ if (== v 9) { printf "OK - %d\n" v } else { printf "ERROR - %d, not 9\n" v } ## ---------------------------------------- fun sum (x) { - if (< x 2) 1 else { core.+ x (sum (- x 1)) } + if (core.< x 2) 1 else { core.+ x (sum (core.- x 1)) } } v := (sum 10) if (== v 55) { printf "OK - %d\n" v } else { printf "ERROR - %d, not 55\n" v }