fix macos compile error

This commit is contained in:
xianjimli 2019-09-30 21:44:18 +08:00
parent 6629e6337a
commit b988f9db1c
8 changed files with 48 additions and 26 deletions

View File

@ -26,9 +26,6 @@
#include "tkc/date_time.h" #include "tkc/date_time.h"
#include "tkc/mem.h" #include "tkc/mem.h"
#define SOKOL_IMPL
#include "sokol/sokol_time.h"
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
#pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "Ws2_32.lib")
@ -85,6 +82,10 @@ static ret_t date_time_get_now_impl(date_time_t* dt) {
#endif #endif
uint64_t stm_now_ms();
void stm_time_init(void);
uint64_t get_time_ms() { uint64_t get_time_ms() {
#if 0 #if 0
/* /*
@ -93,8 +94,7 @@ uint64_t get_time_ms() {
return (uint64_t)(tv.tv_sec) * 1000 + (uint64_t)(tv.tv_usec) / 1000; return (uint64_t)(tv.tv_sec) * 1000 + (uint64_t)(tv.tv_usec) / 1000;
*/ */
#else #else
uint64_t now = stm_now(); return stm_now_ms();
return now/1000000;
#endif #endif
} }
@ -111,7 +111,7 @@ static uint32_t s_heap_mem[1024 * 1024];
#endif /*HAS_STD_MALLOC*/ #endif /*HAS_STD_MALLOC*/
ret_t platform_prepare(void) { ret_t platform_prepare(void) {
stm_setup(); stm_time_init();
#ifndef HAS_STD_MALLOC #ifndef HAS_STD_MALLOC
tk_mem_init(s_heap_mem, sizeof(s_heap_mem)); tk_mem_init(s_heap_mem, sizeof(s_heap_mem));

View File

@ -0,0 +1,32 @@
/**
* File: platform_time.c
* Author: AWTK Develop Team
* Brief: default platform
*
* Copyright (c) 2018 - 2019 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-02-21 Li XianJing <xianjimli@hotmail.com> created
*
*/
#define SOKOL_IMPL
#include "sokol/sokol_time.h"
uint64_t stm_now_ms() {
uint64_t now = stm_now();
return now/1000000;
}
void stm_time_init(void) {
stm_setup();
}

View File

@ -30,7 +30,7 @@
static int32_t tk_istream_udp_read(tk_istream_t* stream, uint8_t* buff, uint32_t max_size) { static int32_t tk_istream_udp_read(tk_istream_t* stream, uint8_t* buff, uint32_t max_size) {
int32_t ret = 0; int32_t ret = 0;
tk_istream_udp_t* istream_udp = TK_ISTREAM_UDP(stream); tk_istream_udp_t* istream_udp = TK_ISTREAM_UDP(stream);
int addr_size = sizeof(istream_udp->addr); socklen_t addr_size = sizeof(istream_udp->addr);
ret = recvfrom(istream_udp->sock, buff, max_size, 0, (struct sockaddr*)&(istream_udp->addr), ret = recvfrom(istream_udp->sock, buff, max_size, 0, (struct sockaddr*)&(istream_udp->addr),
&addr_size); &addr_size);

View File

@ -86,7 +86,6 @@ ret_t tk_ostream_udp_set_target_with_addr(tk_ostream_t* stream, struct sockaddr_
ret_t tk_ostream_udp_set_target_with_host(tk_ostream_t* stream, const char* host, int port) { ret_t tk_ostream_udp_set_target_with_host(tk_ostream_t* stream, const char* host, int port) {
struct sockaddr_in addr_in; struct sockaddr_in addr_in;
tk_ostream_udp_t* ostream_udp = TK_OSTREAM_UDP(stream);
return_value_if_fail(stream != NULL, RET_BAD_PARAMS); return_value_if_fail(stream != NULL, RET_BAD_PARAMS);
return_value_if_fail(socket_resolve(host, port, &addr_in) != NULL, RET_BAD_PARAMS); return_value_if_fail(socket_resolve(host, port, &addr_in) != NULL, RET_BAD_PARAMS);

View File

@ -100,31 +100,27 @@ ret_t value_desc_validate(value_desc_t* schema, value_t* v) {
return RET_OK; return RET_OK;
} }
case VALUE_DESC_TYPE_STRING_ENUMS: { case VALUE_DESC_TYPE_STRING_ENUMS: {
uint32_t i = 0;
const char* value = value_str(v); const char* value = value_str(v);
const value_desc_string_enums_t* desc = (const value_desc_string_enums_t*)schema; const value_desc_string_enums_t* desc = (const value_desc_string_enums_t*)schema;
return_value_if_fail(desc->enums != NULL && value != NULL, RET_FAIL); return_value_if_fail(desc->enums != NULL && value != NULL, RET_FAIL);
if (desc->enums != NULL) { for (i = 0; desc->enums[i] != NULL; i++) {
uint32_t i = 0; if (tk_str_eq(desc->enums[i], value)) {
for (i = 0; desc->enums[i] != NULL; i++) { return RET_OK;
if (tk_str_eq(desc->enums[i], value)) {
return RET_OK;
}
} }
} }
break; break;
} }
case VALUE_DESC_TYPE_INT_ENUMS: { case VALUE_DESC_TYPE_INT_ENUMS: {
uint32_t i = 0;
int32_t value = value_int(v); int32_t value = value_int(v);
const value_desc_int_enums_t* desc = (const value_desc_int_enums_t*)schema; const value_desc_int_enums_t* desc = (const value_desc_int_enums_t*)schema;
return_value_if_fail(desc->enums != NULL, RET_FAIL); return_value_if_fail(desc->enums != NULL, RET_FAIL);
if (desc->enums != NULL) { for (i = 0; desc->enums[i] != NULL; i++) {
uint32_t i = 0; if (tk_atoi(desc->enums[i]) == value) {
for (i = 0; desc->enums[i] != NULL; i++) { return RET_OK;
if (tk_atoi(desc->enums[i]) == value) {
return RET_OK;
}
} }
} }
break; break;

View File

@ -6,11 +6,7 @@
using std::string; using std::string;
TEST(ComboBoxEx, basic) { TEST(ComboBoxEx, basic) {
value_t v1;
value_t v2;
widget_t* w = combo_box_ex_create(NULL, 10, 20, 30, 40); widget_t* w = combo_box_ex_create(NULL, 10, 20, 30, 40);
combo_box_ex_t* combo_box_ex = COMBO_BOX_EX(w);
ASSERT_STREQ(widget_get_prop_str(w, WIDGET_PROP_TYPE, NULL), WIDGET_TYPE_COMBO_BOX_EX); ASSERT_STREQ(widget_get_prop_str(w, WIDGET_PROP_TYPE, NULL), WIDGET_TYPE_COMBO_BOX_EX);
widget_destroy(w); widget_destroy(w);
@ -21,7 +17,6 @@ TEST(ComboBoxEx, localize) {
value_t v2; value_t v2;
widget_t* w = combo_box_ex_create(NULL, 10, 20, 30, 40); widget_t* w = combo_box_ex_create(NULL, 10, 20, 30, 40);
combo_box_t* combo_box = COMBO_BOX(w); combo_box_t* combo_box = COMBO_BOX(w);
combo_box_ex_t* combo_box_ex = COMBO_BOX_EX(w);
ASSERT_EQ(TRUE, combo_box->localize_options); ASSERT_EQ(TRUE, combo_box->localize_options);

View File

@ -41,6 +41,7 @@ GTEST_API_ int main(int argc, char** argv) {
printf("Running main() from gtest_main.cc\n"); printf("Running main() from gtest_main.cc\n");
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
return_value_if_fail(platform_prepare() == RET_OK, RET_FAIL);
system_info_init(APP_SIMULATOR, NULL, "./demos"); system_info_init(APP_SIMULATOR, NULL, "./demos");
tk_init_internal(); tk_init_internal();

View File

@ -140,7 +140,6 @@ TEST(ObjectArray, dup) {
TEST(ObjectArray, path) { TEST(ObjectArray, path) {
value_t v; value_t v;
object_t* clone = NULL;
object_t* root = object_default_create(); object_t* root = object_default_create();
object_t* obja = object_array_create(); object_t* obja = object_array_create();
object_t* obja1 = object_default_create(); object_t* obja1 = object_default_create();