format code

This commit is contained in:
lixianjing 2021-05-31 17:21:47 +08:00
parent 9a56e7848c
commit bdbc5e5437
14 changed files with 38 additions and 42 deletions

View File

@ -595,7 +595,7 @@ ret_t scroll_bar_scroll_to(widget_t* widget, int32_t value, int32_t duration) {
}
#else
scroll_bar_set_value(widget, value);
scroll_bar_on_value_animate_end(widget, NULL);
scroll_bar_on_value_animate_end(widget, NULL);
#endif
return RET_OK;
@ -721,7 +721,7 @@ ret_t scroll_bar_hide_by_opacity_animation(widget_t* widget, int32_t duration, i
#else
widget->opacity = 0;
scroll_bar_on_opactiy_animate_end(widget, NULL);
#endif/*WITHOUT_WIDGET_ANIMATORS*/
#endif /*WITHOUT_WIDGET_ANIMATORS*/
return RET_OK;
}

View File

@ -268,7 +268,7 @@ ret_t scroll_view_scroll_to(widget_t* widget, int32_t xoffset_end, int32_t yoffs
scroll_view->xoffset = xoffset_end;
scroll_view->yoffset = yoffset_end;
scroll_view_on_scroll_done(widget, NULL);
#endif/*WITHOUT_WIDGET_ANIMATORS*/
#endif /*WITHOUT_WIDGET_ANIMATORS*/
return RET_OK;
}
@ -310,7 +310,7 @@ static ret_t scroll_view_on_pointer_up(scroll_view_t* scroll_view, pointer_event
#else
int yv = 0;
int xv = 0;
#endif/*WITHOUT_WIDGET_ANIMATORS*/
#endif /*WITHOUT_WIDGET_ANIMATORS*/
if (scroll_view->wa != NULL) {
widget_animator_scroll_t* wa = (widget_animator_scroll_t*)scroll_view->wa;
int32_t dx = wa->x_to - scroll_view->xoffset;

View File

@ -171,8 +171,8 @@ static ret_t slide_view_animate_to(slide_view_t* slide_view, int32_t xoffset, in
slide_view->animating = FALSE;
slide_view->xoffset = xoffset_end;
slide_view->yoffset = yoffset_end;
slide_view_on_scroll_done(widget, NULL);
#endif/*WITHOUT_WIDGET_ANIMATORS*/
slide_view_on_scroll_done(widget, NULL);
#endif /*WITHOUT_WIDGET_ANIMATORS*/
return RET_OK;
}

View File

@ -88,7 +88,7 @@ static ret_t switch_scroll_to(widget_t* widget, int32_t xoffset_end) {
#else
aswitch->xoffset = xoffset_end;
switch_on_scroll_done(widget, NULL);
#endif/*WITHOUT_WIDGET_ANIMATORS*/
#endif /*WITHOUT_WIDGET_ANIMATORS*/
return RET_OK;
}

View File

@ -583,7 +583,7 @@ static ret_t text_selector_scroll_to(widget_t* widget, int32_t yoffset_end) {
#else
text_selector->yoffset = yoffset_end;
text_selector_on_scroll_done(widget, NULL);
#endif/*WITHOUT_WIDGET_ANIMATORS*/
#endif /*WITHOUT_WIDGET_ANIMATORS*/
return RET_OK;
}

1
src/misc/new.cpp Executable file → Normal file
View File

@ -6,7 +6,6 @@
#if 0
#define MAX_SIZE 2 * 1024 * 1024
#ifndef WITH_SDL
void* operator new(std::size_t size) __TK_THROW_BAD_ALLOC {
if (size >= MAX_SIZE) {

View File

@ -33,7 +33,7 @@ tk_mutex_t* tk_mutex_create() {
tk_mutex_t* mutex = TKMEM_ZALLOC(tk_mutex_t);
return_value_if_fail(mutex != NULL, NULL);
mutex->mutex = xSemaphoreCreateMutex();
mutex->mutex = xSemaphoreCreateMutex();
if (mutex->mutex == NULL) {
TKMEM_FREE(mutex);
}
@ -44,7 +44,7 @@ tk_mutex_t* tk_mutex_create() {
ret_t tk_mutex_lock(tk_mutex_t* mutex) {
return_value_if_fail(mutex != NULL, RET_BAD_PARAMS);
return_value_if_fail( xSemaphoreTake( mutex->mutex, 0xffffff ) == pdTRUE, RET_FAIL);
return_value_if_fail(xSemaphoreTake(mutex->mutex, 0xffffff) == pdTRUE, RET_FAIL);
return RET_OK;
}
@ -52,7 +52,7 @@ ret_t tk_mutex_lock(tk_mutex_t* mutex) {
ret_t tk_mutex_try_lock(tk_mutex_t* mutex) {
return_value_if_fail(mutex != NULL, RET_BAD_PARAMS);
return_value_if_fail( xSemaphoreTake( mutex->mutex, 0) == pdTRUE, RET_FAIL);
return_value_if_fail(xSemaphoreTake(mutex->mutex, 0) == pdTRUE, RET_FAIL);
return RET_OK;
}
@ -60,7 +60,7 @@ ret_t tk_mutex_try_lock(tk_mutex_t* mutex) {
ret_t tk_mutex_unlock(tk_mutex_t* mutex) {
return_value_if_fail(mutex != NULL, RET_BAD_PARAMS);
return_value_if_fail( xSemaphoreGive( mutex->mutex) == pdTRUE, RET_FAIL);
return_value_if_fail(xSemaphoreGive(mutex->mutex) == pdTRUE, RET_FAIL);
return RET_OK;
}
@ -68,10 +68,9 @@ ret_t tk_mutex_unlock(tk_mutex_t* mutex) {
ret_t tk_mutex_destroy(tk_mutex_t* mutex) {
return_value_if_fail(mutex != NULL, RET_BAD_PARAMS);
vSemaphoreDelete(mutex->mutex);
vSemaphoreDelete(mutex->mutex);
memset(mutex, 0x00, sizeof(tk_mutex_t));
TKMEM_FREE(mutex);
return RET_OK;
}

View File

@ -30,16 +30,16 @@ ret_t rtos_init(void) {
}
ret_t rtos_start(void) {
if(!s_is_running) {
s_is_running = TRUE;
vTaskStartScheduler();
}
if (!s_is_running) {
s_is_running = TRUE;
vTaskStartScheduler();
}
return RET_OK;
}
/*implemented in port.c*/
void xPortSysTickHandler( void );
void xPortSysTickHandler(void);
/*
* modify FreeRTOSConfig.h remove the following line
@ -47,18 +47,17 @@ void xPortSysTickHandler( void );
*/
void rtos_tick(void) {
if(s_is_running) {
if (s_is_running) {
xPortSysTickHandler();
}
}
void rtos_delay(uint32_t ms) {
uint32_t ticks = ms * portTICK_PERIOD_MS;
uint32_t ticks = ms * portTICK_PERIOD_MS;
vTaskDelay(ticks);
vTaskDelay(ticks);
}
bool_t rtos_is_running(void) {
return s_is_running;
}

View File

@ -35,7 +35,7 @@ tk_semaphore_t* tk_semaphore_create(uint32_t value, const char* name) {
tk_semaphore_t* semaphore = TKMEM_ZALLOC(tk_semaphore_t);
return_value_if_fail(semaphore != NULL, NULL);
semaphore->sem = xSemaphoreCreateCounting(0xff, value);
semaphore->sem = xSemaphoreCreateCounting(0xff, value);
if (semaphore->sem == NULL) {
TKMEM_FREE(semaphore);
}
@ -44,7 +44,7 @@ tk_semaphore_t* tk_semaphore_create(uint32_t value, const char* name) {
}
ret_t tk_semaphore_wait(tk_semaphore_t* semaphore, uint32_t timeout_ms) {
uint32_t ticks = timeout_ms * portTICK_PERIOD_MS;
uint32_t ticks = timeout_ms * portTICK_PERIOD_MS;
return_value_if_fail(semaphore != NULL, RET_BAD_PARAMS);
if (xSemaphoreTake(semaphore->sem, ticks) != pdTRUE) {
@ -57,7 +57,7 @@ ret_t tk_semaphore_wait(tk_semaphore_t* semaphore, uint32_t timeout_ms) {
ret_t tk_semaphore_post(tk_semaphore_t* semaphore) {
return_value_if_fail(semaphore != NULL, RET_BAD_PARAMS);
return_value_if_fail(xSemaphoreGive(semaphore->sem)== pdTRUE, RET_FAIL);
return_value_if_fail(xSemaphoreGive(semaphore->sem) == pdTRUE, RET_FAIL);
return RET_OK;
}
@ -65,7 +65,7 @@ ret_t tk_semaphore_post(tk_semaphore_t* semaphore) {
ret_t tk_semaphore_destroy(tk_semaphore_t* semaphore) {
return_value_if_fail(semaphore != NULL, RET_BAD_PARAMS);
vSemaphoreDelete(semaphore->sem);
vSemaphoreDelete(semaphore->sem);
memset(semaphore, 0x00, sizeof(tk_semaphore_t));
TKMEM_FREE(semaphore);

View File

@ -103,10 +103,10 @@ tk_thread_t* tk_thread_create(tk_thread_entry_t entry, void* args) {
ret_t tk_thread_start(tk_thread_t* thread) {
return_value_if_fail(thread != NULL && !thread->running, RET_BAD_PARAMS);
xTaskCreate(tk_thread_entry, thread->name, thread->stack_size, thread,
thread->priority, &(thread->task));
xTaskCreate(tk_thread_entry, thread->name, thread->stack_size, thread, thread->priority,
&(thread->task));
if(thread->task == NULL) {
if (thread->task == NULL) {
return RET_FAIL;
} else {
return RET_OK;
@ -139,4 +139,3 @@ ret_t tk_thread_destroy(tk_thread_t* thread) {
uint64_t tk_thread_self(void) {
return (uint64_t)xTaskGetCurrentTaskHandle();
}

View File

@ -199,9 +199,9 @@ ret_t platform_prepare(void) {
#ifndef HAS_STD_MALLOC
#ifndef TK_HEAP_MEM_SIZE
#define TK_HEAP_MEM_SIZE 12 * 1024 * 1024
#endif/*TK_HEAP_MEM_SIZE*/
#endif /*TK_HEAP_MEM_SIZE*/
static uint32_t s_heap_mem[TK_HEAP_MEM_SIZE/4];
static uint32_t s_heap_mem[TK_HEAP_MEM_SIZE / 4];
tk_mem_init(s_heap_mem, sizeof(s_heap_mem));
#endif /*HAS_STD_MALLOC*/

View File

@ -26,6 +26,6 @@ log_level_t log_get_log_level(void) {
return s_log_level;
}
int32_t log_dummy(const char* fmt, ...){
return 0;
int32_t log_dummy(const char* fmt, ...) {
return 0;
}

View File

@ -210,10 +210,10 @@ void awtk_ios_log(const char* message, ...);
#define log_error(format, args...) \
if (log_get_log_level() <= LOG_LEVEL_ERROR) log_impl(format, ##args)
#else
#define log_debug(format, args...) log_dummy(format, ##args)
#define log_info(format, args...) log_dummy(format, ##args)
#define log_warn(format, args...) log_dummy(format, ##args)
#define log_error(format, args...) log_dummy(format, ##args)
#define log_debug(format, args...) log_dummy(format, ##args)
#define log_info(format, args...) log_dummy(format, ##args)
#define log_warn(format, args...) log_dummy(format, ##args)
#define log_error(format, args...) log_dummy(format, ##args)
#endif
END_C_DECLS

View File

@ -115,8 +115,8 @@ static inline void mem_allocator_std_free(mem_allocator_t* allocator, void* ptr)
static inline ret_t mem_allocator_std_dump(mem_allocator_t* allocator) {
mem_allocator_std_t* std_allocator = (mem_allocator_std_t*)allocator;
log_debug("used_nr=%u used_size=%u max_used_nr=%u max_used_size=%u\n",
std_allocator->used_nr, std_allocator->used_size, std_allocator->max_used_nr, std_allocator->max_used_size);
log_debug("used_nr=%u used_size=%u max_used_nr=%u max_used_size=%u\n", std_allocator->used_nr,
std_allocator->used_size, std_allocator->max_used_nr, std_allocator->max_used_size);
return RET_OK;
}