make all kernal files to be single ascii

This commit is contained in:
Lyon 2023-08-01 19:44:05 +08:00
parent 71670cd395
commit a3a3d8fb75
131 changed files with 1370 additions and 2666 deletions

View File

@ -136,14 +136,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
void* context) { void* context) {
DictToStrContext* ctx = (DictToStrContext*)context; DictToStrContext* ctx = (DictToStrContext*)context;
// 判断是否需要在字符串前添加逗号
if (!ctx->isFirst) { if (!ctx->isFirst) {
ctx->buf = arg_strAppend(ctx->buf, ", "); ctx->buf = arg_strAppend(ctx->buf, ", ");
} else { } else {
ctx->isFirst = 0; ctx->isFirst = 0;
} }
// 将键值对添加到字符串
ctx->buf = arg_strAppend(ctx->buf, "'"); ctx->buf = arg_strAppend(ctx->buf, "'");
ctx->buf = arg_strAppend(ctx->buf, builtins_str(self, keyEach)); ctx->buf = arg_strAppend(ctx->buf, builtins_str(self, keyEach));
ctx->buf = arg_strAppend(ctx->buf, "'"); ctx->buf = arg_strAppend(ctx->buf, "'");
@ -160,15 +158,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
} }
char* PikaStdData_Dict___str__(PikaObj* self) { char* PikaStdData_Dict___str__(PikaObj* self) {
// 初始化上下文
DictToStrContext context; DictToStrContext context;
context.buf = arg_newStr("{"); context.buf = arg_newStr("{");
context.isFirst = 1; context.isFirst = 1;
// 使用 objDict_forEach 遍历字典
objDict_forEach(self, dictToStrEachHandle, &context); objDict_forEach(self, dictToStrEachHandle, &context);
// 将字符串添加到结果中并返回
context.buf = arg_strAppend(context.buf, "}"); context.buf = arg_strAppend(context.buf, "}");
obj_setStr(self, "_buf", arg_getStr(context.buf)); obj_setStr(self, "_buf", arg_getStr(context.buf));
arg_deinit(context.buf); arg_deinit(context.buf);

View File

@ -241,9 +241,7 @@ PikaObj* PikaStdData_String_split(PikaObj* self, PikaTuple* s_) {
} else { } else {
s = pikaTuple_getStr(s_, 0); s = pikaTuple_getStr(s_, 0);
} }
/* 创建 list 对象 */
PikaObj* list = newNormalObj(New_PikaStdData_List); PikaObj* list = newNormalObj(New_PikaStdData_List);
/* 初始化 list */
PikaStdData_List___init__(list); PikaStdData_List___init__(list);
Args buffs = {0}; Args buffs = {0};

View File

@ -1,11 +1,39 @@
import os
import sys import sys
import subprocess import subprocess
from pathlib import Path from pathlib import Path
import codecs
def format_file(filepath):
try:
subprocess.run(['clang-format', '-i', str(filepath)], check=True)
except subprocess.CalledProcessError as e:
print(f'Error formatting file: {filepath}. Error message: {str(e)}')
non_ascii_lines = []
with codecs.open(filepath, 'r', 'utf-8-sig') as file:
lines = file.readlines()
for i, line in enumerate(lines):
if filepath.suffix != '.cpp':
if not line.isascii():
non_ascii_lines.append((i + 1, line))
if lines and not lines[-1].endswith('\n'):
lines.append('\n')
print(f'Added newline to file: {filepath}')
with codecs.open(filepath, 'w', 'utf-8') as file:
file.writelines(lines)
if non_ascii_lines:
# print with yellow color
print(f'\033[33mFound non-ASCII lines in file: {filepath}\033[0m')
for line_no, line in non_ascii_lines:
print(f'Line {filepath}:{line_no}: {line}')
def format_files_in_dir(dir_path, dir_skip): def format_files_in_dir(dir_path, dir_skip):
# 遍历目录及其子目录中的所有文件
for filepath in dir_path.rglob('*'): for filepath in dir_path.rglob('*'):
# Skip if the current file's directory or any of its parents are in dir_skip # Skip if the current file's directory or any of its parents are in dir_skip
if any(str(filepath).startswith(dir) for dir in dir_skip): if any(str(filepath).startswith(dir) for dir in dir_skip):
@ -13,22 +41,7 @@ def format_files_in_dir(dir_path, dir_skip):
# 只处理.c, .h, .cpp文件 # 只处理.c, .h, .cpp文件
if filepath.suffix in ['.c', '.h', '.cpp']: if filepath.suffix in ['.c', '.h', '.cpp']:
try: format_file(filepath)
# 使用clang-format命令格式化文件
subprocess.run(
['clang-format', '-i', str(filepath)], check=True)
print(f'Formatted file: {filepath}')
except subprocess.CalledProcessError as e:
print(
f'Error formatting file: {filepath}. Error message: {str(e)}')
# 确保文件最后一行是空行
with open(filepath, 'r+', encoding='utf-8') as file:
lines = file.readlines()
if lines and not lines[-1].endswith('\n'):
# 如果最后一行不是空行,添加一个
file.write('\n')
print(f'Added newline to file: {filepath}')
# 从命令行参数获取目录列表 # 从命令行参数获取目录列表
@ -40,7 +53,10 @@ if len(dirs) == 0:
'package/pikascript/pikascript-core', 'test'] 'package/pikascript/pikascript-core', 'test']
dir_skip = ['package/pikascript/pikascript-lib/re', dir_skip = ['package/pikascript/pikascript-lib/re',
'package/pikascript/pikascript-lib/PikaNN'] 'package/pikascript/pikascript-lib/PikaNN',
'package/pikascript/pikascript-lib/modbus',
'package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_table_rule.h'
]
# 对每个目录进行处理 # 对每个目录进行处理
for dir_path_str in dirs: for dir_path_str in dirs:

View File

@ -1,20 +1,19 @@
/***************************************************************************** /*****************************************************************************
* Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> * * Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
* * * *
* Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License"); * you may
* you may not use this file except in compliance with the License. * *not use this file except in compliance with the License. * You may
* You may obtain a copy of the License at * *obtain a copy of the License at *
* * * *
* http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0 *
* * * *
* Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * ** See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* * * *
****************************************************************************/ ****************************************************************************/
#ifndef __PROTECTED_LOW_OVERHEAD_OBJECT_ORIENTED_C_H__ #ifndef __PROTECTED_LOW_OVERHEAD_OBJECT_ORIENTED_C_H__
#define __PROTECTED_LOW_OVERHEAD_OBJECT_ORIENTED_C_H__ #define __PROTECTED_LOW_OVERHEAD_OBJECT_ORIENTED_C_H__
@ -75,7 +74,8 @@ extern "C" {
#endif #endif
#endif #endif
/*============================ MACROFIED FUNCTIONS ===========================*/ /*============================ MACROFIED FUNCTIONS
* ===========================*/
/*! \note add which macro to support multiple inheriting and implementations /*! \note add which macro to support multiple inheriting and implementations
*! *!
@ -274,7 +274,8 @@ extern "C" {
#define this_interface(__INTERFACE) convert_obj_as(this, __INTERFACE) #define this_interface(__INTERFACE) convert_obj_as(this, __INTERFACE)
#define base_obj(__type) convert_obj_as(this, __type) #define base_obj(__type) convert_obj_as(this, __type)
/*============================ TYPES =========================================*/ /*============================ TYPES
* =========================================*/
//! \name interface: u32_property_t //! \name interface: u32_property_t
//! @{ //! @{
@ -340,9 +341,12 @@ bool (*Disable)(void);
end_def_interface(en_property_t) end_def_interface(en_property_t)
//! @} //! @}
/*============================ GLOBAL VARIABLES ==============================*/ /*============================ GLOBAL VARIABLES
/*============================ LOCAL VARIABLES ===============================*/ * ==============================*/
/*============================ PROTOTYPES ====================================*/ /*============================ LOCAL VARIABLES
* ===============================*/
/*============================ PROTOTYPES
* ====================================*/
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,22 +1,21 @@
/***************************************************************************** /*****************************************************************************
* Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> * * Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
* and SimonQian<simonqian@simonqian.com> * * and SimonQian<simonqian@simonqian.com> * with
* with support from HenryLong<henry_long@163.com> * *support from HenryLong<henry_long@163.com> *
* * * *
* Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License"); * you may
* you may not use this file except in compliance with the License. * *not use this file except in compliance with the License. * You may
* You may obtain a copy of the License at * *obtain a copy of the License at *
* * * *
* http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0 *
* * * *
* Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * ** See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* * * *
****************************************************************************/ ****************************************************************************/
#if defined(__cplusplus) || defined(__OOC_CPP__) #if defined(__cplusplus) || defined(__OOC_CPP__)
#undef __PLOOC_CLASS_USE_STRICT_TEMPLATE__ #undef __PLOOC_CLASS_USE_STRICT_TEMPLATE__
#undef PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___ #undef PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___

View File

@ -1,20 +1,19 @@
/**************************************************************************** /****************************************************************************
* Copyright 2017 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * * Copyright 2017 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
* * * *
* Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License"); * you may
* you may not use this file except in compliance with the License. * *not use this file except in compliance with the License. * You may
* You may obtain a copy of the License at * *obtain a copy of the License at *
* * * *
* http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0 *
* * * *
* Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * ** See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* * * *
****************************************************************************/ ****************************************************************************/
/*============================ INCLUDES ======================================*/ /*============================ INCLUDES ======================================*/
//#include <stdint.h> //#include <stdint.h>
//#include <stdbool.h> //#include <stdbool.h>
@ -38,7 +37,8 @@ extern "C" {
#undef __end_extern_class #undef __end_extern_class
#undef class #undef class
#undef __class #undef __class
/*============================ MACROFIED FUNCTIONS ===========================*/ /*============================ MACROFIED FUNCTIONS
* ===========================*/
#if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT) #if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
@ -183,7 +183,7 @@ extern "C" {
#endif #endif
/*----------------------------------------------------------------------------* /*----------------------------------------------------------------------------*
* new standard (lower case) * * new standard (lower case) *
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
#undef __class_internal #undef __class_internal
@ -211,11 +211,15 @@ extern "C" {
#undef which #undef which
#define which(...) PLOOC_VISIBLE(__VA_ARGS__) #define which(...) PLOOC_VISIBLE(__VA_ARGS__)
/*============================ TYPES =========================================*/ /*============================ TYPES
* =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/ /*============================ GLOBAL VARIABLES
/*============================ LOCAL VARIABLES ===============================*/ * ==============================*/
/*============================ PROTOTYPES ====================================*/ /*============================ LOCAL VARIABLES
* ===============================*/
/*============================ PROTOTYPES
* ====================================*/
#undef __PLOOC_CLASS_IMPLEMENT__ #undef __PLOOC_CLASS_IMPLEMENT__
#undef __PLOOC_CLASS_INHERIT__ #undef __PLOOC_CLASS_INHERIT__

View File

@ -1,22 +1,21 @@
/***************************************************************************** /*****************************************************************************
* Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> * * Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
* and SimonQian<simonqian@simonqian.com> * * and SimonQian<simonqian@simonqian.com> * with
* with support from HenryLong<henry_long@163.com> * *support from HenryLong<henry_long@163.com> *
* * * *
* Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License"); * you may
* you may not use this file except in compliance with the License. * *not use this file except in compliance with the License. * You may
* You may obtain a copy of the License at * *obtain a copy of the License at *
* * * *
* http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0 *
* * * *
* Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * ** See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* * * *
****************************************************************************/ ****************************************************************************/
/****************************************************************************** /******************************************************************************
* HOW TO USE * * HOW TO USE *
******************************************************************************/ ******************************************************************************/
@ -44,7 +43,8 @@ extern "C" {
#undef protected_member #undef protected_member
#undef public_member #undef public_member
/*============================ MACROFIED FUNCTIONS ===========================*/ /*============================ MACROFIED FUNCTIONS
* ===========================*/
#ifndef __PLOOC_CLASS_SIMPLE_H__ #ifndef __PLOOC_CLASS_SIMPLE_H__
#define __PLOOC_CLASS_SIMPLE_H__ #define __PLOOC_CLASS_SIMPLE_H__
@ -201,10 +201,14 @@ extern "C" {
#undef __PLOOC_CLASS_INHERIT__ #undef __PLOOC_CLASS_INHERIT__
#undef __PLOOC_CLASS_IMPLEMENT #undef __PLOOC_CLASS_IMPLEMENT
#undef __PLOOC_CLASS_INHERIT #undef __PLOOC_CLASS_INHERIT
/*============================ TYPES =========================================*/ /*============================ TYPES
/*============================ GLOBAL VARIABLES ==============================*/ * =========================================*/
/*============================ LOCAL VARIABLES ===============================*/ /*============================ GLOBAL VARIABLES
/*============================ PROTOTYPES ====================================*/ * ==============================*/
/*============================ LOCAL VARIABLES
* ===============================*/
/*============================ PROTOTYPES
* ====================================*/
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,22 +1,21 @@
/***************************************************************************** /*****************************************************************************
* Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> * * Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
* and SimonQian<simonqian@simonqian.com> * * and SimonQian<simonqian@simonqian.com> * with
* with support from HenryLong<henry_long@163.com> * *support from HenryLong<henry_long@163.com> *
* * * *
* Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License"); * you may
* you may not use this file except in compliance with the License. * *not use this file except in compliance with the License. * You may
* You may obtain a copy of the License at * *obtain a copy of the License at *
* * * *
* http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0 *
* * * *
* Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * ** See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* * * *
****************************************************************************/ ****************************************************************************/
/****************************************************************************** /******************************************************************************
* HOW TO USE * * HOW TO USE *
******************************************************************************/ ******************************************************************************/
@ -44,7 +43,8 @@ extern "C" {
#undef protected_member #undef protected_member
#undef public_member #undef public_member
/*============================ MACROFIED FUNCTIONS ===========================*/ /*============================ MACROFIED FUNCTIONS
* ===========================*/
#ifndef __PLOOC_CLASS_SIMPLE_C90_H__ #ifndef __PLOOC_CLASS_SIMPLE_C90_H__
#define __PLOOC_CLASS_SIMPLE_C90_H__ #define __PLOOC_CLASS_SIMPLE_C90_H__
@ -152,10 +152,14 @@ extern "C" {
#undef __PLOOC_CLASS_IMPLEMENT #undef __PLOOC_CLASS_IMPLEMENT
#undef __PLOOC_CLASS_INHERIT #undef __PLOOC_CLASS_INHERIT
/*============================ TYPES =========================================*/ /*============================ TYPES
/*============================ GLOBAL VARIABLES ==============================*/ * =========================================*/
/*============================ LOCAL VARIABLES ===============================*/ /*============================ GLOBAL VARIABLES
/*============================ PROTOTYPES ====================================*/ * ==============================*/
/*============================ LOCAL VARIABLES
* ===============================*/
/*============================ PROTOTYPES
* ====================================*/
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,20 +1,19 @@
/***************************************************************************** /*****************************************************************************
* Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> * * Copyright(C)2009-2019 by GorgonMeducer<embedded_zhuoran@hotmail.com> *
* * * *
* Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License"); * you may
* you may not use this file except in compliance with the License. * *not use this file except in compliance with the License. * You may
* You may obtain a copy of the License at * *obtain a copy of the License at *
* * * *
* http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0 *
* * * *
* Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * ** See the License for the specific language governing permissions and *
* limitations under the License. * * limitations under the License. *
* * * *
****************************************************************************/ ****************************************************************************/
//#ifndef __PLOOC_CLASS_STRICT_H__ /* deliberately comment this out! */ //#ifndef __PLOOC_CLASS_STRICT_H__ /* deliberately comment this out! */
//#define __PLOOC_CLASS_STRICT_H__ /* deliberately comment this out! */ //#define __PLOOC_CLASS_STRICT_H__ /* deliberately comment this out! */
@ -61,7 +60,8 @@ extern "C" {
#undef end_extern_class #undef end_extern_class
#undef __end_extern_class #undef __end_extern_class
/*============================ MACROFIED FUNCTIONS ===========================*/ /*============================ MACROFIED FUNCTIONS
* ===========================*/
#if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT) #if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
@ -446,10 +446,14 @@ extern "C" {
#undef __PLOOC_CLASS_INHERIT__ #undef __PLOOC_CLASS_INHERIT__
#undef __PLOOC_CLASS_IMPLEMENT #undef __PLOOC_CLASS_IMPLEMENT
#undef __PLOOC_CLASS_INHERIT #undef __PLOOC_CLASS_INHERIT
/*============================ TYPES =========================================*/ /*============================ TYPES
/*============================ GLOBAL VARIABLES ==============================*/ * =========================================*/
/*============================ LOCAL VARIABLES ===============================*/ /*============================ GLOBAL VARIABLES
/*============================ PROTOTYPES ====================================*/ * ==============================*/
/*============================ LOCAL VARIABLES
* ===============================*/
/*============================ PROTOTYPES
* ====================================*/
//#endif /* deliberately comment this out! */ //#endif /* deliberately comment this out! */

View File

@ -70,11 +70,11 @@ struct JDEC {
uint32_t wreg; /* Working shift register */ uint32_t wreg; /* Working shift register */
uint8_t marker; /* Detected marker (0:None) */ uint8_t marker; /* Detected marker (0:None) */
#if JD_FASTDECODE == 2 #if JD_FASTDECODE == 2
uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */ uint8_t longofs[2][2]; /* Table offset of long code [id][dcac] */
uint16_t* uint16_t* hufflut_ac[2]; /* Fast huffman decode tables for AC short code
hufflut_ac[2]; /* Fast huffman decode tables for AC short code [id] */ [id] */
uint8_t* uint8_t* hufflut_dc[2]; /* Fast huffman decode tables for DC short code
hufflut_dc[2]; /* Fast huffman decode tables for DC short code [id] */ [id] */
#endif #endif
#endif #endif
void* workbuf; /* Working buffer for IDCT and RGB output */ void* workbuf; /* Working buffer for IDCT and RGB output */

View File

@ -27,5 +27,6 @@ KB of code size. / 0: Disable / 1: Enable
/* Optimization level /* Optimization level
/ 0: Basic optimization. Suitable for 8/16-bit MCUs. / 0: Basic optimization. Suitable for 8/16-bit MCUs.
/ 1: + 32-bit barrel shifter. Suitable for 32-bit MCUs. / 1: + 32-bit barrel shifter. Suitable for 32-bit MCUs.
/ 2: + Table conversion for huffman decoding (wants 6 << HUFF_BIT bytes of RAM) / 2: + Table conversion for huffman decoding (wants 6 << HUFF_BIT bytes of
RAM)
*/ */

View File

@ -2,8 +2,8 @@
#include "PikaCV_Transforms.h" #include "PikaCV_Transforms.h"
#include "PikaCV_common.h" #include "PikaCV_common.h"
/* Session identifier for input/output functions (name, members and usage are as /* Session identifier for input/output functions (name, members and usage
user defined) */ are as user defined) */
typedef struct { typedef struct {
uint8_t* input_ptr; /* Pointer to input data */ uint8_t* input_ptr; /* Pointer to input data */
size_t input_offset; /* Offset of input data */ size_t input_offset; /* Offset of input data */
@ -339,7 +339,6 @@ void PikaCV_Converter_toBMP(PikaObj* self, PikaObj* image) {
int width = img->width; int width = img->width;
int height = img->height; int height = img->height;
// bmp的每行数据的长度要4字节对齐
row_align = align(width * 3, 4); row_align = align(width * 3, 4);
/* convert to BMP */ /* convert to BMP */

View File

@ -407,9 +407,7 @@ PikaObj* PikaCV_Image_split(PikaObj* self) {
PikaCV_Image___init__(img); PikaCV_Image___init__(img);
PikaCV_Image_loadGray(img, src->width, src->height, RGB[i]); PikaCV_Image_loadGray(img, src->width, src->height, RGB[i]);
Arg* token_arg = arg_newObj(img); Arg* token_arg = arg_newObj(img);
/* 添加到 list 对象 */
PikaStdData_List_append(list, token_arg); PikaStdData_List_append(list, token_arg);
/* 销毁 arg */
arg_deinit(token_arg); arg_deinit(token_arg);
} }

View File

@ -281,9 +281,9 @@ void PikaCV_Transforms_adaptiveThreshold(PikaObj* self,
memcpy(src_copy, src_data, size); memcpy(src_copy, src_data, size);
if (method == 0) { if (method == 0) {
PikaCV_Filter_meanFilter(self, image, subsize, subsize); //均值滤波 PikaCV_Filter_meanFilter(self, image, subsize, subsize);
} else if (method == 1) { } else if (method == 1) {
PikaCV_Filter_medianFilter(self, image); //中值滤波 PikaCV_Filter_medianFilter(self, image);
} else { } else {
free(src_copy); free(src_copy);
return; return;

View File

@ -3,7 +3,6 @@
#define PI (3.141592653589793115997963468544185161590576171875l) #define PI (3.141592653589793115997963468544185161590576171875l)
#define E (2.718281828459045090795598298427648842334747314453125l) #define E (2.718281828459045090795598298427648842334747314453125l)
//初始化填入π和e的值
void PikaMath_Math___init__(PikaObj* self) { void PikaMath_Math___init__(PikaObj* self) {
obj_setFloat(self, "pi", PI); obj_setFloat(self, "pi", PI);
obj_setFloat(self, "e", E); obj_setFloat(self, "e", E);

View File

@ -264,9 +264,7 @@ PikaObj* PikaMath_Quaternion_toEuler(PikaObj* self) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
Arg* token_arg = arg_newFloat(rpy[i]); Arg* token_arg = arg_newFloat(rpy[i]);
/* 添加到 list 对象 */
PikaStdData_List_append(list, token_arg); PikaStdData_List_append(list, token_arg);
/* 销毁 arg */
arg_deinit(token_arg); arg_deinit(token_arg);
} }

View File

@ -65,17 +65,16 @@ static pika_bool _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
byte <<= 1; byte <<= 1;
} }
// 在发送完字节后检查ACK信号
_GPIO_write(cfg->SCL, 0); _GPIO_write(cfg->SCL, 0);
_IIC_Delay(); _IIC_Delay();
_IIC_SDA_input(cfg); // 设置SDA为输入 _IIC_SDA_input(cfg);
_GPIO_write(cfg->SCL, 1); // 将SCL线设置为高让从设备发送ACK信号 _GPIO_write(cfg->SCL, 1);
int timeout = 1000; int timeout = 1000;
uint32_t ack = 0; uint32_t ack = 0;
do { do {
_IIC_Delay(); _IIC_Delay();
ack = !_GPIO_read(cfg->SDA); // 如果从设备发送了ACK信号SDA线会被拉低 ack = !_GPIO_read(cfg->SDA);
} while (ack == 0 && timeout-- > 0); } while (ack == 0 && timeout-- > 0);
// pika_debug("ack timeout:%d", timeout); // pika_debug("ack timeout:%d", timeout);
@ -83,28 +82,28 @@ static pika_bool _IIC_SendByte(pika_hal_SOFT_IIC_config* cfg, uint8_t byte) {
pika_platform_printf("Error: IIC write byte timeout\r\n"); pika_platform_printf("Error: IIC write byte timeout\r\n");
} }
_GPIO_write(cfg->SCL, 0); // 将SCL线设置为低完成一个I2C周期 _GPIO_write(cfg->SCL, 0);
return ack; return ack;
} }
static void _IIC_Ack(pika_hal_SOFT_IIC_config* cfg) { static void _IIC_Ack(pika_hal_SOFT_IIC_config* cfg) {
_GPIO_write(cfg->SCL, 0); // 拉低时钟线 _GPIO_write(cfg->SCL, 0);
_IIC_SDA_output(cfg); // 设置SDA为输出 _IIC_SDA_output(cfg);
_GPIO_write(cfg->SDA, 0); // 拉低数据线 _GPIO_write(cfg->SDA, 0);
_IIC_Delay(); _IIC_Delay();
_GPIO_write(cfg->SCL, 1); // 产生时钟 _GPIO_write(cfg->SCL, 1);
_IIC_Delay(); _IIC_Delay();
_GPIO_write(cfg->SCL, 0); // 拉低时钟线 _GPIO_write(cfg->SCL, 0);
} }
static void _IIC_NAck(pika_hal_SOFT_IIC_config* cfg) { static void _IIC_NAck(pika_hal_SOFT_IIC_config* cfg) {
_GPIO_write(cfg->SCL, 0); // 拉低时钟线 _GPIO_write(cfg->SCL, 0);
_IIC_SDA_output(cfg); // 设置SDA为输出 _IIC_SDA_output(cfg);
_GPIO_write(cfg->SDA, 1); // 数据线拉高 _GPIO_write(cfg->SDA, 1);
_IIC_Delay(); _IIC_Delay();
_GPIO_write(cfg->SCL, 1); // 产生时钟 _GPIO_write(cfg->SCL, 1);
_IIC_Delay(); _IIC_Delay();
_GPIO_write(cfg->SCL, 0); // 拉低时钟线 _GPIO_write(cfg->SCL, 0);
} }
static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) { static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
@ -120,11 +119,10 @@ static uint8_t _IIC_ReadByte(pika_hal_SOFT_IIC_config* cfg, uint8_t ack) {
_GPIO_write(cfg->SCL, 0); _GPIO_write(cfg->SCL, 0);
_IIC_Delay(); _IIC_Delay();
} }
// 在读取完一个字节后发送ACK信号
if (ack) { if (ack) {
_IIC_Ack(cfg); // 如果ack为真发送ACK信号 _IIC_Ack(cfg);
} else { } else {
_IIC_NAck(cfg); // 如果ack为假发送NACK信号 _IIC_NAck(cfg);
} }
pika_debug(" - iic read: 0x%02X", byte); pika_debug(" - iic read: 0x%02X", byte);
return byte; return byte;
@ -136,11 +134,10 @@ int pika_hal_platform_SOFT_IIC_write(pika_dev* dev, void* buf, size_t count) {
uint8_t* data = (uint8_t*)buf; uint8_t* data = (uint8_t*)buf;
_IIC_Start(iic_cfg); _IIC_Start(iic_cfg);
uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00; // 方向位为0代表写 uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00;
// pika_debug("iic addr_write: 0x%02X", addr_write); // pika_debug("iic addr_write: 0x%02X", addr_write);
_IIC_SendByte(iic_cfg, addr_write); // 方向位为0代表写 _IIC_SendByte(iic_cfg, addr_write);
// 如果启用了mem_addr_ena将设备地址和内存地址发送到I2C总线
if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) { if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) { if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF); _IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
@ -164,12 +161,10 @@ int pika_hal_platform_SOFT_IIC_read(pika_dev* dev, void* buf, size_t count) {
_IIC_Start(iic_cfg); _IIC_Start(iic_cfg);
// 如果启用了mem_addr_ena先写设备地址和内存地址
if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) { if (iic_cfg->mem_addr_ena == PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE) {
uint8_t addr_write = uint8_t addr_write = (iic_cfg->slave_addr << 1) | 0x00;
(iic_cfg->slave_addr << 1) | 0x00; // 方向位为0代表写
// pika_debug("iic addr_write: 0x%02X", addr_write); // pika_debug("iic addr_write: 0x%02X", addr_write);
_IIC_SendByte(iic_cfg, addr_write); // 方向位为0代表写 _IIC_SendByte(iic_cfg, addr_write);
if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) { if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_8BIT) {
_IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF); _IIC_SendByte(iic_cfg, iic_cfg->mem_addr & 0xFF);
} else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) { } else if (iic_cfg->mem_addr_size == PIKA_HAL_IIC_MEM_ADDR_SIZE_16BIT) {
@ -179,9 +174,9 @@ int pika_hal_platform_SOFT_IIC_read(pika_dev* dev, void* buf, size_t count) {
_IIC_Start(iic_cfg); _IIC_Start(iic_cfg);
} }
uint8_t addr_read = (iic_cfg->slave_addr << 1) | 0x01; // 方向位为1代表读 uint8_t addr_read = (iic_cfg->slave_addr << 1) | 0x01;
// pika_debug("iic addr_read: 0x%02X", addr_read); // pika_debug("iic addr_read: 0x%02X", addr_read);
_IIC_SendByte(iic_cfg, addr_read); // 方向位为1代表读 _IIC_SendByte(iic_cfg, addr_read);
for (int i = 0; i < count - 1; i++) { for (int i = 0; i < count - 1; i++) {
// data[i] = _IIC_ReadByte(iic_cfg, 1); // data[i] = _IIC_ReadByte(iic_cfg, 1);
@ -215,7 +210,6 @@ int pika_hal_platform_SOFT_IIC_ioctl_config(pika_dev* dev,
"Error: SOFT IIC config error, SDA and SCL must be set\r\n"); "Error: SOFT IIC config error, SDA and SCL must be set\r\n");
return -1; return -1;
} }
// 检查软件IIC配置项是否正确
if (cfg->master_or_slave != PIKA_HAL_IIC_MASTER && if (cfg->master_or_slave != PIKA_HAL_IIC_MASTER &&
cfg->master_or_slave != PIKA_HAL_IIC_SLAVE) { cfg->master_or_slave != PIKA_HAL_IIC_SLAVE) {
__platform_printf( __platform_printf(
@ -240,7 +234,6 @@ int pika_hal_platform_SOFT_IIC_ioctl_config(pika_dev* dev,
"Error: SOFT IIC config error, mem_addr_size must be set\r\n"); "Error: SOFT IIC config error, mem_addr_size must be set\r\n");
return -1; return -1;
} }
// 在这里我们暂时不检查speed和timeout因为软件模拟的I2C可能无法精确控制速度和超时。
return 0; return 0;
} }

View File

@ -136,14 +136,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
void* context) { void* context) {
DictToStrContext* ctx = (DictToStrContext*)context; DictToStrContext* ctx = (DictToStrContext*)context;
// 判断是否需要在字符串前添加逗号
if (!ctx->isFirst) { if (!ctx->isFirst) {
ctx->buf = arg_strAppend(ctx->buf, ", "); ctx->buf = arg_strAppend(ctx->buf, ", ");
} else { } else {
ctx->isFirst = 0; ctx->isFirst = 0;
} }
// 将键值对添加到字符串
ctx->buf = arg_strAppend(ctx->buf, "'"); ctx->buf = arg_strAppend(ctx->buf, "'");
ctx->buf = arg_strAppend(ctx->buf, builtins_str(self, keyEach)); ctx->buf = arg_strAppend(ctx->buf, builtins_str(self, keyEach));
ctx->buf = arg_strAppend(ctx->buf, "'"); ctx->buf = arg_strAppend(ctx->buf, "'");
@ -160,15 +158,12 @@ int32_t dictToStrEachHandle(PikaObj* self,
} }
char* PikaStdData_Dict___str__(PikaObj* self) { char* PikaStdData_Dict___str__(PikaObj* self) {
// 初始化上下文
DictToStrContext context; DictToStrContext context;
context.buf = arg_newStr("{"); context.buf = arg_newStr("{");
context.isFirst = 1; context.isFirst = 1;
// 使用 objDict_forEach 遍历字典
objDict_forEach(self, dictToStrEachHandle, &context); objDict_forEach(self, dictToStrEachHandle, &context);
// 将字符串添加到结果中并返回
context.buf = arg_strAppend(context.buf, "}"); context.buf = arg_strAppend(context.buf, "}");
obj_setStr(self, "_buf", arg_getStr(context.buf)); obj_setStr(self, "_buf", arg_getStr(context.buf));
arg_deinit(context.buf); arg_deinit(context.buf);

View File

@ -241,9 +241,7 @@ PikaObj* PikaStdData_String_split(PikaObj* self, PikaTuple* s_) {
} else { } else {
s = pikaTuple_getStr(s_, 0); s = pikaTuple_getStr(s_, 0);
} }
/* 创建 list 对象 */
PikaObj* list = newNormalObj(New_PikaStdData_List); PikaObj* list = newNormalObj(New_PikaStdData_List);
/* 初始化 list */
PikaStdData_List___init__(list); PikaStdData_List___init__(list);
Args buffs = {0}; Args buffs = {0};

View File

@ -1,5 +1,4 @@
#include "_base64.h" #include "_base64.h"
#include "mbedtls/base64.h" #include "mbedtls/base64.h"
Arg* _base64_b64decode(PikaObj* self, Arg* s) { Arg* _base64_b64decode(PikaObj* self, Arg* s) {

View File

@ -19,7 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* cJSON */ /* cJSON */
/* JSON parser in C. */ /* JSON parser in C. */

View File

@ -19,7 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
#ifndef pika_cJSON__h #ifndef pika_cJSON__h
#define pika_cJSON__h #define pika_cJSON__h
@ -34,14 +33,14 @@ extern "C" {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid /* When compiling for windows, we specify a specific calling convention to
issues where we are being called from a project with a different default calling avoid issues where we are being called from a project with a different
convention. For windows you have 3 define options: default calling convention. For windows you have 3 define options:
pika_cJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever pika_cJSON_HIDE_SYMBOLS - Define this in the case where you don't want to
dllexport symbols pika_cJSON_EXPORT_SYMBOLS - Define this on library build when ever dllexport symbols pika_cJSON_EXPORT_SYMBOLS - Define this on library
you want to dllexport symbols (default) pika_cJSON_IMPORT_SYMBOLS - Define this build when you want to dllexport symbols (default) pika_cJSON_IMPORT_SYMBOLS
if you want to dllimport symbol - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar For *nix builds that support visibility attribute, you can define similar
behavior by behavior by
@ -52,8 +51,8 @@ or
-xldscope=hidden (for sun cc) -xldscope=hidden (for sun cc)
to CFLAGS to CFLAGS
then using the pika_cJSON_API_VISIBILITY flag to "export" the same symbols the then using the pika_cJSON_API_VISIBILITY flag to "export" the same symbols
way pika_cJSON_EXPORT_SYMBOLS does the way pika_cJSON_EXPORT_SYMBOLS does
*/ */
@ -113,24 +112,26 @@ typedef struct cJSON {
* GetArraySize/GetArrayItem/GetObjectItem */ * GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON* next; struct cJSON* next;
struct cJSON* prev; struct cJSON* prev;
/* An array or object item will have a child pointer pointing to a chain of /* An array or object item will have a child pointer pointing to a chain
* the items in the array/object. */ * of the items in the array/object. */
struct cJSON* child; struct cJSON* child;
/* The type of the item, as above. */ /* The type of the item, as above. */
int type; int type;
/* The item's string, if type==pika_cJSON_String and type == pika_cJSON_Raw /* The item's string, if type==pika_cJSON_String and type ==
* pika_cJSON_Raw
*/ */
char* valuestring; char* valuestring;
/* writing to valueint is DEPRECATED, use pika_cJSON_SetNumberValue instead /* writing to valueint is DEPRECATED, use pika_cJSON_SetNumberValue
* instead
*/ */
int valueint; int valueint;
/* The item's number, if type==pika_cJSON_Number */ /* The item's number, if type==pika_cJSON_Number */
double valuedouble; double valuedouble;
/* The item's name string, if this item is the child of, or is in the list /* The item's name string, if this item is the child of, or is in the
* of subitems of an object. */ * list of subitems of an object. */
char* string; char* string;
} cJSON; } cJSON;
@ -156,13 +157,14 @@ pika_cJSON_PUBLIC(const char*) pika_cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */ /* Supply malloc, realloc and free functions to cJSON */
pika_cJSON_PUBLIC(void) pika_cJSON_InitHooks(pika_cJSON_Hooks* hooks); pika_cJSON_PUBLIC(void) pika_cJSON_InitHooks(pika_cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from /* Memory Management: the caller is always responsible to free the results
* all variants of pika_cJSON_Parse (with pika_cJSON_Delete) and * from all variants of pika_cJSON_Parse (with pika_cJSON_Delete) and
* pika_cJSON_Print (with stdlib free, pika_cJSON_Hooks.free_fn, or * pika_cJSON_Print (with stdlib free, pika_cJSON_Hooks.free_fn, or
* pika_cJSON_free as appropriate). The exception is * pika_cJSON_free as appropriate). The exception is
* pika_cJSON_PrintPreallocated, where the caller has full responsibility of the * pika_cJSON_PrintPreallocated, where the caller has full responsibility of
* buffer. */ * the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. /* Supply a block of JSON, and this returns a cJSON object you can
* interrogate.
*/ */
pika_cJSON_PUBLIC(cJSON*) pika_cJSON_Parse(const char* value); pika_cJSON_PUBLIC(cJSON*) pika_cJSON_Parse(const char* value);
pika_cJSON_PUBLIC(cJSON*) pika_cJSON_PUBLIC(cJSON*)
@ -184,18 +186,19 @@ pika_cJSON_PUBLIC(cJSON*)
/* Render a cJSON entity to text for transfer/storage. */ /* Render a cJSON entity to text for transfer/storage. */
pika_cJSON_PUBLIC(char*) pika_cJSON_Print(const cJSON* item); pika_cJSON_PUBLIC(char*) pika_cJSON_Print(const cJSON* item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */ /* Render a cJSON entity to text for transfer/storage without any
* formatting. */
pika_cJSON_PUBLIC(char*) pika_cJSON_PrintUnformatted(const cJSON* item); pika_cJSON_PUBLIC(char*) pika_cJSON_PrintUnformatted(const cJSON* item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess /* Render a cJSON entity to text using a buffered strategy. prebuffer is a
* at the final size. guessing well reduces reallocation. fmt=0 gives * guess at the final size. guessing well reduces reallocation. fmt=0 gives
* unformatted, =1 gives formatted */ * unformatted, =1 gives formatted */
pika_cJSON_PUBLIC(char*) pika_cJSON_PrintBuffered(const cJSON* item, pika_cJSON_PUBLIC(char*) pika_cJSON_PrintBuffered(const cJSON* item,
int prebuffer, int prebuffer,
pika_cJSON_bool fmt); pika_cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with /* Render a cJSON entity to text using a buffer already allocated in memory
* given length. Returns 1 on success and 0 on failure. */ * with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will /* NOTE: cJSON is not always 100% accurate in estimating how much memory it
* use, so to be safe allocate 5 bytes more than you actually need */ * will use, so to be safe allocate 5 bytes more than you actually need */
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_PrintPreallocated(cJSON* item, pika_cJSON_PrintPreallocated(cJSON* item,
char* buffer, char* buffer,
@ -219,8 +222,9 @@ pika_cJSON_PUBLIC(cJSON*)
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_HasObjectItem(const cJSON* object, const char* string); pika_cJSON_HasObjectItem(const cJSON* object, const char* string);
/* For analysing failed parses. This returns a pointer to the parse error. /* For analysing failed parses. This returns a pointer to the parse error.
* You'll probably need to look a few chars back to make sense of it. Defined * You'll probably need to look a few chars back to make sense of it.
* when pika_cJSON_Parse() returns 0. 0 when pika_cJSON_Parse() succeeds. */ * Defined when pika_cJSON_Parse() returns 0. 0 when pika_cJSON_Parse()
* succeeds. */
pika_cJSON_PUBLIC(const char*) pika_cJSON_GetErrorPtr(void); pika_cJSON_PUBLIC(const char*) pika_cJSON_GetErrorPtr(void);
/* Check item type and return its value */ /* Check item type and return its value */
@ -277,17 +281,17 @@ pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_AddItemToArray(cJSON* array, cJSON* item); pika_cJSON_AddItemToArray(cJSON* array, cJSON* item);
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item); pika_cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and /* Use this when string is definitely const (i.e. a literal, or as good as),
* will definitely survive the cJSON object. WARNING: When this function was * and will definitely survive the cJSON object. WARNING: When this function
* used, make sure to always check that (item->type & pika_cJSON_StringIsConst) * was used, make sure to always check that (item->type &
* is zero before writing to `item->string` */ * pika_cJSON_StringIsConst) is zero before writing to `item->string` */
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_AddItemToObjectCS(cJSON* object, pika_cJSON_AddItemToObjectCS(cJSON* object,
const char* string, const char* string,
cJSON* item); cJSON* item);
/* Append reference to item to the specified array/object. Use this when you /* Append reference to item to the specified array/object. Use this when you
* want to add an existing cJSON to a new cJSON, but don't want to corrupt your * want to add an existing cJSON to a new cJSON, but don't want to corrupt
* existing cJSON. */ * your existing cJSON. */
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item); pika_cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
@ -335,26 +339,27 @@ pika_cJSON_PUBLIC(pika_cJSON_bool)
/* Duplicate a cJSON item */ /* Duplicate a cJSON item */
pika_cJSON_PUBLIC(cJSON*) pika_cJSON_PUBLIC(cJSON*)
pika_cJSON_Duplicate(const cJSON* item, pika_cJSON_bool recurse); pika_cJSON_Duplicate(const cJSON* item, pika_cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new /* Duplicate will create a new, identical cJSON item to the one you pass, in
* memory that will need to be released. With recurse!=0, it will duplicate any * new memory that will need to be released. With recurse!=0, it will
* children connected to the item. The item->next and ->prev pointers are always * duplicate any children connected to the item. The item->next and ->prev
* zero on return from Duplicate. */ * pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or /* Recursively compare two cJSON items for equality. If either a or b is
* invalid, they will be considered unequal. case_sensitive determines if object * NULL or invalid, they will be considered unequal. case_sensitive
* keys are treated case sensitive (1) or case insensitive (0) */ * determines if object keys are treated case sensitive (1) or case
* insensitive (0) */
pika_cJSON_PUBLIC(pika_cJSON_bool) pika_cJSON_PUBLIC(pika_cJSON_bool)
pika_cJSON_Compare(const cJSON* const a, pika_cJSON_Compare(const cJSON* const a,
const cJSON* const b, const cJSON* const b,
const pika_cJSON_bool case_sensitive); const pika_cJSON_bool case_sensitive);
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n')
* strings. The input pointer json cannot point to a read-only address area, * from strings. The input pointer json cannot point to a read-only address
* such as a string constant, but should point to a readable and writable * area, such as a string constant, but should point to a readable and
* address area. */ * writable address area. */
pika_cJSON_PUBLIC(void) pika_cJSON_Minify(char* json); pika_cJSON_PUBLIC(void) pika_cJSON_Minify(char* json);
/* Helper functions for creating and adding items to an object at the same time. /* Helper functions for creating and adding items to an object at the same
* They return the added item or NULL on failure. */ * time. They return the added item or NULL on failure. */
pika_cJSON_PUBLIC(cJSON*) pika_cJSON_PUBLIC(cJSON*)
pika_cJSON_AddNullToObject(cJSON* const object, const char* const name); pika_cJSON_AddNullToObject(cJSON* const object, const char* const name);
pika_cJSON_PUBLIC(cJSON*) pika_cJSON_PUBLIC(cJSON*)
@ -391,8 +396,8 @@ pika_cJSON_PUBLIC(double)
#define pika_cJSON_SetNumberValue(object, number) \ #define pika_cJSON_SetNumberValue(object, number) \
((object != NULL) ? pika_cJSON_SetNumberHelper(object, (double)number) \ ((object != NULL) ? pika_cJSON_SetNumberHelper(object, (double)number) \
: (number)) : (number))
/* Change the valuestring of a pika_cJSON_String object, only takes effect when /* Change the valuestring of a pika_cJSON_String object, only takes effect
* type of object is pika_cJSON_String */ * when type of object is pika_cJSON_String */
pika_cJSON_PUBLIC(char*) pika_cJSON_PUBLIC(char*)
pika_cJSON_SetValuestring(cJSON* object, const char* valuestring); pika_cJSON_SetValuestring(cJSON* object, const char* valuestring);
@ -401,8 +406,8 @@ pika_cJSON_PUBLIC(char*)
for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \ for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \
element = element->next) element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with /* malloc/free objects using the malloc/free functions that have been set
* pika_cJSON_InitHooks */ * with pika_cJSON_InitHooks */
pika_cJSON_PUBLIC(void*) pika_cJSON_malloc(size_t size); pika_cJSON_PUBLIC(void*) pika_cJSON_malloc(size_t size);
pika_cJSON_PUBLIC(void) pika_cJSON_free(void* object); pika_cJSON_PUBLIC(void) pika_cJSON_free(void* object);

View File

@ -3,23 +3,23 @@
* *
* Copyright (c) 2010 Serge Zaitsev * Copyright (c) 2010 Serge Zaitsev
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef JSMN_H #ifndef JSMN_H
#define JSMN_H #define JSMN_H
@ -94,9 +94,8 @@ typedef struct jsmn_parser {
JSMN_API void jsmn_init(jsmn_parser* parser); JSMN_API void jsmn_init(jsmn_parser* parser);
/** /**
* Run JSON parser. It parses a JSON data string into and array of tokens, each * Run JSON parser. It parses a JSON data string into and array of tokens,
* describing * each describing a single JSON object.
* a single JSON object.
*/ */
JSMN_API int jsmn_parse(jsmn_parser* parser, JSMN_API int jsmn_parse(jsmn_parser* parser,
const char* js, const char* js,
@ -153,7 +152,8 @@ static int jsmn_parse_primitive(jsmn_parser* parser,
for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
switch (js[parser->pos]) { switch (js[parser->pos]) {
#ifndef JSMN_STRICT #ifndef JSMN_STRICT
/* In strict mode primitive must be followed by "," or "}" or "]" */ /* In strict mode primitive must be followed by "," or "}" or
* "]" */
case ':': case ':':
#endif #endif
case '\t': case '\t':
@ -310,7 +310,8 @@ JSMN_API int jsmn_parse(jsmn_parser* parser,
if (parser->toksuper != -1) { if (parser->toksuper != -1) {
jsmntok_t* t = &tokens[parser->toksuper]; jsmntok_t* t = &tokens[parser->toksuper];
#ifdef JSMN_STRICT #ifdef JSMN_STRICT
/* In strict mode an object or array can't become a key */ /* In strict mode an object or array can't become a key
*/
if (t->type == JSMN_OBJECT) { if (t->type == JSMN_OBJECT) {
return JSMN_ERROR_INVAL; return JSMN_ERROR_INVAL;
} }

View File

@ -3,7 +3,6 @@
#define PI (3.141592653589793115997963468544185161590576171875l) #define PI (3.141592653589793115997963468544185161590576171875l)
#define E (2.718281828459045090795598298427648842334747314453125l) #define E (2.718281828459045090795598298427648842334747314453125l)
//初始化填入π和e的值
void _math___init__(PikaObj* self) { void _math___init__(PikaObj* self) {
obj_setFloat(self, "pi", PI); obj_setFloat(self, "pi", PI);
obj_setFloat(self, "e", E); obj_setFloat(self, "e", E);

View File

@ -38,7 +38,6 @@
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
*/ */
#include "agile_modbus.h" #include "agile_modbus.h"
#include <string.h> #include <string.h>

View File

@ -10,7 +10,6 @@
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
*/ */
#ifndef __PKG_AGILE_MODBUS_H #ifndef __PKG_AGILE_MODBUS_H
#define __PKG_AGILE_MODBUS_H #define __PKG_AGILE_MODBUS_H

View File

@ -10,7 +10,6 @@
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
*/ */
#ifndef __PKG_AGILE_MODBUS_RTU_H #ifndef __PKG_AGILE_MODBUS_RTU_H
#define __PKG_AGILE_MODBUS_RTU_H #define __PKG_AGILE_MODBUS_RTU_H

View File

@ -10,7 +10,6 @@
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
*/ */
#include "agile_modbus.h" #include "agile_modbus.h"
#include "agile_modbus_tcp.h" #include "agile_modbus_tcp.h"

View File

@ -10,7 +10,6 @@
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
*/ */
#ifndef __PKG_AGILE_MODBUS_TCP_H #ifndef __PKG_AGILE_MODBUS_TCP_H
#define __PKG_AGILE_MODBUS_TCP_H #define __PKG_AGILE_MODBUS_TCP_H

View File

@ -11,10 +11,10 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Ian Craggs - add connack return code definitions *documentation Ian Craggs - add connack return code definitions Xiang Rong -
* Xiang Rong - 442039 Add makefile to Embedded C client *442039 Add makefile to Embedded C client Ian Craggs - fix for issue #64,
* Ian Craggs - fix for issue #64, bit order in connack response *bit order in connack response
*******************************************************************************/ *******************************************************************************/
#ifndef MQTTCONNECT_H_ #ifndef MQTTCONNECT_H_

View File

@ -11,20 +11,20 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"
#include <string.h> #include <string.h>
/** /**
* Determines the length of the MQTT connect packet that would be produced using * Determines the length of the MQTT connect packet that would be produced
* the supplied connect options. * using the supplied connect options.
* @param options the options to be used to build the connect packet * @param options the options to be used to build the connect packet
* @return the length of buffer needed to contain the serialized version of the * @return the length of buffer needed to contain the serialized version of
* packet * the packet
*/ */
int MQTTSerialize_connectLength(MQTTPacket_connectData* options) { int MQTTSerialize_connectLength(MQTTPacket_connectData* options) {
int len = 0; int len = 0;

View File

@ -11,9 +11,9 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include <string.h> #include <string.h>
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"

View File

@ -11,9 +11,9 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include <string.h> #include <string.h>
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"

View File

@ -11,7 +11,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"

View File

@ -11,7 +11,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#if !defined(MQTTFORMAT_H) #if !defined(MQTTFORMAT_H)

View File

@ -11,11 +11,10 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Sergio R. Caprile - non-blocking packet read functions for stream *documentation Sergio R. Caprile - non-blocking packet read functions for
*transport *stream transport
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"

View File

@ -11,10 +11,9 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Xiang Rong - 442039 Add makefile to Embedded C client *documentation Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/ *******************************************************************************/
#ifndef MQTTPACKET_H_ #ifndef MQTTPACKET_H_
#define MQTTPACKET_H_ #define MQTTPACKET_H_

View File

@ -11,8 +11,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Xiang Rong - 442039 Add makefile to Embedded C client *documentation Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/ *******************************************************************************/
#ifndef MQTTPUBLISH_H_ #ifndef MQTTPUBLISH_H_

View File

@ -11,23 +11,23 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Ian Craggs - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144 *documentation Ian Craggs - fix for
*https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"
#include <string.h> #include <string.h>
/** /**
* Determines the length of the MQTT publish packet that would be produced using * Determines the length of the MQTT publish packet that would be produced
* the supplied parameters * using the supplied parameters
* @param qos the MQTT QoS of the publish (packetid is omitted for QoS 0) * @param qos the MQTT QoS of the publish (packetid is omitted for QoS 0)
* @param topicName the topic name to be used in the publish * @param topicName the topic name to be used in the publish
* @param payloadlen the length of the payload to be sent * @param payloadlen the length of the payload to be sent
* @return the length of buffer needed to contain the serialized version of the * @return the length of buffer needed to contain the serialized version of
* packet * the packet
*/ */
int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen) { int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen) {
int len = 0; int len = 0;

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-09 20:15:32 * @Date: 2019-12-09 20:15:32
* @LastEditTime: 2019-12-20 20:37:31 * @LastEditTime: 2019-12-20 20:37:31
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2014 IBM Corp. * Copyright (c) 2014 IBM Corp.

View File

@ -11,9 +11,9 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"
@ -25,8 +25,8 @@
* @param count the number of topic filter strings in topicFilters * @param count the number of topic filter strings in topicFilters
* @param topicFilters the array of topic filter strings to be used in the * @param topicFilters the array of topic filter strings to be used in the
* publish * publish
* @return the length of buffer needed to contain the serialized version of the * @return the length of buffer needed to contain the serialized version of
* packet * the packet
*/ */
int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[]) { int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[]) {
int i; int i;

View File

@ -11,9 +11,9 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"
@ -23,9 +23,10 @@
* Deserializes the supplied (wire) buffer into subscribe data * Deserializes the supplied (wire) buffer into subscribe data
* @param dup integer returned - the MQTT dup flag * @param dup integer returned - the MQTT dup flag
* @param packetid integer returned - the MQTT packet identifier * @param packetid integer returned - the MQTT packet identifier
* @param maxcount - the maximum number of members allowed in the topicFilters * @param maxcount - the maximum number of members allowed in the
* and requestedQoSs arrays * topicFilters and requestedQoSs arrays
* @param count - number of members in the topicFilters and requestedQoSs arrays * @param count - number of members in the topicFilters and requestedQoSs
* arrays
* @param topicFilters - array of topic filter names * @param topicFilters - array of topic filter names
* @param requestedQoSs - array of requested QoS * @param requestedQoSs - array of requested QoS
* @param buf the raw buffer data, of the correct length determined by the * @param buf the raw buffer data, of the correct length determined by the

View File

@ -11,8 +11,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Xiang Rong - 442039 Add makefile to Embedded C client *documentation Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/ *******************************************************************************/
#ifndef MQTTUNSUBSCRIBE_H_ #ifndef MQTTUNSUBSCRIBE_H_

View File

@ -11,22 +11,22 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"
#include <string.h> #include <string.h>
/** /**
* Determines the length of the MQTT unsubscribe packet that would be produced * Determines the length of the MQTT unsubscribe packet that would be
* using the supplied parameters * produced using the supplied parameters
* @param count the number of topic filter strings in topicFilters * @param count the number of topic filter strings in topicFilters
* @param topicFilters the array of topic filter strings to be used in the * @param topicFilters the array of topic filter strings to be used in the
* publish * publish
* @return the length of buffer needed to contain the serialized version of the * @return the length of buffer needed to contain the serialized version of
* packet * the packet
*/ */
int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[]) { int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[]) {
int i; int i;

View File

@ -11,9 +11,9 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
*documentation
*******************************************************************************/ *******************************************************************************/
#include "MQTTPacket.h" #include "MQTTPacket.h"
#include "StackTrace.h" #include "StackTrace.h"
@ -23,9 +23,10 @@
* Deserializes the supplied (wire) buffer into unsubscribe data * Deserializes the supplied (wire) buffer into unsubscribe data
* @param dup integer returned - the MQTT dup flag * @param dup integer returned - the MQTT dup flag
* @param packetid integer returned - the MQTT packet identifier * @param packetid integer returned - the MQTT packet identifier
* @param maxcount - the maximum number of members allowed in the topicFilters * @param maxcount - the maximum number of members allowed in the
* and requestedQoSs arrays * topicFilters and requestedQoSs arrays
* @param count - number of members in the topicFilters and requestedQoSs arrays * @param count - number of members in the topicFilters and requestedQoSs
* arrays
* @param topicFilters - array of topic filter names * @param topicFilters - array of topic filter names
* @param buf the raw buffer data, of the correct length determined by the * @param buf the raw buffer data, of the correct length determined by the
* remaining length field * remaining length field

View File

@ -11,8 +11,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php. * http://www.eclipse.org/org/documents/edl-v10.php.
* *
* Contributors: * Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - initial API and implementation and/or initial
* Ian Craggs - fix for bug #434081 *documentation Ian Craggs - fix for bug #434081
*******************************************************************************/ *******************************************************************************/
#ifndef STACKTRACE_H_ #ifndef STACKTRACE_H_

View File

@ -14,12 +14,6 @@ void Subscribe_Handler(void* client, message_data_t* msg);
const uint32_t MQTT_RECONNECTION_EVENT_ID = 0xFFAA0088; const uint32_t MQTT_RECONNECTION_EVENT_ID = 0xFFAA0088;
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT___init__
// 功能说明:对象初始化
// 输入参数:
// 返 回 值:无
///////////////////////////////////////////////////////////////////
void _mqtt__MQTT___init__(PikaObj* self, void _mqtt__MQTT___init__(PikaObj* self,
char* ip, char* ip,
int port, int port,
@ -92,17 +86,10 @@ void _mqtt__MQTT___init__(PikaObj* self,
mqtt_set_clean_session(_client, 1); mqtt_set_clean_session(_client, 1);
obj_setPtr(self, "_client", obj_setPtr(self, "_client", _client);
_client); // 这里要再保存一次mqtt结构体的内容到python环境
// __platform_printf("Mqtt_Lib buildtime:%s-%s\r\n", __DATE__, __TIME__); // __platform_printf("Mqtt_Lib buildtime:%s-%s\r\n", __DATE__, __TIME__);
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT___del__
// 功能说明:释放对象资源
// 输入参数:
// 返 回 值:无
///////////////////////////////////////////////////////////////////
void _mqtt__MQTT___del__(PikaObj* self) { void _mqtt__MQTT___del__(PikaObj* self) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
if (NULL == _client) { if (NULL == _client) {
@ -117,12 +104,6 @@ void _mqtt__MQTT___del__(PikaObj* self) {
mqtt_release_free(_client); mqtt_release_free(_client);
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_connect
// 功能说明连接mqtt的服务端
// 输入参数:无
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_connect(PikaObj* self) { int _mqtt__MQTT_connect(PikaObj* self) {
int ret; int ret;
obj_setInt(self, "_connected", 1); obj_setInt(self, "_connected", 1);
@ -137,12 +118,6 @@ int _mqtt__MQTT_connect(PikaObj* self) {
return ret; return ret;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_disconnect
// 功能说明:断开 mqtt的连接
// 输入参数:无
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_disconnect(PikaObj* self) { int _mqtt__MQTT_disconnect(PikaObj* self) {
int ret; int ret;
obj_setInt(self, "_connected", 0); obj_setInt(self, "_connected", 0);
@ -157,12 +132,6 @@ int _mqtt__MQTT_disconnect(PikaObj* self) {
return ret; return ret;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_listSubscribeTopic
// 功能说明:罗列出当前订阅的主题
// 输入参数:无
// 返 回 值:对象指针
///////////////////////////////////////////////////////////////////
PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) { PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
// int i = 0; // int i = 0;
@ -180,9 +149,7 @@ PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
return NULL; return NULL;
} }
/* 创建 list 对象 */
list = newNormalObj(New_PikaStdData_List); list = newNormalObj(New_PikaStdData_List);
/* 初始化 list */
PikaStdData_List___init__(list); PikaStdData_List___init__(list);
LIST_FOR_EACH_SAFE(curr, next, &_client->mqtt_msg_handler_list) { LIST_FOR_EACH_SAFE(curr, next, &_client->mqtt_msg_handler_list) {
@ -194,9 +161,7 @@ PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
__LINE__, __FUNCTION__, ++i, msg_handler->topic_filter); __LINE__, __FUNCTION__, ++i, msg_handler->topic_filter);
// __platform_printf("[%d]subscribe topic: %s\n",++i, // __platform_printf("[%d]subscribe topic: %s\n",++i,
// msg_handler->topic_filter); // msg_handler->topic_filter);
/* 用 arg_new<type> 的 api 创建 arg */
Arg* str_arg1 = arg_newStr((char*)msg_handler->topic_filter); Arg* str_arg1 = arg_newStr((char*)msg_handler->topic_filter);
/* 添加到 list 对象 */
PikaStdData_List_append(list, str_arg1); PikaStdData_List_append(list, str_arg1);
arg_deinit(str_arg1); arg_deinit(str_arg1);
} }
@ -204,12 +169,6 @@ PikaObj* _mqtt__MQTT_listSubscribeTopic(PikaObj* self) {
return list; return list;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_publish
// 功能说明:发布主题消息
// 输入参数:主题名称,有效数据
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) { int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) {
int ret; int ret;
mqtt_message_t msg; mqtt_message_t msg;
@ -233,8 +192,7 @@ int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) {
msg.payload = (void*)payload; msg.payload = (void*)payload;
msg.qos = qos; msg.qos = qos;
__platform_printf("msg.qos:%d\r\n", __platform_printf("msg.qos:%d\r\n", msg.qos);
msg.qos); // 这里为了防止被优化,导致运行异常
ret = mqtt_publish(_client, topic, &msg); ret = mqtt_publish(_client, topic, &msg);
if (ret == 0) { if (ret == 0) {
// __platform_printf("MQTT_publish OK\r\n"); // __platform_printf("MQTT_publish OK\r\n");
@ -243,12 +201,6 @@ int _mqtt__MQTT_publish(PikaObj* self, char* topic, char* payload, int qos) {
return ret; return ret;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setCa
// 功能说明设置ca值
// 输入参数ca值
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setCa(PikaObj* self, char* ca) { int _mqtt__MQTT_setCa(PikaObj* self, char* ca) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
@ -268,12 +220,6 @@ int _mqtt__MQTT_setCa(PikaObj* self, char* ca) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setClientID
// 功能说明设置mqtt客户端的id
// 输入参数id 字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setClientID(PikaObj* self, char* id) { int _mqtt__MQTT_setClientID(PikaObj* self, char* id) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
@ -293,12 +239,6 @@ int _mqtt__MQTT_setClientID(PikaObj* self, char* id) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setHost
// 功能说明设置mqtt客户端连接主机的ip或者url
// 输入参数:字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setHost(PikaObj* self, char* host_url) { int _mqtt__MQTT_setHost(PikaObj* self, char* host_url) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
@ -311,23 +251,13 @@ int _mqtt__MQTT_setHost(PikaObj* self, char* host_url) {
return -2; return -2;
} }
obj_setStr(self, "host_str", obj_setStr(self, "host_str", host_url);
host_url); // python 环境创建一个全局变量存放 host mqtt_set_host(_client, obj_getStr(self, "host_str"));
mqtt_set_host(
_client,
obj_getStr(self,
"host_str")); // 从python环境中取出 host的指针 赋值给结构体
// __platform_printf("MQTT_setHost :%s\r\n", host_url); // __platform_printf("MQTT_setHost :%s\r\n", host_url);
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setKeepAlive
// 功能说明设置mqtt客户端的 心跳包发送间隔
// 输入参数:字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setKeepAlive(PikaObj* self, int time) { int _mqtt__MQTT_setKeepAlive(PikaObj* self, int time) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
int tmp; int tmp;
@ -345,12 +275,6 @@ int _mqtt__MQTT_setKeepAlive(PikaObj* self, int time) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setPassword
// 功能说明设置mqtt客户端的 密码
// 输入参数:字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setPassword(PikaObj* self, char* passwd) { int _mqtt__MQTT_setPassword(PikaObj* self, char* passwd) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
@ -370,12 +294,6 @@ int _mqtt__MQTT_setPassword(PikaObj* self, char* passwd) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setPort
// 功能说明设置mqtt客户端连接主机的端口号
// 输入参数:字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setPort(PikaObj* self, int port) { int _mqtt__MQTT_setPort(PikaObj* self, int port) {
char port_str[10] = {0}; char port_str[10] = {0};
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
@ -394,12 +312,6 @@ int _mqtt__MQTT_setPort(PikaObj* self, int port) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setUsername
// 功能说明设置mqtt客户端的用户名
// 输入参数:字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setUsername(PikaObj* self, char* name) { int _mqtt__MQTT_setUsername(PikaObj* self, char* name) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
@ -419,12 +331,6 @@ int _mqtt__MQTT_setUsername(PikaObj* self, char* name) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setVersion
// 功能说明设置mqtt 协议版本
// 输入参数:字符串格式
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setVersion(PikaObj* self, char* version) { int _mqtt__MQTT_setVersion(PikaObj* self, char* version) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
// int tmp; // int tmp;
@ -447,12 +353,6 @@ int _mqtt__MQTT_setVersion(PikaObj* self, char* version) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setWill
// 功能说明:设置遗嘱消息,异常断连时会发送这个消息
// 输入参数:
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setWill(PikaObj* self, int _mqtt__MQTT_setWill(PikaObj* self,
char* topic, char* topic,
char* payload, char* payload,
@ -488,7 +388,6 @@ int _mqtt__MQTT_setWill(PikaObj* self,
return -1; return -1;
} }
// 必须转换成python环境的变量否则函数退出后topic里的是个空指针
memset(topic_str, 0, sizeof(topic_str)); memset(topic_str, 0, sizeof(topic_str));
sprintf(topic_str, "%s", topic); sprintf(topic_str, "%s", topic);
obj_setStr(self, topic_str, topic); obj_setStr(self, topic_str, topic);
@ -513,12 +412,6 @@ int _mqtt__MQTT_setWill(PikaObj* self,
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_subscribe
// 功能说明设置mqtt 订阅主题
// 输入参数:
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) { int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
int ret; int ret;
@ -541,7 +434,6 @@ int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
return -3; return -3;
} }
// 必须转换成python环境的变量否则函数退出后topic里的是个空指针
memset(topic_str, 0, sizeof(topic_str)); memset(topic_str, 0, sizeof(topic_str));
sprintf(topic_str, "%s", topic); sprintf(topic_str, "%s", topic);
obj_setStr(self, topic_str, topic); obj_setStr(self, topic_str, topic);
@ -551,13 +443,11 @@ int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
if (ret == 0) { if (ret == 0) {
// __platform_printf("MQTT_subscribe Topic :%s Qos:%d OK\r\n", // __platform_printf("MQTT_subscribe Topic :%s Qos:%d OK\r\n",
// topic,qos); // topic,qos);
// 注册mqtt订阅主题的 回调函数
if (cb != NULL) { if (cb != NULL) {
char hash_str[32] = {0}; char hash_str[32] = {0};
memset(hash_str, 0, sizeof(hash_str)); memset(hash_str, 0, sizeof(hash_str));
sprintf(hash_str, "C%d", hash_time33(topic_str)); sprintf(hash_str, "C%d", hash_time33(topic_str));
obj_newDirectObj(self, hash_str, obj_newDirectObj(self, hash_str, New_TinyObj);
New_TinyObj); // 新建一个对象来放CB
PikaObj* eventHandler = obj_getPtr(self, hash_str); PikaObj* eventHandler = obj_getPtr(self, hash_str);
obj_setArg(eventHandler, "eventCallBack", cb); obj_setArg(eventHandler, "eventCallBack", cb);
/* init event_listener for the first time */ /* init event_listener for the first time */
@ -577,12 +467,6 @@ int _mqtt__MQTT_subscribe(PikaObj* self, char* topic, Arg* cb, int qos) {
return ret; return ret;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_unsubscribe
// 功能说明取消mqtt 订阅主题
// 输入参数:
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_unsubscribe(PikaObj* self, char* topic) { int _mqtt__MQTT_unsubscribe(PikaObj* self, char* topic) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
int ret; int ret;
@ -601,12 +485,6 @@ int _mqtt__MQTT_unsubscribe(PikaObj* self, char* topic) {
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////
// 函 数 名Subscribe_Handler
// 功能说明mqtt 订阅主题 的回调函数
// 输入参数:
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
void Subscribe_Handler(void* client, message_data_t* msg) { void Subscribe_Handler(void* client, message_data_t* msg) {
char topic_str[MQTT_TOPIC_LEN_MAX + 24]; char topic_str[MQTT_TOPIC_LEN_MAX + 24];
@ -624,7 +502,6 @@ void Subscribe_Handler(void* client, message_data_t* msg) {
obj_setStr(evt_obj, "msg", (char*)msg->message->payload); obj_setStr(evt_obj, "msg", (char*)msg->message->payload);
obj_setInt(evt_obj, "qos", msg->message->qos); obj_setInt(evt_obj, "qos", msg->message->qos);
// 存好数据后,再发送事件信号,防止信号收到了但是需要传输的数据没准备好
pika_eventListener_send(g_mqtt_event_listener, hash_time33(msg->topic_name), pika_eventListener_send(g_mqtt_event_listener, hash_time33(msg->topic_name),
evt_obj_arg); evt_obj_arg);
@ -646,59 +523,37 @@ void _mqtt__MQTT__fakeMsg(PikaObj* self, char* topic, int qos, char* msg) {
Subscribe_Handler(NULL, &msg_data); Subscribe_Handler(NULL, &msg_data);
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt___del__
// 功能说明:释放事件处理器
// 输入参数:
// 返 回 值:
///////////////////////////////////////////////////////////////////
void _mqtt___del__(PikaObj* self) { void _mqtt___del__(PikaObj* self) {
if (NULL != g_mqtt_event_listener) { if (NULL != g_mqtt_event_listener) {
pika_eventListener_deinit(&g_mqtt_event_listener); pika_eventListener_deinit(&g_mqtt_event_listener);
} }
} }
////////////////////////////////////////////////////////////////////
// 函 数 名Reconnect_Handler
// 功能说明mqtt 断开连接后
// 的回调函数这里使用mqttclient库函数的断线重连接口提示发生了mqtt断连的事件
// 输入参数:
// 返 回 值0=成功非0=错误码
///////////////////////////////////////////////////////////////////
void Reconnect_Handler(void* client, void* reconnect_date) { void Reconnect_Handler(void* client, void* reconnect_date) {
// PikaObj* self = ((mqtt_client_t*)client)->user_data; // PikaObj* self = ((mqtt_client_t*)client)->user_data;
// __platform_printf("Reconnect_Handler\r\n"); // __platform_printf("Reconnect_Handler\r\n");
if (((mqtt_client_t*)client)->mqtt_client_state != CLIENT_STATE_CONNECTED) { if (((mqtt_client_t*)client)->mqtt_client_state != CLIENT_STATE_CONNECTED) {
// 发送事件信号
pika_eventListener_sendSignal(g_mqtt_event_listener, pika_eventListener_sendSignal(g_mqtt_event_listener,
MQTT_RECONNECTION_EVENT_ID, 1); MQTT_RECONNECTION_EVENT_ID, 1);
} }
} }
////////////////////////////////////////////////////////////////////
// 函 数 名_mqtt__MQTT_setDisconnectHandler
// 功能说明:设置断开连接的回调函数
// 输入参数:
// 返 回 值:
///////////////////////////////////////////////////////////////////
int _mqtt__MQTT_setDisconnectHandler(PikaObj* self, Arg* cb) { int _mqtt__MQTT_setDisconnectHandler(PikaObj* self, Arg* cb) {
mqtt_client_t* _client = obj_getPtr(self, "_client"); mqtt_client_t* _client = obj_getPtr(self, "_client");
// __platform_printf("_mqtt__MQTT_setDisconnectHandler\r\n"); // __platform_printf("_mqtt__MQTT_setDisconnectHandler\r\n");
// 注册到c库中
mqtt_set_reconnect_handler(_client, Reconnect_Handler); mqtt_set_reconnect_handler(_client, Reconnect_Handler);
// char hash_str[32] = {0}; // char hash_str[32] = {0};
// memset(hash_str,0,sizeof(hash_str)); // memset(hash_str,0,sizeof(hash_str));
// sprintf(hash_str,"C%d",hash_time33(topic_str)); // sprintf(hash_str,"C%d",hash_time33(topic_str));
// obj_newDirectObj(self,hash_str,New_TinyObj);//新建一个对象来放CB // obj_newDirectObj(self,hash_str,New_TinyObj);
// PikaObj* eventHandler = obj_getPtr(self,hash_str); // PikaObj* eventHandler = obj_getPtr(self,hash_str);
// obj_setArg(eventHandler, "eventCallBack", cb); // obj_setArg(eventHandler, "eventCallBack", cb);
obj_setArg(self, "eventCallBack", obj_setArg(self, "eventCallBack", cb);
cb); // 重连回调是唯一的就直接用self对象
/* init event_listener for the first time */ /* init event_listener for the first time */
if (NULL == g_mqtt_event_listener) { if (NULL == g_mqtt_event_listener) {
pika_eventListener_init(&g_mqtt_event_listener); pika_eventListener_init(&g_mqtt_event_listener);

View File

@ -2,8 +2,8 @@
* @Author: jiejie * @Author: jiejie
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @LastEditTime: 2020-06-17 19:31:41 * @LastEditTime: 2020-06-17 19:31:41
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _MQTT_CONFIG_H_ #ifndef _MQTT_CONFIG_H_
#define _MQTT_CONFIG_H_ #define _MQTT_CONFIG_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-15 00:42:16 * @Date: 2019-12-15 00:42:16
* @LastEditTime: 2020-10-17 14:16:15 * @LastEditTime: 2020-10-17 14:16:15
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _MQTT_ERROR_H_ #ifndef _MQTT_ERROR_H_
#define _MQTT_ERROR_H_ #define _MQTT_ERROR_H_

View File

@ -3,10 +3,9 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-11 22:46:33 * @Date: 2019-12-11 22:46:33
* @LastEditTime: 2020-04-27 23:28:12 * @LastEditTime: 2020-04-27 23:28:12
* @Description: the following code references TencentOS tiny, please keep the * @Description: the following code references TencentOS tiny, please keep
* author information and source code according to the license. * the author information and source code according to the license.
*/ */
#include "mqtt_list.h" #include "mqtt_list.h"
static void _mqtt_list_add(mqtt_list_t* node, static void _mqtt_list_add(mqtt_list_t* node,

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-11 22:47:55 * @Date: 2019-12-11 22:47:55
* @LastEditTime: 2020-10-17 14:18:02 * @LastEditTime: 2020-10-17 14:18:02
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _MQTT_LIST_H_ #ifndef _MQTT_LIST_H_
#define _MQTT_LIST_H_ #define _MQTT_LIST_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-27 03:25:58 * @Date: 2019-12-27 03:25:58
* @LastEditTime: 2020-10-17 14:15:55 * @LastEditTime: 2020-10-17 14:15:55
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _MQTT_LOG_H_ #ifndef _MQTT_LOG_H_
#define _MQTT_LOG_H_ #define _MQTT_LOG_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-09 21:31:25 * @Date: 2019-12-09 21:31:25
* @LastEditTime : 2022-06-12 17:39:43 * @LastEditTime : 2022-06-12 17:39:43
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include "mqttclient.h" #include "mqttclient.h"
@ -1172,7 +1172,7 @@ static uint32_t mqtt_read_buf_malloc(mqtt_client_t* c, uint32_t size) {
__LINE__, __FUNCTION__); __LINE__, __FUNCTION__);
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR); RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
} }
memset(c->mqtt_read_buf, 0, c->mqtt_read_buf_size); // 清空申请的内存 memset(c->mqtt_read_buf, 0, c->mqtt_read_buf_size);
return c->mqtt_read_buf_size; return c->mqtt_read_buf_size;
} }

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-09 21:31:25 * @Date: 2019-12-09 21:31:25
* @LastEditTime : 2022-06-11 22:45:02 * @LastEditTime : 2022-06-11 22:45:02
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _MQTTCLIENT_H_ #ifndef _MQTTCLIENT_H_
#define _MQTTCLIENT_H_ #define _MQTTCLIENT_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-15 13:38:52 * @Date: 2019-12-15 13:38:52
* @LastEditTime: 2020-05-25 10:13:41 * @LastEditTime: 2020-05-25 10:13:41
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include "nettype_tcp.h" #include "nettype_tcp.h"
#include "mqtt_log.h" #include "mqtt_log.h"

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-15 13:39:00 * @Date: 2019-12-15 13:39:00
* @LastEditTime: 2020-10-17 14:17:10 * @LastEditTime: 2020-10-17 14:17:10
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _NETTYPE_TCP_H_ #ifndef _NETTYPE_TCP_H_
#define _NETTYPE_TCP_H_ #define _NETTYPE_TCP_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2020-01-11 19:45:35 * @Date: 2020-01-11 19:45:35
* @LastEditTime: 2020-09-20 14:29:06 * @LastEditTime: 2020-09-20 14:29:06
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include "nettype_tls.h" #include "nettype_tls.h"
#include "platform_memory.h" #include "platform_memory.h"

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-09 21:30:54 * @Date: 2019-12-09 21:30:54
* @LastEditTime: 2020-06-05 17:17:48 * @LastEditTime: 2020-06-05 17:17:48
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include <string.h> #include <string.h>
#include "nettype_tcp.h" #include "nettype_tcp.h"

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-09 21:31:02 * @Date: 2019-12-09 21:31:02
* @LastEditTime: 2020-10-17 14:14:41 * @LastEditTime: 2020-10-17 14:14:41
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _NETWORK_H_ #ifndef _NETWORK_H_
#define _NETWORK_H_ #define _NETWORK_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-14 22:02:07 * @Date: 2019-12-14 22:02:07
* @LastEditTime: 2020-02-19 20:26:04 * @LastEditTime: 2020-02-19 20:26:04
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include "platform_memory.h" #include "platform_memory.h"

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-14 22:06:35 * @Date: 2019-12-14 22:06:35
* @LastEditTime: 2020-10-17 14:17:24 * @LastEditTime: 2020-10-17 14:17:24
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _PLATFORM_MEMORY_H_ #ifndef _PLATFORM_MEMORY_H_
#define _PLATFORM_MEMORY_H_ #define _PLATFORM_MEMORY_H_

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2020-01-10 23:45:59 * @Date: 2020-01-10 23:45:59
* @LastEditTime: 2020-06-05 17:13:00 * @LastEditTime: 2020-06-05 17:13:00
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include "platform_net_socket.h" #include "platform_net_socket.h"
#include "mqtt_error.h" #include "mqtt_error.h"

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-15 13:39:00 * @Date: 2019-12-15 13:39:00
* @LastEditTime: 2020-10-17 14:17:45 * @LastEditTime: 2020-10-17 14:17:45
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _PLATFORM_NET_SOCKET_H_ #ifndef _PLATFORM_NET_SOCKET_H_
#define _PLATFORM_NET_SOCKET_H_ #define _PLATFORM_NET_SOCKET_H_

View File

@ -8,7 +8,6 @@
* Copyright (c) 2022 jiejie, All Rights Reserved. Please keep the author * Copyright (c) 2022 jiejie, All Rights Reserved. Please keep the author
* information and source code according to the license. * information and source code according to the license.
*/ */
#ifndef _RANDOM_H_ #ifndef _RANDOM_H_
#define _RANDOM_H_ #define _RANDOM_H_

View File

@ -20,49 +20,41 @@
#define IS_PATH_SEP(ch) ((ch) == '/' || (ch) == '\\') #define IS_PATH_SEP(ch) ((ch) == '/' || (ch) == '\\')
// 返回指定路径的绝对路径
char* os_path_abspath(PikaObj* self, char* path) { char* os_path_abspath(PikaObj* self, char* path) {
char* abs_path = NULL; char* abs_path = NULL;
#ifdef _WIN32 #ifdef _WIN32
DWORD size = GetFullPathNameA(path, 0, NULL, NULL); DWORD size = GetFullPathNameA(path, 0, NULL, NULL);
if (size == 0) { if (size == 0) {
// 获取绝对路径失败
return NULL; return NULL;
} }
abs_path = (char*)malloc(size * sizeof(char)); abs_path = (char*)malloc(size * sizeof(char));
if (abs_path == NULL) { if (abs_path == NULL) {
// 内存分配失败
return NULL; return NULL;
} }
DWORD ret_size = GetFullPathNameA(path, size, abs_path, NULL); DWORD ret_size = GetFullPathNameA(path, size, abs_path, NULL);
if (ret_size == 0 || ret_size > size) { if (ret_size == 0 || ret_size > size) {
// 获取绝对路径失败
free(abs_path); free(abs_path);
return NULL; return NULL;
} }
#else #else
char* cwd = getcwd(NULL, 0); char* cwd = getcwd(NULL, 0);
if (cwd == NULL) { if (cwd == NULL) {
// 获取当前工作目录失败
return NULL; return NULL;
} }
abs_path = realpath(path, NULL); abs_path = realpath(path, NULL);
if (abs_path == NULL) { if (abs_path == NULL) {
// 获取绝对路径失败
free(cwd); free(cwd);
return NULL; return NULL;
} }
// 如果路径不是绝对路径,则将其转换为绝对路径
if (abs_path[0] != '/') { if (abs_path[0] != '/') {
char* temp_path = char* temp_path =
(char*)malloc((strlen(cwd) + strlen(abs_path) + 2) * sizeof(char)); (char*)malloc((strlen(cwd) + strlen(abs_path) + 2) * sizeof(char));
if (temp_path == NULL) { if (temp_path == NULL) {
// 内存分配失败
free(cwd); free(cwd);
free(abs_path); free(abs_path);
return NULL; return NULL;
@ -83,12 +75,10 @@ char* os_path_abspath(PikaObj* self, char* path) {
return res; return res;
} }
// 判断指定路径是否存在
PIKA_BOOL os_path_exists(PikaObj* self, char* path) { PIKA_BOOL os_path_exists(PikaObj* self, char* path) {
#ifdef _WIN32 #ifdef _WIN32
DWORD attr = GetFileAttributesA(path); DWORD attr = GetFileAttributesA(path);
if (attr == INVALID_FILE_ATTRIBUTES) { if (attr == INVALID_FILE_ATTRIBUTES) {
// 获取文件属性失败
return PIKA_FALSE; return PIKA_FALSE;
} }
@ -96,7 +86,6 @@ PIKA_BOOL os_path_exists(PikaObj* self, char* path) {
#else #else
struct stat statbuf; struct stat statbuf;
if (stat(path, &statbuf) == -1) { if (stat(path, &statbuf) == -1) {
// 获取文件状态失败
return PIKA_FALSE; return PIKA_FALSE;
} }
@ -104,7 +93,6 @@ PIKA_BOOL os_path_exists(PikaObj* self, char* path) {
#endif #endif
} }
// 判断指定路径是否为绝对路径
PIKA_BOOL os_path_isabs(PikaObj* self, char* path) { PIKA_BOOL os_path_isabs(PikaObj* self, char* path) {
#ifdef _WIN32 #ifdef _WIN32
if (path[0] == '\\' || path[0] == '/') { if (path[0] == '\\' || path[0] == '/') {
@ -231,16 +219,13 @@ int _os_path_split(char* path, char** folder, char** file) {
} }
char* p = strrchr(path, PATH_SEPARATOR); char* p = strrchr(path, PATH_SEPARATOR);
if (p) { if (p) {
/* 字符串最后一个路径分隔符的位置 */
size_t idx = p - path; size_t idx = p - path;
/* 获取最后一个路径分隔符之前的路径 */
*folder = pika_platform_malloc(idx + 2); *folder = pika_platform_malloc(idx + 2);
if (*folder == NULL) { if (*folder == NULL) {
return -1; return -1;
} }
strncpy(*folder, path, idx + 1); strncpy(*folder, path, idx + 1);
(*folder)[idx] = '\0'; (*folder)[idx] = '\0';
/* 获取最后一个路径分隔符之后的文件名 */
*file = strdup(p + 1); *file = strdup(p + 1);
if (*file == NULL) { if (*file == NULL) {
pika_platform_free(*folder); pika_platform_free(*folder);
@ -249,7 +234,6 @@ int _os_path_split(char* path, char** folder, char** file) {
} }
return 0; return 0;
} else { } else {
/* 如果路径没有分隔符,则返回路径本身和空字符串 */
*folder = strdup(path); *folder = strdup(path);
if (*folder == NULL) { if (*folder == NULL) {
return -1; return -1;
@ -267,35 +251,27 @@ int _os_path_split(char* path, char** folder, char** file) {
int _os_path_splitext(char* path, char** file, char** ext) { int _os_path_splitext(char* path, char** file, char** ext) {
char* p = strrchr(path, '.'); char* p = strrchr(path, '.');
if (p) { if (p) {
/* 字符串最后一个点的位置 */
size_t idx = p - path; size_t idx = p - path;
/* 获取点之前的路径 */
*file = malloc(idx + 1); *file = malloc(idx + 1);
if (!(*file)) { if (!(*file)) {
/* 内存分配失败 */
return -1; return -1;
} }
strncpy(*file, path, idx); strncpy(*file, path, idx);
(*file)[idx] = '\0'; (*file)[idx] = '\0';
/* 获取点之后的扩展名 */
*ext = strdup(p); *ext = strdup(p);
if (!(*ext)) { if (!(*ext)) {
/* 内存分配失败 */
pika_platform_free(*file); pika_platform_free(*file);
*file = NULL; *file = NULL;
return -1; return -1;
} }
return 0; return 0;
} else { } else {
/* 如果没有扩展名,则返回路径本身和空字符串 */
*file = strdup(path); *file = strdup(path);
if (!(*file)) { if (!(*file)) {
/* 内存分配失败 */
return -1; return -1;
} }
*ext = strdup(""); *ext = strdup("");
if (!(*ext)) { if (!(*ext)) {
/* 内存分配失败 */
free(*file); free(*file);
*file = NULL; *file = NULL;
return -1; return -1;
@ -310,7 +286,7 @@ PikaObj* os_path_split(PikaObj* self, char* path) {
PikaObj* tuple = NULL; PikaObj* tuple = NULL;
if (0 != _os_path_split(path, &folder, &file)) { if (0 != _os_path_split(path, &folder, &file)) {
goto __exit; // 发生错误,跳转到 __exit 处做资源回收 goto __exit;
} }
tuple = objTuple_new(arg_newStr(folder), arg_newStr(file)); tuple = objTuple_new(arg_newStr(folder), arg_newStr(file));
@ -339,7 +315,7 @@ PikaObj* os_path_splitext(PikaObj* self, char* path) {
Arg* aExt = NULL; Arg* aExt = NULL;
if (0 != _os_path_splitext(path, &file, &ext)) { if (0 != _os_path_splitext(path, &file, &ext)) {
goto __exit; // 发生错误,跳转到 __exit 处做资源回收 goto __exit;
} }
tuple = newNormalObj(New_PikaStdData_Tuple); tuple = newNormalObj(New_PikaStdData_Tuple);

View File

@ -58,7 +58,6 @@ char* os_read_platform(PikaObj* self, PikaObj* fd, int len) {
size = fread(buf, 1, len, fp); size = fread(buf, 1, len, fp);
if (size > 0) { if (size > 0) {
//转换成
obj_setStr(self, "os_file_read", buf); obj_setStr(self, "os_file_read", buf);
free(buf); free(buf);
return obj_getStr(self, "os_file_read"); return obj_getStr(self, "os_file_read");
@ -122,7 +121,6 @@ PikaObj* os_listdir_platform(char* path) {
PikaStdData_List___init__(list); PikaStdData_List___init__(list);
handle = _findfirst(dirpath, &fb); handle = _findfirst(dirpath, &fb);
//找到第一个匹配的文件
if (handle != -1L) { if (handle != -1L) {
if (memcmp(fb.name, ".", 1) != 0) { if (memcmp(fb.name, ".", 1) != 0) {
Arg* arg = arg_setStr(NULL, "", fb.name); Arg* arg = arg_setStr(NULL, "", fb.name);

View File

@ -19,7 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* cJSON */ /* cJSON */
/* JSON parser in C. */ /* JSON parser in C. */

View File

@ -19,7 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
#ifndef cJSON__h #ifndef cJSON__h
#define cJSON__h #define cJSON__h
@ -34,14 +33,14 @@ extern "C" {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid /* When compiling for windows, we specify a specific calling convention to
issues where we are being called from a project with a different default calling avoid issues where we are being called from a project with a different
convention. For windows you have 3 define options: default calling convention. For windows you have 3 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever
dllexport symbols CJSON_EXPORT_SYMBOLS - Define this on library build when you dllexport symbols CJSON_EXPORT_SYMBOLS - Define this on library build when
want to dllexport symbols (default) CJSON_IMPORT_SYMBOLS - Define this if you you want to dllexport symbols (default) CJSON_IMPORT_SYMBOLS - Define this
want to dllimport symbol if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar For *nix builds that support visibility attribute, you can define similar
behavior by behavior by
@ -52,8 +51,8 @@ or
-xldscope=hidden (for sun cc) -xldscope=hidden (for sun cc)
to CFLAGS to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way then using the CJSON_API_VISIBILITY flag to "export" the same symbols the
CJSON_EXPORT_SYMBOLS does way CJSON_EXPORT_SYMBOLS does
*/ */
@ -113,8 +112,8 @@ typedef struct cJSON {
* GetArraySize/GetArrayItem/GetObjectItem */ * GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON* next; struct cJSON* next;
struct cJSON* prev; struct cJSON* prev;
/* An array or object item will have a child pointer pointing to a chain of /* An array or object item will have a child pointer pointing to a chain
* the items in the array/object. */ * of the items in the array/object. */
struct cJSON* child; struct cJSON* child;
/* The type of the item, as above. */ /* The type of the item, as above. */
@ -122,13 +121,14 @@ typedef struct cJSON {
/* The item's string, if type==cJSON_String and type == cJSON_Raw */ /* The item's string, if type==cJSON_String and type == cJSON_Raw */
char* valuestring; char* valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead
*/
int valueint; int valueint;
/* The item's number, if type==cJSON_Number */ /* The item's number, if type==cJSON_Number */
double valuedouble; double valuedouble;
/* The item's name string, if this item is the child of, or is in the list /* The item's name string, if this item is the child of, or is in the
* of subitems of an object. */ * list of subitems of an object. */
char* string; char* string;
} cJSON; } cJSON;
@ -154,12 +154,13 @@ CJSON_PUBLIC(const char*) cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */ /* Supply malloc, realloc and free functions to cJSON */
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks); CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from /* Memory Management: the caller is always responsible to free the results
* all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib * from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print
* free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is * (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate).
* cJSON_PrintPreallocated, where the caller has full responsibility of the * The exception is cJSON_PrintPreallocated, where the caller has full
* buffer. */ * responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. /* Supply a block of JSON, and this returns a cJSON object you can
* interrogate.
*/ */
CJSON_PUBLIC(cJSON*) cJSON_Parse(const char* value); CJSON_PUBLIC(cJSON*) cJSON_Parse(const char* value);
CJSON_PUBLIC(cJSON*) CJSON_PUBLIC(cJSON*)
@ -181,17 +182,18 @@ cJSON_ParseWithLengthOpts(const char* value,
/* Render a cJSON entity to text for transfer/storage. */ /* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char*) cJSON_Print(const cJSON* item); CJSON_PUBLIC(char*) cJSON_Print(const cJSON* item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */ /* Render a cJSON entity to text for transfer/storage without any
* formatting. */
CJSON_PUBLIC(char*) cJSON_PrintUnformatted(const cJSON* item); CJSON_PUBLIC(char*) cJSON_PrintUnformatted(const cJSON* item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess /* Render a cJSON entity to text using a buffered strategy. prebuffer is a
* at the final size. guessing well reduces reallocation. fmt=0 gives * guess at the final size. guessing well reduces reallocation. fmt=0 gives
* unformatted, =1 gives formatted */ * unformatted, =1 gives formatted */
CJSON_PUBLIC(char*) CJSON_PUBLIC(char*)
cJSON_PrintBuffered(const cJSON* item, int prebuffer, cJSON_bool fmt); cJSON_PrintBuffered(const cJSON* item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with /* Render a cJSON entity to text using a buffer already allocated in memory
* given length. Returns 1 on success and 0 on failure. */ * with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will /* NOTE: cJSON is not always 100% accurate in estimating how much memory it
* use, so to be safe allocate 5 bytes more than you actually need */ * will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
cJSON_PrintPreallocated(cJSON* item, cJSON_PrintPreallocated(cJSON* item,
char* buffer, char* buffer,
@ -214,8 +216,8 @@ cJSON_GetObjectItemCaseSensitive(const cJSON* const object,
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
cJSON_HasObjectItem(const cJSON* object, const char* string); cJSON_HasObjectItem(const cJSON* object, const char* string);
/* For analysing failed parses. This returns a pointer to the parse error. /* For analysing failed parses. This returns a pointer to the parse error.
* You'll probably need to look a few chars back to make sense of it. Defined * You'll probably need to look a few chars back to make sense of it.
* when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ * Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char*) cJSON_GetErrorPtr(void); CJSON_PUBLIC(const char*) cJSON_GetErrorPtr(void);
/* Check item type and return its value */ /* Check item type and return its value */
@ -258,8 +260,10 @@ CJSON_PUBLIC(cJSON*) cJSON_CreateArrayReference(const cJSON* child);
* The parameter count cannot be greater than the number of elements in the * The parameter count cannot be greater than the number of elements in the
* number array, otherwise array access will be out of bounds.*/ * number array, otherwise array access will be out of bounds.*/
CJSON_PUBLIC(cJSON*) cJSON_CreateIntArray(const int* numbers, int count); CJSON_PUBLIC(cJSON*) cJSON_CreateIntArray(const int* numbers, int count);
CJSON_PUBLIC(cJSON*) cJSON_CreateFloatArray(const double* numbers, int count); CJSON_PUBLIC(cJSON*)
CJSON_PUBLIC(cJSON*) cJSON_CreateDoubleArray(const double* numbers, int count); cJSON_CreateFloatArray(const double* numbers, int count);
CJSON_PUBLIC(cJSON*)
cJSON_CreateDoubleArray(const double* numbers, int count);
CJSON_PUBLIC(cJSON*) CJSON_PUBLIC(cJSON*)
cJSON_CreateStringArray(const char* const* strings, int count); cJSON_CreateStringArray(const char* const* strings, int count);
@ -267,15 +271,15 @@ cJSON_CreateStringArray(const char* const* strings, int count);
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON* array, cJSON* item); CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON* array, cJSON* item);
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item); cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and /* Use this when string is definitely const (i.e. a literal, or as good as),
* will definitely survive the cJSON object. WARNING: When this function was * and will definitely survive the cJSON object. WARNING: When this function
* used, make sure to always check that (item->type & cJSON_StringIsConst) is * was used, make sure to always check that (item->type &
* zero before writing to `item->string` */ * cJSON_StringIsConst) is zero before writing to `item->string` */
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
cJSON_AddItemToObjectCS(cJSON* object, const char* string, cJSON* item); cJSON_AddItemToObjectCS(cJSON* object, const char* string, cJSON* item);
/* Append reference to item to the specified array/object. Use this when you /* Append reference to item to the specified array/object. Use this when you
* want to add an existing cJSON to a new cJSON, but don't want to corrupt your * want to add an existing cJSON to a new cJSON, but don't want to corrupt
* existing cJSON. */ * your existing cJSON. */
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item); cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
@ -316,26 +320,27 @@ cJSON_ReplaceItemInObjectCaseSensitive(cJSON* object,
/* Duplicate a cJSON item */ /* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON*) cJSON_Duplicate(const cJSON* item, cJSON_bool recurse); CJSON_PUBLIC(cJSON*) cJSON_Duplicate(const cJSON* item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new /* Duplicate will create a new, identical cJSON item to the one you pass, in
* memory that will need to be released. With recurse!=0, it will duplicate any * new memory that will need to be released. With recurse!=0, it will
* children connected to the item. The item->next and ->prev pointers are always * duplicate any children connected to the item. The item->next and ->prev
* zero on return from Duplicate. */ * pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or /* Recursively compare two cJSON items for equality. If either a or b is
* invalid, they will be considered unequal. case_sensitive determines if object * NULL or invalid, they will be considered unequal. case_sensitive
* keys are treated case sensitive (1) or case insensitive (0) */ * determines if object keys are treated case sensitive (1) or case
* insensitive (0) */
CJSON_PUBLIC(cJSON_bool) CJSON_PUBLIC(cJSON_bool)
cJSON_Compare(const cJSON* const a, cJSON_Compare(const cJSON* const a,
const cJSON* const b, const cJSON* const b,
const cJSON_bool case_sensitive); const cJSON_bool case_sensitive);
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n')
* strings. The input pointer json cannot point to a read-only address area, * from strings. The input pointer json cannot point to a read-only address
* such as a string constant, but should point to a readable and writable * area, such as a string constant, but should point to a readable and
* address area. */ * writable address area. */
CJSON_PUBLIC(void) cJSON_Minify(char* json); CJSON_PUBLIC(void) cJSON_Minify(char* json);
/* Helper functions for creating and adding items to an object at the same time. /* Helper functions for creating and adding items to an object at the same
* They return the added item or NULL on failure. */ * time. They return the added item or NULL on failure. */
CJSON_PUBLIC(cJSON*) CJSON_PUBLIC(cJSON*)
cJSON_AddNullToObject(cJSON* const object, const char* const name); cJSON_AddNullToObject(cJSON* const object, const char* const name);
CJSON_PUBLIC(cJSON*) CJSON_PUBLIC(cJSON*)
@ -373,8 +378,8 @@ CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON* object, double number);
#define cJSON_SetNumberValue(object, number) \ #define cJSON_SetNumberValue(object, number) \
((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) \ ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) \
: (number)) : (number))
/* Change the valuestring of a cJSON_String object, only takes effect when type /* Change the valuestring of a cJSON_String object, only takes effect when
* of object is cJSON_String */ * type of object is cJSON_String */
CJSON_PUBLIC(char*) CJSON_PUBLIC(char*)
cJSON_SetValuestring(cJSON* object, const char* valuestring); cJSON_SetValuestring(cJSON* object, const char* valuestring);
@ -383,8 +388,8 @@ cJSON_SetValuestring(cJSON* object, const char* valuestring);
for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \ for (element = (array != NULL) ? (array)->child : NULL; element != NULL; \
element = element->next) element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with /* malloc/free objects using the malloc/free functions that have been set
* cJSON_InitHooks */ * with cJSON_InitHooks */
CJSON_PUBLIC(void*) cJSON_malloc(size_t size); CJSON_PUBLIC(void*) cJSON_malloc(size_t size);
CJSON_PUBLIC(void) cJSON_free(void* object); CJSON_PUBLIC(void) cJSON_free(void* object);

View File

@ -112,6 +112,6 @@ __exit:
void _pika_lua___del__(PikaObj* self) { void _pika_lua___del__(PikaObj* self) {
pika_debug("lua close!\r\n"); pika_debug("lua close!\r\n");
lua_close(g_pika_L); // 关闭 Lua 状态机,释放所有关联的资源 lua_close(g_pika_L);
g_pika_L = NULL; g_pika_L = NULL;
} }

View File

@ -1,4 +1,4 @@
#include "PikaPlatform_socket.h" #include "PikaPlatform_socket.h"
/* /*
The functinos start with PIKA_WEAK are weak functions, The functinos start with PIKA_WEAK are weak functions,
you need to override them in your platform. you need to override them in your platform.

View File

@ -1,4 +1,4 @@
#include "PikaObj.h" #include "PikaObj.h"
#ifdef __linux__ #ifdef __linux__
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <errno.h>

View File

@ -1,4 +1,4 @@
#include "PikaPlatform_socket.h" #include "PikaPlatform_socket.h"
#include "_socket_socket.h" #include "_socket_socket.h"
#if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 12, 0) #if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 12, 0)

View File

@ -7,25 +7,24 @@
* Copyright (c) 2014 Paul Sokolovsky * Copyright (c) 2014 Paul Sokolovsky
* Copyright (c) 2023 Lyon * Copyright (c) 2023 Lyon
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "_struct.h" #include "_struct.h"
#include "pika_adapter_mpy.h" #include "pika_adapter_mpy.h"

View File

@ -42,8 +42,6 @@ void _time_platformGetTick(PikaObj* self) {
#include "stdint.h" #include "stdint.h"
#include "stdio.h" #include "stdio.h"
// 结构体时间类型定义(来源c标准库corect_wtime.h)
// 无论是16位整数还是32位整数都满足需求
typedef struct _tm { typedef struct _tm {
int tm_sec; // seconds after the minute - [0, 60] including leap second int tm_sec; // seconds after the minute - [0, 60] including leap second
int tm_min; // minutes after the hour - [0, 59] int tm_min; // minutes after the hour - [0, 59]
@ -56,16 +54,11 @@ typedef struct _tm {
int tm_isdst; // daylight savings time flag int tm_isdst; // daylight savings time flag
} _tm; } _tm;
// 时间戳时间类型定义(来源c标准库time.h)
// 直接支持64位秒数时间附加时间精度为ns根据设备决定需要1GHz及以上时钟频率才能支持1ns级别时间精度
// 内部时间比对数据类型,传递给外界的时候会使用浮点数,所以精度会降低
// 但内部使用复合数据类型比对,以实现平台支持的最小时间精度比较
typedef struct { typedef struct {
int64_t tv_sec; // Seconds - >= 0 int64_t tv_sec; // Seconds - >= 0
int32_t tv_nsec; // Nanoseconds - [0, 999999999] int32_t tv_nsec; // Nanoseconds - [0, 999999999]
} _timespec; } _timespec;
// 错误处理
typedef int status; typedef int status;
#define TIME_OK 0 #define TIME_OK 0
@ -77,9 +70,7 @@ typedef int status;
#define TIME_LESS_THAN_1970 5 #define TIME_LESS_THAN_1970 5
#define TIME_ERROR_STRUCT_TIME 6 #define TIME_ERROR_STRUCT_TIME 6
// 错误状态处理函数
void status_deal(status s) { void status_deal(status s) {
// 输出异常信息
#define time_printf(...) __platform_printf(__VA_ARGS__) #define time_printf(...) __platform_printf(__VA_ARGS__)
time_printf("\n[Error-info]Checking a exception : "); time_printf("\n[Error-info]Checking a exception : ");
@ -111,59 +102,46 @@ void status_deal(status s) {
time_printf("\n"); time_printf("\n");
} }
// 获取硬件平台的Unix时间戳,时间精度为1s级别
status time_get_unix_time(PikaObj* self, _timespec* this_timespec) { status time_get_unix_time(PikaObj* self, _timespec* this_timespec) {
this_timespec->tv_sec = (int64_t)(obj_getInt(self, "tick") / 1000); this_timespec->tv_sec = (int64_t)(obj_getInt(self, "tick") / 1000);
return TIME_OK; return TIME_OK;
} }
// 获取硬件平台的Tick时间,时间精度为1s级别以下
// 即1s的小数部分
status time_get_tick_ns(PikaObj* self, _timespec* this_timespec) { status time_get_tick_ns(PikaObj* self, _timespec* this_timespec) {
this_timespec->tv_nsec = (obj_getInt(self, "tick") % 1000) * 1000000; this_timespec->tv_nsec = (obj_getInt(self, "tick") % 1000) * 1000000;
return TIME_OK; return TIME_OK;
} }
// 标准time()方法,返回以浮点数表示的从 epoch 开始的秒数的时间值。
// epoch 是 1970 年 1 月 1 日 00:00:00 (UTC)
pika_float time_time(PikaObj* self) { pika_float time_time(PikaObj* self) {
status res = 0; // 状态响应 status res = 0;
_timespec temp_timespec = {0}; _timespec temp_timespec = {0};
// 调用硬件平台函数,获取当前时间
res = time_get_unix_time(self, &temp_timespec); res = time_get_unix_time(self, &temp_timespec);
if (res) { if (res) {
status_deal(res); status_deal(res);
} // 异常处理 }
res = time_get_tick_ns(self, &temp_timespec); res = time_get_tick_ns(self, &temp_timespec);
if (res) { if (res) {
status_deal(res); status_deal(res);
} // 异常处理 }
// 以浮点数返回时间float
return temp_timespec.tv_sec + return temp_timespec.tv_sec +
(pika_float)temp_timespec.tv_nsec / 1000000000; (pika_float)temp_timespec.tv_nsec / 1000000000;
} }
// 标准time_ns()方法,返回以整数表示的从 epoch 开始的纳秒数的时间值。
// epoch 是 1970 年 1 月 1 日 00:00:00 (UTC)
int64_t time_time_ns(PikaObj* self) { int64_t time_time_ns(PikaObj* self) {
status res = 0; // 状态响应 status res = 0;
_timespec temp_timespec = {0}; _timespec temp_timespec = {0};
// 调用硬件平台函数,获取当前时间
res = time_get_unix_time(self, &temp_timespec); res = time_get_unix_time(self, &temp_timespec);
if (res) { if (res) {
status_deal(res); status_deal(res);
} // 异常处理 }
res = time_get_tick_ns(self, &temp_timespec); res = time_get_tick_ns(self, &temp_timespec);
if (res) { if (res) {
status_deal(res); status_deal(res);
} // 异常处理 }
// 以浮点数返回时间float
return temp_timespec.tv_sec * 1000000000 + temp_timespec.tv_nsec; return temp_timespec.tv_sec * 1000000000 + temp_timespec.tv_nsec;
} }
// 利用基姆拉尔森计算公式计算星期
int time_get_week(const _tm* this_tm) { int time_get_week(const _tm* this_tm) {
// 月份要+1
int month = this_tm->tm_mon + 1; int month = this_tm->tm_mon + 1;
int year = this_tm->tm_year; int year = this_tm->tm_year;
int day = this_tm->tm_mday; int day = this_tm->tm_mday;
@ -172,195 +150,131 @@ int time_get_week(const _tm* this_tm) {
month += 12; month += 12;
year -= 1; year -= 1;
w = day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - w = day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 -
year / 100 + year / 400 + 1; // 0~6,星期日 ~ 星期六 year / 100 + year / 400 + 1; //
w = w % 7; w = w % 7;
} else { } else {
w = day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - w = day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 -
year / 100 + year / 400 + 1; // 0~6,星期日 ~ 星期六 year / 100 + year / 400 + 1; //
w = w % 7; w = w % 7;
} }
return w; return w;
} }
// 由Unix时间戳计算标准UTC时间
status unix_time_to_utc_struct_time(_tm* this_tm, int64_t unix_time) { status unix_time_to_utc_struct_time(_tm* this_tm, int64_t unix_time) {
int32_t total_day; int32_t total_day;
int32_t extra_second; int32_t extra_second;
int year_400, year_100, year_4, year_1; int year_400, year_100, year_4, year_1;
int february_offset, temp; // 二月偏移量,零时变量 int february_offset, temp;
// 判断是否输入小于0的时间戳
if (unix_time < 0) { if (unix_time < 0) {
// 暂不支持小于0的时间戳
return TIME_LESS_THAN_ZERO; return TIME_LESS_THAN_ZERO;
} }
// Unix时间戳每天秒数是固定的 62*60*24
#define DAY_SECOND (86400) #define DAY_SECOND (86400)
total_day = unix_time / DAY_SECOND; total_day = unix_time / DAY_SECOND;
extra_second = unix_time - total_day * DAY_SECOND; extra_second = unix_time - total_day * DAY_SECOND;
// 为了减少额外闰年判断把时间往前推到1600年即闰年最大的一次公倍数开始计算判断 #define YEAR_START (1600)
// 1970-1600 = 370 年 370/4 -(370/100-1)=90 个闰年 #define DAY_OFFSET (135140)
// 1600 DAY_OFFSET 365*(1970-1600)+90 = 135140,7为修正天数
#define YEAR_START (1600) // 初始年份
#define DAY_OFFSET (135140) // 时间偏移量
total_day += DAY_OFFSET; total_day += DAY_OFFSET;
// 从1600年到3200年有1600/4-(1600/100-1600/400)=388个闰年 #define MAX_DAY (584388)
// 即 MAX_DAY 1600*365+388=584388 day
#define MAX_DAY (584388) // 最大可判断时间天数
if (total_day > MAX_DAY) { if (total_day > MAX_DAY) {
// 超过3200年的换算暂不支持
return TIME_OVER_3200; return TIME_OVER_3200;
} else { } else {
// 从1600年开始天数都要多减一天因为1600年是闰年
// 但是由于日期不包含当天时间即2月2号实际是2月1号+时:分:秒
// 所以算出来的日期要加上一天
// 两者配合,无需加减
// 从400年100年4年逐渐缩小范围
// 400个公历年天数为365*400+97=146097天
// 400年内的100个公历年天数为365*100+24=36524天
// 100年内的4年365*4+1=1461天
#define DAY_OF_400Y (146097) #define DAY_OF_400Y (146097)
#define DAY_OF_100Y (36524) #define DAY_OF_100Y (36524)
#define DAY_OF_4Y (1461) #define DAY_OF_4Y (1461)
#define DAY_OF_1Y (365) #define DAY_OF_1Y (365)
// 400年也要注意要实际401年才可
year_400 = (total_day - 366) / DAY_OF_400Y; year_400 = (total_day - 366) / DAY_OF_400Y;
total_day -= year_400 * DAY_OF_400Y; total_day -= year_400 * DAY_OF_400Y;
// 计算400年内的情况
year_100 = (total_day - 1) / DAY_OF_100Y; year_100 = (total_day - 1) / DAY_OF_100Y;
total_day -= year_100 * DAY_OF_100Y; total_day -= year_100 * DAY_OF_100Y;
// 计算100年内的情况要到第二年的第一天才算即365+1
year_4 = (total_day - 366) / DAY_OF_4Y; year_4 = (total_day - 366) / DAY_OF_4Y;
// 计算4年需要格外注意0-5-8年才会计算一个闰年因为它才包含了4这个闰年但并不包含8
total_day -= year_4 * DAY_OF_4Y; total_day -= year_4 * DAY_OF_4Y;
// 计算4年内的情况
// 需要减去1天因为当天是不存在的
// 需要注意闰年会多一天
// 所有闰年都放在这里来考虑,即只要当前是闰年,那么这里就会剩下第一年闰年和第四年闰年两种情况
if (year_100 == 4) { if (year_100 == 4) {
// 第一年是闰年,此时为400*n+1年内
year_1 = 0; year_1 = 0;
february_offset = 1; february_offset = 1;
} else if (total_day <= DAY_OF_1Y * 4) { } else if (total_day <= DAY_OF_1Y * 4) {
// 100*n+(4,8,...96)+1年都是从第二年算起非闰年
// 非闰年,需要减去1天因为当天是不存在的
year_1 = (total_day - 1) / DAY_OF_1Y; year_1 = (total_day - 1) / DAY_OF_1Y;
total_day -= year_1 * DAY_OF_1Y; total_day -= year_1 * DAY_OF_1Y;
february_offset = 0; february_offset = 0;
} else { } else {
// 第四年是闰年
year_1 = 4; year_1 = 4;
total_day -= year_1 * DAY_OF_1Y; total_day -= year_1 * DAY_OF_1Y;
february_offset = 1; february_offset = 1;
} }
// 计算出当前年份
this_tm->tm_year = this_tm->tm_year =
(year_400 * 400 + year_100 * 100 + year_4 * 4 + year_1) + (year_400 * 400 + year_100 * 100 + year_4 * 4 + year_1) +
YEAR_START; YEAR_START;
// 保存一年的天数
this_tm->tm_yday = total_day; this_tm->tm_yday = total_day;
// 剩下的天数为1年内的天数,直接计算月和日
// 根据当前是否为闰年设置二月偏移量是否为1
// 能被4整除且不被100整除或者能被400整除
// 闰年需要减去一天再计算
total_day -= february_offset; total_day -= february_offset;
// 使用二分法快速定位月份使用平年计算在月份确定到2月时再考虑闰年
// 判断是否在1-6月里面
// 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
if (total_day <= 181) { if (total_day <= 181) {
// 判断是否在1-3月里面
if (total_day <= 90) { if (total_day <= 90) {
// 判断是否在1-2月里面
if (total_day <= 59) { if (total_day <= 59) {
total_day += february_offset; // 去掉二月的偏置 total_day += february_offset;
if (total_day <= 31) { if (total_day <= 31) {
// 1月
temp = 0; temp = 0;
} else { } else {
total_day -= 31; total_day -= 31;
// 2月
temp = 1; temp = 1;
} }
} else { } else {
total_day -= 59; total_day -= 59;
// 3月
temp = 2; temp = 2;
} }
} else { } else {
// 4-6月
total_day -= 90; total_day -= 90;
// 是否在4月里面
if (total_day <= 30) { if (total_day <= 30) {
// 4月
temp = 3; temp = 3;
} else { } else {
// 5-6月
total_day -= 30; total_day -= 30;
if (total_day <= 31) { if (total_day <= 31) {
// 5月
temp = 4; temp = 4;
} else { } else {
total_day -= 31; total_day -= 31;
// 6月
temp = 5; temp = 5;
} }
} }
} }
} else { } else {
total_day -= 181; total_day -= 181;
// 判断是否在7-9月里面
if (total_day <= 92) { if (total_day <= 92) {
// 是否在7-8月
if (total_day <= 62) { if (total_day <= 62) {
if (total_day <= 31) { if (total_day <= 31) {
// 7月
temp = 6; temp = 6;
} else { } else {
total_day -= 31; total_day -= 31;
// 8月
temp = 7; temp = 7;
} }
} else { } else {
// 9月
total_day -= 62; total_day -= 62;
temp = 8; temp = 8;
} }
} else { } else {
// 10-12月
total_day -= 92; total_day -= 92;
// 是否在10-11月
if (total_day <= 61) { if (total_day <= 61) {
if (total_day <= 31) { if (total_day <= 31) {
// 10月
temp = 9; temp = 9;
} else { } else {
// 11 月
total_day -= 31; total_day -= 31;
temp = 10; temp = 10;
} }
} else { } else {
// 12月
total_day -= 61; total_day -= 61;
temp = 11; temp = 11;
} }
} }
} }
// 记录当前月份和天数 this_tm->tm_mon = temp;
this_tm->tm_mon = temp; // 月份 [0,11] this_tm->tm_mday = total_day;
this_tm->tm_mday = total_day; // 天数
// 利用额外秒数计算时-分-秒
temp = extra_second / 3600; temp = extra_second / 3600;
this_tm->tm_hour = temp; this_tm->tm_hour = temp;
extra_second = extra_second - temp * 3600; extra_second = extra_second - temp * 3600;
@ -371,70 +285,47 @@ status unix_time_to_utc_struct_time(_tm* this_tm, int64_t unix_time) {
this_tm->tm_sec = extra_second; this_tm->tm_sec = extra_second;
// 计算出当前日期的星期数
this_tm->tm_wday = time_get_week(this_tm); this_tm->tm_wday = time_get_week(this_tm);
// 夏令时不明
this_tm->tm_isdst = -1; this_tm->tm_isdst = -1;
} }
return TIME_OK; return TIME_OK;
} }
// 由标准UTC时间生成Unix时间戳
status utc_struct_time_to_unix_time(const _tm* this_tm, int64_t* unix_time) { status utc_struct_time_to_unix_time(const _tm* this_tm, int64_t* unix_time) {
int32_t total_day, total_leap_year, dyear; int32_t total_day, total_leap_year, dyear;
int february_offset; // 二月偏移量,零时变量 int february_offset;
// 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 // 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
// 每个月份对应前面所有月的天数
const int month_day[] = {0, 31, 59, 90, 120, 151, const int month_day[] = {0, 31, 59, 90, 120, 151,
181, 212, 243, 273, 304, 334}; 181, 212, 243, 273, 304, 334};
// 每天总秒数一定将UTC时间年月转换成天数
// 为了减少额外闰年判断把时间往前推到1600年即闰年最大的一次公倍数开始计算判断
// 1970-1600 = 370 年 370/4 -(370/100-1)=90 个闰年
// 1600 DAY_OFFSET 365*(1970-1600)+90 = 135140,7为修正天数
if (this_tm->tm_year < 1970) { if (this_tm->tm_year < 1970) {
// 暂不支持1970之前的时间
*unix_time = 0; *unix_time = 0;
return TIME_LESS_THAN_1970; return TIME_LESS_THAN_1970;
} }
if (this_tm->tm_year >= 3200) { if (this_tm->tm_year >= 3200) {
// 暂不支持3200及以后的时间
*unix_time = 0; *unix_time = 0;
return TIME_OVER_3200; return TIME_OVER_3200;
} }
// 计算总年数要去掉尾巴如年数20年那么实际应该4个闰年因为20这一年没有包含在里面
// 要减去一年来算闰年次数
// 先计算到相对1600年的天数再转换到1970年
dyear = this_tm->tm_year - YEAR_START - 1; dyear = this_tm->tm_year - YEAR_START - 1;
total_leap_year = dyear / 4 - (dyear / 100 - dyear / 400 - 1); total_leap_year = dyear / 4 - (dyear / 100 - dyear / 400 - 1);
// 恢复减去的一年
dyear += 1; dyear += 1;
total_day = dyear * 365 + total_leap_year; total_day = dyear * 365 + total_leap_year;
// 减去1970到1600的总天数
total_day -= DAY_OFFSET; total_day -= DAY_OFFSET;
// 增加月和日的总天数
// 判断是否是闰年
// 能被4整除且不被100整除或者能被400整除
if (((dyear % 4 == 0) && (dyear % 100 != 0)) || (dyear % 400 == 0)) { if (((dyear % 4 == 0) && (dyear % 100 != 0)) || (dyear % 400 == 0)) {
// 闰年
february_offset = 1; february_offset = 1;
} else { } else {
february_offset = 0; february_offset = 0;
} }
// 计算含月和日的总天数,日期要减去当天
total_day += month_day[this_tm->tm_mon] + this_tm->tm_mday - 1; total_day += month_day[this_tm->tm_mon] + this_tm->tm_mday - 1;
// 二月以上需要加上偏移量
if (this_tm->tm_mon > 1) { if (this_tm->tm_mon > 1) {
total_day += february_offset; total_day += february_offset;
} }
// 根据天数以及时分秒计算Unix时间戳
*unix_time = (int64_t)total_day * DAY_SECOND + this_tm->tm_hour * 3600 + *unix_time = (int64_t)total_day * DAY_SECOND + this_tm->tm_hour * 3600 +
this_tm->tm_min * 60 + this_tm->tm_sec; this_tm->tm_min * 60 + this_tm->tm_sec;
@ -450,41 +341,30 @@ void time_struct_format(const _tm* this_tm, char* str) {
this_tm->tm_wday, this_tm->tm_yday, this_tm->tm_isdst); this_tm->tm_wday, this_tm->tm_yday, this_tm->tm_isdst);
} }
// 标准库函数gmtime,将以自 epoch 开始的秒数表示的时间转换为 UTC 的 struct_time
void time_gmtime(pika_float unix_time, _tm* this_tm) { void time_gmtime(pika_float unix_time, _tm* this_tm) {
status res; status res;
// 转化时间
res = unix_time_to_utc_struct_time(this_tm, (int64_t)unix_time); res = unix_time_to_utc_struct_time(this_tm, (int64_t)unix_time);
if (res) { if (res) {
status_deal(res); // 异常情况处理 status_deal(res);
// 返回默认值
// note: 异常情况返回默认时间起始点
unix_time_to_utc_struct_time(this_tm, (int64_t)0); unix_time_to_utc_struct_time(this_tm, (int64_t)0);
} }
} }
// 标准库函数localtime,将以自 epoch 开始的秒数表示的时间转换为当地时间的
// struct_time // struct_time
void time_localtime(pika_float unix_time, _tm* this_tm, int locale) { void time_localtime(pika_float unix_time, _tm* this_tm, int locale) {
status res; status res;
int local_offset; int local_offset;
// 获取本地时间偏移量(小时)
local_offset = locale * 60 * 60; local_offset = locale * 60 * 60;
// 转化时间
res = unix_time_to_utc_struct_time(this_tm, res = unix_time_to_utc_struct_time(this_tm,
(int64_t)unix_time + local_offset); (int64_t)unix_time + local_offset);
if (res) { if (res) {
status_deal(res); // 异常情况处理 status_deal(res);
// 这里处理的策略和标准库不同标准库最初始的时间是1970-1-1,00:00:00对于不同时区来说其值是不一样的
// 但本函数是要求各时区的起始时间不超过1970-1-1,00:00:00实际上UTC时间可以更前可靠的最早时间可到1600年
// 对于西时区来说,时间会缺失
unix_time_to_utc_struct_time(this_tm, (int64_t)0); unix_time_to_utc_struct_time(this_tm, (int64_t)0);
} }
} }
// 检测结构体时间是否在合适的范围内,但不检查它的正确性
status time_check_struct_time(const _tm* this_tm) { status time_check_struct_time(const _tm* this_tm) {
if (this_tm->tm_sec < 0 || this_tm->tm_sec > 60) { if (this_tm->tm_sec < 0 || this_tm->tm_sec > 60) {
return TIME_ERROR_STRUCT_TIME; return TIME_ERROR_STRUCT_TIME;
@ -510,47 +390,33 @@ status time_check_struct_time(const _tm* this_tm) {
return TIME_OK; return TIME_OK;
} }
// 标准库函数mktime(t),将当地时间的
// struct_time转换为以自epoch开始的秒数表示的时间
int64_t time_mktime(const _tm* this_tm, int locale) { int64_t time_mktime(const _tm* this_tm, int locale) {
status res; status res;
int local_offset; int local_offset;
int64_t unix_time; int64_t unix_time;
// 获取本地时间偏移量(小时)
local_offset = locale * 60 * 60; local_offset = locale * 60 * 60;
// 检测时间结构体范围正确性
res = time_check_struct_time(this_tm); res = time_check_struct_time(this_tm);
if (res) { if (res) {
status_deal(res); status_deal(res);
return 0; return 0;
} // 异常情况返回时间零点 }
// 转化时间
res = utc_struct_time_to_unix_time(this_tm, &unix_time); res = utc_struct_time_to_unix_time(this_tm, &unix_time);
if (res) { if (res) {
status_deal(res); status_deal(res);
return 0; return 0;
} // 异常情况返回时间零点 }
// 减去本地偏移时间
// 可能出现负数,严格来说,这不影响什么!
unix_time -= local_offset; unix_time -= local_offset;
// 显示出来
// time_printf("%I64d\n",unix_time); // time_printf("%I64d\n",unix_time);
// 返回数据
return unix_time; return unix_time;
} }
// 标准库函数asctime()
// 把结构化时间struct_time元组表示为以下形式的字符串: `'Sun Jun 20 23:21:05
// 1993'`。
void time_asctime(const _tm* this_tm) { void time_asctime(const _tm* this_tm) {
// 星期缩写python标准库是三个字母这里并不相同
const char* week[] = {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"}; const char* week[] = {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"};
// 月份缩写
const char* month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", const char* month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec"}; "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"};
@ -616,9 +482,7 @@ void _time_gmtime(PikaObj* self, pika_float unix_time) {
char str[200]; char str[200];
time_gmtime(unix_time, &this_tm); time_gmtime(unix_time, &this_tm);
time_set_tm_value(self, &this_tm); time_set_tm_value(self, &this_tm);
// 格式化字符
time_struct_format(&this_tm, str); time_struct_format(&this_tm, str);
// 显示出来
time_printf("%s\n", str); time_printf("%s\n", str);
#endif #endif
} }
@ -634,9 +498,7 @@ void _time_localtime(PikaObj* self, pika_float unix_time) {
int locale = g_pika_local_timezone; int locale = g_pika_local_timezone;
time_localtime(unix_time, &this_tm, locale); time_localtime(unix_time, &this_tm, locale);
time_set_tm_value(self, &this_tm); time_set_tm_value(self, &this_tm);
// 格式化字符
time_struct_format(&this_tm, str); time_struct_format(&this_tm, str);
// 显示出来
time_printf("%s\n", str); time_printf("%s\n", str);
#endif #endif
} }

View File

@ -20,7 +20,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
#include "fastlz.h" #include "fastlz.h"
#include "PikaObj.h" #include "PikaObj.h"
#include <stdint.h> #include <stdint.h>

View File

@ -20,7 +20,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
#ifndef FASTLZ_H #ifndef FASTLZ_H
#define FASTLZ_H #define FASTLZ_H
@ -87,8 +86,8 @@ int fastlz_decompress(const void* input, int length, void* output, int maxout);
This is similar to fastlz_compress_level above, but with the level This is similar to fastlz_compress_level above, but with the level
automatically chosen. automatically chosen.
This function is deprecated and it will be completely removed in some future This function is deprecated and it will be completely removed in some
version. future version.
*/ */
int fastlz_compress(const void* input, int length, void* output); int fastlz_compress(const void* input, int length, void* output);

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE) #if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE)
TEST(PikaCV, test1) { TEST(PikaCV, test1) {
/* init */ /* init */

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE) #if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE)
TEST(PikaNN, test1) { TEST(PikaNN, test1) {

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if PIKA_SYNTAX_SLICE_ENABLE #if PIKA_SYNTAX_SLICE_ENABLE
TEST(ctypes, test1) { TEST(ctypes, test1) {
/* init */ /* init */

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if !PIKA_NANO_ENABLE #if !PIKA_NANO_ENABLE
TEST_RUN_SINGLE_FILE_PASS(json, loads, "test/python/json/json_loads.py") TEST_RUN_SINGLE_FILE_PASS(json, loads, "test/python/json/json_loads.py")

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if PIKA_POOL_ENABLE #if PIKA_POOL_ENABLE
TEST(bitmap, init) { TEST(bitmap, init) {
uint8_t* bitmap = bitmap_init(10); uint8_t* bitmap = bitmap_init(10);

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if PIKA_SYNTAX_IMPORT_EX_ENABLE #if PIKA_SYNTAX_IMPORT_EX_ENABLE
TEST(module, cmodule_import) { TEST(module, cmodule_import) {
/* init */ /* init */

View File

@ -3,8 +3,8 @@
* @Github: https://github.com/jiejieTop * @Github: https://github.com/jiejieTop
* @Date: 2019-12-11 21:53:07 * @Date: 2019-12-11 21:53:07
* @LastEditTime: 2020-06-08 20:38:41 * @LastEditTime: 2020-06-08 20:38:41
* @Description: the code belongs to jiejie, please keep the author information * @Description: the code belongs to jiejie, please keep the author
* and source code according to the license. * information and source code according to the license.
*/ */
#include "test_common.h" #include "test_common.h"
extern "C" { extern "C" {
@ -46,12 +46,14 @@ static const char* test_baidu_ca_crt = {
static void topic1_handler(void* client, message_data_t* msg) { static void topic1_handler(void* client, message_data_t* msg) {
(void)client; (void)client;
MQTT_LOG_I( MQTT_LOG_I(
"----------------------------------------------------------------------" "------------------------------------------------------------------"
"----"
"-------------"); "-------------");
MQTT_LOG_I("%s:%d %s()...\ntopic: %s\nmessage:%s", __FILE__, __LINE__, MQTT_LOG_I("%s:%d %s()...\ntopic: %s\nmessage:%s", __FILE__, __LINE__,
__FUNCTION__, msg->topic_name, (char*)msg->message->payload); __FUNCTION__, msg->topic_name, (char*)msg->message->payload);
MQTT_LOG_I( MQTT_LOG_I(
"----------------------------------------------------------------------" "------------------------------------------------------------------"
"----"
"-------------"); "-------------");
} }

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#include "PikaCompiler.h" #include "PikaCompiler.h"
// TEST(packtool, unpack) { // TEST(packtool, unpack) {

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if PIKA_GC_MARK_SWEEP_ENABLE #if PIKA_GC_MARK_SWEEP_ENABLE
TEST(pikaui, page) { TEST(pikaui, page) {

View File

@ -4,89 +4,406 @@ TEST_START
#if !PIKA_NANO_ENABLE #if !PIKA_NANO_ENABLE
TEST_RUN_SINGLE_FILE(thread, test2, "test/python/_thread/test2.py") TEST_RUN_SINGLE_FILE(thread, test2, "test/python/_thread/test2.py")
TEST_RUN_SINGLE_FILE(eventloop, test1, "test/python/eventloop/test1.py") TEST_RUN_SINGLE_FILE(eventloop, test1, "test/python/eventloop/test1.py")
TEST_RUN_SINGLE_FILE(eventloop, test2, "test/python/eventloop/test2.py") TEST_RUN_SINGLE_FILE(eventloop,
test2,
"test/python/"
"eventloop/"
"test2.py")
TEST_RUN_SINGLE_FILE(eventloop, test3, "test/python/eventloop/test3.py") TEST_RUN_SINGLE_FILE(eventloop, test3, "test/python/eventloop/test3.py")
TEST_RUN_SINGLE_FILE(eventloop, delay1, "test/python/eventloop/delay1.py") TEST_RUN_SINGLE_FILE(eventloop, delay1, "test/python/eventloop/delay1.py")
TEST_RUN_SINGLE_FILE(eventloop, once1, "test/python/eventloop/once1.py") TEST_RUN_SINGLE_FILE(eventloop,
TEST_RUN_SINGLE_FILE(eventloop, once2, "test/python/eventloop/once2.py") once1,
TEST_RUN_SINGLE_FILE(fsm, test1, "test/python/fsm/test1.py") "test/"
"python/"
"eventloop/"
"once1.py")
TEST_RUN_SINGLE_FILE(eventloop,
once2,
"test/python/eventloop/"
"once2.py")
TEST_RUN_SINGLE_FILE(fsm,
test1,
"test/"
"python/"
"fsm/"
"test1."
"py")
TEST_RUN_SINGLE_FILE_PASS(builtin, TEST_RUN_SINGLE_FILE_PASS(builtin,
list_tuple_equ, list_tuple_equ,
"test/python/builtins/list_tuple_equ.py") "test/python/builtins/list_tuple_equ.py")
TEST_RUN_SINGLE_FILE_PASS(builtin, TEST_RUN_SINGLE_FILE_PASS(builtin,
fn_default1, fn_default1,
"test/python/builtins/fn_default1.py") "te"
"st"
"/p"
"yt"
"ho"
"n/"
"bu"
"il"
"ti"
"ns"
"/f"
"n_"
"de"
"fa"
"ul"
"t1"
".p"
"y")
TEST_RUN_SINGLE_FILE_PASS(builtin, TEST_RUN_SINGLE_FILE_PASS(builtin,
fn_default_tuple, fn_default_tuple,
"test/python/builtins/fn_default_tuple.py") "test/python/builtins/fn_default_tuple.py")
TEST_RUN_SINGLE_FILE_PASS(builtin, max_min, "test/python/builtins/max_min.py") TEST_RUN_SINGLE_FILE_PASS(builtin,
TEST_RUN_SINGLE_FILE_PASS(builtin, split, "test/python/builtins/split.py") max_min,
"test"
"/pyt"
"hon/"
"buil"
"tins"
"/max"
"_min"
".py")
TEST_RUN_SINGLE_FILE_PASS(builtin,
split,
"test/"
"python/"
"builtins/"
"split.py")
TEST_RUN_LINES_EXCEPT_OUTPUT(builtin, TEST_RUN_LINES_EXCEPT_OUTPUT(builtin,
split_slice, split_slice,
"'test'.split('e')[0]", "'test'.split('e')[0]",
"'t'\r\n") "'t'\r\n")
TEST_RUN_LINES_EXCEPT_OUTPUT(builtin, TEST_RUN_LINES_EXCEPT_OUTPUT(builtin,
split_slice_1, split_slice_1,
"'test'.split('e')[1]", "'test'"
"'st'\r\n") ".split"
"('e')["
"1]",
"'st'"
"\r\n")
TEST_RUN_LINES_EXCEPT_OUTPUT(builtin, TEST_RUN_LINES_EXCEPT_OUTPUT(builtin,
replace_split_0, replace_split_0,
"'a b c d'.replace(' ', ',').split(',')[0]", "'a b c "
"d'.replace(' ', "
"',').split(',')["
"0]",
"'a'\r\n") "'a'\r\n")
TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(builtin, TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(builtin,
class_script, class_script,
"test/python/builtins/class_script.py", "test"
"Obj1.test\r\n") "/pyt"
"hon/"
"buil"
"tins"
"/cla"
"ss_"
"scri"
"pt."
"py",
"Obj1"
".tes"
"t\r"
"\n")
TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(builtin, TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(builtin,
class_hint, class_hint,
"test/python/builtins/class_hint.py", "test/"
"python/"
"builtins/"
"class_"
"hint.py",
"1\r\n") "1\r\n")
TEST_RUN_SINGLE_FILE_PASS(builtin, TEST_RUN_SINGLE_FILE_PASS(builtin,
isinstance, isinstance,
"test/python/builtins/isinstance.py") "tes"
TEST_RUN_SINGLE_FILE_PASS(builtin, getitem, "test/python/builtins/getitem.py") "t/"
TEST_RUN_SINGLE_FILE_PASS(lua, eval, "test/python/pika_lua/eval.py") "pyt"
TEST_RUN_SINGLE_FILE_PASS(lua, require, "test/python/pika_lua/require.py") "hon"
"/bu"
"ilt"
"ins"
"/is"
"ins"
"tan"
"ce."
"py")
TEST_RUN_SINGLE_FILE_PASS(builtin,
getitem,
"test/python/"
"builtins/"
"getitem.py")
TEST_RUN_SINGLE_FILE_PASS(lua,
eval,
"te"
"st"
"/p"
"yt"
"ho"
"n/"
"pi"
"ka"
"_l"
"ua"
"/e"
"va"
"l."
"p"
"y")
TEST_RUN_SINGLE_FILE_PASS(lua,
require,
"test/python/"
"pika_lua/"
"require.py")
TEST_RUN_LINES(vm, dot_issue, ".") TEST_RUN_LINES(vm, dot_issue, ".")
TEST_RUN_LINES(vm, char_issue1, "~") TEST_RUN_LINES(vm, char_issue1, "~")
TEST_RUN_LINES(vm, char_issue2, "/") TEST_RUN_LINES(vm, char_issue2, "/") TEST_RUN_LINES(vm, char_issue3, "%")
TEST_RUN_LINES(vm, char_issue3, "%") TEST_RUN_LINES(vm, char_issue4, "=") TEST_RUN_SINGLE_FILE(
TEST_RUN_LINES(vm, char_issue4, "=") vm,
TEST_RUN_SINGLE_FILE(vm, issue_star_dict,
issue_star_dict, "test/"
"test/python/issue/issue_star_dict.py") "python/"
TEST_RUN_SINGLE_FILE_PASS(vm, proxy2, "test/python/proxy/proxy2.py") "issue/"
TEST_RUN_LINES(vm, abs_none, "abs(None)") "issue_"
TEST_RUN_LINES(vm, abs_str, "abs('test')") "star_"
TEST_RUN_SINGLE_FILE_PASS(datastruct, "dict.py") TEST_RUN_SINGLE_FILE_PASS(vm,
circlequeue, proxy2,
"test/python/datastruct/circlequeue.py") "t"
"e"
"s"
"t"
"/"
"p"
"y"
"t"
"h"
"o"
"n"
"/"
"p"
"r"
"o"
"x"
"y"
"/"
"p"
"r"
"o"
"x"
"y"
"2"
"."
"p"
"y") TEST_RUN_LINES(vm,
abs_none,
"ab"
"s("
"No"
"ne"
")")
TEST_RUN_LINES(vm,
abs_str,
"ab"
"s("
"'t"
"es"
"t'"
")") TEST_RUN_SINGLE_FILE_PASS(datastruct,
circlequeue,
"test/python/datastruct/"
"circlequeue.py")
TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple, "(1,)", "(1,)\r\n") TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple, "(1,)", "(1,)\r\n")
TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple_str, "('test',)", "('test',)\r\n") TEST_RUN_LINES_EXCEPT_OUTPUT(
TEST_RUN_SINGLE_FILE_PASS(vm, is_not, "test/python/builtins/is_not.py") vm,
TEST_RUN_LINES(vm, single_tuple_str,
var_global, "('test',)",
"import PikaStdLib\n" "('test',)"
"mem = PikaStdLib.MemChecker()\n" "\r\n") TEST_RUN_SINGLE_FILE_PASS(vm,
"mem.clear\n") is_not,
TEST_RUN_LINES(vm, "test"
var_global_run, "/pyt"
"import PikaStdLib\n" "hon/"
"mem = PikaStdLib.MemChecker()\n" "buil"
"mem.clear()\n") "tins"
TEST_RUN_LINES(vm, "/"
var_global_module, "is_"
"import configparser\n" "not."
"configparser.clear\n") "py")
TEST_RUN_LINES(vm, import_void, "import \n") TEST_RUN_LINES(vm,
TEST_RUN_SINGLE_FILE_PASS(vm, fn_fn, "test/python/builtins/fn_fn.py") var_global,
TEST_RUN_LINES_EXCEPT_OUTPUT(vm, isinstance, "isinstance(1, int)\n", "True\r\n") "im"
TEST_RUN_SINGLE_FILE_PASS(except, "po"
try_while_return, "rt"
"test/python/except/try_while_return.py"); " P"
"ik"
"aS"
"td"
"Li"
"b"
"\n"
"me"
"m "
"= "
"Pi"
"ka"
"St"
"dL"
"ib"
"."
"Me"
"mC"
"he"
"ck"
"er"
"()"
"\n"
"me"
"m."
"cl"
"ea"
"r"
"\n") TEST_RUN_LINES(vm,
var_global_run,
"i"
"m"
"p"
"o"
"r"
"t"
" "
"P"
"i"
"k"
"a"
"S"
"t"
"d"
"L"
"i"
"b"
"\n"
"m"
"e"
"m"
" "
"="
" "
"P"
"i"
"k"
"a"
"S"
"t"
"d"
"L"
"i"
"b"
"."
"M"
"e"
"m"
"C"
"h"
"e"
"c"
"k"
"e"
"r"
"("
")"
"\n"
"m"
"e"
"m"
"."
"c"
"l"
"e"
"a"
"r"
"("
")"
"\n")
TEST_RUN_LINES(vm,
var_global_module,
"im"
"po"
"rt"
" c"
"on"
"fi"
"gp"
"ar"
"se"
"r"
"\n"
"co"
"nf"
"ig"
"pa"
"rs"
"er"
".c"
"le"
"ar"
"\n") TEST_RUN_LINES(vm,
import_void,
"i"
"m"
"p"
"o"
"r"
"t"
" "
"\n")
TEST_RUN_SINGLE_FILE_PASS(vm,
fn_fn,
"test/"
"python"
"/built"
"ins/"
"fn_fn."
"py")
TEST_RUN_LINES_EXCEPT_OUTPUT(vm,
isinstance,
"is"
"in"
"st"
"an"
"ce"
"(1"
", "
"in"
"t)"
"\n",
"Tr"
"ue"
"\r"
"\n")
TEST_RUN_SINGLE_FILE_PASS(except,
try_while_return,
"te"
"st"
"/p"
"yt"
"ho"
"n/"
"ex"
"ce"
"pt"
"/t"
"ry"
"_w"
"hi"
"le"
"_r"
"et"
"ur"
"n."
"p"
"y");
TEST_RUN_SINGLE_FILE_PASS(except, TEST_RUN_SINGLE_FILE_PASS(except,
isinstance, isinstance,
"test/python/except/except_isinstance.py"); "test/python/except/except_isinstance.py");

View File

@ -10,7 +10,6 @@
*/ */
extern "C" { extern "C" {
#include "../pikascript-lib/requests/webclient.h" #include "../pikascript-lib/requests/webclient.h"
#define GET_HEADER_BUFSZ 1024 #define GET_HEADER_BUFSZ 1024
@ -18,8 +17,8 @@ extern "C" {
#define GET_LOCAL_URI "http://www.rt-thread.com/service/rt-thread.txt" #define GET_LOCAL_URI "http://www.rt-thread.com/service/rt-thread.txt"
/* send HTTP GET request by common request interface, it used to receive longer /* send HTTP GET request by common request interface, it used to receive
* data */ * longer data */
static int webclient_get_comm(const char* uri) { static int webclient_get_comm(const char* uri) {
struct webclient_session* session = RT_NULL; struct webclient_session* session = RT_NULL;
unsigned char* buffer = RT_NULL; unsigned char* buffer = RT_NULL;
@ -175,7 +174,8 @@ int webclient_get_test(int argc, char** argv) {
} else { } else {
rt_kprintf("web_get_test [URI] - webclient GET request test.\n"); rt_kprintf("web_get_test [URI] - webclient GET request test.\n");
rt_kprintf( rt_kprintf(
"web_get_test -s [URI] - webclient simplify GET request test.\n"); "web_get_test -s [URI] - webclient simplify GET request "
"test.\n");
return -RT_ERROR; return -RT_ERROR;
} }

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if PIKA_SYNTAX_SLICE_ENABLE #if PIKA_SYNTAX_SLICE_ENABLE
TEST(stddata, test1) { TEST(stddata, test1) {
/* init */ /* init */

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
TEST_START TEST_START
#if PIKA_SYNTAX_FORMAT_ENABLE #if PIKA_SYNTAX_FORMAT_ENABLE
TEST(string, cformat) { TEST(string, cformat) {
/* init */ /* init */

View File

@ -4,25 +4,25 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "BaseObj.h" #include "BaseObj.h"

View File

@ -4,27 +4,26 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -4,25 +4,25 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "PikaCompiler.h" #include "PikaCompiler.h"
#include "BaseObj.h" #include "BaseObj.h"
@ -311,8 +311,7 @@ int LibObj_staticLinkFile_New(LibObj* self, char* input_file_name, char* path) {
pika_platform_printf("error: can't open file %s\r\n", input_file_name); pika_platform_printf("error: can't open file %s\r\n", input_file_name);
return -1; return -1;
} }
char* module_name = strsGetLastToken( char* module_name = strsGetLastToken(&buffs, input_file_name, '/');
&buffs, input_file_name, '/'); /*找到最后一个 / 出现的位置的下一个地址*/
size_t module_name_len = strlen(module_name); size_t module_name_len = strlen(module_name);
@ -437,10 +436,6 @@ static int32_t __foreach_handler_selectBlockSize(Arg* argEach,
return 0; return 0;
} }
/* 这里包括文件内容大小,文件信息所占的大小(文件名和文件大小)
* unit Namelen4 bytes+ Name (strlen("namelen") + 1) \
* + fileSize (4 bytes)
*/
static int32_t __foreach_handler_libSumSize(Arg* argEach, PikaLinker* linker) { static int32_t __foreach_handler_libSumSize(Arg* argEach, PikaLinker* linker) {
if (arg_isObject(argEach)) { if (arg_isObject(argEach)) {
PikaObj* module_obj = arg_getPtr(argEach); PikaObj* module_obj = arg_getPtr(argEach);
@ -566,14 +561,10 @@ static PIKA_RES _loadModuleDataWithIndex(uint8_t* library_bytes,
char** name_p, char** name_p,
uint8_t** addr_p, uint8_t** addr_p,
size_t* size) { size_t* size) {
/*两个指针,一个指向文件信息部分,一个指向文件内容部分 */ uint32_t block_size = *(uint32_t*)(library_bytes + 4 * sizeof(uint32_t));
uint32_t block_size =
*(uint32_t*)(library_bytes +
4 * sizeof(uint32_t)); /* 每个文件信息大小的总和 */
uint8_t* file_info_block_start = library_bytes + block_size; uint8_t* file_info_block_start = library_bytes + block_size;
uint8_t* bytecode_ptr = file_info_block_start + block_size * module_num; uint8_t* bytecode_ptr = file_info_block_start + block_size * module_num;
uint8_t* bytecode_ptr_next = bytecode_ptr; uint8_t* bytecode_ptr_next = bytecode_ptr;
/* 每一个模块的信息 */
uint32_t module_size = 0; uint32_t module_size = 0;
char* module_name = NULL; char* module_name = NULL;
uintptr_t offset = 0; uintptr_t offset = 0;
@ -624,8 +615,7 @@ PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
size_t size = 0; size_t size = 0;
_loadModuleDataWithIndex(library_bytes, module_num, i, &name, &addr, _loadModuleDataWithIndex(library_bytes, module_num, i, &name, &addr,
&size); &size);
name = strsGetLastToken(&buffs, name, name = strsGetLastToken(&buffs, name, '/');
'/'); /*找到最后一个 / 出现的位置的下一个地址*/
if (strEqu(module_name, name)) { if (strEqu(module_name, name)) {
*addr_p = addr; *addr_p = addr;
@ -638,16 +628,6 @@ PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
return PIKA_RES_ERR_ARG_NO_FOUND; return PIKA_RES_ERR_ARG_NO_FOUND;
} }
/**
* @brief .pack Arg pack library_bytes
*
* @param
* @param char* pack_name pack
* @return Arg* arg, a pointer to an Arg object, which point to the
* library_bytes of the pack file.
* @note
*
*/
Arg* _getPack_libraryBytes(char* pack_name) { Arg* _getPack_libraryBytes(char* pack_name) {
if (NULL == pack_name) { if (NULL == pack_name) {
pika_platform_printf( pika_platform_printf(
@ -728,7 +708,7 @@ int LibObj_loadLibraryFile(LibObj* self, char* lib_file_name) {
*/ */
PIKA_RES pikafs_unpack_files(char* pack_name, char* out_path) { PIKA_RES pikafs_unpack_files(char* pack_name, char* out_path) {
PIKA_RES stat = PIKA_RES_OK; PIKA_RES stat = PIKA_RES_OK;
Arg* file_arg = NULL; /* file_arg 存在的意义就是获取文件的 library_bytes*/ Arg* file_arg = NULL;
uint8_t* library_bytes = NULL; uint8_t* library_bytes = NULL;
pikafs_FILE* fptr = NULL; pikafs_FILE* fptr = NULL;
if (NULL == out_path) { if (NULL == out_path) {
@ -758,8 +738,7 @@ PIKA_RES pikafs_unpack_files(char* pack_name, char* out_path) {
size = 0; size = 0;
stat = _loadModuleDataWithIndex(library_bytes, module_num, i, &name, stat = _loadModuleDataWithIndex(library_bytes, module_num, i, &name,
&addr, &size); &addr, &size);
name = strsGetLastToken(&buffs, name, name = strsGetLastToken(&buffs, name, '/');
'/'); /*找到最后一个 / 出现的位置的下一个地址*/
output_file_path = strsPathJoin(&buffs, out_path, name); output_file_path = strsPathJoin(&buffs, out_path, name);
pika_platform_printf("output_file_path: %s\r\n", output_file_path); pika_platform_printf("output_file_path: %s\r\n", output_file_path);
new_fp = pika_platform_fopen(output_file_path, "wb+"); new_fp = pika_platform_fopen(output_file_path, "wb+");
@ -1189,7 +1168,7 @@ PIKA_RES pikaMaker_linkRaw(PikaMaker* self, char* file_path) {
PIKA_RES pikaMaker_linkRaw_New(PikaMaker* self, PIKA_RES pikaMaker_linkRaw_New(PikaMaker* self,
char* file_path, char* file_path,
char* pack_path) { char* pack_path) {
LibObj* lib = obj_getPtr(self, "lib"); /* self 下面的lib 对象 */ LibObj* lib = obj_getPtr(self, "lib");
PIKA_RES ret = LibObj_staticLinkFile_New(lib, file_path, pack_path); PIKA_RES ret = LibObj_staticLinkFile_New(lib, file_path, pack_path);
return ret; return ret;
} }
@ -1203,22 +1182,22 @@ PIKA_RES pikaMaker_linkRaw_New(PikaMaker* self,
pikafs_FILE* pikafs_fopen(char* file_name, char* mode) { pikafs_FILE* pikafs_fopen(char* file_name, char* mode) {
pikafs_FILE* f = (pikafs_FILE*)pikaMalloc(sizeof(pikafs_FILE)); pikafs_FILE* f = (pikafs_FILE*)pikaMalloc(sizeof(pikafs_FILE));
if (NULL == f) { if (NULL == f) {
return NULL; // 避免空指针 return NULL;
} }
memset(f, 0, sizeof(pikafs_FILE)); memset(f, 0, sizeof(pikafs_FILE));
extern volatile PikaObj* __pikaMain; extern volatile PikaObj* __pikaMain;
uint8_t* library_bytes = obj_getPtr((PikaObj*)__pikaMain, "@libraw"); uint8_t* library_bytes = obj_getPtr((PikaObj*)__pikaMain, "@libraw");
if (NULL == library_bytes) { if (NULL == library_bytes) {
goto __error; // 如果library_bytes为NULL则跳转到__error goto __error;
} }
if (PIKA_RES_OK != if (PIKA_RES_OK !=
_loadModuleDataWithName(library_bytes, file_name, &f->addr, &f->size)) { _loadModuleDataWithName(library_bytes, file_name, &f->addr, &f->size)) {
goto __error; // 如果_loadModuleDataWithName的结果不是PIKA_RES_OK则跳转到__error goto __error;
} }
return f; return f;
__error: __error:
pikaFree(f, sizeof(pikafs_FILE)); // 释放内存 pikaFree(f, sizeof(pikafs_FILE));
return NULL; return NULL;
} }
@ -1249,8 +1228,7 @@ pikafs_FILE* pikafs_fopen_pack(char* pack_name, char* file_name) {
} }
f->farg = file_arg; f->farg = file_arg;
// arg_deinit(file_arg); /* file_arg 被释放以后library_bytes // arg_deinit(file_arg); /* file_arg
// 就是个野指针了 */
return f; return f;
__exit: __exit:

View File

@ -4,26 +4,26 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* Copyright (c) 2023 Gorgon Meducer embedded_zhuroan@hotmail.com * Copyright (c) 2023 Gorgon Meducer embedded_zhuroan@hotmail.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "PikaObj.h" #include "PikaObj.h"
@ -677,8 +677,6 @@ PikaObj* newNormalObj(NewFun newObjFun) {
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL) #define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL)
// 函数set_disp_mode用于控制是否开启输入回显功能
// 如果option为0则关闭回显为1则打开回显
static int set_disp_mode(int fd, int option) { static int set_disp_mode(int fd, int option) {
int err; int err;
struct termios term; struct termios term;
@ -707,14 +705,14 @@ struct termios original_termios;
static void enable_raw_mode(void) { static void enable_raw_mode(void) {
struct termios raw; struct termios raw;
tcgetattr(STDIN_FILENO, &original_termios); // 获取当前终端属性 tcgetattr(STDIN_FILENO, &original_termios);
raw = original_termios; raw = original_termios;
raw.c_lflag &= ~(ECHO | ICANON); // 禁用回显和规范模式 raw.c_lflag &= ~(ECHO | ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw); // 设置终端属性 tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
} }
static void disable_raw_mode(void) { static void disable_raw_mode(void) {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &original_termios); // 恢复原始终端属性 tcsetattr(STDIN_FILENO, TCSAFLUSH, &original_termios);
printf("\n"); printf("\n");
} }
@ -743,10 +741,9 @@ PikaObj* newRootObj(char* name, NewFun newObjFun) {
mem_pool_init(); mem_pool_init();
#endif #endif
#ifdef __linux #ifdef __linux
signal(SIGINT, signal_handler); // 捕获 SIGINT 信号Ctrl+C signal(SIGTERM, signal_handler);
signal(SIGTERM, signal_handler); // 捕获 SIGTERM 信号 signal(SIGHUP, signal_handler);
signal(SIGHUP, signal_handler); // 捕获 SIGHUP 信号 signal(SIGSEGV, signal_handler);
signal(SIGSEGV, signal_handler); // 捕获 SIGHUP 信号
signal(SIGABRT, signal_handler); signal(SIGABRT, signal_handler);
signal(SIGQUIT, signal_handler); signal(SIGQUIT, signal_handler);
signal(SIGTRAP, signal_handler); signal(SIGTRAP, signal_handler);

View File

@ -4,26 +4,26 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* Copyright (c) 2023 Gorgon Meducer embedded_zhuroan@hotmail.com * Copyright (c) 2023 Gorgon Meducer embedded_zhuroan@hotmail.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include <stdint.h> #include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -434,8 +434,8 @@ Arg* obj_newObjInPackage(NewFun newObjFun);
* arguments (of type Arg*) to it. */ * arguments (of type Arg*) to it. */
PikaObj* _pika_tuple_new(int num_args, ...); PikaObj* _pika_tuple_new(int num_args, ...);
/* A helper function to create a new list PikaObj and append the given arguments /* A helper function to create a new list PikaObj and append the given
* (of type Arg*) to it. */ * arguments (of type Arg*) to it. */
PikaObj* _pika_list_new(int num_args, ...); PikaObj* _pika_list_new(int num_args, ...);
PikaObj* _pika_dict_new(int num_args, ...); PikaObj* _pika_dict_new(int num_args, ...);
@ -449,7 +449,8 @@ PikaObj* _pika_dict_new(int num_args, ...);
#define objList_new(...) \ #define objList_new(...) \
_pika_list_new(sizeof((Arg*[]){__VA_ARGS__}) / sizeof(Arg*), __VA_ARGS__) _pika_list_new(sizeof((Arg*[]){__VA_ARGS__}) / sizeof(Arg*), __VA_ARGS__)
/* Macro to create a new dict PikaObj with the given arguments (of type Arg*). /* Macro to create a new dict PikaObj with the given arguments (of type
* Arg*).
*/ */
#define objDict_new(...) \ #define objDict_new(...) \

View File

@ -4,25 +4,25 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "PikaParser.h" #include "PikaParser.h"

View File

@ -4,25 +4,25 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -1,28 +1,28 @@
/* /*
* This file is part of the PikaPython project. * This file is part of the PikaPython project.
* http://github.com/pikastech/pikapython * http://github.com/pikastech/pikapython
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "PikaPlatform.h" #include "PikaPlatform.h"

View File

@ -1,28 +1,28 @@
/* /*
* This file is part of the PikaPython project. * This file is part of the PikaPython project.
* http://github.com/pikastech/pikapython * http://github.com/pikastech/pikapython
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -143,9 +143,8 @@ typedef enum {
/* /*
[Note]: [Note]:
Create a pika_config.c to override the following weak functions to config Create a pika_config.c to override the following weak functions to
PikaScript. [Example]: config PikaScript. [Example]: 1.
1.
https://gitee.com/Lyon1998/pikascript/blob/master/package/STM32G030Booter/pika_config.c https://gitee.com/Lyon1998/pikascript/blob/master/package/STM32G030Booter/pika_config.c
2. 2.
https://gitee.com/Lyon1998/pikascript/blob/master/package/pikaRTBooter/pika_config.c https://gitee.com/Lyon1998/pikascript/blob/master/package/pikaRTBooter/pika_config.c

View File

@ -4,25 +4,25 @@
* *
* MIT License * MIT License
* *
* Copyright (c) 2021 lyon liang6516@outlook.com * Copyright (c) 2021 lyon liang6516@outlook.com
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a
* of this software and associated documentation files (the "Software"), to deal * copy of this software and associated documentation files (the "Software"),
* in the Software without restriction, including without limitation the rights * to deal in the Software without restriction, including without limitation
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* copies of the Software, and to permit persons to whom the Software is * and/or sell copies of the Software, and to permit persons to whom the
* furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "PikaVM.h" #include "PikaVM.h"

Some files were not shown because too many files have changed in this diff Show More