YAML: add a debug word to check sizes of structs
parent
64db12711a
commit
5b5a680fb4
|
@ -1,8 +1,10 @@
|
|||
! Copyright (C) 2014 Jon Harper.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.data classes.struct combinators
|
||||
continuations destructors io.encodings.string io.encodings.utf8
|
||||
kernel libc locals prettyprint sequences yaml.ffi ;
|
||||
USING: accessors alien.c-types alien.data assocs classes.struct
|
||||
combinators continuations destructors io io.backend
|
||||
io.encodings.ascii io.encodings.string io.encodings.utf8
|
||||
io.launcher kernel libc locals math.parser prettyprint sequences
|
||||
yaml.ffi ;
|
||||
IN: yaml.dbg
|
||||
|
||||
: event. ( event -- )
|
||||
|
@ -41,3 +43,65 @@ f :> done!
|
|||
] with-destructors
|
||||
|
||||
;
|
||||
|
||||
: factor-struct-sizes ( -- arr ) {
|
||||
yaml_version_directive_t
|
||||
yaml_tag_directive_t
|
||||
yaml_mark_t
|
||||
stream_start_token_data
|
||||
alias_token_data
|
||||
anchor_token_data
|
||||
tag_token_data
|
||||
scalar_token_data
|
||||
version_directive_token_data
|
||||
yaml_token_t
|
||||
stream_start_event_data
|
||||
tag_directives_document_start_event_data
|
||||
document_start_event_data
|
||||
document_end_event_data
|
||||
alias_event_data
|
||||
scalar_event_data
|
||||
sequence_start_event_data
|
||||
mapping_start_event_data
|
||||
yaml_event_t
|
||||
yaml_node_pair_t
|
||||
scalar_node_data
|
||||
sequence_node_data_items
|
||||
sequence_node_data
|
||||
mapping_node_data_pairs
|
||||
mapping_node_data
|
||||
yaml_node_t
|
||||
yaml_document_nodes
|
||||
yaml_document_tag_directives
|
||||
yaml_document_t
|
||||
yaml_simple_key_t
|
||||
yaml_alias_data_t
|
||||
string_yaml_parser_input
|
||||
yaml_parser_buffer
|
||||
yaml_parser_raw_buffer
|
||||
yaml_parser_tokens
|
||||
yaml_parser_indents
|
||||
yaml_parser_simple_keys
|
||||
yaml_parser_states
|
||||
yaml_parser_marks
|
||||
yaml_parser_tag_directives
|
||||
yaml_parser_aliases
|
||||
yaml_parser_t
|
||||
yaml_emitter_output_string
|
||||
yaml_emitter_buffer
|
||||
yaml_emitter_raw_buffer
|
||||
yaml_emitter_states
|
||||
yaml_emitter_events
|
||||
yaml_emitter_indents
|
||||
yaml_emitter_tag_directives
|
||||
yaml_emitter_anchor_data
|
||||
yaml_emitter_tag_data
|
||||
yaml_emitter_scalar_data
|
||||
yaml_emitter_anchors
|
||||
yaml_emitter_t }
|
||||
[ heap-size ] map ;
|
||||
|
||||
: c-struct-sizes ( -- sizes ) "vocab:yaml/dbg/structs" normalize-path ascii <process-reader> stream-lines [ string>number ] map ;
|
||||
|
||||
: struct-sizes-dbg ( -- )
|
||||
c-struct-sizes factor-struct-sizes zip [ first2 = not ] find . . ;
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <yaml.h>
|
||||
|
||||
yaml_token_t yaml_token;
|
||||
yaml_event_t yaml_event;
|
||||
yaml_node_t yaml_node;
|
||||
yaml_document_t yaml_document;
|
||||
yaml_parser_t yaml_parser;
|
||||
yaml_emitter_t yaml_emitter;
|
||||
|
||||
int main() {
|
||||
printf("%ld\n", sizeof(yaml_version_directive_t));
|
||||
printf("%ld\n", sizeof(yaml_tag_directive_t));
|
||||
printf("%ld\n", sizeof(yaml_mark_t));
|
||||
printf("%ld\n", sizeof(yaml_token.data.stream_start));
|
||||
printf("%ld\n", sizeof(yaml_token.data.alias));
|
||||
printf("%ld\n", sizeof(yaml_token.data.anchor));
|
||||
printf("%ld\n", sizeof(yaml_token.data.tag));
|
||||
printf("%ld\n", sizeof(yaml_token.data.scalar));
|
||||
printf("%ld\n", sizeof(yaml_token.data.version_directive));
|
||||
printf("%ld\n", sizeof(yaml_token_t));
|
||||
printf("%ld\n", sizeof(yaml_event.data.stream_start));
|
||||
printf("%ld\n", sizeof(yaml_event.data.document_start.tag_directives));
|
||||
printf("%ld\n", sizeof(yaml_event.data.document_start));
|
||||
printf("%ld\n", sizeof(yaml_event.data.document_end));
|
||||
printf("%ld\n", sizeof(yaml_event.data.alias));
|
||||
printf("%ld\n", sizeof(yaml_event.data.scalar));
|
||||
printf("%ld\n", sizeof(yaml_event.data.sequence_start));
|
||||
printf("%ld\n", sizeof(yaml_event.data.mapping_start));
|
||||
printf("%ld\n", sizeof(yaml_event_t));
|
||||
printf("%ld\n", sizeof(yaml_node_pair_t));
|
||||
printf("%ld\n", sizeof(yaml_node.data.scalar));
|
||||
printf("%ld\n", sizeof(yaml_node.data.sequence.items));
|
||||
printf("%ld\n", sizeof(yaml_node.data.sequence));
|
||||
printf("%ld\n", sizeof(yaml_node.data.mapping.pairs));
|
||||
printf("%ld\n", sizeof(yaml_node.data.mapping));
|
||||
printf("%ld\n", sizeof(yaml_node_t));
|
||||
printf("%ld\n", sizeof(yaml_document.nodes));
|
||||
printf("%ld\n", sizeof(yaml_document.tag_directives));
|
||||
printf("%ld\n", sizeof(yaml_document_t));
|
||||
printf("%ld\n", sizeof(yaml_simple_key_t));
|
||||
printf("%ld\n", sizeof(yaml_alias_data_t));
|
||||
printf("%ld\n", sizeof(yaml_parser.input.string));
|
||||
printf("%ld\n", sizeof(yaml_parser.buffer));
|
||||
printf("%ld\n", sizeof(yaml_parser.raw_buffer));
|
||||
printf("%ld\n", sizeof(yaml_parser.tokens));
|
||||
printf("%ld\n", sizeof(yaml_parser.indents));
|
||||
printf("%ld\n", sizeof(yaml_parser.simple_keys));
|
||||
printf("%ld\n", sizeof(yaml_parser.states));
|
||||
printf("%ld\n", sizeof(yaml_parser.marks));
|
||||
printf("%ld\n", sizeof(yaml_parser.tag_directives));
|
||||
printf("%ld\n", sizeof(yaml_parser.aliases));
|
||||
printf("%ld\n", sizeof(yaml_parser_t));
|
||||
printf("%ld\n", sizeof(yaml_emitter.output.string));
|
||||
printf("%ld\n", sizeof(yaml_emitter.buffer));
|
||||
printf("%ld\n", sizeof(yaml_emitter.raw_buffer));
|
||||
printf("%ld\n", sizeof(yaml_emitter.states));
|
||||
printf("%ld\n", sizeof(yaml_emitter.events));
|
||||
printf("%ld\n", sizeof(yaml_emitter.indents));
|
||||
printf("%ld\n", sizeof(yaml_emitter.tag_directives));
|
||||
printf("%ld\n", sizeof(yaml_emitter.anchor_data));
|
||||
printf("%ld\n", sizeof(yaml_emitter.tag_data));
|
||||
printf("%ld\n", sizeof(yaml_emitter.scalar_data));
|
||||
printf("%ld\n", sizeof(*(yaml_emitter.anchors)));
|
||||
printf("%ld\n", sizeof(yaml_emitter_t));
|
||||
}
|
Loading…
Reference in New Issue