Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
8001e00a
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
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看板
提交
8001e00a
编写于
12月 21, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[iter] First sample use
上级
19d2b501
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
20 deletion
+35
-20
src/Makefile.am
src/Makefile.am
+4
-1
src/hb-iter.hh
src/hb-iter.hh
+11
-14
src/test-iter.cc
src/test-iter.cc
+20
-5
未找到文件。
src/Makefile.am
浏览文件 @
8001e00a
...
...
@@ -388,13 +388,16 @@ compiled_tests = test-iter test-ot-tag test-unicode-ranges
check_PROGRAMS
+=
$(compiled_tests)
TESTS
+=
$(compiled_tests)
test_iter_SOURCES
=
test-iter.cc
test_iter_SOURCES
=
test-iter.cc hb-static.cc
test_iter_CPPFLAGS
=
$(HBCFLAGS)
-DMAIN
test_iter_LDADD
=
libharfbuzz.la
$(HBLIBS)
test_ot_tag_SOURCES
=
hb-ot-tag.cc
test_ot_tag_CPPFLAGS
=
$(HBCFLAGS)
-DMAIN
test_ot_tag_LDADD
=
libharfbuzz.la
$(HBLIBS)
test_unicode_ranges_SOURCES
=
test-unicode-ranges.cc
test_unicode_ranges_CPPFLAGS
=
$(HBCFLAGS)
-DMAIN
test_unicode_ranges_LDADD
=
libharfbuzz.la
$(HBLIBS)
TESTS_ENVIRONMENT
=
\
...
...
src/hb-iter.hh
浏览文件 @
8001e00a
...
...
@@ -41,11 +41,11 @@
*/
/* Base class for all iterators. */
template
<
typename
Iter
>
template
<
typename
Iter
,
typename
Item
=
typename
Iter
::
__item_type__
>
struct
hb_iter_t
{
typedef
Iter
type_t
;
typedef
typename
Iter
::
__type__
item_type_t
;
typedef
Item
item_type_t
;
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
const
type_t
*
thiz
()
const
{
return
static_cast
<
const
type_t
*>
(
this
);
}
...
...
@@ -56,10 +56,10 @@ struct hb_iter_t
explicit_operator
bool
()
const
{
return
more
();
}
item_type_t
&
operator
*
()
{
return
item
();
}
item_type_t
&
operator
[]
(
unsigned
i
)
{
return
item
(
i
);
}
type_t
&
operator
+=
(
unsigned
count
)
{
forward
(
count
);
return
thiz
();
}
type_t
&
operator
++
()
{
next
();
return
thiz
();
}
type_t
&
operator
-=
(
unsigned
count
)
{
rewind
(
count
);
return
thiz
();
}
type_t
&
operator
--
()
{
prev
();
return
thiz
();
}
type_t
&
operator
+=
(
unsigned
count
)
{
forward
(
count
);
return
*
thiz
();
}
type_t
&
operator
++
()
{
next
();
return
*
thiz
();
}
type_t
&
operator
-=
(
unsigned
count
)
{
rewind
(
count
);
return
*
thiz
();
}
type_t
&
operator
--
()
{
prev
();
return
*
thiz
();
}
type_t
operator
+
(
unsigned
count
)
{
type_t
c
(
*
thiz
());
c
+=
count
;
return
c
;
}
type_t
operator
++
(
int
)
{
type_t
c
(
*
thiz
());
++*
thiz
();
return
c
;
}
type_t
operator
-
(
unsigned
count
)
{
type_t
c
(
*
thiz
());
c
-=
count
;
return
c
;
}
...
...
@@ -67,8 +67,8 @@ struct hb_iter_t
/* Methods. */
type_t
iter
()
const
{
return
*
thiz
();
}
item_type_t
item
()
const
{
return
thiz
()
->
__item__
();
}
item_type_t
item
(
unsigned
i
)
const
{
return
thiz
()
->
__item
__
(
i
);
}
item_type_t
&
item
()
const
{
return
thiz
()
->
__item__
();
}
item_type_t
&
item_at
(
unsigned
i
)
const
{
return
thiz
()
->
__item_at
__
(
i
);
}
bool
more
()
const
{
return
thiz
()
->
__more__
();
}
void
next
()
{
thiz
()
->
__next__
();
}
void
forward
(
unsigned
n
)
{
thiz
()
->
__forward__
(
n
);
}
...
...
@@ -80,12 +80,9 @@ struct hb_iter_t
* Subclasses overrides:
*/
/* Item type. */
//typedef ... __type__;
/* Access: Implement __item__(), or __item__(n) if random-access. */
item_type_t
__item__
()
const
{
return
thiz
()
->
item
(
0
);
}
item_type_t
__item__
(
unsigned
i
)
const
{
return
*
(
thiz
()
+
i
);
}
/* Access: Implement __item__(), or __item_at__() if random-access. */
item_type_t
&
__item__
()
const
{
return
thiz
()
->
item_at
(
0
);
}
item_type_t
&
__item_at__
(
unsigned
i
)
const
{
return
*
(
thiz
()
+
i
);
}
/* Termination: Implement __more__() or __end__(). */
bool
__more__
()
const
{
return
item
()
!=
thiz
()
->
__end__
();
}
...
...
src/test-iter.cc
浏览文件 @
8001e00a
...
...
@@ -26,16 +26,32 @@
#include "hb-iter.hh"
#include "hb-array.hh"
template
<
typename
T
>
struct
array_iter_t
:
hb_iter_t
<
array_iter_t
<
T
>
,
T
>
{
array_iter_t
(
hb_array_t
<
T
>
arr_
)
:
arr
(
arr_
)
{}
T
&
__item_at__
(
unsigned
i
)
const
{
return
arr
[
i
];
}
bool
__more__
()
const
{
return
arr
.
len
;
}
void
__forward__
(
unsigned
n
)
{
arr
+=
n
;
}
void
__rewind__
(
unsigned
n
)
{
arr
-=
n
;
}
unsigned
__len__
()
const
{
return
arr
.
len
;
}
private:
hb_array_t
<
T
>
arr
;
};
int
main
(
int
argc
,
char
**
argv
)
{
const
int
src
[
10
]
=
{};
int
dst
[
20
];
#if 0
hb_iter_t<const int *> s (src);
hb_iter_t<const int *> s2 (src, 5);
hb_iter_t<int *> t (dst);
array_iter_t
<
const
int
>
s
(
src
);
array_iter_t
<
const
int
>
s2
(
src
);
array_iter_t
<
int
>
t
(
dst
);
s2
=
s
;
...
...
@@ -43,7 +59,6 @@ main (int argc, char **argv)
{
*
t
=
*
s
;
}
#endif
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录