#ifndef __WXML_H_ #define __WXML_H_ #include #include #include #include #include #include #include #include namespace WXML { namespace Rewrite { void ToStringCode(char const*, int, std::stringstream &ss); void ToStringCode(std::string const&, std::stringstream &); void ToStringCode(std::string const&, std::string&); std::string ToStringCode(std::string const&); std::string ToStringCode2(char const*, int); std::string ToStringCode2(std::string const&); std::string ToStringCode3(char const*, int); std::string ToStringCode3(std::string const&); } class NameAllocator { private: /* data */ std::string offset_1; // v5 std::string offset_7; // v4 public: std::string ALPAHBET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; static int ALPAHBETLEN; NameAllocator(std::string const&,std::string const&); ~NameAllocator(); void GetNextName(std::string &); }; namespace StringTemplating { class Token { private: /* data */ public: Token(/* args */); ~Token(); }; void Deal( char const*, std::string &, std::vector &, bool & ); } namespace DOMLib { class Token { /* Token 00(起点) B6 BF 00(文件内容) 80 CC BF 00 01 00 00 00(行数?) 01 00 00 00(行长度?) // 15 01 00 00 00(pos) 04 00 00 00(size) 00 00 00 00 00(布尔值) F6 97 00 // 31 38 F0 97 00 00 00 00 00 00 CC FA 00 CC F0 97 00 // 47(40是32字符串的 缓冲区起点) 00 00 BF 00 00 00 00 00 FF FF FF FF 54 F0 97 00 // 63 00 00 00 00 00 3A 53 00 00 00 00 00 78 F0 97 00 // 79 00 00 00 00 00(?) F2 97 00 70 F0 97 00 00 00 00 00 00 00 00 00 62 00 00 40 F8 F1 97 00 7A 15 46 00 */ private: /* data */ bool offset_28 = false; // hasCache toString std::string offset_32 = ""; // chcheData toString bool offset_84 = false; // hasCache attrContent std::string offset_88; // chcheData attrContent public: std::string offset_0 = ""; // content int offset_8 = 0; // ??? int offset_12 = 0; // ??? int offset_16 = 0; // pos int offset_20 = 0; // size int offset_24 = 0; // ??? int offset_40 = 0; // AttrsCompartor用到,怎么来不知道 // int offset_48 = 0; int offset_56 = 0; // ??? -3, -1 std::string offset_60 = ""; // ??? Token(); Token(std::string &); Token(WXML::DOMLib::Token&&); Token(WXML::DOMLib::Token const&); ~Token(); WXML::DOMLib::Token& operator=(WXML::DOMLib::Token const&); WXML::DOMLib::Token& operator=(WXML::DOMLib::Token &&); void SetContent(std::string &content); std::string& GetContent(); int GetPos(); /** * size: offset_20 */ int GetSize(); std::string ToString(); /** * * 返回值类型string */ std::string ToAttrContent(); /** * 变量名是否有效 */ static bool IsValidVariableName(std::string const&); bool IsMatch(char const*); /** * 获取模板内容 * {{ exp }} */ static int GetTemplateContent(std::string const&, std::string&); }; /** * 拼接字符串 * * @param data 要拼接的字符串 * @param join 拼接字符 * */ std::string joinString(std::vector& data, char join); /** * 分割字符串 * * @param str 要分割的字符串 * @param split 分割字符 */ std::vector splitString(std::string const& str, char split); /** * 路径拼接 * * @param path1 基础路径 * @param path2 目标路径 */ std::string resolvePath(std::string const& path1, std::string const& path2); /** * */ bool AttrsCompartor( std::pair const& a1, std::pair const& a2); class ParseException { private: /* data */ public: ParseException(/* args */); ~ParseException(); }; class Machine { private: /* data */ static bool bInited; // 初始化标志 static int TT[0x101000u]; //类型不确定 static int STT[0x80]; int fileLength = 0; // offset + 0 int offset_4 = 0; // offset + 4 int lineCount = 0;// 当前处理的行数 offset + 8 int lineLength = 0; // 正在处理行的长度 offset + 12 int offset_16 = 0; // offset + 16 int offset_20 = 0; // offset + 20 int offset_24 = 0; // offset + 24 std::string filePath; // 文件路径 offset + 28 public: Machine(/* args */); Machine(std::string const& filePath); ~Machine(); void Reset(void); void InitTransitTable(void); int Feed(char,std::vector &,std::string &,std::vector &,int); }; class Tokenizer { private: /* data */ std::string fileContent; std::string fileName; WXML::DOMLib::Machine machine; // this + 2 public: Tokenizer(char const* fileContent, std::string const& filePath); Tokenizer(/* args */); ~Tokenizer(); int GetTokens( std::vector &, std::string &, std::vector & ); }; class StrCache { private: /* data */ std::map d; std::vector offset_6; public: StrCache(/* args */); ~StrCache(); void RenderPathDefine(std::stringstream &ss); void Insert(std::string); int GetStrID(std::string); }; class RVMOpCodePosition { private: /* data */ public: RVMOpCodePosition(/* args */); ~RVMOpCodePosition(); }; class RVMOpCodePositionRecorder { private: /* data */ public: RVMOpCodePositionRecorder(/* args */); ~RVMOpCodePositionRecorder(); }; class WXMLDom { private: /* 偏移应该不超过0x128u, 296 */ bool offset_28; // std::string offset_52; int offset_92; // pos1 int offset_96; // pos2 int offset_104; // len int offset_140; std::string offset_144; std::string offset_196; std::string offset_220; int offset_244; int componentCnt = 0; public: std::string offset_0; // type // std::map offset_12; std::string offset_24; // ??? std::map offset_48; std::vector> offset_72; // WXML::DOMLib::Token offset_84; // token StrCache offset_248; int offset_256; // ??? std::map offset_272; WXMLDom(/* args */); ~WXMLDom(); std::string Error( std::string const& a2, WXML::DOMLib::Token const& a3, std::string const& a4, std::string const& a5 ); void RenderMeAsFunction( std::string const&, std::string const&, std::string&, std::string const&, std::stringstream &, WXML::NameAllocator *, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, char, std::string const&, bool, bool, uint, std::string const& ); void RenderChildren( std::string const& a2, std::string const& a3, std::string& a4, std::string const& a5, std::stringstream & a6, WXML::NameAllocator * a7, std::string const& a8, std::string const& a9, std::string const& a10, std::string const& a11, char a12, bool a13, uint a14, std::map * a15 ); void RenderNonDefine( std::string const& a2, std::string const& a3, std::string& a4, std::string const& a5, std::stringstream &a6, WXML::NameAllocator *a7, std::string const& a8, std::string const& a9, std::string const& a10, std::string const& a11, char a12, bool a13, uint a14, std::map * a15 ); bool IfHasItsElse( int a2, std::vector const& a3 ); void RecordAllPath(void); void Print(int,char const*, std::stringstream *); void PrintMe(int,char const*, std::stringstream *); bool operator==(std::string tag); std::string ToCamelStyle(std::string const&); void AddTestAttr(std::string const&, std::stringstream &, char); bool HasSpAttrPrefix(void); void MarkIfHasDescendant(std::vector const&); void CutDomsForCustomComponent(std::vector const&); void RenderAllOpsAndRecord( std::string const&, std::string&, std::stringstream &, std::map &, WXML::DOMLib::RVMOpCodePositionRecorder *, bool, const std::map &); }; void recurseDependencies(std::shared_ptr const&,std::string const&,std::set &); class Parser { private: /* data */ std::shared_ptr dom; // offset_4 ? int offset_4 = 0; std::deque dequeStr;// offset_8 std::deque> dequeDom; // offset_48 int a1 + 48, _DWORD * a1 + 12 std::vector tokenList; // offset_88 int peekIndex = 0; // offset_100 WXML::DOMLib::Token offset_104; int offset_128 = 0; WXML::DOMLib::Token offset_216; std::string filePath; public: Parser(/* args */); ~Parser(); void Match(); /** * wxml tag * view | */ static bool IsValidTag(std::string &); WXML::DOMLib::Token Peek(); bool Parse( char const*fileContent, // Str std::string & errorMessage, // a4 std::string const& filePath, // a5 std::vector & // a6 ); WXML::DOMLib::ParseException Error(char const*, WXML::DOMLib::Token *); std::shared_ptr GetParsed(); void DOM(); void DOMS(); void ATTR_LIST(); void ATTR(); }; }; namespace Compiler { int ParseSource( std::string const& content, // 源码?a2 std::string const& filePath, // 文件名? a3 char lineEndMark, // '\n' a4 std::string const& gwxMark, // gwxMark a5 std::string const& fMark, // "f_" a6 std::map const&, // fileData a7 std::string&, // 错误信息 a8 std::map>&,// map a9 std::map&,// ??? a10 std::map&, // ??? a11 bool, // mark指定运算结果是否非0 a12 bool); // mark指定运算结果是否非0 a13 int CompileLazy( std::map const& fileContent, std::string& errorMessage, // 错误信息 std::map& outputContentMap, // 输出1 编译后的代码映射 std::map& outputFuncMap, // 输出2 编译后的函数名 std::map>& dependencyListMap, std::map>& componentListMap, // vecFileContentMap componentList 页面使用的组件列表 std::vector const& splitedData, // splitedData std::map const&, // mapData1 bool, // isLLA std::string const&, // gwxMark uint, // mark char, // '\n' std::string const&, // 'e' std::string const&, // const char off_5403C3[] = {'s','\0','e','\0'} std::string const&, // "gg" std::string const&, // "e_" std::string const&, // "d_" std::string const&, // "p_" std::string const&, // '\0' std::string const&, // "boxofchocolate" std::string const&, // "$gdwx" std::string const& // "f_" ); int Compile( std::map const&,// a1 std::string&, // a2 std::string&, // a3 std::map>,// a4 std::map const&,// a5 bool,// a6 std::string const& gwxMark,// a7 uint mark, // a8 char lineEndMark, // a9 std::string const&, // a10 std::string const&, // a11 std::string const& , // a12 std::string const& ggMark, // a13 std::string const& eMark, // a14 std::string const& dMark, // a15 std::string const& pMark, // a16 std::string const& endMark, // a17 std::string const& boxMark, // a18 std::string const& gdwxMark, // a19 std::string const& fMark); // a20 int DealWxsTag( std::string const& a1, WXML::DOMLib::Token & a2, std::string& a3, std::string& a4, std::string& a5, int * a6, std::string& a7 ); std::string GetFuncId(std::map &, std::string const&); void GetVersionInfo(std::string &a1, std::string a2); int RenderDefine( WXML::DOMLib::WXMLDom &, std::string const&, std::map &, std::string&, std::stringstream &, std::map const&, bool, uint, char, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, std::string const&, std::string const& ); void WXMLHelperCode(std::string &result); }; namespace EXPRLib { class Tokenizer { private: /* data */ public: Tokenizer(/* args */); ~Tokenizer(); }; class ExprSyntaxTree { private: /* data */ public: ExprSyntaxTree(/* args */); ~ExprSyntaxTree(); }; class Token { /** * 内存结构: * 00 00 00 00 标识type * 00 00 00 00... 当标识为0时后面为需要的动态字符串tokenName */ private: /* data */ int type; std::string tokenName; public: Token(/* args */); ~Token(); const char * GetTokenName(); }; } // namespace EXPRLib } #endif