提交 7584ca2f 编写于 作者: N Nathan Hourt

Remove cruft, rename BitShares -> Eos

上级 26777134
......@@ -69,7 +69,7 @@ ENDIF()
if( WIN32 )
message( STATUS "Configuring BitShares on WIN32")
message( STATUS "Configuring Eos on WIN32")
set( DB_VERSION 60 )
set( BDB_STATIC_LIBS 1 )
......@@ -110,11 +110,11 @@ else( WIN32 ) # Apple AND Linux
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring BitShares on OS X" )
message( STATUS "Configuring Eos on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring BitShares on Linux" )
message( STATUS "Configuring Eos on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
set( rt_library rt )
set( pthread_library pthread)
......@@ -144,7 +144,7 @@ else( WIN32 ) # Apple AND Linux
endif( WIN32 )
set(ENABLE_COVERAGE_TESTING FALSE CACHE BOOL "Build BitShares for code coverage analysis")
set(ENABLE_COVERAGE_TESTING FALSE CACHE BOOL "Build Eos for code coverage analysis")
if(ENABLE_COVERAGE_TESTING)
SET(CMAKE_CXX_FLAGS "--coverage ${CMAKE_CXX_FLAGS}")
......@@ -173,18 +173,18 @@ set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "A client for the BitShares network")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A client for the BitShares network")
set(CPACK_PACKAGE_DESCRIPTION "A client for the Eos network")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A client for the Eos network")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "BitShares ${CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Eos ${CPACK_PACKAGE_VERSION}")
if(WIN32)
SET(CPACK_GENERATOR "ZIP;NSIS")
set(CPACK_PACKAGE_NAME "BitShares") # override above
set(CPACK_PACKAGE_NAME "Eos") # override above
set(CPACK_NSIS_EXECUTABLES_DIRECTORY .)
set(CPACK_NSIS_PACKAGE_NAME "BitShares v${CPACK_PACKAGE_VERSION}")
set(CPACK_NSIS_PACKAGE_NAME "Eos v${CPACK_PACKAGE_VERSION}")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_PACKAGE_NAME}")
set(CPACK_NSIS_DEFINES " !define MUI_STARTMENUPAGE_DEFAULTFOLDER \\\"BitShares\\\"")
set(CPACK_NSIS_DEFINES " !define MUI_STARTMENUPAGE_DEFAULTFOLDER \\\"Eos\\\"")
# it seems like windows zip files usually don't have a single directory inside them, unix tgz frequently do
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
......
......@@ -107,7 +107,7 @@ namespace detail {
void reset_p2p_node(const fc::path& data_dir)
{ try {
_p2p_network = std::make_shared<net::node>("BitShares Reference Implementation");
_p2p_network = std::make_shared<net::node>("Eos Reference Implementation");
_p2p_network->load_configuration(data_dir / "p2p");
_p2p_network->set_node_delegate(this);
......
add_subdirectory( build_helpers )
add_subdirectory( producer_node )
add_subdirectory( debug_node )
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} )
add_executable( member_enumerator member_enumerator.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( member_enumerator PRIVATE fc eos_app eos_net eos_chain eos_egenesis_brief eos_utilities ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
#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::create_directories(opath.parent_path());
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;
}
#!/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( eos::... in all cpp,hpp files under libraries/ programs/ tests/
re_reflect = re.compile(r"""
FC_REFLECT\s*[(]
\s*(eos::[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*(eos::[a-zA-Z0-9_:]+)
\s*,
\s*[(]\s*(eos::[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)
return
"""
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)
"""
validate_members(name2members_doxygen, name2members_re)
/*
* Copyright (c) 2017, Respective Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Any modified source or binaries are used only with the BitShares network.
*
* 2. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <eos/chain/protocol/protocol.hpp>
#include <eos/chain/producer_object.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/io/json.hpp>
#include <iostream>
using namespace eos::chain;
namespace eos { namespace member_enumerator {
struct class_processor
{
class_processor( std::map< std::string, std::vector< std::string > >& r ) : result(r) {}
template< typename T >
void process_class( const T* dummy );
template< typename... T >
void process_class( const static_variant< T... >* dummy );
template< typename T >
void process_class( const std::vector< T >* dummy );
template< typename K, typename V >
void process_class( const std::map< K, V >* dummy );
template< typename T >
void process_class( const fc::flat_set< T >* dummy );
template< typename K, typename V >
void process_class( const fc::flat_map< K, V >* dummy );
template< typename T >
void process_class( const fc::optional< T >* dummy );
template< typename T >
static void process_class( std::map< std::string, std::vector< std::string > >& result );
std::map< std::string, std::vector< std::string > >& result;
};
template< typename T >
struct member_visitor
{
member_visitor( class_processor* p ) : proc(p) {}
template<typename Member, class Class, Member (Class::*member)>
void operator()( const char* name )const
{
members.emplace_back( name );
proc->process_class( (const Member*) nullptr );
}
class_processor* proc;
mutable std::vector< std::string > members;
};
struct static_variant_visitor
{
static_variant_visitor( class_processor* p ) : proc(p) {}
typedef void result_type;
template<typename T>
void operator()( const T& element )const
{
proc->process_class( (const T*) nullptr );
}
class_processor* proc;
};
template< typename... T >
void class_processor::process_class( const static_variant< T... >* dummy )
{
static_variant<T...> dummy2;
static_variant_visitor vtor( this );
for( int w=0; w<dummy2.count(); w++ )
{
dummy2.set_which(w);
dummy2.visit( vtor );
}
}
template<typename IsReflected=fc::false_type>
struct if_reflected
{
template< typename T >
static void process_class( class_processor* proc, const T* dummy )
{
std::string tname = fc::get_typename<T>::name();
std::cerr << "skipping non-reflected class " << tname << std::endl;
}
};
template<>
struct if_reflected<fc::true_type>
{
template< typename T >
static void process_class( class_processor* proc, const T* dummy )
{
std::string tname = fc::get_typename<T>::name();
if( proc->result.find( tname ) != proc->result.end() )
return;
ilog( "processing class ${c}", ("c", tname) );
// need this to keep from recursing on same class
proc->result.emplace( tname, std::vector< std::string >() );
member_visitor<T> vtor( proc );
fc::reflector<T>::visit( vtor );
ilog( "members of class ${c} are ${m}", ("c", tname)("m", vtor.members) );
proc->result[tname] = vtor.members;
}
};
template< typename T >
void class_processor::process_class( const T* dummy )
{
if_reflected< typename fc::reflector<T>::is_defined >::process_class( this, dummy );
}
template< typename T >
void class_processor::process_class( const std::vector< T >* dummy )
{
process_class( (T*) nullptr );
}
template< typename K, typename V >
void class_processor::process_class( const std::map< K, V >* dummy )
{
process_class( (K*) nullptr );
process_class( (V*) nullptr );
}
template< typename T >
void class_processor::process_class( const fc::flat_set< T >* dummy )
{
process_class( (T*) nullptr );
}
template< typename K, typename V >
void class_processor::process_class( const fc::flat_map< K, V >* dummy )
{
process_class( (K*) nullptr );
process_class( (V*) nullptr );
}
template< typename T >
void class_processor::process_class( const fc::optional< T >* dummy )
{
process_class( (T*) nullptr );
}
template< typename T >
void class_processor::process_class( std::map< std::string, std::vector< std::string > >& result )
{
class_processor proc(result);
proc.process_class( (T*) nullptr );
}
} }
int main( int argc, char** argv )
{
try
{
std::map< std::string, std::vector< std::string > > result;
eos::member_enumerator::class_processor::process_class<signed_block>(result);
//eos::member_enumerator::process_class<transfer_operation>(result);
fc::mutable_variant_object mvo;
for( const std::pair< std::string, std::vector< std::string > >& e : result )
{
variant v;
to_variant( e.second, v );
mvo.set( e.first, v );
}
std::cout << fc::json::to_string( mvo ) << std::endl;
}
catch ( const fc::exception& e )
{
edump((e.to_detail_string()));
}
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册