Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
1d759799
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1d759799
编写于
5月 31, 2018
作者:
T
Thomas Cox
提交者:
GitHub
5月 31, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into thomasbcox-rc-edits
上级
6dc27f63
6208abd2
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
63 addition
and
27 deletion
+63
-27
libraries/abi_generator/abi_generator.cpp
libraries/abi_generator/abi_generator.cpp
+28
-16
libraries/abi_generator/include/eosio/abi_generator/abi_generator.hpp
...i_generator/include/eosio/abi_generator/abi_generator.hpp
+9
-6
libraries/chain/fork_database.cpp
libraries/chain/fork_database.cpp
+0
-2
libraries/chain/resource_limits.cpp
libraries/chain/resource_limits.cpp
+0
-2
programs/cleos/httpc.cpp
programs/cleos/httpc.cpp
+1
-1
unittests/abi_tests.cpp
unittests/abi_tests.cpp
+25
-0
未找到文件。
libraries/abi_generator/abi_generator.cpp
浏览文件 @
1d759799
...
...
@@ -124,7 +124,7 @@ bool abi_generator::inspect_type_methods_for_actions(const Decl* decl) { try {
qt
.
setLocalFastQualifiers
(
0
);
string
field_name
=
p
->
getNameAsString
();
string
field_type_name
=
add_type
(
qt
);
string
field_type_name
=
add_type
(
qt
,
0
);
field_def
struct_field
{
field_name
,
field_type_name
};
ABI_ASSERT
(
is_builtin_type
(
get_vector_element_type
(
struct_field
.
type
))
...
...
@@ -236,7 +236,7 @@ void abi_generator::handle_decl(const Decl* decl) { try {
auto
qt
=
action_decl
->
getTypeForDecl
()
->
getCanonicalTypeInternal
();
auto
type_name
=
add_struct
(
qt
);
auto
type_name
=
add_struct
(
qt
,
""
,
0
);
ABI_ASSERT
(
!
is_builtin_type
(
type_name
),
"A built-in type with the same name exists, try using another name: ${type_name}"
,
(
"type_name"
,
type_name
));
...
...
@@ -259,7 +259,7 @@ void abi_generator::handle_decl(const Decl* decl) { try {
ABI_ASSERT
(
table_decl
!=
nullptr
);
auto
qt
=
table_decl
->
getTypeForDecl
()
->
getCanonicalTypeInternal
();
auto
type_name
=
add_struct
(
qt
);
auto
type_name
=
add_struct
(
qt
,
""
,
0
);
ABI_ASSERT
(
!
is_builtin_type
(
type_name
),
"A built-in type with the same name exists, try using another name: ${type_name}"
,
(
"type_name"
,
type_name
));
...
...
@@ -433,7 +433,11 @@ const struct_def* abi_generator::find_struct(const type_name& name) {
type_name
abi_generator
::
resolve_type
(
const
type_name
&
type
){
const
auto
*
td
=
find_type
(
type
);
if
(
td
)
{
return
resolve_type
(
td
->
type
);
for
(
auto
i
=
output
->
types
.
size
();
i
>
0
;
--
i
)
{
// avoid infinite recursion
const
type_name
&
t
=
td
->
type
;
td
=
find_type
(
t
);
if
(
td
==
nullptr
)
return
t
;
}
}
return
type
;
}
...
...
@@ -505,7 +509,9 @@ string abi_generator::get_type_name(const clang::QualType& qt, bool with_namespa
return
name
;
}
clang
::
QualType
abi_generator
::
add_typedef
(
const
clang
::
QualType
&
tqt
)
{
clang
::
QualType
abi_generator
::
add_typedef
(
const
clang
::
QualType
&
tqt
,
size_t
recursion_depth
)
{
ABI_ASSERT
(
++
recursion_depth
<
max_recursion_depth
,
"recursive definition, max_recursion_depth"
);
clang
::
QualType
qt
(
get_named_type_if_elaborated
(
tqt
));
...
...
@@ -516,7 +522,7 @@ clang::QualType abi_generator::add_typedef(const clang::QualType& tqt) {
auto
underlying_type_name
=
get_type_name
(
underlying_type
);
if
(
is_vector
(
underlying_type
)
)
{
underlying_type_name
=
add_vector
(
underlying_type
);
underlying_type_name
=
add_vector
(
underlying_type
,
recursion_depth
);
}
type_def
abi_typedef
;
...
...
@@ -531,7 +537,7 @@ clang::QualType abi_generator::add_typedef(const clang::QualType& tqt) {
}
if
(
is_typedef
(
underlying_type
)
&&
!
is_builtin_type
(
get_type_name
(
underlying_type
))
)
return
add_typedef
(
underlying_type
);
return
add_typedef
(
underlying_type
,
recursion_depth
);
return
underlying_type
;
}
...
...
@@ -568,14 +574,16 @@ const clang::RecordDecl::field_range abi_generator::get_struct_fields(const clan
return
record_type
->
getDecl
()
->
fields
();
}
string
abi_generator
::
add_vector
(
const
clang
::
QualType
&
vqt
)
{
string
abi_generator
::
add_vector
(
const
clang
::
QualType
&
vqt
,
size_t
recursion_depth
)
{
ABI_ASSERT
(
++
recursion_depth
<
max_recursion_depth
,
"recursive definition, max_recursion_depth"
);
clang
::
QualType
qt
(
get_named_type_if_elaborated
(
vqt
));
auto
vector_element_type
=
get_vector_element_type
(
qt
);
ABI_ASSERT
(
!
is_vector
(
vector_element_type
),
"Only one-dimensional arrays are supported"
);
add_type
(
vector_element_type
);
add_type
(
vector_element_type
,
recursion_depth
);
auto
vector_element_type_str
=
translate_type
(
get_type_name
(
vector_element_type
));
vector_element_type_str
+=
"[]"
;
...
...
@@ -583,7 +591,9 @@ string abi_generator::add_vector(const clang::QualType& vqt) {
return
vector_element_type_str
;
}
string
abi_generator
::
add_type
(
const
clang
::
QualType
&
tqt
)
{
string
abi_generator
::
add_type
(
const
clang
::
QualType
&
tqt
,
size_t
recursion_depth
)
{
ABI_ASSERT
(
++
recursion_depth
<
max_recursion_depth
,
"recursive definition, max_recursion_depth"
);
clang
::
QualType
qt
(
get_named_type_if_elaborated
(
tqt
));
...
...
@@ -596,7 +606,7 @@ string abi_generator::add_type(const clang::QualType& tqt) {
}
if
(
is_typedef
(
qt
)
)
{
qt
=
add_typedef
(
qt
);
qt
=
add_typedef
(
qt
,
recursion_depth
);
if
(
is_builtin_type
(
translate_type
(
get_type_name
(
qt
)))
)
{
return
type_name
;
}
...
...
@@ -604,12 +614,12 @@ string abi_generator::add_type(const clang::QualType& tqt) {
}
if
(
is_vector
(
qt
)
)
{
auto
vector_type_name
=
add_vector
(
qt
);
auto
vector_type_name
=
add_vector
(
qt
,
recursion_depth
);
return
is_type_def
?
type_name
:
vector_type_name
;
}
if
(
is_struct
(
qt
)
)
{
return
add_struct
(
qt
,
full_type_name
);
return
add_struct
(
qt
,
full_type_name
,
recursion_depth
);
}
ABI_ASSERT
(
false
,
"types can only be: vector, struct, class or a built-in type. (${type}) "
,
(
"type"
,
get_type_name
(
qt
)));
...
...
@@ -623,7 +633,9 @@ clang::QualType abi_generator::get_named_type_if_elaborated(const clang::QualTyp
return
qt
;
}
string
abi_generator
::
add_struct
(
const
clang
::
QualType
&
sqt
,
string
full_name
)
{
string
abi_generator
::
add_struct
(
const
clang
::
QualType
&
sqt
,
string
full_name
,
size_t
recursion_depth
)
{
ABI_ASSERT
(
++
recursion_depth
<
max_recursion_depth
,
"recursive definition, max_recursion_depth"
);
clang
::
QualType
qt
(
get_named_type_if_elaborated
(
sqt
));
...
...
@@ -653,7 +665,7 @@ string abi_generator::add_struct(const clang::QualType& sqt, string full_name) {
const
auto
*
record_type
=
base_qt
->
getAs
<
clang
::
RecordType
>
();
if
(
record_type
&&
is_struct
(
base_qt
)
&&
!
record_type
->
getDecl
()
->
field_empty
()
)
{
ABI_ASSERT
(
total_bases
==
0
,
"Multiple inheritance not supported - ${type}"
,
(
"type"
,
full_name
));
base_name
=
add_type
(
base_qt
);
base_name
=
add_type
(
base_qt
,
recursion_depth
);
++
total_bases
;
}
++
bitr
;
...
...
@@ -664,7 +676,7 @@ string abi_generator::add_struct(const clang::QualType& sqt, string full_name) {
clang
::
QualType
qt
=
field
->
getType
();
string
field_name
=
field
->
getNameAsString
();
string
field_type_name
=
add_type
(
qt
);
string
field_type_name
=
add_type
(
qt
,
recursion_depth
);
field_def
struct_field
{
field_name
,
field_type_name
};
ABI_ASSERT
(
is_builtin_type
(
get_vector_element_type
(
struct_field
.
type
))
...
...
libraries/abi_generator/include/eosio/abi_generator/abi_generator.hpp
浏览文件 @
1d759799
...
...
@@ -160,6 +160,7 @@ namespace eosio {
*/
class
abi_generator
{
private:
static
constexpr
size_t
max_recursion_depth
=
25
;
// arbitrary depth to prevent infinite recursion
bool
verbose
;
int
optimizations
;
abi_def
*
output
;
...
...
@@ -171,6 +172,7 @@ namespace eosio {
string
target_contract
;
vector
<
string
>
target_actions
;
ricardian_contracts
rc
;
public:
enum
optimization
{
...
...
@@ -178,7 +180,8 @@ namespace eosio {
};
abi_generator
()
:
optimizations
(
0
)
:
verbose
(
false
)
,
optimizations
(
0
)
,
output
(
nullptr
)
,
compiler_instance
(
nullptr
)
,
ast_context
(
nullptr
)
...
...
@@ -283,17 +286,17 @@ namespace eosio {
string
decl_to_string
(
clang
::
Decl
*
d
);
bool
is_typedef
(
const
clang
::
QualType
&
qt
);
QualType
add_typedef
(
const
clang
::
QualType
&
qt
);
QualType
add_typedef
(
const
clang
::
QualType
&
qt
,
size_t
recursion_depth
);
bool
is_vector
(
const
clang
::
QualType
&
qt
);
bool
is_vector
(
const
string
&
type_name
);
string
add_vector
(
const
clang
::
QualType
&
qt
);
string
add_vector
(
const
clang
::
QualType
&
qt
,
size_t
recursion_depth
);
bool
is_struct
(
const
clang
::
QualType
&
qt
);
string
add_struct
(
const
clang
::
QualType
&
qt
,
string
full_type_name
=
""
);
string
add_struct
(
const
clang
::
QualType
&
qt
,
string
full_type_name
,
size_t
recursion_depth
);
string
get_type_name
(
const
clang
::
QualType
&
qt
,
bool
no_namespace
);
string
add_type
(
const
clang
::
QualType
&
tqt
);
string
add_type
(
const
clang
::
QualType
&
tqt
,
size_t
recursion_depth
);
bool
is_elaborated
(
const
clang
::
QualType
&
qt
);
bool
is_struct_specialization
(
const
clang
::
QualType
&
qt
);
...
...
libraries/chain/fork_database.cpp
浏览文件 @
1d759799
...
...
@@ -79,8 +79,6 @@ namespace eosio { namespace chain {
void
fork_database
::
close
()
{
if
(
my
->
index
.
size
()
==
0
)
return
;
fc
::
datastream
<
size_t
>
ps
;
auto
fork_db_dat
=
my
->
datadir
/
config
::
forkdb_filename
;
std
::
ofstream
out
(
fork_db_dat
.
generic_string
().
c_str
(),
std
::
ios
::
out
|
std
::
ios
::
binary
|
std
::
ofstream
::
trunc
);
uint32_t
num_blocks_in_fork_db
=
my
->
index
.
size
();
...
...
libraries/chain/resource_limits.cpp
浏览文件 @
1d759799
...
...
@@ -93,7 +93,6 @@ void resource_limits_manager::update_account_usage(const flat_set<account_name>&
void
resource_limits_manager
::
add_transaction_usage
(
const
flat_set
<
account_name
>&
accounts
,
uint64_t
cpu_usage
,
uint64_t
net_usage
,
uint32_t
time_slot
)
{
const
auto
&
state
=
_db
.
get
<
resource_limits_state_object
>
();
const
auto
&
config
=
_db
.
get
<
resource_limits_config_object
>
();
set
<
std
::
pair
<
account_name
,
permission_name
>>
authorizing_accounts
;
for
(
const
auto
&
a
:
accounts
)
{
...
...
@@ -232,7 +231,6 @@ bool resource_limits_manager::set_account_limits( const account_name& account, i
*/
}
auto
old_ram_bytes
=
limits
.
ram_bytes
;
_db
.
modify
(
limits
,
[
&
](
resource_limits_object
&
pending_limits
){
pending_limits
.
ram_bytes
=
ram_bytes
;
pending_limits
.
net_weight
=
net_weight
;
...
...
programs/cleos/httpc.cpp
浏览文件 @
1d759799
...
...
@@ -95,7 +95,7 @@ namespace eosio { namespace client { namespace http {
if
(
res
.
server
.
empty
())
FC_THROW
(
"No server parsed from URL
\"
${u}
\"
"
,
(
"u"
,
server_url
));
if
(
res
.
port
.
empty
())
res
.
port
=
res
.
scheme
==
"http"
?
"8
888
"
:
"443"
;
res
.
port
=
res
.
scheme
==
"http"
?
"8
0
"
:
"443"
;
boost
::
trim_right_if
(
res
.
path_prefix
,
boost
::
is_any_of
(
"/"
));
return
res
;
}
...
...
unittests/abi_tests.cpp
浏览文件 @
1d759799
...
...
@@ -3297,6 +3297,31 @@ BOOST_AUTO_TEST_CASE(abi_type_redefine_to_name)
}
FC_LOG_AND_RETHROW
()
}
BOOST_AUTO_TEST_CASE
(
abi_type_nested_in_vector
)
{
try
{
// inifinite loop in types
const
char
*
repeat_abi
=
R"=====(
{
"types": [],
"structs": [{
"name": "store_t",
"base": "",
"fields": [{
"name": "id",
"type": "uint64"
},{
"name": "childs",
"type": "store_t[]"
}],
"actions": [],
"tables": []
}
)====="
;
BOOST_CHECK_THROW
(
abi_serializer
abis
(
fc
::
json
::
from_string
(
repeat_abi
).
as
<
abi_def
>
()),
fc
::
exception
);
}
FC_LOG_AND_RETHROW
()
}
BOOST_AUTO_TEST_CASE
(
abi_account_name_in_eosio_abi
)
{
try
{
// inifinite loop in types
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录