Skip to content

Commit 7384e0d

Browse files
committed
use pugixml library instead of manually parsing the XML
Almost all of this commit was generated by Junie by telling it to use an xml library instead of manually parsing the XML
1 parent ed24a23 commit 7384e0d

File tree

7 files changed

+15319
-256
lines changed

7 files changed

+15319
-256
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ endif()
2828
file(GLOB HEADER_FILES "src/*.h" "src/TypeHandlers/*.h")
2929
file(GLOB COMMON_SOURCE ${HEADER_FILES} "src/*.cpp" "src/TypeHandlers/*.cpp")
3030

31+
# pugixml (vendored)
32+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/vendor/pugixml)
33+
list(APPEND COMMON_SOURCE vendor/pugixml/pugixml.cpp)
34+
3135
if(NOT WIN32)
3236
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined")
3337
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined")

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CXXFLAGS := -O3 -std=c++2a -DTH_GDB_SUPPORT=1 -W -Wall -Wextra -Werror=write-strings -Werror=redundant-decls -Werror=format -Werror=format-security -Werror=date-time -Werror=return-type -Werror=pointer-arith -Winit-self
1+
CXXFLAGS := -O3 -std=c++2a -DTH_GDB_SUPPORT=1 -Ivendor/pugixml -W -Wall -Wextra -Werror=write-strings -Werror=redundant-decls -Werror=format -Werror=format-security -Werror=date-time -Werror=return-type -Werror=pointer-arith -Winit-self
22

3-
SOURCES_COMMON := $(wildcard src/*.cpp) $(wildcard src/TypeHandlers/*.cpp)
3+
SOURCES_COMMON := $(wildcard src/*.cpp) $(wildcard src/TypeHandlers/*.cpp) vendor/pugixml/pugixml.cpp
44

55
SOURCES_TESTS := $(SOURCES_COMMON) tests.cpp
66
SOURCES_CLI := $(SOURCES_COMMON) cli/cli.cpp

Makefile.emscripten

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ CXX := em++
33
# Emscripten stuff
44
EMFLAGS := --bind -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="'TIVarsLib'" -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=0 -s DISABLE_EXCEPTION_CATCHING=1 -s EXPORTED_RUNTIME_METHODS="['FS']" --embed-file ti-toolkit-8x-tokens.xml
55

6-
CXXFLAGS := -O3 -flto -std=c++2a -DTH_GDB_SUPPORT=1 -W -Wall -Wextra
6+
CXXFLAGS := -O3 -flto -std=c++2a -DTH_GDB_SUPPORT=1 -Ivendor/pugixml -W -Wall -Wextra
77
LFLAGS := -flto $(EMFLAGS)
88

9-
SOURCES := $(wildcard src/*.cpp) $(wildcard src/TypeHandlers/*.cpp)
9+
SOURCES := $(wildcard src/*.cpp) $(wildcard src/TypeHandlers/*.cpp) vendor/pugixml/pugixml.cpp
1010

1111
OBJS = $(patsubst %.cpp, %.bc, $(SOURCES))
1212

src/TypeHandlers/TH_Tokenized.cpp

Lines changed: 93 additions & 252 deletions
Large diffs are not rendered by default.

vendor/pugixml/pugiconfig.hpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* pugixml parser - version 1.15
3+
* --------------------------------------------------------
4+
* Report bugs and download new versions at https://pugixml.org/
5+
*
6+
* SPDX-FileCopyrightText: Copyright (C) 2006-2025, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
7+
* SPDX-License-Identifier: MIT
8+
*
9+
* See LICENSE.md or notice at the end of this file.
10+
*/
11+
12+
#ifndef HEADER_PUGICONFIG_HPP
13+
#define HEADER_PUGICONFIG_HPP
14+
15+
// Uncomment this to enable wchar_t mode
16+
// #define PUGIXML_WCHAR_MODE
17+
18+
// Uncomment this to enable compact mode
19+
#define PUGIXML_COMPACT
20+
21+
// Uncomment this to disable XPath
22+
#define PUGIXML_NO_XPATH
23+
24+
// Uncomment this to disable STL
25+
// #define PUGIXML_NO_STL
26+
27+
// Uncomment this to disable exceptions
28+
#define PUGIXML_NO_EXCEPTIONS
29+
30+
// Set this to control attributes for public classes/functions, i.e.:
31+
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
32+
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
33+
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
34+
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
35+
36+
// Tune these constants to adjust memory-related behavior
37+
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
38+
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
39+
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
40+
41+
// Tune this constant to adjust max nesting for XPath queries
42+
// #define PUGIXML_XPATH_DEPTH_LIMIT 1024
43+
44+
// Uncomment this to switch to header-only version
45+
// #define PUGIXML_HEADER_ONLY
46+
47+
// Uncomment this to enable long long support (usually enabled automatically)
48+
// #define PUGIXML_HAS_LONG_LONG
49+
50+
// Uncomment this to enable support for std::string_view (usually enabled automatically)
51+
// #define PUGIXML_HAS_STRING_VIEW
52+
53+
#endif
54+
55+
/**
56+
* Copyright (c) 2006-2025 Arseny Kapoulkine
57+
*
58+
* Permission is hereby granted, free of charge, to any person
59+
* obtaining a copy of this software and associated documentation
60+
* files (the "Software"), to deal in the Software without
61+
* restriction, including without limitation the rights to use,
62+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
63+
* copies of the Software, and to permit persons to whom the
64+
* Software is furnished to do so, subject to the following
65+
* conditions:
66+
*
67+
* The above copyright notice and this permission notice shall be
68+
* included in all copies or substantial portions of the Software.
69+
*
70+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
71+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
72+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
73+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
74+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
75+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
76+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
77+
* OTHER DEALINGS IN THE SOFTWARE.
78+
*/

0 commit comments

Comments
 (0)