Skip to content

Commit 6851e9a

Browse files
committed
refactor: change type naming style
1 parent 8e06b4e commit 6851e9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+235
-233
lines changed

examples/fabric/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define FABRIC_WIDTH 800
1010
#define FABRIC_HEIGHT 600
1111

12-
typedef struct ui_fabric_t {
12+
typedef struct ui_fabric {
1313
int timer;
1414
} ui_fabric_t;
1515

examples/todolist/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#include <LCUI.h>
44
#include <ptk/main.h>
55

6-
typedef struct task_t {
6+
typedef struct task {
77
unsigned id;
88
wchar_t *name;
99
const char *status;
1010
} task_t;
1111

12-
struct todolist_app_t {
12+
struct todolist_app {
1313
unsigned id;
1414
list_t tasks;
1515
} app = { 0 };

include/LCUI/app.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LCUI_BEGIN_HEADER
2323

2424
// Settings
2525

26-
typedef struct lcui_settings_t {
26+
typedef struct lcui_settings {
2727
int frame_rate_cap;
2828
int parallel_rendering_threads;
2929
bool paint_flashing;

lib/css/include/css/parser.h

+9-10
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ typedef enum css_rule_type_t {
3838
CSS_RULE_TOTAL_NUM
3939
} css_rule_type_t;
4040

41-
typedef struct css_parser_t css_parser_t;
42-
typedef struct css_style_parser_t css_style_parser_t;
43-
typedef int (*css_parser_method_t)(css_parser_t *);
44-
typedef int (*css_property_parser_method_t)(css_style_parser_t *, const char *);
41+
typedef struct css_parser css_parser_t;
42+
typedef struct css_style_parser css_style_parser_t;
43+
typedef int (*css_parser_cb)(css_parser_t *);
4544

46-
typedef struct css_rule_parser_t {
45+
typedef struct css_rule_parser {
4746
char name[32];
4847
void *data;
49-
css_parser_method_t begin;
50-
css_parser_method_t parse;
48+
css_parser_cb begin;
49+
css_parser_cb parse;
5150
} css_rule_parser_t;
5251

53-
typedef struct css_style_parser_t {
52+
typedef struct css_style_parser {
5453
char *dirname; /**< 当前所在的目录 */
5554
char *space; /**< 样式记录所属的空间 */
5655
char *property;
@@ -62,7 +61,7 @@ typedef struct css_style_parser_t {
6261
css_style_decl_t *style; /**< 当前缓存的样式表 */
6362
} css_style_parser_t;
6463

65-
typedef struct css_comment_parser_t {
64+
typedef struct css_comment_parser {
6665
/** 是否为单行注释 */
6766
bool is_line_comment;
6867

@@ -71,7 +70,7 @@ typedef struct css_comment_parser_t {
7170
} css_comment_parser_t;
7271

7372
/** CSS 代码解析器的环境参数(上下文数据) */
74-
struct css_parser_t {
73+
struct css_parser {
7574
int pos; /**< 缓存中的字符串的下标位置 */
7675
const char *cur; /**< 用于遍历字符串的指针 */
7776
char *space; /**< 样式记录所属的空间 */

lib/css/include/css/types.h

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* lib/css/include/css/types.h
33
*
44
* Copyright (c) 2023-2024, Liu Chao <[email protected]> All rights reserved.
@@ -516,12 +516,12 @@ typedef int32_t css_unit_ident_t;
516516
// TODO: 优化内存占用
517517

518518
/** https://developer.mozilla.org/en-US/docs/Web/API/CSSUnitValue */
519-
typedef struct css_unit_value_t {
519+
typedef struct css_unit_value {
520520
css_numeric_value_t value;
521521
css_unit_t unit;
522522
} css_unit_value_t;
523523

524-
typedef struct css_style_value_t css_style_value_t;
524+
typedef struct css_style_value css_style_value_t;
525525
typedef css_style_value_t *css_style_array_value_t;
526526
typedef enum css_keyword_value_t {
527527
CSS_KEYWORD_INHERIT,
@@ -537,6 +537,7 @@ typedef enum css_keyword_value_t {
537537
CSS_KEYWORD_BLOCK,
538538
CSS_KEYWORD_INLINE_BLOCK,
539539
CSS_KEYWORD_FLEX,
540+
CSS_KEYWORD_INLINE_FLEX,
540541

541542
CSS_KEYWORD_LEFT,
542543
CSS_KEYWORD_CENTER,
@@ -594,7 +595,7 @@ typedef enum css_keyword_value_t {
594595
} css_keyword_value_t;
595596

596597
/** https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleValue */
597-
struct css_style_value_t {
598+
struct css_style_value {
598599
css_style_value_type_t type;
599600
union {
600601
css_private_value_t value;
@@ -611,14 +612,14 @@ struct css_style_value_t {
611612
};
612613
};
613614

614-
typedef struct css_valdef_t css_valdef_t;
615+
typedef struct css_valdef css_valdef_t;
615616
typedef list_t css_style_decl_t;
616617

617618
typedef css_style_decl_t css_style_decl_t;
618619
typedef unsigned css_selector_hash_t;
619620

620621
/** 样式规则记录 */
621-
typedef struct css_style_rule_t {
622+
typedef struct css_style_rule {
622623
int rank; /**< 权值,决定优先级 */
623624
int batch_num; /**< 批次号 */
624625
char *space; /**< 所属的空间 */
@@ -627,13 +628,13 @@ typedef struct css_style_rule_t {
627628
list_node_t node; /**< 在链表中的结点 */
628629
} css_style_rule_t;
629630

630-
typedef struct css_prop_t {
631+
typedef struct css_prop {
631632
css_prop_key_t key;
632633
css_style_value_t value;
633634
list_node_t node;
634635
} css_prop_t;
635636

636-
typedef struct css_selector_node_t {
637+
typedef struct css_selector_node {
637638
char *id;
638639
char *type;
639640
char **classes;
@@ -642,34 +643,34 @@ typedef struct css_selector_node_t {
642643
int rank;
643644
} css_selector_node_t;
644645

645-
typedef struct css_selector_t {
646+
typedef struct css_selector {
646647
int rank; /**< 权值,决定优先级 */
647648
int batch_num; /**< 批次号 */
648649
int length; /**< 选择器结点长度 */
649650
css_selector_hash_t hash; /**< 哈希值 */
650651
css_selector_node_t **nodes; /**< 选择器结点列表 */
651652
} css_selector_t;
652653

653-
typedef struct css_font_face_t {
654+
typedef struct css_font_face {
654655
char *font_family;
655656
css_font_style_t font_style;
656657
css_font_weight_t font_weight;
657658
char *src;
658659
} css_font_face_t;
659660

660-
typedef struct css_metrics_t {
661+
typedef struct css_metrics {
661662
float dpi;
662663
float density;
663664
float scaled_density;
664665
float scale;
665666
} css_metrics_t;
666667

667-
typedef struct css_computed_style_t {
668+
typedef struct css_computed_style {
668669
/**
669670
* 属性值类型的比特数据
670671
* 以比特位为单位分配的存储空间,用于节省属性值的内存占用
671672
*/
672-
struct css_type_bits_t {
673+
struct css_type_bits {
673674
uint8_t display : 5;
674675
uint8_t box_sizing : 2;
675676
uint8_t visibility : 4;
@@ -738,7 +739,7 @@ typedef struct css_computed_style_t {
738739
/**
739740
* 属性值单位的比特数据
740741
*/
741-
struct css_unit_bits_t {
742+
struct css_unit_bits {
742743
css_unit_t left : 4;
743744
css_unit_t right : 4;
744745
css_unit_t top : 4;
@@ -844,9 +845,9 @@ typedef struct css_computed_style_t {
844845
size_t custom_props_count;
845846
} css_computed_style_t;
846847

847-
typedef struct css_propdef_t css_propdef_t;
848+
typedef struct css_propdef css_propdef_t;
848849

849-
struct css_propdef_t {
850+
struct css_propdef {
850851
/**
851852
* 属性标识号
852853
* 值为 -1 时,则表明它是简写属性
@@ -859,8 +860,8 @@ struct css_propdef_t {
859860
int (*cascade)(const css_style_array_value_t, css_computed_style_t *);
860861
};
861862

862-
typedef bool (*css_value_parse_func_t)(css_style_value_t *, const char *);
863+
typedef bool (*css_value_parse_cb)(css_style_value_t *, const char *);
863864

864-
typedef struct css_value_type_record_t css_value_type_record_t;
865+
typedef struct css_value_type_record css_value_type_record_t;
865866

866867
#endif

lib/css/include/css/value.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LIBCSS_PUBLIC size_t css_valdef_to_string(const css_valdef_t *valdef, char *str,
2727
size_t max_len);
2828

2929
LIBCSS_PUBLIC const css_value_type_record_t *css_register_value_type(
30-
const char *type_name, css_value_parse_func_t parse);
30+
const char *type_name, css_value_parse_cb parse);
3131

3232
LIBCSS_PUBLIC const css_value_type_record_t *css_get_value_type(
3333
const char *type_name);

lib/css/src/dump.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include <css/style_value.h>
1616
#include <css/style_decl.h>
1717

18-
typedef struct css_dump_context_t css_dump_context_t;
18+
typedef struct css_dump_context css_dump_context_t;
1919

20-
struct css_dump_context_t {
20+
struct css_dump_context {
2121
char *data;
2222
size_t len;
2323
size_t max_len;

lib/css/src/font_face_parser.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum FontFaceKey {
2626
KEY_SRC
2727
};
2828

29-
typedef struct css_font_face_parser_t {
29+
typedef struct css_font_face_parser {
3030
int key;
3131
int state;
3232
css_font_face_t *face;

lib/css/src/keywords.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* lib/css/src/keywords.c
33
*
44
* Copyright (c) 2023-2024, Liu Chao <[email protected]> All rights reserved.
@@ -12,12 +12,12 @@
1212
#include <errno.h>
1313
#include <css/keywords.h>
1414

15-
typedef struct css_keyword_t {
15+
typedef struct css_keyword {
1616
int key;
1717
char *name;
1818
} css_keyword_t;
1919

20-
static struct css_keywords_module_t {
20+
static struct css_keywords_module {
2121
css_keyword_t **list;
2222
unsigned used;
2323
unsigned size;

lib/css/src/library.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
typedef dict_t css_style_group_t;
2828

2929
/** 样式链接记录组 */
30-
typedef struct css_style_link_group_t {
30+
typedef struct css_style_link_group {
3131
dict_t *links; /**< 样式链接表 */
3232
char *name; /**< 选择器名称 */
3333
css_selector_node_t *snode; /**< 选择器结点 */
3434
} css_style_link_group_t;
3535

3636
/** 样式链接记录 */
37-
typedef struct css_style_link_t {
37+
typedef struct css_style_link {
3838
char *selector; /**< 选择器 */
3939
css_style_link_group_t *group; /**< 所属组 */
4040

@@ -51,7 +51,7 @@ typedef struct css_style_link_t {
5151
dict_t *parents;
5252
} css_style_link_t;
5353

54-
static struct css_library_module_t {
54+
static struct css_library_module {
5555
/**
5656
* 样式组列表
5757
* list_t<css_style_group_t*>

lib/css/src/properties.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* lib/css/src/properties.c
33
*
44
* Copyright (c) 2023-2024, Liu Chao <[email protected]> All rights reserved.
@@ -26,7 +26,7 @@
2626
css_style_decl_t *); \
2727
css_register_shorthand_property(NAME, VALDEF, css_parse_##PROP_KEY)
2828

29-
static struct css_properties_module_t {
29+
static struct css_properties_module {
3030
/**
3131
* 样式属性列表
3232
* css_propdef_t*[]

lib/css/src/selector.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum css_selector_name_finder_level {
3434
};
3535

3636
/* 样式表查找器的上下文数据结构 */
37-
typedef struct css_selector_name_collector_t {
37+
typedef struct css_selector_name_collector {
3838
int level; /**< 当前选择器层级 */
3939
int class_i; /**< 当前处理到第几个类名 */
4040
int status_i; /**< 当前处理到第几个状态名(伪类名) */

lib/css/src/value.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ typedef enum css_valdef_sign_t {
4040
CSS_VALDEF_SIGN_ANGLE_BRACKET
4141
} css_valdef_sign_t;
4242

43-
struct css_value_type_record_t {
43+
struct css_value_type_record {
4444
char *name;
45-
css_value_parse_func_t parse_value;
45+
css_value_parse_cb parse_value;
4646
};
4747

48-
struct css_valdef_t {
48+
struct css_valdef {
4949
css_valdef_sign_t sign;
5050
unsigned min_count;
5151
unsigned max_count;
@@ -69,7 +69,7 @@ typedef enum css_valdef_parser_target_t {
6969
CSS_VALDEF_PARSER_TARGET_SIGN
7070
} css_valdef_parser_target_t;
7171

72-
typedef struct css_valdef_parser_t {
72+
typedef struct css_valdef_parser {
7373
const char *cur;
7474
char *buffer;
7575
char terminator;
@@ -84,7 +84,7 @@ typedef struct css_valdef_parser_t {
8484
list_t valdef_parents;
8585
} css_valdef_parser_t;
8686

87-
typedef struct css_value_matcher_t {
87+
typedef struct css_value_matcher {
8888
const char *cur;
8989
const char *next;
9090

@@ -95,7 +95,7 @@ typedef struct css_value_matcher_t {
9595
unsigned value_len;
9696
} css_value_matcher_t;
9797

98-
static struct css_value_module_t {
98+
static struct css_value_module {
9999
/** dict_t<string, css_valdef_t> */
100100
dict_t *alias;
101101

@@ -212,7 +212,7 @@ static void css_valdef_append(css_valdef_t *valdef, css_valdef_t *child)
212212
}
213213

214214
const css_value_type_record_t *css_register_value_type(
215-
const char *type_name, css_value_parse_func_t parse)
215+
const char *type_name, css_value_parse_cb parse)
216216
{
217217
css_value_type_record_t *t;
218218

lib/i18n/src/i18n-private.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
typedef enum { NONE, STRING, DICT } dict_value_type_t;
1818

19-
typedef struct dict_string_value_t {
19+
typedef struct dict_string_value {
2020
wchar_t *data;
2121
size_t length;
2222
} dict_string_value_t;
2323

24-
typedef struct dict_value_t dict_value_t;
24+
typedef struct dict_value dict_value_t;
2525

26-
struct dict_value_t {
26+
struct dict_value {
2727
dict_value_type_t type;
2828
union {
2929
dict_string_value_t string;

0 commit comments

Comments
 (0)