fast-xml 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +145 -37
- data/ext/fastxml/ccan/build_assert/build_assert.h +40 -0
- data/ext/fastxml/ccan/check_type/check_type.h +63 -0
- data/ext/fastxml/ccan/container_of/container_of.h +142 -0
- data/ext/fastxml/ccan/list/list.h +773 -0
- data/ext/fastxml/ccan/str/str.h +16 -0
- data/ext/fastxml/fastxml.c +35 -2
- data/ext/fastxml/xh.c +19 -8
- data/ext/fastxml/xh.h +2 -1
- data/ext/fastxml/xh_config.h +3 -0
- data/ext/fastxml/xh_core.h +1 -5
- data/ext/fastxml/xh_log.h +37 -27
- data/ext/fastxml/xh_param.c +3 -11
- data/ext/fastxml/xh_param.h +1 -1
- data/ext/fastxml/xh_reader.c +528 -0
- data/ext/fastxml/xh_reader.h +43 -0
- data/ext/fastxml/xh_ruby_hash.h +384 -0
- data/ext/fastxml/xh_x2h.c +1002 -0
- data/ext/fastxml/xh_x2h.h +133 -0
- data/lib/fastxml/version.rb +1 -1
- metadata +13 -3
@@ -0,0 +1,133 @@
|
|
1
|
+
#ifndef _XH_X2H_H_
|
2
|
+
#define _XH_X2H_H_
|
3
|
+
|
4
|
+
#include "xh_config.h"
|
5
|
+
#include "xh_core.h"
|
6
|
+
|
7
|
+
#define XH_X2H_XPATH_MAX_LEN 1023
|
8
|
+
|
9
|
+
#define XH_X2H_NORMALIZE_REF 1
|
10
|
+
#define XH_X2H_NORMALIZE_LINE_FEED 2
|
11
|
+
#define XH_X2H_FILTER_ENABLED 4
|
12
|
+
#define XH_X2H_FILTER_MATCHED 8
|
13
|
+
#define XH_X2H_ROOT_FOUND 16
|
14
|
+
#define XH_X2H_IS_NOT_BLANK 32
|
15
|
+
|
16
|
+
#define XH_X2H_NEED_NORMALIZE (XH_X2H_NORMALIZE_REF | \
|
17
|
+
XH_X2H_NORMALIZE_LINE_FEED)
|
18
|
+
#define XH_X2H_FILTER_SEARCH(f) (((f) & (XH_X2H_FILTER_ENABLED | XH_X2H_FILTER_MATCHED)) ==\
|
19
|
+
XH_X2H_FILTER_ENABLED)
|
20
|
+
|
21
|
+
#define XH_X2H_PARSER_STATE_LIST \
|
22
|
+
XH_X2H_PROCESS_STATE(CONTENT_START) \
|
23
|
+
XH_X2H_PROCESS_STATE(PARSE_ELEMENT_START) \
|
24
|
+
XH_X2H_PROCESS_STATE(XML_COMMENT_NODE_OR_CDATA_START) \
|
25
|
+
XH_X2H_PROCESS_STATE(COMMENT1_START) \
|
26
|
+
XH_X2H_PROCESS_STATE(END_COMMENT1_START) \
|
27
|
+
XH_X2H_PROCESS_STATE(END_COMMENT2_START) \
|
28
|
+
XH_X2H_PROCESS_STATE(END_COMMENT3_START) \
|
29
|
+
XH_X2H_PROCESS_STATE(CDATA_1_1_START) \
|
30
|
+
XH_X2H_PROCESS_STATE(CDATA_1_2_START) \
|
31
|
+
XH_X2H_PROCESS_STATE(CDATA_1_3_START) \
|
32
|
+
XH_X2H_PROCESS_STATE(CDATA_2_1_START) \
|
33
|
+
XH_X2H_PROCESS_STATE(CDATA_2_2_START) \
|
34
|
+
XH_X2H_PROCESS_STATE(CDATA_2_3_START) \
|
35
|
+
XH_X2H_PROCESS_STATE(END_CDATA1_START) \
|
36
|
+
XH_X2H_PROCESS_STATE(END_CDATA2_START) \
|
37
|
+
XH_X2H_PROCESS_STATE(END_CDATA3_START) \
|
38
|
+
XH_X2H_PROCESS_STATE(CDATA_WITH_TRIM_1_1_START) \
|
39
|
+
XH_X2H_PROCESS_STATE(CDATA_WITH_TRIM_1_2_START) \
|
40
|
+
XH_X2H_PROCESS_STATE(CDATA_WITH_TRIM_1_3_START) \
|
41
|
+
XH_X2H_PROCESS_STATE(CDATA_WITH_TRIM_2_1_START) \
|
42
|
+
XH_X2H_PROCESS_STATE(CDATA_WITH_TRIM_2_2_START) \
|
43
|
+
XH_X2H_PROCESS_STATE(CDATA_WITH_TRIM_2_3_START) \
|
44
|
+
XH_X2H_PROCESS_STATE(END_CDATA_WITH_TRIM1_START) \
|
45
|
+
XH_X2H_PROCESS_STATE(END_CDATA_WITH_TRIM2_START) \
|
46
|
+
XH_X2H_PROCESS_STATE(END_CDATA_WITH_TRIM3_START) \
|
47
|
+
XH_X2H_PROCESS_STATE(PARSE_CLOSING_TAG_START) \
|
48
|
+
XH_X2H_PROCESS_STATE(SEARCH_CLOSING_END_TAG_START) \
|
49
|
+
XH_X2H_PROCESS_STATE(PARSE_OPENING_TAG_START) \
|
50
|
+
XH_X2H_PROCESS_STATE(SEARCH_OPENING_END_TAG_START) \
|
51
|
+
XH_X2H_PROCESS_STATE(NODE_SEARCH_ATTR_START) \
|
52
|
+
XH_X2H_PROCESS_STATE(SEARCH_END_TAG_START) \
|
53
|
+
XH_X2H_PROCESS_STATE(NODE_PARSE_ATTR_NAME_START) \
|
54
|
+
XH_X2H_PROCESS_STATE(NODE_ATTR_SKIP_BLANK_START) \
|
55
|
+
XH_X2H_PROCESS_STATE(NODE_PARSE_ATTR_VALUE_START) \
|
56
|
+
XH_X2H_PROCESS_STATE(NODE_1_END_ATTR_VALUE_START) \
|
57
|
+
XH_X2H_PROCESS_STATE(NODE_2_END_ATTR_VALUE_START) \
|
58
|
+
XH_X2H_PROCESS_STATE(XML_DECL_1_START) \
|
59
|
+
XH_X2H_PROCESS_STATE(XML_DECL_2_START) \
|
60
|
+
XH_X2H_PROCESS_STATE(XML_DECL_3_START) \
|
61
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_START) \
|
62
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_SEARCH_ATTR_START) \
|
63
|
+
XH_X2H_PROCESS_STATE(XML_DECL_SEARCH_END_TAG2_START) \
|
64
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_PARSE_ATTR_NAME_START) \
|
65
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_ATTR_SKIP_BLANK_START) \
|
66
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_PARSE_ATTR_VALUE_START) \
|
67
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_1_END_ATTR_VALUE_START) \
|
68
|
+
XH_X2H_PROCESS_STATE(XML_DECL_ATTR_2_END_ATTR_VALUE_START)
|
69
|
+
|
70
|
+
#define XH_X2H_PROCESS_STATE(st) st,
|
71
|
+
typedef enum {
|
72
|
+
PARSER_ST_NONE = 0,
|
73
|
+
XH_X2H_PARSER_STATE_LIST
|
74
|
+
XML_DECL_FOUND,
|
75
|
+
PARSER_ST_DONE
|
76
|
+
} xh_x2h_state_t;
|
77
|
+
#undef XH_X2H_PROCESS_STATE
|
78
|
+
|
79
|
+
#define XH_X2H_NODE_FLAG_NONE 0
|
80
|
+
#define XH_X2H_NODE_FLAG_FORCE_ARRAY 1
|
81
|
+
|
82
|
+
typedef struct {
|
83
|
+
VALUE *lval;
|
84
|
+
unsigned int flags;
|
85
|
+
} xh_x2h_node_t;
|
86
|
+
|
87
|
+
typedef struct {
|
88
|
+
xh_opts_t opts;
|
89
|
+
VALUE hash;
|
90
|
+
xh_char_t encoding[XH_PARAM_LEN];
|
91
|
+
xh_char_t *tmp;
|
92
|
+
size_t tmp_size;
|
93
|
+
xh_char_t *node, *end, *content;
|
94
|
+
unsigned int flags;
|
95
|
+
xh_x2h_node_t *nodes;
|
96
|
+
VALUE *lval;
|
97
|
+
unsigned int depth, real_depth, code;
|
98
|
+
xh_x2h_state_t state;
|
99
|
+
xh_reader_t reader;
|
100
|
+
VALUE result, input;
|
101
|
+
xh_char_t xpath[XH_X2H_XPATH_MAX_LEN + 1];
|
102
|
+
} xh_x2h_ctx_t;
|
103
|
+
|
104
|
+
VALUE xh_x2h(xh_x2h_ctx_t *ctx);
|
105
|
+
|
106
|
+
XH_INLINE void
|
107
|
+
xh_x2h_destroy_ctx(xh_x2h_ctx_t *ctx)
|
108
|
+
{
|
109
|
+
if (ctx->nodes != NULL) free(ctx->nodes);
|
110
|
+
if (ctx->tmp != NULL) free(ctx->tmp);
|
111
|
+
|
112
|
+
xh_destroy_opts(&ctx->opts);
|
113
|
+
}
|
114
|
+
|
115
|
+
XH_INLINE void
|
116
|
+
xh_x2h_init_ctx(xh_x2h_ctx_t *ctx, xh_int_t argc, VALUE *argv)
|
117
|
+
{
|
118
|
+
xh_opts_t *opts = NULL;
|
119
|
+
xh_int_t nparam = 0;
|
120
|
+
|
121
|
+
memset(ctx, 0, sizeof(xh_x2h_ctx_t));
|
122
|
+
|
123
|
+
//opts = (xh_opts_t *) xh_get_obj_param(&nparam, ax, items, "XML::Hash::XS");
|
124
|
+
ctx->input = xh_get_str_param(&nparam, argc, argv);
|
125
|
+
xh_merge_opts(&ctx->opts, opts, &nparam, argc, argv);
|
126
|
+
|
127
|
+
if ((ctx->nodes = malloc(sizeof(xh_x2h_node_t) * ctx->opts.max_depth)) == NULL) {
|
128
|
+
rb_raise(rb_eNoMemError, "Memory allocation error");
|
129
|
+
}
|
130
|
+
memset(ctx->nodes, 0, sizeof(xh_x2h_node_t) * ctx->opts.max_depth);
|
131
|
+
}
|
132
|
+
|
133
|
+
#endif /* _XH_X2H_H_ */
|
data/lib/fastxml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuriy Ustushenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -77,6 +77,11 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- LICENSE
|
79
79
|
- README.md
|
80
|
+
- ext/fastxml/ccan/build_assert/build_assert.h
|
81
|
+
- ext/fastxml/ccan/check_type/check_type.h
|
82
|
+
- ext/fastxml/ccan/container_of/container_of.h
|
83
|
+
- ext/fastxml/ccan/list/list.h
|
84
|
+
- ext/fastxml/ccan/str/str.h
|
80
85
|
- ext/fastxml/extconf.rb
|
81
86
|
- ext/fastxml/fastxml.c
|
82
87
|
- ext/fastxml/fastxml.h
|
@@ -97,8 +102,11 @@ files:
|
|
97
102
|
- ext/fastxml/xh_log.h
|
98
103
|
- ext/fastxml/xh_param.c
|
99
104
|
- ext/fastxml/xh_param.h
|
105
|
+
- ext/fastxml/xh_reader.c
|
106
|
+
- ext/fastxml/xh_reader.h
|
100
107
|
- ext/fastxml/xh_ruby_buffer.c
|
101
108
|
- ext/fastxml/xh_ruby_buffer.h
|
109
|
+
- ext/fastxml/xh_ruby_hash.h
|
102
110
|
- ext/fastxml/xh_sort.c
|
103
111
|
- ext/fastxml/xh_sort.h
|
104
112
|
- ext/fastxml/xh_stack.c
|
@@ -106,6 +114,8 @@ files:
|
|
106
114
|
- ext/fastxml/xh_string.h
|
107
115
|
- ext/fastxml/xh_writer.c
|
108
116
|
- ext/fastxml/xh_writer.h
|
117
|
+
- ext/fastxml/xh_x2h.c
|
118
|
+
- ext/fastxml/xh_x2h.h
|
109
119
|
- ext/fastxml/xh_xml.h
|
110
120
|
- lib/fastxml.rb
|
111
121
|
- lib/fastxml/error.rb
|
@@ -132,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
142
|
version: '0'
|
133
143
|
requirements: []
|
134
144
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.6.12
|
136
146
|
signing_key:
|
137
147
|
specification_version: 4
|
138
148
|
summary: Fast Ruby Hash to XML and XML to Ruby Hash converter
|