edn_turbo 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -40
- data/ext/edn_turbo/edn_parser.cc +1651 -1529
- data/ext/edn_turbo/edn_parser.h +15 -12
- data/ext/edn_turbo/edn_parser.rl +375 -327
- data/ext/edn_turbo/edn_parser_unicode.cc +1 -1
- data/ext/edn_turbo/{edn_parser_def.cc → edn_parser_util.cc} +23 -15
- data/lib/edn_turbo/version.rb +2 -2
- data/test/test_output_diff.rb +1 -1
- metadata +3 -3
@@ -15,7 +15,7 @@ namespace edn
|
|
15
15
|
//
|
16
16
|
// unescapes any values that need to be replaced, saves it to utf8
|
17
17
|
//
|
18
|
-
bool Parser::
|
18
|
+
bool Parser::to_utf8(const char *s, std::size_t len, std::string& rslt)
|
19
19
|
{
|
20
20
|
icu::UnicodeString ustr(s, len);
|
21
21
|
|
@@ -13,6 +13,8 @@
|
|
13
13
|
|
14
14
|
namespace edn
|
15
15
|
{
|
16
|
+
//
|
17
|
+
// used to determine max number of chars in string value of a type
|
16
18
|
template <typename T>
|
17
19
|
static std::size_t get_max_chars(T)
|
18
20
|
{
|
@@ -57,19 +59,25 @@ namespace edn
|
|
57
59
|
//
|
58
60
|
// copies the string data, unescaping any present values that need to be replaced
|
59
61
|
//
|
60
|
-
bool Parser::parse_byte_stream(const char *p_start, const char *p_end, Rice::String& s
|
62
|
+
bool Parser::parse_byte_stream(const char *p_start, const char *p_end, Rice::String& s,
|
63
|
+
bool encode)
|
61
64
|
{
|
62
65
|
if (p_end > p_start) {
|
63
66
|
std::string buf;
|
64
67
|
|
65
|
-
if (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return true;
|
68
|
+
if (encode) {
|
69
|
+
if (!to_utf8(p_start, p_end - p_start, buf))
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
buf.append(p_start, p_end - p_start);
|
72
74
|
}
|
75
|
+
|
76
|
+
// utf-8 encode
|
77
|
+
VALUE vs = Rice::protect( rb_str_new2, buf.c_str() );
|
78
|
+
VALUE s_utf8 = Rice::protect( rb_enc_associate, vs, rb_utf8_encoding() );
|
79
|
+
s = Rice::String(s_utf8);
|
80
|
+
return true;
|
73
81
|
}
|
74
82
|
|
75
83
|
return false;
|
@@ -85,14 +93,14 @@ namespace edn
|
|
85
93
|
buf.append(p, len);
|
86
94
|
|
87
95
|
if (len > 1) {
|
88
|
-
if (buf == "newline") buf =
|
89
|
-
else if (buf == "tab") buf =
|
90
|
-
else if (buf == "return") buf =
|
91
|
-
else if (buf == "space") buf =
|
92
|
-
else if (buf == "formfeed") buf =
|
93
|
-
else if (buf == "backspace") buf =
|
96
|
+
if (buf == "newline") buf = '\n';
|
97
|
+
else if (buf == "tab") buf = '\t';
|
98
|
+
else if (buf == "return") buf = '\r';
|
99
|
+
else if (buf == "space") buf = ' ';
|
100
|
+
else if (buf == "formfeed") buf = '\f';
|
101
|
+
else if (buf == "backspace") buf = '\b';
|
94
102
|
// TODO: is this supported?
|
95
|
-
else if (buf == "verticaltab") buf =
|
103
|
+
else if (buf == "verticaltab") buf = '\v';
|
96
104
|
else return false;
|
97
105
|
}
|
98
106
|
|
data/lib/edn_turbo/version.rb
CHANGED
data/test/test_output_diff.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn_turbo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Porras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: edn
|
@@ -83,8 +83,8 @@ files:
|
|
83
83
|
- ext/edn_turbo/edn_parser.cc
|
84
84
|
- ext/edn_turbo/edn_parser.h
|
85
85
|
- ext/edn_turbo/edn_parser.rl
|
86
|
-
- ext/edn_turbo/edn_parser_def.cc
|
87
86
|
- ext/edn_turbo/edn_parser_unicode.cc
|
87
|
+
- ext/edn_turbo/edn_parser_util.cc
|
88
88
|
- ext/edn_turbo/extconf.rb
|
89
89
|
- ext/edn_turbo/main.cc
|
90
90
|
- lib/edn_turbo.rb
|