forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
2 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
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
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,8 @@ | ||
|
||
add_executable( cat-parts cat-parts.cpp ) | ||
if( UNIX AND NOT APPLE ) | ||
set(rt_library rt ) | ||
endif() | ||
|
||
# we only actually need Boost, but link against FC for now so we don't duplicate it. | ||
target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) |
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,77 @@ | ||
|
||
#include <boost/filesystem.hpp> | ||
#include <boost/filesystem/fstream.hpp> | ||
|
||
#include <algorithm> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
int main( int argc, char** argv, char** envp ) | ||
{ | ||
if( argc != 3 ) | ||
{ | ||
std::cerr << "syntax: cat-parts DIR OUTFILE" << std::endl; | ||
return 1; | ||
} | ||
|
||
boost::filesystem::path p(argv[1]); | ||
|
||
try | ||
{ | ||
std::vector< boost::filesystem::path > v; | ||
|
||
for( boost::filesystem::directory_iterator it(p); | ||
it != boost::filesystem::directory_iterator(); | ||
++it ) | ||
{ | ||
boost::filesystem::path pit = it->path(); | ||
std::string spit = pit.generic_string(); | ||
size_t n = spit.length(); | ||
if( n <= 3 ) | ||
continue; | ||
if( spit.substr(n-3, 3) != ".hf" ) | ||
continue; | ||
v.push_back( pit ); | ||
} | ||
std::sort( v.begin(), v.end() ); | ||
|
||
// open each file and grab its contents, concatenating into single stringstream | ||
std::stringstream ss_data; | ||
for( const boost::filesystem::path& p : v ) | ||
{ | ||
boost::filesystem::ifstream ifs(p); | ||
ss_data << ifs.rdbuf(); | ||
} | ||
std::string new_data = ss_data.str(); | ||
|
||
boost::filesystem::path opath(argv[2]); | ||
|
||
if( boost::filesystem::exists( opath ) ) | ||
{ | ||
boost::filesystem::ifstream ifs(opath); | ||
std::stringstream ss_old_data; | ||
ss_old_data << ifs.rdbuf(); | ||
std::string old_data = ss_old_data.str(); | ||
if( old_data == new_data ) | ||
{ | ||
std::cerr << "File " << opath << " up-to-date with .d directory" << std::endl; | ||
return 0; | ||
} | ||
} | ||
|
||
{ | ||
boost::filesystem::ofstream ofs(opath); | ||
ofs.write( new_data.c_str(), new_data.length() ); | ||
} | ||
|
||
std::cerr << "Built " << opath << " from .d directory" << std::endl; | ||
} | ||
catch( const boost::filesystem::filesystem_error& e ) | ||
{ | ||
std::cout << e.what() << std::endl; | ||
return 1; | ||
} | ||
return 0; | ||
} |
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,133 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import os | ||
import re | ||
import xml.etree.ElementTree as etree | ||
|
||
def process_node(path, node): | ||
""" | ||
if node.tag == "TestCase": | ||
if node.attrib.get("result", "UNKNOWN") != "passed": | ||
failset.add(node) | ||
return | ||
if node.tag in ["TestResult", "TestSuite"]: | ||
for child in node: | ||
cpath = path+"/"+child.attrib["name"] | ||
process_node(cpath, child) | ||
return | ||
""" | ||
#print("unknown node", node.tag) | ||
print(node.tag) | ||
return | ||
|
||
name2members_doxygen = {} | ||
|
||
def process_class_node(node): | ||
result = {"name":"", "vmembers":[]} | ||
for child in node: | ||
if child.tag == "name": | ||
result["name"] = child.text | ||
elif child.tag == "member": | ||
kind = child.attrib.get("kind") | ||
if kind == "variable": | ||
result["vmembers"].append(child[0].text) | ||
name2members_doxygen[result["name"]] = result["vmembers"] | ||
return | ||
|
||
tree = etree.parse("doxygen/xml/index.xml") | ||
root = tree.getroot() | ||
for child in root: | ||
if (child.tag == "compound") and (child.attrib.get("kind") in ["struct", "class"]): | ||
process_class_node(child) | ||
|
||
s_static_names = set(["space_id", "type_id"]) | ||
|
||
for k, v in name2members_doxygen.items(): | ||
name2members_doxygen[k] = [x for x in v if x not in s_static_names] | ||
|
||
#with open("stuff/member_enumerator.out", "r") as f: | ||
# name2members_fc = json.load(f) | ||
|
||
# scan for FC_REFLECT( graphene::... in all cpp,hpp files under libraries/ programs/ tests/ | ||
|
||
re_reflect = re.compile(r""" | ||
FC_REFLECT\s*[(] | ||
\s*(steemit::[a-zA-Z0-9_:]+) | ||
\s*, | ||
((?:\s*[(]\s*[a-zA-Z0-9_]+\s*[)])*) | ||
""", re.VERBOSE) | ||
|
||
re_reflect_derived = re.compile(r""" | ||
FC_REFLECT_DERIVED\s*[(] | ||
\s*(steemit::[a-zA-Z0-9_:]+) | ||
\s*, | ||
\s*[(]\s*((?:graphene|steemit)::[a-zA-Z0-9_:]+)\s*[)] | ||
\s*, | ||
((?:\s*[(]\s*[a-zA-Z0-9_]+\s*[)])*) | ||
""", re.VERBOSE) | ||
|
||
re_bubble_item = re.compile(r"\s*[(]\s*([a-zA-Z0-9_]+)\s*") | ||
|
||
def bubble_list(x): | ||
return [re_bubble_item.match(e).group(1) for e in x.split(")")[:-1]] | ||
|
||
name2members_re = {} | ||
|
||
for root, dirs, files in os.walk("."): | ||
if root == ".": | ||
dirs[:] = ["libraries", "programs", "tests"] | ||
for filename in files: | ||
if not (filename.endswith(".cpp") or filename.endswith(".hpp")): | ||
continue | ||
try: | ||
with open( os.path.join(root, filename), "r" ) as f: | ||
content = f.read() | ||
for m in re_reflect.finditer(content): | ||
cname = m.group(1) | ||
members = bubble_list(m.group(2)) | ||
name2members_re[cname] = members | ||
if cname.endswith("_object"): | ||
print("FC_REFLECT on {} should be FC_REFLECT_DERIVED".format(cname)) | ||
for m in re_reflect_derived.finditer(content): | ||
cname = m.group(1) | ||
members = bubble_list(m.group(3)) | ||
name2members_re[cname] = members | ||
except OSError as e: | ||
pass | ||
|
||
def validate_members(name2members_ref, name2members_test): | ||
ok_items = [] | ||
ne_items = [] | ||
error_items = [] | ||
|
||
for name in sorted(name2members_ref.keys()): | ||
if name not in name2members_test: | ||
ne_items.append(name) | ||
elif sorted(name2members_ref[name]) != sorted(name2members_test[name]): | ||
error_items.append(name) | ||
print("") | ||
print("error in", name) | ||
print("doxygen:", name2members_ref[name]) | ||
print("fc :", name2members_test[name]) | ||
else: | ||
ok_items.append(name) | ||
|
||
print("") | ||
print("ok:") | ||
for item in ok_items: | ||
print(item) | ||
|
||
print("") | ||
print("not evaluated:") | ||
for item in ne_items: | ||
print(item) | ||
|
||
print("") | ||
print("error:") | ||
for item in error_items: | ||
print(item) | ||
|
||
return | ||
|
||
validate_members(name2members_doxygen, name2members_re) |