diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-19 09:49:20 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-19 09:49:20 +0300 |
commit | 304935a296997c9781688f08693ef70180dd24e4 (patch) | |
tree | 7b7801f3a97a780af1719826b2b9ef471151a352 /src/grecs.h | |
parent | 6ef143bd53c35635b6d7edc6410d45fa58f54da2 (diff) | |
download | grecs-304935a296997c9781688f08693ef70180dd24e4.tar.gz grecs-304935a296997c9781688f08693ef70180dd24e4.tar.bz2 |
Reimplement grecs_format_ familiy as output-independent functions.
* src/format.c (grecs_format_docstring): Rename to grecs_print_docstring.
(grecs_format_simple_statement): Rename to grecs_print_simple_statement.
(grecs_format_block_statement): Rename to grecs_print_block_statement.
(grecs_format_statement_array): Rename to grecs_print_statement_array.
(grecs_format_locus): Rename to grecs_print_locus.
(grecs_format_node_path): Rename to grecs_print_node_path.
(grecs_format_value): Rename to grecs_print_value.
(grecs_format_node): Rename to grecs_print_node.
(grecs_format_locus,grecs_format_node_path)
(grecs_format_value,grecs_format_node): Reimplement as
output-independent functions.
All uses changed.
* src/grecs.h: Update prototypes.
* doc/grecs_format_locus.3: Update.
* doc/grecs_format_node.3: Update.
* doc/grecs_format_node_path.3: Update.
* doc/grecs_format_value.3: Update.
Diffstat (limited to 'src/grecs.h')
-rw-r--r-- | src/grecs.h | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/grecs.h b/src/grecs.h index 3662204..fd44e40 100644 --- a/src/grecs.h +++ b/src/grecs.h @@ -279,23 +279,27 @@ void grecs_include_path_setup_v(char **dirs); ssize_t grecs_getline(char **pbuf, size_t *psize, FILE *fp); const char *grecs_data_type_string(enum grecs_data_type type); -void grecs_format_docstring(const char *docstring, unsigned level, - FILE *stream); -void grecs_format_simple_statement(struct grecs_keyword *kwp, - unsigned level, FILE *stream); -void grecs_format_block_statement(struct grecs_keyword *kwp, +void grecs_print_docstring(const char *docstring, unsigned level, + FILE *stream); +void grecs_print_simple_statement(struct grecs_keyword *kwp, unsigned level, FILE *stream); -void grecs_format_statement_array(struct grecs_keyword *kwp, - unsigned n, - unsigned level, FILE *stream); - -void grecs_format_locus(grecs_locus_t *locus, FILE *fp); -void grecs_format_node_path(struct grecs_node *node, int flag, FILE *fp); -void grecs_format_value(struct grecs_value *val, int flags, FILE *fp); +void grecs_print_block_statement(struct grecs_keyword *kwp, + unsigned level, FILE *stream); +void grecs_print_statement_array(struct grecs_keyword *kwp, + unsigned n, + unsigned level, FILE *stream); + +struct grecs_format_closure +{ + int (*fmtfun)(const char *, void *); + void *data; +}; -struct grecs_txtacc; -void grecs_txtacc_format_value(struct grecs_value *val, int flags, - struct grecs_txtacc *acc); +void grecs_format_locus(grecs_locus_t *locus, struct grecs_format_closure *fp); +void grecs_format_node_path(struct grecs_node *node, int flag, + struct grecs_format_closure *fp); +void grecs_format_value(struct grecs_value *val, int flags, + struct grecs_format_closure *fp); #define GRECS_NODE_FLAG_LOCUS 0x0100 #define GRECS_NODE_FLAG_PATH 0x0200 @@ -306,7 +310,20 @@ void grecs_txtacc_format_value(struct grecs_value *val, int flags, #define GRECS_NODE_FLAG_NODESCEND 0x4000 #define GRECS_NODE_FLAG_DEFAULT \ (GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE|GRECS_NODE_FLAG_QUOTE) -void grecs_format_node(struct grecs_node *node, int flags, FILE *fp); +void grecs_format_node(struct grecs_node *node, int flags, + struct grecs_format_closure *fp); + +void grecs_print_locus(grecs_locus_t *locus, FILE *fp); +void grecs_print_node_path(struct grecs_node *node, int flag, FILE *fp); +void grecs_print_value(struct grecs_value *val, int flags, FILE *fp); + +void grecs_print_node(struct grecs_node *node, int flags, FILE *fp); + +struct grecs_txtacc; +void grecs_txtacc_format_value(struct grecs_value *val, int flags, + struct grecs_txtacc *acc); + + struct grecs_list *grecs_list_create(void); size_t grecs_list_size(struct grecs_list *lp); |