This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added src/bin/dump_xml_compiler_result
- Loading branch information
Showing
4 changed files
with
353 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#CONFIGURATION = Debug | ||
CONFIGURATION = Release | ||
|
||
all: | ||
mkdir -p build/Release | ||
$(MAKE) -C ../../../pkginfo | ||
$(MAKE) -C ../../lib/xml_compiler | ||
xcodebuild -alltargets -configuration $(CONFIGURATION) build | ||
|
||
clean: | ||
rm -rf build | ||
rm -f Info.plist | ||
rm -f *.xcodeproj/*.mode1 | ||
rm -f *.xcodeproj/*.mode1v3 | ||
rm -f *.xcodeproj/*.pbxuser | ||
rm -rf *.xcodeproj/xcuserdata | ||
rm -rf *.xcodeproj/project.xcworkspace/xcuserdata | ||
make -C ../../lib/xml_compiler clean | ||
|
||
xcode: | ||
open *.xcodeproj | ||
|
||
dump_data: | ||
@./build/Release/dump_xml_compiler_result \ | ||
/Library/org.pqrs/KeyRemap4MacBook/app/KeyRemap4MacBook.app/Contents/Resources \ | ||
/noexistspath \ | ||
dump_data | ||
|
||
dump_tree: | ||
@./build/Release/dump_xml_compiler_result \ | ||
/Library/org.pqrs/KeyRemap4MacBook/app/KeyRemap4MacBook.app/Contents/Resources \ | ||
/noexistspath \ | ||
dump_tree | ||
|
||
dump_number: | ||
@./build/Release/dump_xml_compiler_result \ | ||
/Library/org.pqrs/KeyRemap4MacBook/app/KeyRemap4MacBook.app/Contents/Resources \ | ||
/noexistspath \ | ||
dump_number | ||
|
||
dump_identifier_except_essential: | ||
@./build/Release/dump_xml_compiler_result \ | ||
/Library/org.pqrs/KeyRemap4MacBook/app/KeyRemap4MacBook.app/Contents/Resources \ | ||
/noexistspath \ | ||
dump_identifier_except_essential |
193 changes: 193 additions & 0 deletions
193
src/bin/dump_xml_compiler_result/dump_xml_compiler_result.xcodeproj/project.pbxproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
// !$*UTF8*$! | ||
{ | ||
archiveVersion = 1; | ||
classes = { | ||
}; | ||
objectVersion = 46; | ||
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
3465056D153665B20095CCC9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3465056C153665B20095CCC9 /* main.cpp */; }; | ||
3465059F153668690095CCC9 /* libxml_compiler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3465059E153668690095CCC9 /* libxml_compiler.a */; }; | ||
/* End PBXBuildFile section */ | ||
|
||
/* Begin PBXCopyFilesBuildPhase section */ | ||
34650566153665B20095CCC9 /* CopyFiles */ = { | ||
isa = PBXCopyFilesBuildPhase; | ||
buildActionMask = 2147483647; | ||
dstPath = /usr/share/man/man1/; | ||
dstSubfolderSpec = 0; | ||
files = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 1; | ||
}; | ||
/* End PBXCopyFilesBuildPhase section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
34650568153665B20095CCC9 /* dump_xml_compiler_result */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dump_xml_compiler_result; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
3465056C153665B20095CCC9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; | ||
3465059E153668690095CCC9 /* libxml_compiler.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libxml_compiler.a; path = ../../lib/xml_compiler/build/Release/libxml_compiler.a; sourceTree = "<group>"; }; | ||
/* End PBXFileReference section */ | ||
|
||
/* Begin PBXFrameworksBuildPhase section */ | ||
34650565153665B20095CCC9 /* Frameworks */ = { | ||
isa = PBXFrameworksBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
3465059F153668690095CCC9 /* libxml_compiler.a in Frameworks */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXFrameworksBuildPhase section */ | ||
|
||
/* Begin PBXGroup section */ | ||
3465055D153665B20095CCC9 = { | ||
isa = PBXGroup; | ||
children = ( | ||
3465059E153668690095CCC9 /* libxml_compiler.a */, | ||
3465056B153665B20095CCC9 /* dump_xml_compiler_result */, | ||
34650569153665B20095CCC9 /* Products */, | ||
); | ||
sourceTree = "<group>"; | ||
}; | ||
34650569153665B20095CCC9 /* Products */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
34650568153665B20095CCC9 /* dump_xml_compiler_result */, | ||
); | ||
name = Products; | ||
sourceTree = "<group>"; | ||
}; | ||
3465056B153665B20095CCC9 /* dump_xml_compiler_result */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
3465056C153665B20095CCC9 /* main.cpp */, | ||
); | ||
path = dump_xml_compiler_result; | ||
sourceTree = "<group>"; | ||
}; | ||
/* End PBXGroup section */ | ||
|
||
/* Begin PBXNativeTarget section */ | ||
34650567153665B20095CCC9 /* dump_xml_compiler_result */ = { | ||
isa = PBXNativeTarget; | ||
buildConfigurationList = 34650572153665B20095CCC9 /* Build configuration list for PBXNativeTarget "dump_xml_compiler_result" */; | ||
buildPhases = ( | ||
34650564153665B20095CCC9 /* Sources */, | ||
34650565153665B20095CCC9 /* Frameworks */, | ||
34650566153665B20095CCC9 /* CopyFiles */, | ||
); | ||
buildRules = ( | ||
); | ||
dependencies = ( | ||
); | ||
name = dump_xml_compiler_result; | ||
productName = dump_xml_compiler_result; | ||
productReference = 34650568153665B20095CCC9 /* dump_xml_compiler_result */; | ||
productType = "com.apple.product-type.tool"; | ||
}; | ||
/* End PBXNativeTarget section */ | ||
|
||
/* Begin PBXProject section */ | ||
3465055F153665B20095CCC9 /* Project object */ = { | ||
isa = PBXProject; | ||
attributes = { | ||
LastUpgradeCheck = 0430; | ||
}; | ||
buildConfigurationList = 34650562153665B20095CCC9 /* Build configuration list for PBXProject "dump_xml_compiler_result" */; | ||
compatibilityVersion = "Xcode 3.2"; | ||
developmentRegion = English; | ||
hasScannedForEncodings = 0; | ||
knownRegions = ( | ||
en, | ||
); | ||
mainGroup = 3465055D153665B20095CCC9; | ||
productRefGroup = 34650569153665B20095CCC9 /* Products */; | ||
projectDirPath = ""; | ||
projectRoot = ""; | ||
targets = ( | ||
34650567153665B20095CCC9 /* dump_xml_compiler_result */, | ||
); | ||
}; | ||
/* End PBXProject section */ | ||
|
||
/* Begin PBXSourcesBuildPhase section */ | ||
34650564153665B20095CCC9 /* Sources */ = { | ||
isa = PBXSourcesBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
3465056D153665B20095CCC9 /* main.cpp in Sources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXSourcesBuildPhase section */ | ||
|
||
/* Begin XCBuildConfiguration section */ | ||
34650571153665B20095CCC9 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; | ||
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; | ||
COPY_PHASE_STRIP = YES; | ||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
GCC_ENABLE_OBJC_EXCEPTIONS = YES; | ||
GCC_ENABLE_OBJC_GC = unsupported; | ||
GCC_SYMBOLS_PRIVATE_EXTERN = YES; | ||
GCC_TREAT_WARNINGS_AS_ERRORS = YES; | ||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES; | ||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES; | ||
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; | ||
GCC_WARN_MISSING_PARENTHESES = YES; | ||
GCC_WARN_SHADOW = YES; | ||
GCC_WARN_SIGN_COMPARE = YES; | ||
GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_LABEL = YES; | ||
GCC_WARN_UNUSED_VALUE = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
HEADER_SEARCH_PATHS = ../../lib/xml_compiler/include; | ||
MACOSX_DEPLOYMENT_TARGET = 10.6; | ||
RUN_CLANG_STATIC_ANALYZER = YES; | ||
SDKROOT = macosx10.6; | ||
}; | ||
name = Release; | ||
}; | ||
34650574153665B20095CCC9 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
LIBRARY_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
"\"$(SRCROOT)/../../lib/xml_compiler/build/Release\"", | ||
); | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
}; | ||
name = Release; | ||
}; | ||
/* End XCBuildConfiguration section */ | ||
|
||
/* Begin XCConfigurationList section */ | ||
34650562153665B20095CCC9 /* Build configuration list for PBXProject "dump_xml_compiler_result" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
34650571153665B20095CCC9 /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
34650572153665B20095CCC9 /* Build configuration list for PBXNativeTarget "dump_xml_compiler_result" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
34650574153665B20095CCC9 /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
/* End XCConfigurationList section */ | ||
}; | ||
rootObject = 3465055F153665B20095CCC9 /* Project object */; | ||
} |
7 changes: 7 additions & 0 deletions
7
...er_result/dump_xml_compiler_result.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
src/bin/dump_xml_compiler_result/dump_xml_compiler_result/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include <iostream> | ||
#include <boost/algorithm/string.hpp> | ||
#include "pqrs/xml_compiler.hpp" | ||
|
||
namespace { | ||
int total_identifier_count_ = 0; | ||
|
||
void | ||
escapeHTML(std::string& string) | ||
{ | ||
boost::replace_all(string, "&", "&"); | ||
boost::replace_all(string, "<", "<"); | ||
boost::replace_all(string, ">", ">"); | ||
} | ||
|
||
void | ||
dump_tree(const pqrs::xml_compiler::preferences_node_tree<pqrs::xml_compiler::preferences_checkbox_node>& node_tree) | ||
{ | ||
auto children_ptr = node_tree.get_children(); | ||
if (children_ptr) { | ||
auto& children = *children_ptr; | ||
|
||
std::cout << "<ul>" << std::endl; | ||
|
||
for (auto& it : children) { | ||
auto& node = it->get_node(); | ||
|
||
std::string name = node.get_name(); | ||
escapeHTML(name); | ||
std::cout << "<li>" << name << "</li>" << std::endl; | ||
|
||
dump_tree(*it); | ||
|
||
auto& identifier = node.get_identifier(); | ||
if (! identifier.empty()) { | ||
++total_identifier_count_; | ||
} | ||
} | ||
|
||
std::cout << "</ul>" << std::endl; | ||
} | ||
} | ||
|
||
void | ||
dump_number(const pqrs::xml_compiler::preferences_node_tree<pqrs::xml_compiler::preferences_number_node>& node_tree) | ||
{ | ||
auto children_ptr = node_tree.get_children(); | ||
if (children_ptr) { | ||
auto& children = *children_ptr; | ||
|
||
for (auto& it : children) { | ||
auto& node = it->get_node(); | ||
|
||
std::cout << node.get_name() << std::endl | ||
<< " default_value:" << node.get_default_value() << std::endl | ||
<< " step:" << node.get_step() << std::endl | ||
<< " base_unit:" << node.get_base_unit() << std::endl | ||
<< std::endl; | ||
|
||
dump_number(*it); | ||
} | ||
} | ||
} | ||
} | ||
|
||
int | ||
main(int argc, const char* argv[]) | ||
{ | ||
if (argc != 4) { | ||
std::cerr << "Usage: " << argv[0] << " system_xml_directory private_xml_directory command" << std::endl | ||
<< std::endl | ||
<< "Example: " << argv[0] | ||
<< " /Library/org.pqrs/KeyRemap4MacBook/app/KeyRemap4MacBook.app/Contents/Resources" | ||
<< " ~/Library/Application\\ Support/KeyRemap4MacBook" | ||
<< " dump_data" | ||
<< std::endl; | ||
exit(1); | ||
} | ||
|
||
pqrs::xml_compiler xml_compiler(argv[1], argv[2]); | ||
xml_compiler.reload(); | ||
|
||
std::string command(argv[3]); | ||
|
||
if (command == "dump_data") { | ||
auto v = xml_compiler.get_remapclasses_initialize_vector().get(); | ||
for (auto& it : v) { | ||
std::cout << it << std::endl; | ||
} | ||
|
||
} else if (command == "dump_tree") { | ||
dump_tree(xml_compiler.get_preferences_checkbox_node_tree()); | ||
std::cout << "Total items: " << total_identifier_count_ << std::endl; | ||
|
||
} else if (command == "dump_number") { | ||
dump_number(xml_compiler.get_preferences_number_node_tree()); | ||
|
||
} else if (command == "dump_identifier_except_essential") { | ||
for (int i = 0;; ++i) { | ||
auto identifier = xml_compiler.get_identifier(i); | ||
if (! identifier) break; | ||
|
||
std::cout << *identifier << std::endl; | ||
} | ||
} | ||
|
||
return 0; | ||
} |