Next: , Previous: , Up: Extension API Description   [Contents][Index]


16.4.4 Constructor Functions

The API provides a number of constructor functions for creating string and numeric values, as well as a number of convenience macros. This subsection presents them all as function prototypes, in the way that extension code would use them:

static inline awk_value_t *
make_const_string(const char *string, size_t length, awk_value_t *result);

This function creates a string value in the awk_value_t variable pointed to by result. It expects string to be a C string constant (or other string data), and automatically creates a copy of the data for storage in result. It returns result.

static inline awk_value_t *
make_malloced_string(const char *string, size_t length, awk_value_t *result);

This function creates a string value in the awk_value_t variable pointed to by result. It expects string to be a ‘char *’ value pointing to data previously obtained from gawk_malloc(), gawk_calloc(), or gawk_realloc(). The idea here is that the data is passed directly to gawk, which assumes responsibility for it. It returns result.

static inline awk_value_t *
make_null_string(awk_value_t *result);

This specialized function creates a null string (the “undefined” value) in the awk_value_t variable pointed to by result. It returns result.

static inline awk_value_t *
make_number(double num, awk_value_t *result);

This function simply creates a numeric value in the awk_value_t variable pointed to by result.