From c264fc0d0663a92d65144c1f00ffa9f1bc32bebf Mon Sep 17 00:00:00 2001 From: msojocs Date: Sat, 15 Jul 2023 09:33:23 +0800 Subject: [PATCH] fix: pos --- src/include/wxml.h | 4 +--- src/wxml/dom_lib/parser.cpp | 1 - src/wxml/dom_lib/wxml_dom.cpp | 32 +++++++++++++++----------------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/include/wxml.h b/src/include/wxml.h index e50eb9a..5a28a91 100644 --- a/src/include/wxml.h +++ b/src/include/wxml.h @@ -261,8 +261,6 @@ namespace WXML 偏移应该不超过0x128u, 296 */ // std::string offset_52; - int offset_92 = 0; // pos1 - int offset_96 = 0; // pos2 int offset_104 = 0; // len int offset_140 = 0; std::string offset_144; @@ -278,7 +276,7 @@ namespace WXML std::vector> offset_72; // WXML::DOMLib::Token offset_84; // token StrCache offset_248; - int offset_256; // ??? + int offset_256 = 0; // ??? std::map offset_272; WXMLDom(/* args */); ~WXMLDom(); diff --git a/src/wxml/dom_lib/parser.cpp b/src/wxml/dom_lib/parser.cpp index 7e73445..8613dd0 100644 --- a/src/wxml/dom_lib/parser.cpp +++ b/src/wxml/dom_lib/parser.cpp @@ -207,7 +207,6 @@ namespace WXML if (v16.length() > 0) { int v17 = 0; - // TODO v18 = *v16 + v43[4]; char* v18 = &v16[0] + token.offset_16; // offset_20第一次是3 while(token.offset_20 > v17) diff --git a/src/wxml/dom_lib/wxml_dom.cpp b/src/wxml/dom_lib/wxml_dom.cpp index 9ec524d..b191549 100644 --- a/src/wxml/dom_lib/wxml_dom.cpp +++ b/src/wxml/dom_lib/wxml_dom.cpp @@ -530,9 +530,7 @@ namespace WXML { } } - /** - * 有点问题 - */ + void WXMLDom::RenderChildren( std::string const& a2, std::string const& a3, @@ -711,7 +709,7 @@ namespace WXML { std::string v66 = srcToken->second.ToAttrContent(); int v67 = this->offset_248.GetStrID(v66); a6 << v67 << "]," << a3 << ",x[" << this->offset_248.GetStrID(a2) << "],"; - a6 << cur->offset_92 << "," << cur->offset_96 << ")" << a12; + a6 << cur->offset_84.offset_8 << "," << cur->offset_84.offset_12 << ")" << a12; goto LABEL_74; } } @@ -844,7 +842,7 @@ namespace WXML { { a6 << "cs.push(\""; std::string sc = WXML::Rewrite::ToStringCode(a2); - a6 << sc << ":" << this->offset_24 << ":" << this->offset_92 << ":" << this->offset_96 << "\")"; + a6 << sc << ":" << this->offset_24 << ":" << this->offset_84.offset_8 << ":" << this->offset_84.offset_12 << "\")" << a12; } if (this->offset_0 == "TEXTNODE") { @@ -1017,8 +1015,8 @@ namespace WXML { { a6 << "_wp('" << WXML::Rewrite::ToStringCode(a2) << ":"; a6 << this->offset_24 << ":"; - a6 << this->offset_92 << ":"; - a6 << this->offset_96; + a6 << this->offset_84.offset_8 << ":"; + a6 << this->offset_84.offset_12; a6 << ": Now you can provide attr `wx:key` for a `wx:for` to improve performance.')"; a6 << a12; } @@ -1074,8 +1072,8 @@ namespace WXML { LABEL_181: a6 << "_wp('" << WXML::Rewrite::ToStringCode(a2) << ":"; a6 << this->offset_24 << ":"; - a6 << this->offset_92 << ":"; - a6 << this->offset_96 << ": wx:key=\""; + a6 << this->offset_84.offset_8 << ":"; + a6 << this->offset_84.offset_12 << ": wx:key=\""; a6 << WXML::Rewrite::ToStringCode(v336) << "\" does not look like a valid key name (did you mean wx:key=\""; a6 << WXML::Rewrite::ToStringCode(v339) << "\" ?)')"; a6 << a12; @@ -1106,7 +1104,7 @@ namespace WXML { if (v336 != "*this") { a6 << "_wp('" << WXML::Rewrite::ToStringCode(a2) << ":"; - a6 << this->offset_24 << ":" << this->offset_92 << ":" << this->offset_96; + a6 << this->offset_24 << ":" << this->offset_84.offset_8 << ":" << this->offset_84.offset_12; a6 << ": wx:key=\"" << WXML::Rewrite::ToStringCode(v336); a6 << "\" does not look like a valid key name.')" << a12; @@ -1180,7 +1178,7 @@ namespace WXML { if (v269) { a6 << "_wp(\"" << WXML::Rewrite::ToStringCode(a2) << ":template:"; - a6 << this->offset_92 << ":" << this->offset_96 << ": `"; + a6 << this->offset_84.offset_8 << ":" << this->offset_84.offset_12 << ": `"; auto v92 = v281->second.ToAttrContent(); WXML::Rewrite::ToStringCode(v92, a6); a6 << "` is not a valid expression for a template.\")"; @@ -1516,11 +1514,11 @@ namespace WXML { } if (v4->tellp()) { - printf("pos: %d, %d, tag: %s, ", this->offset_92, this->offset_96, this->offset_0.c_str()); + printf("pos: %d, %d, tag: %s, ", this->offset_84.offset_8, this->offset_84.offset_12, this->offset_0.c_str()); } else { - *v4 << "pos: " << this->offset_92 << ", " << this->offset_96 << " tag: " << this->offset_0 << ", "; + *v4 << "pos: " << this->offset_84.offset_8 << ", " << this->offset_84.offset_12 << " tag: " << this->offset_0 << ", "; } if (this->offset_0 == "TEXTNODE") @@ -1556,16 +1554,16 @@ namespace WXML { { printf( "pos: %d, %d, len: %d, %s", - this->offset_92, - this->offset_96, + this->offset_84.offset_8, + this->offset_84.offset_12, this->offset_104, this->offset_84.ToString().data() ); } else { - *v4 << "pos: " << this->offset_92 - << ", " << this->offset_96 << ", len: " << this->offset_104 + *v4 << "pos: " << this->offset_84.offset_8 + << ", " << this->offset_84.offset_12 << ", len: " << this->offset_104 << ", "; *v4 << this->offset_84.ToString(); }