Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
df138da2
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
df138da2
编写于
12月 28, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[iter/meta] Implement is_iterator
Removes use of auto type deduction again, which was not supported on many bots.
上级
8570da1d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
11 deletion
+48
-11
src/hb-iter.hh
src/hb-iter.hh
+39
-3
src/hb-meta.hh
src/hb-meta.hh
+2
-2
src/hb-open-type.hh
src/hb-open-type.hh
+7
-6
未找到文件。
src/hb-iter.hh
浏览文件 @
df138da2
...
...
@@ -55,6 +55,7 @@ struct hb_iter_t
typedef
Iter
iter_t
;
typedef
Item
item_t
;
enum
{
item_size
=
hb_static_size
(
Item
)
};
enum
{
is_iter
=
true
};
private:
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
...
...
@@ -88,6 +89,10 @@ struct hb_iter_t
};
#define HB_ITER_USING(Name) \
using typename Name::iter_t; \
using typename Name::item_t; \
using Name::item_size; \
using Name::is_iter; \
using Name::iter; \
using Name::operator bool; \
using Name::len; \
...
...
@@ -154,18 +159,49 @@ struct hb_iter_mixin_t
* Meta-programming predicates.
*/
template
<
class
T
,
typename
B
>
/* hb_is_iterable() */
template
<
typename
T
,
typename
B
>
struct
_hb_is_iterable
{
enum
{
value
=
false
};
};
template
<
class
T
>
template
<
typename
T
>
struct
_hb_is_iterable
<
T
,
hb_bool_tt
<
true
||
sizeof
(
hb_declval
<
T
>
().
iter
())
>
>
{
enum
{
value
=
true
};
};
template
<
class
T
>
template
<
typename
T
>
struct
hb_is_iterable
{
enum
{
value
=
_hb_is_iterable
<
T
,
hb_true_t
>::
value
};
};
#define hb_is_iterable(Iterable) hb_is_iterable<Iterable>::value
/* hb_is_iterator() */
/* The following SFINAE fails to match template parameters to hb_iter_t<>.
* As such, just check for member is_iter being there. */
# if 0
template
<
typename
T
=
void
>
char
_hb_is_iterator
(
T
*
)
{};
template
<
typename
Iter
,
typename
Item
>
int
_hb_is_iterator
(
hb_iter_t
<
Iter
,
Item
>
*
)
{};
static_assert
(
sizeof
(
char
)
!=
sizeof
(
int
),
""
);
template
<
typename
T
>
struct
hb_is_iterator
{
enum
{
value
=
sizeof
(
int
)
==
sizeof
(
_hb_is_iterator
(
hb_declval
<
T
*>
()))
};
};
#endif
template
<
typename
T
,
typename
B
>
struct
_hb_is_iterator
{
enum
{
value
=
false
};
};
template
<
typename
T
>
struct
_hb_is_iterator
<
T
,
hb_bool_tt
<
true
||
sizeof
(
T
::
is_iter
)
>
>
{
enum
{
value
=
true
};
};
template
<
typename
T
>
struct
hb_is_iterator
{
enum
{
value
=
_hb_is_iterator
<
T
,
hb_true_t
>::
value
};
};
#define hb_is_iterator(Iterator) hb_is_iterator<Iterator>::value
/*
* Algorithms operating on iterators or iteratables.
*/
...
...
src/hb-meta.hh
浏览文件 @
df138da2
...
...
@@ -48,10 +48,10 @@ typedef hb_bool_tt<true> hb_true_t;
typedef
hb_bool_tt
<
false
>
hb_false_t
;
template
<
bool
B
,
class
T
=
void
>
template
<
bool
B
,
typename
T
=
void
>
struct
hb_enable_if
{};
template
<
class
T
>
template
<
typename
T
>
struct
hb_enable_if
<
true
,
T
>
{
typedef
T
type
;
};
#define hb_enable_if(Cond) typename hb_enable_if<Cond>::type* = nullptr
...
...
src/hb-open-type.hh
浏览文件 @
df138da2
...
...
@@ -552,17 +552,18 @@ struct ArrayOf
if
(
unlikely
(
!
c
->
extend
(
*
this
)))
return_trace
(
false
);
return_trace
(
true
);
}
template
<
typename
Itera
ble
,
hb_enable_if
(
hb_is_itera
ble
(
Iterable
))>
template
<
typename
Itera
tor
,
hb_enable_if
(
hb_is_itera
tor
(
Iterator
))>
bool
serialize
(
hb_serialize_context_t
*
c
,
const
Iterable
&
items
)
Iterator
items
)
{
TRACE_SERIALIZE
(
this
);
unsigned
count
=
items
.
len
();
if
(
unlikely
(
!
serialize
(
c
,
count
)))
return_trace
(
false
);
auto
iter
=
items
.
iter
();
for
(
unsigned
i
=
0
;
i
<
count
;
i
++
,
iter
++
)
hb_assign
(
arrayZ
[
i
],
*
iter
);
/* TODO Umm. Just exhaust the iterator instead? Being extra
* cautious right now.. */
for
(
unsigned
i
=
0
;
i
<
count
;
i
++
,
items
++
)
hb_assign
(
arrayZ
[
i
],
*
items
);
return_trace
(
true
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录