Skip to content

Commit

Permalink
refactor: change type naming style
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Dec 22, 2024
1 parent 8e06b4e commit 6851e9a
Show file tree
Hide file tree
Showing 67 changed files with 235 additions and 233 deletions.
2 changes: 1 addition & 1 deletion examples/fabric/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define FABRIC_WIDTH 800
#define FABRIC_HEIGHT 600

typedef struct ui_fabric_t {
typedef struct ui_fabric {
int timer;
} ui_fabric_t;

Expand Down
4 changes: 2 additions & 2 deletions examples/todolist/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include <LCUI.h>
#include <ptk/main.h>

typedef struct task_t {
typedef struct task {
unsigned id;
wchar_t *name;
const char *status;
} task_t;

struct todolist_app_t {
struct todolist_app {
unsigned id;
list_t tasks;
} app = { 0 };
Expand Down
2 changes: 1 addition & 1 deletion include/LCUI/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LCUI_BEGIN_HEADER

// Settings

typedef struct lcui_settings_t {
typedef struct lcui_settings {
int frame_rate_cap;
int parallel_rendering_threads;
bool paint_flashing;
Expand Down
19 changes: 9 additions & 10 deletions lib/css/include/css/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ typedef enum css_rule_type_t {
CSS_RULE_TOTAL_NUM
} css_rule_type_t;

typedef struct css_parser_t css_parser_t;
typedef struct css_style_parser_t css_style_parser_t;
typedef int (*css_parser_method_t)(css_parser_t *);
typedef int (*css_property_parser_method_t)(css_style_parser_t *, const char *);
typedef struct css_parser css_parser_t;
typedef struct css_style_parser css_style_parser_t;
typedef int (*css_parser_cb)(css_parser_t *);

typedef struct css_rule_parser_t {
typedef struct css_rule_parser {
char name[32];
void *data;
css_parser_method_t begin;
css_parser_method_t parse;
css_parser_cb begin;
css_parser_cb parse;
} css_rule_parser_t;

typedef struct css_style_parser_t {
typedef struct css_style_parser {
char *dirname; /**< 当前所在的目录 */
char *space; /**< 样式记录所属的空间 */
char *property;
Expand All @@ -62,7 +61,7 @@ typedef struct css_style_parser_t {
css_style_decl_t *style; /**< 当前缓存的样式表 */
} css_style_parser_t;

typedef struct css_comment_parser_t {
typedef struct css_comment_parser {
/** 是否为单行注释 */
bool is_line_comment;

Expand All @@ -71,7 +70,7 @@ typedef struct css_comment_parser_t {
} css_comment_parser_t;

/** CSS 代码解析器的环境参数(上下文数据) */
struct css_parser_t {
struct css_parser {
int pos; /**< 缓存中的字符串的下标位置 */
const char *cur; /**< 用于遍历字符串的指针 */
char *space; /**< 样式记录所属的空间 */
Expand Down
37 changes: 19 additions & 18 deletions lib/css/include/css/types.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* lib/css/include/css/types.h
*
* Copyright (c) 2023-2024, Liu Chao <[email protected]> All rights reserved.
Expand Down Expand Up @@ -516,12 +516,12 @@ typedef int32_t css_unit_ident_t;
// TODO: 优化内存占用

/** https://developer.mozilla.org/en-US/docs/Web/API/CSSUnitValue */
typedef struct css_unit_value_t {
typedef struct css_unit_value {
css_numeric_value_t value;
css_unit_t unit;
} css_unit_value_t;

typedef struct css_style_value_t css_style_value_t;
typedef struct css_style_value css_style_value_t;
typedef css_style_value_t *css_style_array_value_t;
typedef enum css_keyword_value_t {
CSS_KEYWORD_INHERIT,
Expand All @@ -537,6 +537,7 @@ typedef enum css_keyword_value_t {
CSS_KEYWORD_BLOCK,
CSS_KEYWORD_INLINE_BLOCK,
CSS_KEYWORD_FLEX,
CSS_KEYWORD_INLINE_FLEX,

CSS_KEYWORD_LEFT,
CSS_KEYWORD_CENTER,
Expand Down Expand Up @@ -594,7 +595,7 @@ typedef enum css_keyword_value_t {
} css_keyword_value_t;

/** https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleValue */
struct css_style_value_t {
struct css_style_value {
css_style_value_type_t type;
union {
css_private_value_t value;
Expand All @@ -611,14 +612,14 @@ struct css_style_value_t {
};
};

typedef struct css_valdef_t css_valdef_t;
typedef struct css_valdef css_valdef_t;
typedef list_t css_style_decl_t;

typedef css_style_decl_t css_style_decl_t;
typedef unsigned css_selector_hash_t;

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

typedef struct css_prop_t {
typedef struct css_prop {
css_prop_key_t key;
css_style_value_t value;
list_node_t node;
} css_prop_t;

typedef struct css_selector_node_t {
typedef struct css_selector_node {
char *id;
char *type;
char **classes;
Expand All @@ -642,34 +643,34 @@ typedef struct css_selector_node_t {
int rank;
} css_selector_node_t;

typedef struct css_selector_t {
typedef struct css_selector {
int rank; /**< 权值,决定优先级 */
int batch_num; /**< 批次号 */
int length; /**< 选择器结点长度 */
css_selector_hash_t hash; /**< 哈希值 */
css_selector_node_t **nodes; /**< 选择器结点列表 */
} css_selector_t;

typedef struct css_font_face_t {
typedef struct css_font_face {
char *font_family;
css_font_style_t font_style;
css_font_weight_t font_weight;
char *src;
} css_font_face_t;

typedef struct css_metrics_t {
typedef struct css_metrics {
float dpi;
float density;
float scaled_density;
float scale;
} css_metrics_t;

typedef struct css_computed_style_t {
typedef struct css_computed_style {
/**
* 属性值类型的比特数据
* 以比特位为单位分配的存储空间,用于节省属性值的内存占用
*/
struct css_type_bits_t {
struct css_type_bits {
uint8_t display : 5;
uint8_t box_sizing : 2;
uint8_t visibility : 4;
Expand Down Expand Up @@ -738,7 +739,7 @@ typedef struct css_computed_style_t {
/**
* 属性值单位的比特数据
*/
struct css_unit_bits_t {
struct css_unit_bits {
css_unit_t left : 4;
css_unit_t right : 4;
css_unit_t top : 4;
Expand Down Expand Up @@ -844,9 +845,9 @@ typedef struct css_computed_style_t {
size_t custom_props_count;
} css_computed_style_t;

typedef struct css_propdef_t css_propdef_t;
typedef struct css_propdef css_propdef_t;

struct css_propdef_t {
struct css_propdef {
/**
* 属性标识号
* 值为 -1 时,则表明它是简写属性
Expand All @@ -859,8 +860,8 @@ struct css_propdef_t {
int (*cascade)(const css_style_array_value_t, css_computed_style_t *);
};

typedef bool (*css_value_parse_func_t)(css_style_value_t *, const char *);
typedef bool (*css_value_parse_cb)(css_style_value_t *, const char *);

typedef struct css_value_type_record_t css_value_type_record_t;
typedef struct css_value_type_record css_value_type_record_t;

#endif
2 changes: 1 addition & 1 deletion lib/css/include/css/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LIBCSS_PUBLIC size_t css_valdef_to_string(const css_valdef_t *valdef, char *str,
size_t max_len);

LIBCSS_PUBLIC const css_value_type_record_t *css_register_value_type(
const char *type_name, css_value_parse_func_t parse);
const char *type_name, css_value_parse_cb parse);

LIBCSS_PUBLIC const css_value_type_record_t *css_get_value_type(
const char *type_name);
Expand Down
4 changes: 2 additions & 2 deletions lib/css/src/dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include <css/style_value.h>
#include <css/style_decl.h>

typedef struct css_dump_context_t css_dump_context_t;
typedef struct css_dump_context css_dump_context_t;

struct css_dump_context_t {
struct css_dump_context {
char *data;
size_t len;
size_t max_len;
Expand Down
2 changes: 1 addition & 1 deletion lib/css/src/font_face_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum FontFaceKey {
KEY_SRC
};

typedef struct css_font_face_parser_t {
typedef struct css_font_face_parser {
int key;
int state;
css_font_face_t *face;
Expand Down
6 changes: 3 additions & 3 deletions lib/css/src/keywords.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* lib/css/src/keywords.c
*
* Copyright (c) 2023-2024, Liu Chao <[email protected]> All rights reserved.
Expand All @@ -12,12 +12,12 @@
#include <errno.h>
#include <css/keywords.h>

typedef struct css_keyword_t {
typedef struct css_keyword {
int key;
char *name;
} css_keyword_t;

static struct css_keywords_module_t {
static struct css_keywords_module {
css_keyword_t **list;
unsigned used;
unsigned size;
Expand Down
6 changes: 3 additions & 3 deletions lib/css/src/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
typedef dict_t css_style_group_t;

/** 样式链接记录组 */
typedef struct css_style_link_group_t {
typedef struct css_style_link_group {
dict_t *links; /**< 样式链接表 */
char *name; /**< 选择器名称 */
css_selector_node_t *snode; /**< 选择器结点 */
} css_style_link_group_t;

/** 样式链接记录 */
typedef struct css_style_link_t {
typedef struct css_style_link {
char *selector; /**< 选择器 */
css_style_link_group_t *group; /**< 所属组 */

Expand All @@ -51,7 +51,7 @@ typedef struct css_style_link_t {
dict_t *parents;
} css_style_link_t;

static struct css_library_module_t {
static struct css_library_module {
/**
* 样式组列表
* list_t<css_style_group_t*>
Expand Down
4 changes: 2 additions & 2 deletions lib/css/src/properties.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* lib/css/src/properties.c
*
* Copyright (c) 2023-2024, Liu Chao <[email protected]> All rights reserved.
Expand Down Expand Up @@ -26,7 +26,7 @@
css_style_decl_t *); \
css_register_shorthand_property(NAME, VALDEF, css_parse_##PROP_KEY)

static struct css_properties_module_t {
static struct css_properties_module {
/**
* 样式属性列表
* css_propdef_t*[]
Expand Down
2 changes: 1 addition & 1 deletion lib/css/src/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum css_selector_name_finder_level {
};

/* 样式表查找器的上下文数据结构 */
typedef struct css_selector_name_collector_t {
typedef struct css_selector_name_collector {
int level; /**< 当前选择器层级 */
int class_i; /**< 当前处理到第几个类名 */
int status_i; /**< 当前处理到第几个状态名(伪类名) */
Expand Down
14 changes: 7 additions & 7 deletions lib/css/src/value.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ typedef enum css_valdef_sign_t {
CSS_VALDEF_SIGN_ANGLE_BRACKET
} css_valdef_sign_t;

struct css_value_type_record_t {
struct css_value_type_record {
char *name;
css_value_parse_func_t parse_value;
css_value_parse_cb parse_value;
};

struct css_valdef_t {
struct css_valdef {
css_valdef_sign_t sign;
unsigned min_count;
unsigned max_count;
Expand All @@ -69,7 +69,7 @@ typedef enum css_valdef_parser_target_t {
CSS_VALDEF_PARSER_TARGET_SIGN
} css_valdef_parser_target_t;

typedef struct css_valdef_parser_t {
typedef struct css_valdef_parser {
const char *cur;
char *buffer;
char terminator;
Expand All @@ -84,7 +84,7 @@ typedef struct css_valdef_parser_t {
list_t valdef_parents;
} css_valdef_parser_t;

typedef struct css_value_matcher_t {
typedef struct css_value_matcher {
const char *cur;
const char *next;

Expand All @@ -95,7 +95,7 @@ typedef struct css_value_matcher_t {
unsigned value_len;
} css_value_matcher_t;

static struct css_value_module_t {
static struct css_value_module {
/** dict_t<string, css_valdef_t> */
dict_t *alias;

Expand Down Expand Up @@ -212,7 +212,7 @@ static void css_valdef_append(css_valdef_t *valdef, css_valdef_t *child)
}

const css_value_type_record_t *css_register_value_type(
const char *type_name, css_value_parse_func_t parse)
const char *type_name, css_value_parse_cb parse)
{
css_value_type_record_t *t;

Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/src/i18n-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

typedef enum { NONE, STRING, DICT } dict_value_type_t;

typedef struct dict_string_value_t {
typedef struct dict_string_value {
wchar_t *data;
size_t length;
} dict_string_value_t;

typedef struct dict_value_t dict_value_t;
typedef struct dict_value dict_value_t;

struct dict_value_t {
struct dict_value {
dict_value_type_t type;
union {
dict_string_value_t string;
Expand Down
Loading

0 comments on commit 6851e9a

Please sign in to comment.