Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
694eaf63
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
694eaf63
编写于
2月 14, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[set] Add backwards iterator
New API: - hb_set_previous() - hb_set_previous_range()
上级
fe3bc524
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
194 addition
and
8 deletion
+194
-8
docs/harfbuzz-sections.txt
docs/harfbuzz-sections.txt
+2
-0
src/hb-set-private.hh
src/hb-set-private.hh
+78
-1
src/hb-set.cc
src/hb-set.cc
+48
-1
src/hb-set.h
src/hb-set.h
+15
-4
test/api/test-set.c
test/api/test-set.c
+51
-2
未找到文件。
docs/harfbuzz-sections.txt
浏览文件 @
694eaf63
...
...
@@ -528,7 +528,9 @@ hb_set_intersect
hb_set_is_empty
hb_set_is_equal
hb_set_next
hb_set_previous
hb_set_next_range
hb_set_previous_range
hb_set_reference
hb_set_set
hb_set_set_user_data
...
...
src/hb-set-private.hh
浏览文件 @
694eaf63
...
...
@@ -121,6 +121,33 @@ struct hb_set_t
*
codepoint
=
INVALID
;
return
false
;
found:
*
codepoint
=
i
*
ELT_BITS
+
j
;
return
true
;
}
inline
bool
previous
(
hb_codepoint_t
*
codepoint
)
const
{
unsigned
int
m
=
(
*
codepoint
-
1
)
&
MASK
;
if
(
m
==
MASK
)
{
*
codepoint
=
INVALID
;
return
false
;
}
unsigned
int
i
=
m
/
ELT_BITS
;
unsigned
int
j
=
m
&
ELT_MASK
;
for
(;
(
int
)
j
>=
0
;
j
--
)
if
(
v
[
i
]
&
(
elt_t
(
1
)
<<
j
))
goto
found
;
for
(
i
--
;
(
int
)
i
>=
0
;
i
--
)
if
(
v
[
i
])
for
(
j
=
ELT_BITS
-
1
;
(
int
)
j
>=
0
;
j
--
)
if
(
v
[
i
]
&
(
elt_t
(
1
)
<<
j
))
goto
found
;
*
codepoint
=
INVALID
;
return
false
;
found:
*
codepoint
=
i
*
ELT_BITS
+
j
;
return
true
;
...
...
@@ -476,7 +503,7 @@ struct hb_set_t
if
(
pages
[
page_map
[
i
].
index
].
next
(
codepoint
))
{
*
codepoint
+=
page_map
[
i
].
major
*
page_t
::
PAGE_BITS
;
return
true
;
return
true
;
}
i
++
;
}
...
...
@@ -492,6 +519,37 @@ struct hb_set_t
*
codepoint
=
INVALID
;
return
false
;
}
inline
bool
previous
(
hb_codepoint_t
*
codepoint
)
const
{
if
(
unlikely
(
*
codepoint
==
INVALID
))
{
*
codepoint
=
get_max
();
return
*
codepoint
!=
INVALID
;
}
page_map_t
map
=
{
get_major
(
*
codepoint
),
0
};
unsigned
int
i
;
page_map
.
bfind
(
map
,
&
i
);
if
(
i
<
page_map
.
len
&&
page_map
[
i
].
major
==
map
.
major
)
{
if
(
pages
[
page_map
[
i
].
index
].
previous
(
codepoint
))
{
*
codepoint
+=
page_map
[
i
].
major
*
page_t
::
PAGE_BITS
;
return
true
;
}
}
i
--
;
for
(;
(
int
)
i
>=
0
;
i
--
)
{
hb_codepoint_t
m
=
pages
[
page_map
[
i
].
index
].
get_max
();
if
(
m
!=
INVALID
)
{
*
codepoint
=
page_map
[
i
].
major
*
page_t
::
PAGE_BITS
+
m
;
return
true
;
}
}
*
codepoint
=
INVALID
;
return
false
;
}
inline
bool
next_range
(
hb_codepoint_t
*
first
,
hb_codepoint_t
*
last
)
const
{
hb_codepoint_t
i
;
...
...
@@ -503,12 +561,31 @@ struct hb_set_t
return
false
;
}
/* TODO Speed up. */
*
last
=
*
first
=
i
;
while
(
next
(
&
i
)
&&
i
==
*
last
+
1
)
(
*
last
)
++
;
return
true
;
}
inline
bool
previous_range
(
hb_codepoint_t
*
first
,
hb_codepoint_t
*
last
)
const
{
hb_codepoint_t
i
;
i
=
*
first
;
if
(
!
previous
(
&
i
))
{
*
last
=
*
first
=
INVALID
;
return
false
;
}
/* TODO Speed up. */
*
last
=
*
first
=
i
;
while
(
previous
(
&
i
)
&&
i
==
*
first
-
1
)
(
*
first
)
--
;
return
true
;
}
inline
unsigned
int
get_population
(
void
)
const
{
...
...
src/hb-set.cc
浏览文件 @
694eaf63
...
...
@@ -437,7 +437,9 @@ hb_set_get_max (const hb_set_t *set)
* @set: a set.
* @codepoint: (inout):
*
*
* Gets the next number in @set that is greater than current value of @codepoint.
*
* Set @codepoint to %HB_SET_VALUE_INVALID to get started.
*
* Return value: whether there was a next value.
*
...
...
@@ -450,6 +452,26 @@ hb_set_next (const hb_set_t *set,
return
set
->
next
(
codepoint
);
}
/**
* hb_set_previous:
* @set: a set.
* @codepoint: (inout):
*
* Gets the previous number in @set that is slower than current value of @codepoint.
*
* Set @codepoint to %HB_SET_VALUE_INVALID to get started.
*
* Return value: whether there was a previous value.
*
* Since: 1.8.0
**/
hb_bool_t
hb_set_previous
(
const
hb_set_t
*
set
,
hb_codepoint_t
*
codepoint
)
{
return
set
->
previous
(
codepoint
);
}
/**
* hb_set_next_range:
* @set: a set.
...
...
@@ -459,6 +481,8 @@ hb_set_next (const hb_set_t *set,
* Gets the next consecutive range of numbers in @set that
* are greater than current value of @last.
*
* Set @last to %HB_SET_VALUE_INVALID to get started.
*
* Return value: whether there was a next range.
*
* Since: 0.9.7
...
...
@@ -470,3 +494,26 @@ hb_set_next_range (const hb_set_t *set,
{
return
set
->
next_range
(
first
,
last
);
}
/**
* hb_set_previous_range:
* @set: a set.
* @first: (inout): input current first and output first codepoint in the range.
* @last: (out): output last codepoint in the range.
*
* Gets the previous consecutive range of numbers in @set that
* are greater than current value of @last.
*
* Set @first to %HB_SET_VALUE_INVALID to get started.
*
* Return value: whether there was a previous range.
*
* Since: 1.8.0
**/
hb_bool_t
hb_set_previous_range
(
const
hb_set_t
*
set
,
hb_codepoint_t
*
first
,
hb_codepoint_t
*
last
)
{
return
set
->
previous_range
(
first
,
last
);
}
src/hb-set.h
浏览文件 @
694eaf63
...
...
@@ -129,25 +129,36 @@ hb_set_symmetric_difference (hb_set_t *set,
HB_EXTERN
unsigned
int
hb_set_get_population
(
const
hb_set_t
*
set
);
/* Returns
-1
if set empty. */
/* Returns
HB_SET_VALUE_INVALID
if set empty. */
HB_EXTERN
hb_codepoint_t
hb_set_get_min
(
const
hb_set_t
*
set
);
/* Returns
-1
if set empty. */
/* Returns
HB_SET_VALUE_INVALID
if set empty. */
HB_EXTERN
hb_codepoint_t
hb_set_get_max
(
const
hb_set_t
*
set
);
/* Pass
-1
in to get started. */
/* Pass
HB_SET_VALUE_INVALID
in to get started. */
HB_EXTERN
hb_bool_t
hb_set_next
(
const
hb_set_t
*
set
,
hb_codepoint_t
*
codepoint
);
/* Pass -1 for first and last to get started. */
/* Pass HB_SET_VALUE_INVALID in to get started. */
HB_EXTERN
hb_bool_t
hb_set_previous
(
const
hb_set_t
*
set
,
hb_codepoint_t
*
codepoint
);
/* Pass HB_SET_VALUE_INVALID for first and last to get started. */
HB_EXTERN
hb_bool_t
hb_set_next_range
(
const
hb_set_t
*
set
,
hb_codepoint_t
*
first
,
hb_codepoint_t
*
last
);
/* Pass HB_SET_VALUE_INVALID for first and last to get started. */
HB_EXTERN
hb_bool_t
hb_set_previous_range
(
const
hb_set_t
*
set
,
hb_codepoint_t
*
first
,
hb_codepoint_t
*
last
);
HB_END_DECLS
...
...
test/api/test-set.c
浏览文件 @
694eaf63
...
...
@@ -32,25 +32,33 @@
static
void
test_empty
(
hb_set_t
*
s
)
{
hb_codepoint_t
next
=
HB_SET_VALUE_INVALID
;
hb_codepoint_t
next
;
g_assert_cmpint
(
hb_set_get_population
(
s
),
==
,
0
);
g_assert_cmpint
(
hb_set_get_min
(
s
),
==
,
HB_SET_VALUE_INVALID
);
g_assert_cmpint
(
hb_set_get_max
(
s
),
==
,
HB_SET_VALUE_INVALID
);
g_assert
(
!
hb_set_has
(
s
,
13
));
next
=
53043
;
g_assert
(
!
hb_set_next
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
HB_SET_VALUE_INVALID
);
next
=
07734
;
g_assert
(
!
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
HB_SET_VALUE_INVALID
);
g_assert
(
hb_set_is_empty
(
s
));
}
static
void
test_not_empty
(
hb_set_t
*
s
)
{
hb_codepoint_t
next
=
HB_SET_VALUE_INVALID
;
hb_codepoint_t
next
;
g_assert_cmpint
(
hb_set_get_population
(
s
),
!=
,
0
);
g_assert_cmpint
(
hb_set_get_min
(
s
),
!=
,
HB_SET_VALUE_INVALID
);
g_assert_cmpint
(
hb_set_get_max
(
s
),
!=
,
HB_SET_VALUE_INVALID
);
next
=
HB_SET_VALUE_INVALID
;
g_assert
(
hb_set_next
(
s
,
&
next
));
g_assert_cmpint
(
next
,
!=
,
HB_SET_VALUE_INVALID
);
next
=
HB_SET_VALUE_INVALID
;
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
!=
,
HB_SET_VALUE_INVALID
);
}
static
void
...
...
@@ -271,6 +279,27 @@ test_set_iter (void)
g_assert
(
!
hb_set_next
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
HB_SET_VALUE_INVALID
);
next
=
HB_SET_VALUE_INVALID
;
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
20005
);
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
1200
);
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
1100
);
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
15
);
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
13
);
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
10
);
g_assert
(
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
6
);
g_assert
(
!
hb_set_previous
(
s
,
&
next
));
g_assert_cmpint
(
next
,
==
,
HB_SET_VALUE_INVALID
);
first
=
last
=
HB_SET_VALUE_INVALID
;
g_assert
(
hb_set_next_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
6
);
...
...
@@ -291,6 +320,26 @@ test_set_iter (void)
g_assert_cmpint
(
first
,
==
,
HB_SET_VALUE_INVALID
);
g_assert_cmpint
(
last
,
==
,
HB_SET_VALUE_INVALID
);
first
=
last
=
HB_SET_VALUE_INVALID
;
g_assert
(
hb_set_previous_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
20005
);
g_assert_cmpint
(
last
,
==
,
20005
);
g_assert
(
hb_set_previous_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
1200
);
g_assert_cmpint
(
last
,
==
,
1200
);
g_assert
(
hb_set_previous_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
1100
);
g_assert_cmpint
(
last
,
==
,
1100
);
g_assert
(
hb_set_previous_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
10
);
g_assert_cmpint
(
last
,
==
,
15
);
g_assert
(
hb_set_previous_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
6
);
g_assert_cmpint
(
last
,
==
,
6
);
g_assert
(
!
hb_set_previous_range
(
s
,
&
first
,
&
last
));
g_assert_cmpint
(
first
,
==
,
HB_SET_VALUE_INVALID
);
g_assert_cmpint
(
last
,
==
,
HB_SET_VALUE_INVALID
);
hb_set_destroy
(
s
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录