xs/Parser.xsi

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 176 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 235 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/MessageIterator.xsi ↑ Summary xs/ServerParser.xsi »
1 MODE: INLINE
2  
3 static inline Sv get_send_message_params (Parser::MessageBuilder& builder, SV** args, I32 items) {
4 Sv payload_sv;
5 for (I32 i = 0; i < items - 1; i += 2) {
6 auto name = xs::in<string_view>(args[i]);
7 if (!name.length()) continue;
8 auto val = args[i+1];
9 switch (name[0]) {
10 case 'd': if (name == "deflate" && sv_defined(val)) builder.deflate(SvTRUE(val)); break;
11 case 'o': if (name == "opcode") builder.opcode((Opcode)SvIV(val)); break;
12 case 'p': if (name == "payload") payload_sv = val; break;
13 }
14 }
15 return payload_sv;
16 }
17  
18 MODULE = Protocol::WebSocket::Fast PACKAGE = Protocol::WebSocket::Fast::Parser
19 PROTOTYPES: DISABLE
20  
21 0 ▶void Parser::configure (Parser::Config config)
Branch: 1 branch
BranchTrueFalseTotal
void Parser::configure (Parser::Config config) 0 0 0
22  
23 0 size_t Parser::max_frame_size ()
24  
25 0 size_t Parser::max_message_size ()
26  
27 0 size_t Parser::max_handshake_size ()
28  
29 Scalar Parser::deflate_config () {
30 0 ▶ auto deflate_cfg = THIS->deflate_config();
Branch: 1 branch
BranchTrueFalseTotal
auto deflate_cfg = THIS->deflate_config(); 0 0 0
31 0 ▶ if (deflate_cfg) {
Branch: 1 branch
BranchTrueFalseTotal
if (deflate_cfg) { 0 0 0
32 0 ▶ RETVAL = xs::out(deflate_cfg.value());
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = xs::out(deflate_cfg.value()); 0 0 0
RETVAL = xs::out(deflate_cfg.value()); 0 0 0
33 }
34 0 else XSRETURN_UNDEF;
35 }
36  
37 Scalar Parser::effective_deflate_config () {
38 0 ▶ auto deflate_cfg = THIS->effective_deflate_config();
Branch: 1 branch
BranchTrueFalseTotal
auto deflate_cfg = THIS->effective_deflate_config(); 0 0 0
39 0 ▶ if (deflate_cfg) {
Branch: 1 branch
BranchTrueFalseTotal
if (deflate_cfg) { 0 0 0
40 0 ▶ RETVAL = xs::out(deflate_cfg.value());
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = xs::out(deflate_cfg.value()); 0 0 0
RETVAL = xs::out(deflate_cfg.value()); 0 0 0
41 }
42 0 else XSRETURN_UNDEF;
43 }
44  
45 0 ▶bool Parser::established ()
Branch: 1 branch
BranchTrueFalseTotal
bool Parser::established () 0 0 0
46  
47 0 ▶bool Parser::recv_closed ()
Branch: 1 branch
BranchTrueFalseTotal
bool Parser::recv_closed () 0 0 0
48  
49 0 ▶bool Parser::send_closed ()
Branch: 1 branch
BranchTrueFalseTotal
bool Parser::send_closed () 0 0 0
50  
51 0 bool Parser::is_deflate_active ()
52  
53 void Parser::get_frames (string buf = string()) {
54 0 ▶ auto frames = buf ? THIS->get_frames(buf) : THIS->get_frames();
Branch: 3 branches
BranchTrueFalseTotal
auto frames = buf ? THIS->get_frames(buf) : THIS->get_frames(); 0 0 0
auto frames = buf ? THIS->get_frames(buf) : THIS->get_frames(); 0 0 0
auto frames = buf ? THIS->get_frames(buf) : THIS->get_frames(); 0 0 0
55 0 ▶ if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach());
Branch: 10 branches
BranchTrueFalseTotal
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto frame : frames) mXPUSHs(xs::out(frame).detach()); 0 0 0
56 else {
57 0 ▶ if (frames.begin() == frames.end()) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (frames.begin() == frames.end()) XSRETURN_UNDEF; 0 0 0
58 0 ▶ auto itsv = xs::out(new XSFrameIterator(frames.begin()));
Branch: 4 branches
BranchTrueFalseTotal
auto itsv = xs::out(new XSFrameIterator(frames.begin())); 0 0 0
auto itsv = xs::out(new XSFrameIterator(frames.begin())); 0 0 0
auto itsv = xs::out(new XSFrameIterator(frames.begin())); 0 0 0
auto itsv = xs::out(new XSFrameIterator(frames.begin())); 0 0 0
59 0 ▶ mPUSHs(itsv.detach());
Branch: 1 branch
BranchTrueFalseTotal
mPUSHs(itsv.detach()); 0 0 0
60 0 }
61 }
62  
63 void Parser::get_messages (string buf = string()) {
64 0 ▶ auto messages = buf ? THIS->get_messages(buf) : THIS->get_messages();
Branch: 3 branches
BranchTrueFalseTotal
auto messages = buf ? THIS->get_messages(buf) : THIS->get_messages(); 0 0 0
auto messages = buf ? THIS->get_messages(buf) : THIS->get_messages(); 0 0 0
auto messages = buf ? THIS->get_messages(buf) : THIS->get_messages(); 0 0 0
65 0 ▶ if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach());
Branch: 10 branches
BranchTrueFalseTotal
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
if (GIMME_V == G_ARRAY) for (auto message : messages) mXPUSHs(xs::out(message).detach()); 0 0 0
66 else {
67 0 ▶ if (messages.begin() == messages.end()) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (messages.begin() == messages.end()) XSRETURN_UNDEF; 0 0 0
68 0 ▶ auto itsv = xs::out(new XSMessageIterator(messages.begin()));
Branch: 4 branches
BranchTrueFalseTotal
auto itsv = xs::out(new XSMessageIterator(messages.begin())); 0 0 0
auto itsv = xs::out(new XSMessageIterator(messages.begin())); 0 0 0
auto itsv = xs::out(new XSMessageIterator(messages.begin())); 0 0 0
auto itsv = xs::out(new XSMessageIterator(messages.begin())); 0 0 0
69 0 ▶ mPUSHs(itsv.detach());
Branch: 1 branch
BranchTrueFalseTotal
mPUSHs(itsv.detach()); 0 0 0
70 0 }
71 }
72  
73 XSFrameSender* Parser::start_message (...) {
74 0 Opcode opcode = Opcode::BINARY;
75 0 auto deflate = DeflateFlag::NO;
76 0
77 for (I32 i = 1; i < items - 1; i += 2) {
78 0 ▶ auto name = xs::in<string_view>(ST(i));
Branch: 1 branch
BranchTrueFalseTotal
auto name = xs::in<string_view>(ST(i)); 0 0 0
79 0 ▶ if (!name.length()) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!name.length()) continue; 0 0 0
80 0 ▶ auto val = ST(i+1);
Branch: 1 branch
BranchTrueFalseTotal
auto val = ST(i+1); 0 0 0
81 0 switch (name[0]) {
82 0 case 'd': if (name == "deflate") deflate = SvTRUE(val) ? DeflateFlag::YES : DeflateFlag::NO; break;
83 0 ▶ case 'o': if (name == "opcode") opcode = (Opcode)SvIV(val); break;
Branch: 4 branches
BranchTrueFalseTotal
case 'o': if (name == "opcode") opcode = (Opcode)SvIV(val); break; 0 0 0
case 'o': if (name == "opcode") opcode = (Opcode)SvIV(val); break; 0 0 0
case 'o': if (name == "opcode") opcode = (Opcode)SvIV(val); break; 0 0 0
case 'o': if (name == "opcode") opcode = (Opcode)SvIV(val); break; 0 0 0
84 0 ▶ }
Branch: 3 branches
BranchTrueFalseTotal
} 0 0 0
} 0 0 0
} 0 0 0
85 }
86
87 RETVAL = new XSFrameSender(THIS->start_message(opcode, deflate));
88 0 ▶}
Branch: 4 branches
BranchTrueFalseTotal
} 0 0 0
} 0 0 0
} 0 0 0
} 0 0 0
89  
90 string Parser::send_control (int opcode, string_view payload = {}) {
91 0 ▶ RETVAL = THIS->send_control((Opcode)opcode, payload);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->send_control((Opcode)opcode, payload); 0 0 0
RETVAL = THIS->send_control((Opcode)opcode, payload); 0 0 0
92 }
93  
94 string Parser::send_ping (string_view payload = {}) {
95 0 ▶ RETVAL = THIS->send_ping(payload);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->send_ping(payload); 0 0 0
RETVAL = THIS->send_ping(payload); 0 0 0
96 }
97  
98 string Parser::send_pong (string_view payload = {}) {
99 0 ▶ RETVAL = THIS->send_pong(payload);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = THIS->send_pong(payload); 0 0 0
RETVAL = THIS->send_pong(payload); 0 0 0
100 }
101  
102 string Parser::send_close (SV* code = NULL, string_view message = string()) {
103 0 ▶ RETVAL = code ? THIS->send_close((uint16_t)SvUV(code), message) :
Branch: 4 branches
BranchTrueFalseTotal
RETVAL = code ? THIS->send_close((uint16_t)SvUV(code), message) : 0 0 0
RETVAL = code ? THIS->send_close((uint16_t)SvUV(code), message) : 0 0 0
RETVAL = code ? THIS->send_close((uint16_t)SvUV(code), message) : 0 0 0
RETVAL = code ? THIS->send_close((uint16_t)SvUV(code), message) : 0 0 0
104 0 ▶ THIS->send_close();
Branch: 1 branch
BranchTrueFalseTotal
THIS->send_close(); 0 0 0
105 }
106  
107 string Parser::send_message (...) {
108 0 auto builder = THIS->message();
109 0 ▶ Sv payload_sv = get_send_message_params(builder, &ST(1), items-1);
Branch: 1 branch
BranchTrueFalseTotal
Sv payload_sv = get_send_message_params(builder, &ST(1), items-1); 0 0 0
110
111 0 ▶ if (payload_sv.is_array_ref()) {
Branch: 2 branches
BranchTrueFalseTotal
if (payload_sv.is_array_ref()) { 0 0 0
if (payload_sv.is_array_ref()) { 0 0 0
112 0 ▶ auto list = xs::in<std::vector<string_view>>(payload_sv);
Branch: 1 branch
BranchTrueFalseTotal
auto list = xs::in<std::vector<string_view>>(payload_sv); 0 0 0
113 0 ▶ RETVAL = builder.send(list.begin(), list.end());
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = builder.send(list.begin(), list.end()); 0 0 0
RETVAL = builder.send(list.begin(), list.end()); 0 0 0
114 0 }
115 else {
116 0 ▶ RETVAL = builder.send(xs::in<string_view>(payload_sv));
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = builder.send(xs::in<string_view>(payload_sv)); 0 0 0
RETVAL = builder.send(xs::in<string_view>(payload_sv)); 0 0 0
RETVAL = builder.send(xs::in<string_view>(payload_sv)); 0 0 0
117 }
118 }
119  
120 Simple Parser::send_message_multiframe (...) {
121 0 auto builder = THIS->message();
122 0 ▶ Sv payload_sv = get_send_message_params(builder, &ST(1), items-1);
Branch: 1 branch
BranchTrueFalseTotal
Sv payload_sv = get_send_message_params(builder, &ST(1), items-1); 0 0 0
123 0 ▶ auto payloads = xs::in<std::vector<string_view>>(payload_sv);
Branch: 1 branch
BranchTrueFalseTotal
auto payloads = xs::in<std::vector<string_view>>(payload_sv); 0 0 0
124 0 ▶ auto range = builder.send_multiframe(payloads.begin(), payloads.end());
Branch: 1 branch
BranchTrueFalseTotal
auto range = builder.send_multiframe(payloads.begin(), payloads.end()); 0 0 0
125 0 ▶ RETVAL = strings_to_sv(range);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = strings_to_sv(range); 0 0 0
126 }
127  
128 0 void Parser::reset ()
129  
130 0 uint16_t Parser::suggested_close_code ()
131  
132 0 void Parser::no_deflate ()
133  
« xs/MessageIterator.xsi ↑ Summary xs/ServerParser.xsi »