diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-06 11:36:42 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-06 11:36:42 -0400 |
| commit | 57b97197153fa965a9ea43a57c63886a616c17c5 (patch) | |
| tree | 9b4fd7f85a5b3a61e855dab351a289f563385419 | |
| parent | fa56d845c05ddd9add3e59623d9f4d8f65dd717f (diff) | |
Add convenience function for debug printing
| -rw-r--r-- | builtins/functions.c | 5 | ||||
| -rw-r--r-- | builtins/functions.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/builtins/functions.c b/builtins/functions.c index 84b3051d..94dda009 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -182,6 +182,11 @@ public Text_t generic_as_text(const void *obj, bool colorize, const TypeInfo *ty } } +public int generic_print(const void *obj, bool colorize, const TypeInfo *type) +{ + Text_t text = generic_as_text(obj, colorize, type); + return Text$print(stdout, text) + printf("\n"); +} public Text_t builtin_last_err() { diff --git a/builtins/functions.h b/builtins/functions.h index 6445400a..372c42c4 100644 --- a/builtins/functions.h +++ b/builtins/functions.h @@ -25,6 +25,7 @@ uint64_t generic_hash(const void *obj, const TypeInfo *type); int32_t generic_compare(const void *x, const void *y, const TypeInfo *type); bool generic_equal(const void *x, const void *y, const TypeInfo *type); Text_t generic_as_text(const void *obj, bool colorize, const TypeInfo *type); +int generic_print(const void *obj, bool colorize, const TypeInfo *type); closure_t spawn(closure_t fn); bool pop_flag(char **argv, int *i, const char *flag, Text_t *result); |
