Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
f06ab8a4
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
f06ab8a4
编写于
6月 05, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better hide nil objects and make them const
上级
bf93b636
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
146 addition
and
157 deletion
+146
-157
src/hb-blob.cc
src/hb-blob.cc
+17
-17
src/hb-buffer.cc
src/hb-buffer.cc
+19
-20
src/hb-font.cc
src/hb-font.cc
+34
-36
src/hb-ft.cc
src/hb-ft.cc
+22
-27
src/hb-glib.cc
src/hb-glib.cc
+12
-13
src/hb-icu.cc
src/hb-icu.cc
+12
-13
src/hb-set.cc
src/hb-set.cc
+8
-8
src/hb-unicode-private.hh
src/hb-unicode-private.hh
+5
-6
src/hb-unicode.cc
src/hb-unicode.cc
+17
-17
未找到文件。
src/hb-blob.cc
浏览文件 @
f06ab8a4
...
...
@@ -59,19 +59,6 @@ struct _hb_blob_t {
hb_destroy_func_t
destroy
;
};
static
hb_blob_t
_hb_blob_nil
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
NULL
,
/* data */
0
,
/* length */
HB_MEMORY_MODE_READONLY
,
/* mode */
NULL
,
/* user_data */
NULL
/* destroy */
};
static
bool
_try_writable
(
hb_blob_t
*
blob
);
...
...
@@ -97,7 +84,7 @@ hb_blob_create (const char *data,
if
(
!
length
||
!
(
blob
=
hb_object_create
<
hb_blob_t
>
()))
{
if
(
destroy
)
destroy
(
user_data
);
return
&
_hb_blob_nil
;
return
hb_blob_get_empty
()
;
}
blob
->
data
=
data
;
...
...
@@ -111,7 +98,7 @@ hb_blob_create (const char *data,
blob
->
mode
=
HB_MEMORY_MODE_READONLY
;
if
(
!
_try_writable
(
blob
))
{
hb_blob_destroy
(
blob
);
return
&
_hb_blob_nil
;
return
hb_blob_get_empty
()
;
}
}
...
...
@@ -126,7 +113,7 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
hb_blob_t
*
blob
;
if
(
!
length
||
offset
>=
parent
->
length
)
return
&
_hb_blob_nil
;
return
hb_blob_get_empty
()
;
hb_blob_make_immutable
(
parent
);
...
...
@@ -142,7 +129,20 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
hb_blob_t
*
hb_blob_get_empty
(
void
)
{
return
&
_hb_blob_nil
;
static
const
hb_blob_t
_hb_blob_nil
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
NULL
,
/* data */
0
,
/* length */
HB_MEMORY_MODE_READONLY
,
/* mode */
NULL
,
/* user_data */
NULL
/* destroy */
};
return
const_cast
<
hb_blob_t
*>
(
&
_hb_blob_nil
);
}
hb_blob_t
*
...
...
src/hb-buffer.cc
浏览文件 @
f06ab8a4
...
...
@@ -37,21 +37,8 @@
#define HB_DEBUG_BUFFER (HB_DEBUG+0)
#endif
static
hb_buffer_t
_hb_buffer_nil
=
{
HB_OBJECT_HEADER_STATIC
,
&
_hb_unicode_funcs_default
,
{
HB_DIRECTION_INVALID
,
HB_SCRIPT_INVALID
,
NULL
,
},
TRUE
,
/* in_error */
TRUE
,
/* have_output */
TRUE
/* have_positions */
};
#define _HB_BUFFER_UNICODE_FUNCS_DEFAULT _hb_unicode_funcs_default
#define _HB_BUFFER_PROPS_DEFAULT { HB_DIRECTION_INVALID, HB_SCRIPT_INVALID, HB_LANGUAGE_INVALID }
/* Here is how the buffer works internally:
*
...
...
@@ -154,9 +141,10 @@ hb_buffer_t::reset (void)
return
;
hb_unicode_funcs_destroy
(
unicode
);
unicode
=
_
hb_buffer_nil
.
unicode
;
unicode
=
_
HB_BUFFER_UNICODE_FUNCS_DEFAULT
;
props
=
_hb_buffer_nil
.
props
;
hb_segment_properties_t
default_props
=
_HB_BUFFER_PROPS_DEFAULT
;
props
=
default_props
;
in_error
=
FALSE
;
have_output
=
FALSE
;
...
...
@@ -543,7 +531,7 @@ hb_buffer_create ()
hb_buffer_t
*
buffer
;
if
(
!
(
buffer
=
hb_object_create
<
hb_buffer_t
>
()))
return
&
_hb_buffer_nil
;
return
hb_buffer_get_empty
()
;
buffer
->
reset
();
...
...
@@ -553,7 +541,18 @@ hb_buffer_create ()
hb_buffer_t
*
hb_buffer_get_empty
(
void
)
{
return
&
_hb_buffer_nil
;
static
const
hb_buffer_t
_hb_buffer_nil
=
{
HB_OBJECT_HEADER_STATIC
,
_HB_BUFFER_UNICODE_FUNCS_DEFAULT
,
_HB_BUFFER_PROPS_DEFAULT
,
TRUE
,
/* in_error */
TRUE
,
/* have_output */
TRUE
/* have_positions */
};
return
const_cast
<
hb_buffer_t
*>
(
&
_hb_buffer_nil
);
}
hb_buffer_t
*
...
...
@@ -601,7 +600,7 @@ hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
return
;
if
(
!
unicode
)
unicode
=
_
hb_buffer_nil
.
unicode
;
unicode
=
_
HB_BUFFER_UNICODE_FUNCS_DEFAULT
;
hb_unicode_funcs_reference
(
unicode
);
hb_unicode_funcs_destroy
(
buffer
->
unicode
);
...
...
src/hb-font.cc
浏览文件 @
f06ab8a4
...
...
@@ -217,7 +217,7 @@ hb_font_get_glyph_from_name_nil (hb_font_t *font,
}
static
hb_font_funcs_t
_hb_font_funcs_nil
=
{
static
const
hb_font_funcs_t
_hb_font_funcs_nil
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
...
...
@@ -236,7 +236,7 @@ hb_font_funcs_create (void)
hb_font_funcs_t
*
ffuncs
;
if
(
!
(
ffuncs
=
hb_object_create
<
hb_font_funcs_t
>
()))
return
&
_hb_font_funcs_nil
;
return
hb_font_funcs_get_empty
()
;
ffuncs
->
get
=
_hb_font_funcs_nil
.
get
;
...
...
@@ -246,7 +246,7 @@ hb_font_funcs_create (void)
hb_font_funcs_t
*
hb_font_funcs_get_empty
(
void
)
{
return
&
_hb_font_funcs_nil
;
return
const_cast
<
hb_font_funcs_t
*>
(
&
_hb_font_funcs_nil
)
;
}
hb_font_funcs_t
*
...
...
@@ -578,7 +578,7 @@ hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
* hb_face_t
*/
static
hb_face_t
_hb_face_nil
=
{
static
const
hb_face_t
_hb_face_nil
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
...
...
@@ -604,7 +604,7 @@ hb_face_create_for_tables (hb_reference_table_func_t reference_table,
if
(
!
reference_table
||
!
(
face
=
hb_object_create
<
hb_face_t
>
()))
{
if
(
destroy
)
destroy
(
user_data
);
return
&
_hb_face_nil
;
return
hb_face_get_empty
()
;
}
face
->
reference_table
=
reference_table
;
...
...
@@ -671,12 +671,12 @@ hb_face_create (hb_blob_t *blob,
hb_face_t
*
face
;
if
(
unlikely
(
!
blob
||
!
hb_blob_get_length
(
blob
)))
return
&
_hb_face_nil
;
return
hb_face_get_empty
()
;
hb_face_for_data_closure_t
*
closure
=
_hb_face_for_data_closure_create
(
Sanitizer
<
OpenTypeFontFile
>::
sanitize
(
hb_blob_reference
(
blob
)),
index
);
if
(
unlikely
(
!
closure
))
return
&
_hb_face_nil
;
return
hb_face_get_empty
()
;
face
=
hb_face_create_for_tables
(
_hb_face_for_data_reference_table
,
closure
,
...
...
@@ -690,7 +690,7 @@ hb_face_create (hb_blob_t *blob,
hb_face_t
*
hb_face_get_empty
(
void
)
{
return
&
_hb_face_nil
;
return
const_cast
<
hb_face_t
*>
(
&
_hb_face_nil
)
;
}
...
...
@@ -811,40 +811,21 @@ hb_face_get_upem (hb_face_t *face)
* hb_font_t
*/
static
hb_font_t
_hb_font_nil
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
NULL
,
/* parent */
&
_hb_face_nil
,
0
,
/* x_scale */
0
,
/* y_scale */
0
,
/* x_ppem */
0
,
/* y_ppem */
&
_hb_font_funcs_nil
,
/* klass */
NULL
,
/* user_data */
NULL
/* destroy */
};
hb_font_t
*
hb_font_create
(
hb_face_t
*
face
)
{
hb_font_t
*
font
;
if
(
unlikely
(
!
face
))
face
=
&
_hb_face_nil
;
face
=
hb_face_get_empty
()
;
if
(
unlikely
(
hb_object_is_inert
(
face
)))
return
&
_hb_font_nil
;
return
hb_font_get_empty
()
;
if
(
!
(
font
=
hb_object_create
<
hb_font_t
>
()))
return
&
_hb_font_nil
;
return
hb_font_get_empty
()
;
hb_face_make_immutable
(
face
);
font
->
face
=
hb_face_reference
(
face
);
font
->
klass
=
&
_hb_font_funcs_nil
;
font
->
klass
=
hb_font_funcs_get_empty
()
;
return
font
;
}
...
...
@@ -853,7 +834,7 @@ hb_font_t *
hb_font_create_sub_font
(
hb_font_t
*
parent
)
{
if
(
unlikely
(
!
parent
))
return
&
_hb_font_nil
;
return
hb_font_get_empty
()
;
hb_font_t
*
font
=
hb_font_create
(
parent
->
face
);
...
...
@@ -868,15 +849,32 @@ hb_font_create_sub_font (hb_font_t *parent)
font
->
x_ppem
=
parent
->
x_ppem
;
font
->
y_ppem
=
parent
->
y_ppem
;
font
->
klass
=
&
_hb_font_funcs_nil
;
return
font
;
}
hb_font_t
*
hb_font_get_empty
(
void
)
{
return
&
_hb_font_nil
;
static
const
hb_font_t
_hb_font_nil
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
NULL
,
/* parent */
const_cast
<
hb_face_t
*>
(
&
_hb_face_nil
),
0
,
/* x_scale */
0
,
/* y_scale */
0
,
/* x_ppem */
0
,
/* y_ppem */
const_cast
<
hb_font_funcs_t
*>
(
&
_hb_font_funcs_nil
),
/* klass */
NULL
,
/* user_data */
NULL
/* destroy */
};
return
const_cast
<
hb_font_t
*>
(
&
_hb_font_nil
);
}
hb_font_t
*
...
...
@@ -960,7 +958,7 @@ hb_font_set_funcs (hb_font_t *font,
font
->
destroy
(
font
->
user_data
);
if
(
!
klass
)
klass
=
&
_hb_font_funcs_nil
;
klass
=
hb_font_funcs_get_empty
()
;
hb_font_funcs_reference
(
klass
);
hb_font_funcs_destroy
(
font
->
klass
);
...
...
src/hb-ft.cc
浏览文件 @
f06ab8a4
...
...
@@ -271,22 +271,22 @@ hb_ft_get_glyph_from_name (hb_font_t *font,
}
static
hb_font_funcs_t
ft_ffuncs
=
{
HB_OBJECT_HEADER_STATIC
,
static
hb_font_funcs_t
*
_hb_ft_get_font_funcs
(
void
)
{
static
const
hb_font_funcs_t
ft_ffuncs
=
{
HB_OBJECT_HEADER_STATIC
,
TRUE
,
/* immutable */
TRUE
,
/* immutable */
{
{
#define HB_FONT_FUNC_IMPLEMENT(name) hb_ft_get_##name,
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT
}
};
}
};
static
hb_font_funcs_t
*
_hb_ft_get_font_funcs
(
void
)
{
return
&
ft_ffuncs
;
return
const_cast
<
hb_font_funcs_t
*>
(
&
ft_ffuncs
);
}
...
...
@@ -398,26 +398,21 @@ hb_ft_font_create (FT_Face ft_face,
}
static
FT_Library
ft_library
;
static
hb_bool_t
ft_library_initialized
;
static
struct
ft_library_destructor
{
~
ft_library_destructor
(
void
)
{
if
(
ft_library
)
FT_Done_FreeType
(
ft_library
);
}
}
static_ft_library_destructor
;
static
FT_Library
_get_ft_library
(
void
)
{
if
(
unlikely
(
!
ft_library_initialized
))
{
FT_Init_FreeType
(
&
ft_library
);
ft_library_initialized
=
TRUE
;
}
static
struct
ft_library_singleton
{
ft_library_singleton
(
void
)
{
FT_Init_FreeType
(
&
ft_library
);
}
~
ft_library_singleton
(
void
)
{
FT_Done_FreeType
(
ft_library
);
}
FT_Library
ft_library
;
}
ft_library_singleton
;
return
ft_library
;
return
ft_library
_singleton
.
ft_library
;
}
static
void
...
...
src/hb-glib.cc
浏览文件 @
f06ab8a4
...
...
@@ -337,22 +337,21 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
}
extern
HB_INTERNAL
hb_unicode_funcs_t
_hb_unicode_funcs_glib
;
hb_unicode_funcs_t
_hb_glib_unicode_funcs
=
{
HB_OBJECT_HEADER_STATIC
,
hb_unicode_funcs_t
*
hb_glib_get_unicode_funcs
(
void
)
{
static
const
hb_unicode_funcs_t
_hb_glib_unicode_funcs
=
{
HB_OBJECT_HEADER_STATIC
,
NULL
,
/* parent */
TRUE
,
/* immutable */
{
NULL
,
/* parent */
TRUE
,
/* immutable */
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
}
};
}
};
hb_unicode_funcs_t
*
hb_glib_get_unicode_funcs
(
void
)
{
return
&
_hb_glib_unicode_funcs
;
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_glib_unicode_funcs
);
}
src/hb-icu.cc
浏览文件 @
f06ab8a4
...
...
@@ -269,23 +269,22 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
return
ret
;
}
extern
HB_INTERNAL
hb_unicode_funcs_t
_hb_unicode_funcs_icu
;
hb_unicode_funcs_t
_hb_icu_unicode_funcs
=
{
HB_OBJECT_HEADER_STATIC
,
hb_unicode_funcs_t
*
hb_icu_get_unicode_funcs
(
void
)
{
static
const
hb_unicode_funcs_t
_hb_icu_unicode_funcs
=
{
HB_OBJECT_HEADER_STATIC
,
NULL
,
/* parent */
TRUE
,
/* immutable */
{
NULL
,
/* parent */
TRUE
,
/* immutable */
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
}
};
}
};
hb_unicode_funcs_t
*
hb_icu_get_unicode_funcs
(
void
)
{
return
&
_hb_icu_unicode_funcs
;
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_icu_unicode_funcs
);
}
src/hb-set.cc
浏览文件 @
f06ab8a4
...
...
@@ -30,12 +30,6 @@
/* Public API */
static
hb_set_t
_hb_set_nil
=
{
HB_OBJECT_HEADER_STATIC
,
{
0
}
/* elts */
};
hb_set_t
*
hb_set_create
()
...
...
@@ -43,7 +37,7 @@ hb_set_create ()
hb_set_t
*
set
;
if
(
!
(
set
=
hb_object_create
<
hb_set_t
>
()))
return
&
_hb_set_nil
;
return
hb_set_get_empty
()
;
set
->
clear
();
...
...
@@ -53,7 +47,13 @@ hb_set_create ()
hb_set_t
*
hb_set_get_empty
(
void
)
{
return
&
_hb_set_nil
;
static
const
hb_set_t
_hb_set_nil
=
{
HB_OBJECT_HEADER_STATIC
,
{
0
}
/* elts */
};
return
const_cast
<
hb_set_t
*>
(
&
_hb_set_nil
);
}
hb_set_t
*
...
...
src/hb-unicode-private.hh
浏览文件 @
f06ab8a4
...
...
@@ -91,15 +91,14 @@ struct _hb_unicode_funcs_t {
#ifdef HAVE_GLIB
extern
HB_INTERNAL
hb_unicode_funcs_t
_hb_glib_unicode_funcs
;
#define _hb_unicode_funcs_default
_hb_glib_unicode_funcs
extern
"C"
hb_unicode_funcs_t
*
hb_glib_get_unicode_funcs
(
void
)
;
#define _hb_unicode_funcs_default
hb_glib_get_unicode_funcs ()
#elif defined(HAVE_ICU)
extern
HB_INTERNAL
hb_unicode_funcs_t
_hb_icu_unicode_funcs
;
#define _hb_unicode_funcs_default
_hb_icu_unicode_funcs
extern
"C"
hb_unicode_funcs_t
*
hb_icu_get_unicode_funcs
(
void
)
;
#define _hb_unicode_funcs_default
hb_icu_get_unicode_funcs ()
#else
#define HB_UNICODE_FUNCS_NIL 1
extern
HB_INTERNAL
hb_unicode_funcs_t
_hb_unicode_funcs_nil
;
#define _hb_unicode_funcs_default _hb_unicode_funcs_nil
#define _hb_unicode_funcs_default hb_unicode_funcs_get_empty ()
#endif
...
...
src/hb-unicode.cc
浏览文件 @
f06ab8a4
...
...
@@ -99,23 +99,11 @@ hb_unicode_decompose_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
}
hb_unicode_funcs_t
_hb_unicode_funcs_nil
=
{
HB_OBJECT_HEADER_STATIC
,
NULL
,
/* parent */
TRUE
,
/* immutable */
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_nil,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
}
};
hb_unicode_funcs_t
*
hb_unicode_funcs_get_default
(
void
)
{
return
&
_hb_unicode_funcs_default
;
return
_hb_unicode_funcs_default
;
}
hb_unicode_funcs_t
*
...
...
@@ -124,10 +112,10 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
hb_unicode_funcs_t
*
ufuncs
;
if
(
!
(
ufuncs
=
hb_object_create
<
hb_unicode_funcs_t
>
()))
return
&
_hb_unicode_funcs_nil
;
return
hb_unicode_funcs_get_empty
()
;
if
(
!
parent
)
parent
=
&
_hb_unicode_funcs_nil
;
parent
=
hb_unicode_funcs_get_empty
()
;
hb_unicode_funcs_make_immutable
(
parent
);
ufuncs
->
parent
=
hb_unicode_funcs_reference
(
parent
);
...
...
@@ -145,7 +133,19 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
hb_unicode_funcs_t
*
hb_unicode_funcs_get_empty
(
void
)
{
return
&
_hb_unicode_funcs_nil
;
static
const
hb_unicode_funcs_t
_hb_unicode_funcs_nil
=
{
HB_OBJECT_HEADER_STATIC
,
NULL
,
/* parent */
TRUE
,
/* immutable */
{
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_nil,
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
}
};
return
const_cast
<
hb_unicode_funcs_t
*>
(
&
_hb_unicode_funcs_nil
);
}
hb_unicode_funcs_t
*
...
...
@@ -205,7 +205,7 @@ hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
hb_unicode_funcs_t
*
hb_unicode_funcs_get_parent
(
hb_unicode_funcs_t
*
ufuncs
)
{
return
ufuncs
->
parent
?
ufuncs
->
parent
:
&
_hb_unicode_funcs_nil
;
return
ufuncs
->
parent
?
ufuncs
->
parent
:
hb_unicode_funcs_get_empty
()
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录