Skip to content

Commit

Permalink
feat: replace custom bool type with bool type in stdbool.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Aug 24, 2024
1 parent fec8303 commit 75bb270
Show file tree
Hide file tree
Showing 59 changed files with 320 additions and 331 deletions.
11 changes: 0 additions & 11 deletions include/LCUI/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,4 @@
logger_log(LOGGER_LEVEL_DEBUG, __FILE__ ":%d: %s(): " format, \
__LINE__, __FUNCTION__, ##__VA_ARGS__)

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif

typedef unsigned char LCUI_BOOL;
typedef unsigned char uchar_t;

#endif
1 change: 1 addition & 0 deletions lib/css/include/css/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef LIBCSS_INCLUDE_CSS_DEF_H
#define LIBCSS_INCLUDE_CSS_DEF_H

#include <stdbool.h>
#include <yutil.h>
#include <stdbool.h>

Expand Down
2 changes: 1 addition & 1 deletion lib/css/src/value.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static bool css_valdef_has_children(css_valdef_t *valdef)
default:
break;
}
return FALSE;
return false;
}

void css_valdef_destroy(css_valdef_t *valdef)
Expand Down
10 changes: 5 additions & 5 deletions lib/pandagl/include/pandagl/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ PD_INLINE const pd_canvas_t *pd_canvas_get_quote_source_readonly(

PD_PUBLIC void pd_canvas_init(pd_canvas_t *canvas);

PD_PUBLIC pd_bool_t pd_canvas_is_valid(const pd_canvas_t *canvas);
PD_PUBLIC bool pd_canvas_is_valid(const pd_canvas_t *canvas);

PD_PUBLIC int pd_canvas_quote(pd_canvas_t *self, pd_canvas_t *source,
const pd_rect_t *rect);
Expand All @@ -91,7 +91,7 @@ PD_PUBLIC int pd_canvas_cut(const pd_canvas_t *canvas, pd_rect_t rect,
PD_PUBLIC void pd_canvas_copy(pd_canvas_t *des, const pd_canvas_t *src);

PD_PUBLIC int pd_canvas_mix(pd_canvas_t *back, const pd_canvas_t *fore, int left,
int top, pd_bool_t with_alpha);
int top, bool with_alpha);

PD_PUBLIC int pd_canvas_fill_rect(pd_canvas_t *canvas, pd_color_t color,
pd_rect_t rect);
Expand All @@ -103,17 +103,17 @@ PD_INLINE int pd_canvas_fill(pd_canvas_t *canvas, pd_color_t color)
}

PD_PUBLIC int pd_canvas_tile(pd_canvas_t *buff, const pd_canvas_t *canvas,
pd_bool_t replace, pd_bool_t with_alpha);
bool replace, bool with_alpha);

PD_PUBLIC int pd_canvas_veri_flip(const pd_canvas_t *canvas, pd_canvas_t *buff);

PD_PUBLIC int pd_canvas_horiz_flip(const pd_canvas_t *canvas, pd_canvas_t *buff);

PD_PUBLIC int pd_canvas_zoom(const pd_canvas_t *canvas, pd_canvas_t *buff,
pd_bool_t keep_scale, int width, int height);
bool keep_scale, int width, int height);

PD_PUBLIC int pd_canvas_zoom_bilinear(const pd_canvas_t *canvas,
pd_canvas_t *buff, pd_bool_t keep_scale,
pd_canvas_t *buff, bool keep_scale,
int width, int height);

PD_END_DECLS
Expand Down
10 changes: 5 additions & 5 deletions lib/pandagl/include/pandagl/rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

PD_BEGIN_DECLS

PD_INLINE pd_bool_t pd_rect_is_include(pd_rect_t *a, pd_rect_t *b)
PD_INLINE bool pd_rect_is_include(pd_rect_t *a, pd_rect_t *b)
{
return (b->x >= a->x && b->x + b->width <= a->x + a->width &&
b->y >= a->y && b->y + b->height <= a->y + a->height);
Expand All @@ -29,11 +29,11 @@ PD_PUBLIC pd_rect_t pd_rect_crop(const pd_rect_t *rect, int container_width,
int container_height);

/** 将矩形区域纠正在容器有效区域内 */
PD_PUBLIC pd_bool_t pd_rect_correct(pd_rect_t *rect, int container_width,
PD_PUBLIC bool pd_rect_correct(pd_rect_t *rect, int container_width,
int container_height);

/** 检测矩形是否遮盖另一个矩形 */
PD_PUBLIC pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b);
PD_PUBLIC bool pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b);

/**
* 获取两个矩形中的重叠矩形
Expand All @@ -42,13 +42,13 @@ PD_PUBLIC pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b);
* @param[out] out 矩形A和B重叠处的矩形
* @returns 如果两个矩形重叠,则返回PD_TRUE,否则返回PD_FALSE
*/
PD_PUBLIC pd_bool_t pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b,
PD_PUBLIC bool pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b,
pd_rect_t *overlapping_rect);

PD_PUBLIC void pd_rect_split(pd_rect_t *base, pd_rect_t *target,
pd_rect_t rects[4]);

PD_INLINE pd_bool_t pd_rect_is_equal(const pd_rect_t *a, const pd_rect_t *b)
PD_INLINE bool pd_rect_is_equal(const pd_rect_t *a, const pd_rect_t *b)
{
return a->x == b->x && a->y == b->y && a->width == b->width &&
a->height == b->height;
Expand Down
32 changes: 16 additions & 16 deletions lib/pandagl/include/pandagl/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
PD_BEGIN_DECLS

typedef struct pd_text_style_t {
pd_bool_t has_family : 1;
pd_bool_t has_style : 1;
pd_bool_t has_weight : 1;
pd_bool_t has_back_color : 1;
pd_bool_t has_fore_color : 1;
pd_bool_t has_pixel_size : 1;
bool has_family : 1;
bool has_style : 1;
bool has_weight : 1;
bool has_back_color : 1;
bool has_fore_color : 1;
bool has_pixel_size : 1;

int style;
int weight;
Expand Down Expand Up @@ -109,19 +109,19 @@ typedef struct pd_text_t {
int line_height;
pd_text_align_t text_align;
pd_word_break_t word_break;
pd_bool_t mulitiline_enabled;
pd_bool_t autowrap_enabled;
pd_bool_t style_tag_enabled;
bool mulitiline_enabled;
bool autowrap_enabled;
bool style_tag_enabled;
list_t dirty_rects;
list_t styles;
pd_text_style_t default_style;
pd_text_line_t **lines;
int lines_length;
struct {
pd_bool_t update_bitmap;
pd_bool_t update_typeset;
bool update_bitmap;
bool update_typeset;
int typeset_start_line;
pd_bool_t redraw_all;
bool redraw_all;
} task;
} pd_text_t;

Expand All @@ -141,7 +141,7 @@ PD_PUBLIC void pd_text_set_typeset_task(pd_text_t *layer, int start_row);
PD_PUBLIC void pd_text_set_align(pd_text_t *layer, int align);

/** 设置坐标偏移量 */
PD_PUBLIC pd_bool_t pd_text_set_offset(pd_text_t *layer, int offset_x,
PD_PUBLIC bool pd_text_set_offset(pd_text_t *layer, int offset_x,
int offset_y);

PD_PUBLIC pd_text_t *pd_text_create(void);
Expand Down Expand Up @@ -195,7 +195,7 @@ PD_PUBLIC int pd_text_set_fixed_size(pd_text_t *layer, int width, int height);
PD_PUBLIC int pd_text_set_max_size(pd_text_t *layer, int width, int height);

/** 设置是否启用多行文本模式 */
PD_PUBLIC void pd_text_set_multiline(pd_text_t *layer, pd_bool_t enabled);
PD_PUBLIC void pd_text_set_multiline(pd_text_t *layer, bool enabled);

/** 删除文本光标的当前坐标右边的文本 */
PD_PUBLIC int pd_text_delete(pd_text_t *layer, int n_char);
Expand All @@ -204,13 +204,13 @@ PD_PUBLIC int pd_text_delete(pd_text_t *layer, int n_char);
PD_PUBLIC int pd_text_backspace(pd_text_t *layer, int n_char);

/** 设置是否启用自动换行模式 */
PD_PUBLIC void pd_text_set_autowrap(pd_text_t *layer, pd_bool_t autowrap);
PD_PUBLIC void pd_text_set_autowrap(pd_text_t *layer, bool autowrap);

/** 设置单词内断行模式 */
PD_PUBLIC void pd_text_set_word_break(pd_text_t *layer, pd_word_break_t mode);

/** 设置是否使用样式标签 */
PD_PUBLIC void pd_text_set_style_tag(pd_text_t *layer, pd_bool_t enabled);
PD_PUBLIC void pd_text_set_style_tag(pd_text_t *layer, bool enabled);

/** 重新载入各个文字的字体位图 */
PD_PUBLIC void pd_text_reload_bitmap(pd_text_t *layer);
Expand Down
11 changes: 5 additions & 6 deletions lib/pandagl/include/pandagl/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
#define LIB_PANDAGL_INCLUDE_PANDAGL_TPYES_H

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

typedef unsigned char pd_bool_t;

#define PD_FALSE 0
#define PD_TRUE 1

Expand Down Expand Up @@ -65,7 +64,7 @@ typedef struct pd_canvas_t pd_canvas_t;
typedef struct pd_canvas_quote_t {
int top;
int left;
pd_bool_t is_valid;
bool is_valid;
pd_canvas_t *source;
} pd_canvas_quote_t;

Expand All @@ -88,14 +87,14 @@ struct pd_canvas_t {
typedef struct pd_context_t {
pd_rect_t rect; /**< 需要绘制的区域 */
pd_canvas_t canvas; /**< 绘制后的位图缓存(可称为:画布) */
pd_bool_t with_alpha; /**< 绘制时是否需要处理 alpha 通道 */
bool with_alpha; /**< 绘制时是否需要处理 alpha 通道 */
} pd_context_t;

typedef struct pd_background_t {
pd_canvas_t *image;
pd_color_t color;
pd_bool_t repeat_x;
pd_bool_t repeat_y;
bool repeat_x;
bool repeat_y;
int x;
int y;
int width;
Expand Down
18 changes: 9 additions & 9 deletions lib/pandagl/src/boxshadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void pd_get_boxshadow_canvas_rect(const pd_boxshadow_t *shadow,
canvas_rect->y;
}

static pd_bool_t pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx)
{
int x, y;
int right;
Expand Down Expand Up @@ -181,7 +181,7 @@ static pd_bool_t pd_paint_boxshadow_left_blur(pd_boxshadow_context_t *ctx)
return PD_TRUE;
}

static pd_bool_t pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx)
{
int x, y;
int left;
Expand Down Expand Up @@ -222,7 +222,7 @@ static pd_bool_t pd_paint_boxshadow_right_blur(pd_boxshadow_context_t *ctx)
return PD_TRUE;
}

static pd_bool_t pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx)
{
int x, y;
int bottom;
Expand Down Expand Up @@ -263,7 +263,7 @@ static pd_bool_t pd_paint_boxshadow_top_blur(pd_boxshadow_context_t *ctx)
return PD_TRUE;
}

static pd_bool_t pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx)
{
int x, y;
int top;
Expand Down Expand Up @@ -303,7 +303,7 @@ static pd_bool_t pd_paint_boxshadow_bottom_blur(pd_boxshadow_context_t *ctx)
return PD_TRUE;
}

static pd_bool_t pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx,
static bool pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx,
const pd_rect_t *circle_rect,
double center_x, double center_y,
int radius)
Expand Down Expand Up @@ -373,7 +373,7 @@ static pd_bool_t pd_paint_boxshadow_circle_blur(pd_boxshadow_context_t *ctx,
return PD_TRUE;
}

static pd_bool_t pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx)
{
int radius;
pd_rect_t rect;
Expand All @@ -388,7 +388,7 @@ static pd_bool_t pd_paint_boxshadow_top_left_blur(pd_boxshadow_context_t *ctx)
rect.height, radius);
}

static pd_bool_t pd_paint_boxshadow_top_right_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_top_right_blur(pd_boxshadow_context_t *ctx)
{
int radius;
pd_rect_t rect;
Expand All @@ -403,7 +403,7 @@ static pd_bool_t pd_paint_boxshadow_top_right_blur(pd_boxshadow_context_t *ctx)
radius);
}

static pd_bool_t pd_paint_boxshadow_bottom_left_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_bottom_left_blur(pd_boxshadow_context_t *ctx)
{
int radius;
pd_rect_t rect;
Expand All @@ -418,7 +418,7 @@ static pd_bool_t pd_paint_boxshadow_bottom_left_blur(pd_boxshadow_context_t *ctx
radius);
}

static pd_bool_t pd_paint_boxshadow_bottom_right_blur(pd_boxshadow_context_t *ctx)
static bool pd_paint_boxshadow_bottom_right_blur(pd_boxshadow_context_t *ctx)
{
int radius;
pd_rect_t rect;
Expand Down
4 changes: 2 additions & 2 deletions lib/pandagl/src/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void pd_canvas_init(pd_canvas_t *canvas)
canvas->bytes_per_row = 0;
}

pd_bool_t pd_canvas_is_valid(const pd_canvas_t *canvas)
bool pd_canvas_is_valid(const pd_canvas_t *canvas)
{
if (!canvas) {
return PD_FALSE;
Expand Down Expand Up @@ -378,7 +378,7 @@ static void pd_canvas_mix_argb2rgb(pd_canvas_t *des, pd_rect_t des_rect,
}

int pd_canvas_mix(pd_canvas_t *back, const pd_canvas_t *fore, int left, int top,
pd_bool_t with_alpha)
bool with_alpha)
{
pd_canvas_t w_slot;
pd_rect_t r_rect, w_rect;
Expand Down
2 changes: 1 addition & 1 deletion lib/pandagl/src/font/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef struct font_family_node_t {
static struct font_library_module_t {
int count; /**< 计数器,主要用于为字体信息生成标识号 */
int font_cache_num; /**< 字体信息缓存区的数量 */
pd_bool_t active; /**< 标记,指示数据库是否初始化 */
bool active; /**< 标记,指示数据库是否初始化 */
dict_t *font_families; /**< 字族信息库,以字族名称索引字体信息 */
dict_type_t font_families_type; /**< 字族信息库的字典类型数据 */
rbtree_t bitmap_cache; /**< 字体位图缓存区 */
Expand Down
2 changes: 1 addition & 1 deletion lib/pandagl/src/image/jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef struct pd_jpeg_reader_t {
struct jpeg_decompress_struct cinfo;
jmp_buf env;
pd_jpeg_error_t err;
pd_bool_t start_of_file;
bool start_of_file;
pd_image_reader_t *base;
unsigned char buffer[BUFFER_SIZE];
} pd_jpeg_reader_t;
Expand Down
10 changes: 5 additions & 5 deletions lib/pandagl/src/rect.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ pd_rect_t pd_rect_crop(const pd_rect_t *rect, int container_width,
return cropped_rect;
}

pd_bool_t pd_rect_correct(pd_rect_t *rect, int container_width,
bool pd_rect_correct(pd_rect_t *rect, int container_width,
int container_height)
{
pd_bool_t overflow = PD_FALSE;
bool overflow = PD_FALSE;

if (rect->x < 0) {
overflow = PD_TRUE;
Expand Down Expand Up @@ -77,7 +77,7 @@ pd_bool_t pd_rect_correct(pd_rect_t *rect, int container_width,
return overflow;
}

pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b)
bool pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b)
{
if (a->x > b->x) {
if (b->x + b->width <= a->x) {
Expand All @@ -100,7 +100,7 @@ pd_bool_t pd_rect_is_cover(const pd_rect_t *a, const pd_rect_t *b)
return PD_TRUE;
}

pd_bool_t pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b,
bool pd_rect_overlap(const pd_rect_t *a, const pd_rect_t *b,
pd_rect_t *overlapping_rect)
{
if (a->x > b->x) {
Expand Down Expand Up @@ -286,7 +286,7 @@ int pd_rects_remove(list_t *list, pd_rect_t *rect)
{
int i;

pd_bool_t deletable;
bool deletable;
pd_rect_t *p, child_rects[4];

list_t extra_list;
Expand Down
Loading

0 comments on commit 75bb270

Please sign in to comment.