Skip to content

Commit

Permalink
build: update header files and xmake.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Apr 16, 2023
1 parent d4ea54a commit 75717f8
Show file tree
Hide file tree
Showing 99 changed files with 1,682 additions and 1,563 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PointerAlignment: Right
ReflowComments: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
Expand All @@ -32,4 +32,4 @@ SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SortIncludes: false
UseTab: ForContinuationAndIndentation
UseTab: Never
8 changes: 0 additions & 8 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
const fs = require("fs");
const path = require("path");

module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"header-min-length": [2, "always", 1],
"header-max-length": [2, "always", 72],
"subject-case": [0],
"scope-enum": [
2,
"always",
[...fs.readdirSync(path.resolve(__dirname, "lib")), "docs"],
],
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ test/build
lcpkg/*
!lcpkg/ports
vsxmake*
compile_commands.json
26 changes: 0 additions & 26 deletions .vscode/c_cpp_properties.json

This file was deleted.

31 changes: 0 additions & 31 deletions .vscode/settings.json

This file was deleted.

5 changes: 3 additions & 2 deletions include/LCUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <ui_widgets.h>
#include <ui_cursor.h>
#include <ui_server.h>
#include <ui_builder.h>
#include <ui_xml.h>
#include <platform.h>
#include <LCUI/timer.h>
#include <worker.h>
#include <timer.h>
#include <LCUI/app.h>
58 changes: 19 additions & 39 deletions include/LCUI/app.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef LCUI_H
#define LCUI_H
#ifndef LCUI_INCLUDE_LCUI_APP_H
#define LCUI_INCLUDE_LCUI_APP_H

#include <LCUI/def.h>
#include "common.h"
#include <platform.h>
#include <LCUI/worker.h>
#include <worker.h>

#define LCUI_MAX_FRAMES_PER_SEC 120
#define LCUI_MAX_FRAME_MSEC ((int)(1000.0 / LCUI_MAX_FRAMES_PER_SEC + 0.5))
Expand All @@ -13,11 +13,11 @@ LCUI_BEGIN_HEADER
// Settings

typedef struct lcui_settings_t {
int frame_rate_cap;
int parallel_rendering_threads;
LCUI_BOOL record_profile;
LCUI_BOOL fps_meter;
LCUI_BOOL paint_flashing;
int frame_rate_cap;
int parallel_rendering_threads;
bool record_profile;
bool fps_meter;
bool paint_flashing;
} lcui_settings_t;

/* Initialize settings with the current global settings. */
Expand All @@ -29,52 +29,32 @@ LCUI_API void lcui_apply_settings(lcui_settings_t *settings);
/* Reset global settings to their defaults. */
LCUI_API void lcui_reset_settings(void);

// Timers

LCUI_API int lcui_destroy_timer(int timer_id);
LCUI_API int lcui_pause_timer(int timer_id);
LCUI_API int lcui_continue_timer(int timer_id);
LCUI_API int lcui_reset_timer(int timer_id, long int n_ms);
LCUI_API int lcui_set_timeout(long int n_ms, void (*callback)(void *),
void *arg);
LCUI_API int lcui_set_interval(long int n_ms, void (*callback)(void *),
void *arg);

// Tasks

typedef void (*LCUI_AppTaskFunc)(void *, void *);

/**
* 添加任务
* 该任务将会添加至主线程中执行
*/
LCUI_API LCUI_BOOL lcui_post_task(LCUI_Task task);
LCUI_API bool lcui_post_task(worker_task_t *task);

/**
* 添加异步任务
* 该任务将会添加至指定 id 的工作线程中执行
* @param[in] task 任务数据
* @param[in] target_worker_id 目标工作线程的编号
*/
LCUI_API void lcui_post_async_task(LCUI_Task task, int target_worker_id);

/** lcui_post_task 的简化版本 */
#define lcui_post_simple_task(FUNC, ARG1, ARG2) \
do { \
LCUI_TaskRec _ui_task = { 0 }; \
_ui_task.arg[0] = (void *)ARG1; \
_ui_task.arg[1] = (void *)ARG2; \
_ui_task.func = (LCUI_AppTaskFunc)(FUNC); \
lcui_post_task(&_ui_task); \
} while (0);
LCUI_API void lcui_post_async_task(worker_task_t *task, int target_worker_id);

LCUI_API bool lcui_post_simple_task(worker_callback_t callback, void *arg1,
void *arg2);

// UI

typedef enum lcui_display_mode_t {
LCUI_DISPLAY_MODE_DEFAULT,
LCUI_DISPLAY_MODE_WINDOWED,
LCUI_DISPLAY_MODE_FULLSCREEN,
LCUI_DISPLAY_MODE_SEAMLESS,
LCUI_DISPLAY_MODE_DEFAULT,
LCUI_DISPLAY_MODE_WINDOWED,
LCUI_DISPLAY_MODE_FULLSCREEN,
LCUI_DISPLAY_MODE_SEAMLESS,
} lcui_display_mode_t;

LCUI_API void lcui_init_ui(void);
Expand All @@ -93,7 +73,7 @@ LCUI_API int lcui_process_events(app_process_events_option_t option);

INLINE int lcui_process_all_events(void)
{
return lcui_process_events(APP_PROCESS_EVENTS_ALL_IF_PRESENT);
return lcui_process_events(APP_PROCESS_EVENTS_ALL_IF_PRESENT);
}

// Base
Expand Down
67 changes: 67 additions & 0 deletions include/LCUI/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#ifndef LCUI_INCLUDE_LCUI_COMMON_H
#define LCUI_INCLUDE_LCUI_COMMON_H

#include "config.h"

#ifndef LCUI_API
#if defined(_MSC_VER) && !defined(LCUI_STATIC_BUILD)
#ifdef LCUI_DLL_EXPORT
#define LCUI_API __declspec(dllexport)
#else
#define LCUI_API __declspec(dllimport)
#endif
#elif __GNUC__ >= 4
#define LCUI_API extern __attribute__((visibility("default")))
#else
#define LCUI_API extern
#endif
#endif

#if defined(_WIN32) && !defined(__cplusplus)
#define INLINE __inline
#else
#define INLINE static inline
#endif

#ifdef _WIN32
#define LIBPLAT_WIN32
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#define LIBPLAT_UWP
#else
#define LIBPLAT_WIN_DESKTOP
#endif
#else
#define LIBPLAT_LINUX
#endif

#ifdef __cplusplus
#define LCUI_BEGIN_HEADER extern "C" {
#define LCUI_END_HEADER }
#else
#define LCUI_BEGIN_HEADER /* nothing */
#define LCUI_END_HEADER
#endif

#ifdef DEBUG
#define DEBUG_MSG _DEBUG_MSG
#else
#define DEBUG_MSG(format, ...)
#endif

#define _DEBUG_MSG(format, ...) \
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
65 changes: 0 additions & 65 deletions include/LCUI/def.h

This file was deleted.

Loading

0 comments on commit 75717f8

Please sign in to comment.