Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bec5345
refactor: 避免未对齐访问
Ryan-CW-Code Dec 25, 2025
c8d8140
refactor: 手动实现访问非对其指针
Ryan-CW-Code Dec 25, 2025
9c9d896
refactor: 优化json存储结构
Ryan-CW-Code Jan 6, 2026
aa5fb75
refactor: 优化函数命名
Ryan-CW-Code Jan 6, 2026
9111db2
fix: inline模式chang修复并补充测试例程
Ryan-CW-Code Jan 6, 2026
4d15c73
feat: 兼容大端环境
Ryan-CW-Code Jan 6, 2026
40e7db5
test: 补充更多示例
Ryan-CW-Code Jan 6, 2026
938076d
test: 补充测试描述
Ryan-CW-Code Jan 6, 2026
e7a1efd
doc: 完善readme
Ryan-CW-Code Jan 6, 2026
0b97df2
refactor: 完善模糊测试覆盖率
Ryan-CW-Code Jan 6, 2026
14b3f07
refactor: 优化print double的实现
Ryan-CW-Code Jan 7, 2026
1141052
style: 整理目录
Ryan-CW-Code Jan 7, 2026
c02b973
test: 优化测试代码
Ryan-CW-Code Jan 7, 2026
a0c0742
refactor: RyanJsonCompareDouble 开放出来
Ryan-CW-Code Jan 7, 2026
3db45e2
refactor: 优化double打印实现
Ryan-CW-Code Jan 7, 2026
93dbbdd
test: 完善jsonUtils模糊测试覆盖率
Ryan-CW-Code Jan 7, 2026
92a59cf
test: 增加数据解析一致性测试,优化测试代码
Ryan-CW-Code Jan 7, 2026
65dff5d
refactor: 优化double打印
Ryan-CW-Code Jan 8, 2026
94cbf58
refactor: 撤回double解析共用的函数
Ryan-CW-Code Jan 8, 2026
83b338e
test: 优化测试代码
Ryan-CW-Code Jan 8, 2026
06ea8f8
refactor: 再次整合double的解析和打印
Ryan-CW-Code Jan 8, 2026
5a68fc1
refactor: 优化嵌入式平台打印Double
Ryan-CW-Code Jan 8, 2026
0cb3edc
doc: 更新readme
Ryan-CW-Code Jan 8, 2026
b8b98ca
refactor: 优化double打印实现
Ryan-CW-Code Jan 11, 2026
10593b6
test: 拆分fuzzer测试文件,更新字典
Ryan-CW-Code Jan 11, 2026
cbda13f
test: 优化部分测试代码
Ryan-CW-Code Jan 12, 2026
b63328e
doc: 更新readme
Ryan-CW-Code Jan 12, 2026
890e29f
feat: 消除递归代码,规范化测试(单元测试、模糊测试),qemu模拟测试更符合真实硬件环境,增加skills
Ryan-CW-Code Feb 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions .agent/rules/gemini.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
trigger: always_on
---

对RyanJson核心代码使用最严格的审查,其余代码审查可以不那么严格
始终考虑嵌入式约束,有限的RAM和ROM,资源利用效率
优化内存管理,保证高效和实时性
关注模块解耦和可维护性
检查 RTOS 环境下的线程安全问题
代码风格一致性
240 changes: 134 additions & 106 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,149 +1,185 @@
# SPDX-License-Identifier: Apache-2.0
#
# Note: The list of ForEachMacros can be obtained using:
#
# git grep -h '^#define [^[:space:]]*FOR_EACH[^[:space:]]*(' include/ \
# | sed "s,^#define \([^[:space:]]*FOR_EACH[^[:space:]]*\)(.*$, - '\1'," \
# | sort | uniq
#
# References:
# - https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# RyanJson clang-format 基线配置
# 说明:
# - 注释尽量覆盖每个配置项,便于长期维护
# - 以 LLVM 为基线,只覆盖项目明确约束
# - 参考:https://clang.llvm.org/docs/ClangFormatStyleOptions.html

---
# 基于 LLVM 的代码风格作为起点,随后覆盖指定字段
# 基础风格模板:以 LLVM 为起点
BasedOnStyle: LLVM

# 连续宏定义的对齐方式
# Enabled: true -> 启用对齐连续宏定义
# AcrossComments: true -> 跨注释也会对齐,适合一组宏中间穿插注释的情况
AlignConsecutiveMacros:
Enabled: true
AcrossComments: true
# 单行最大宽度:超过后自动换行
ColumnLimit: 140

# 是否允许短代码块(如 { ... })出现在单行
AllowShortBlocksOnASingleLine: true
# 基础缩进宽度(单位:列)
IndentWidth: 8

# 是否允许短 case 标签单行
# true -> 允许 `case X: doSomething();`
AllowShortCaseLabelsOnASingleLine: true
# Tab 显示宽度(单位:列)
TabWidth: 8

# 是否允许短枚举在一行
# true -> 允许短枚举如 `enum { A, B };`
AllowShortEnumsOnASingleLine: false
# 续行缩进宽度(函数参数折行、表达式折行等)
ContinuationIndentWidth: 8

# 是否允许短函数在单行
AllowShortFunctionsOnASingleLine: true
# 构造函数初始化列表缩进宽度(主要影响 C++,保留统一)
ConstructorInitializerIndentWidth: 8

AllowShortCaseExpressionOnASingleLine: true
# Tab 使用策略:缩进和续行使用 Tab
UseTab: ForContinuationAndIndentation

# 短 if 语句单行显示策略
# Always -> 允许并尽可能保留短 if 语句为单行(包括带 else 的情况)
# 你希望单行 + 大括号时使用这个选项
AllowShortIfStatementsOnASingleLine: true
# 注释重排:false 表示不自动重排注释文本
ReflowComments: false

# 是否允许短循环(for/while)单行显示
AllowShortLoopsOnASingleLine: true
# 是否允许短代码块单行(如 { return; })
AllowShortBlocksOnASingleLine: Always

# 属性宏列表,列出在格式化时应视为属性的宏(影响对齐、换行等)
# 如果代码库使用自定义属性宏,把它们列在这里可以提升格式化准确性
AttributeMacros:
- __aligned
- __deprecated
- __packed
- __printf_like
- __syscall
- __syscall_always_inline
- __subsystem
# 是否允许短函数单行
AllowShortFunctionsOnASingleLine: false

# 位字段冒号后的空格:After 表示 `int x : 3;` 中冒号后带一个空格(风格选择)
BitFieldColonSpacing: After
# 是否允许短 if 单行
AllowShortIfStatementsOnASingleLine: WithoutElse

# 是否允许短循环单行
AllowShortLoopsOnASingleLine: false

# 大括号换行策略:使用 Custom 配合 BraceWrapping 指定细节
# 你用了 Custom,这意味着下面的 BraceWrapping 字段决定具体行为
# 是否允许短 case 标签单行
AllowShortCaseLabelsOnASingleLine: true

# 是否允许短 case 表达式单行
AllowShortCaseExpressionOnASingleLine: true

# 是否允许短枚举单行
AllowShortEnumsOnASingleLine: false

# 花括号总策略:自定义
BreakBeforeBraces: Custom

# case 标签后的大括号是否换行
BraceWrapping:
AfterCaseLabel: false # case 标签后不另起行放 {,通常 case: 仍和语句对齐
AfterClass: true # class 后大括号另起行
AfterControlStatement: Always # 控制语句(if/for/while)后通常将 { 放在新行(可被覆盖)
AfterEnum: true # enum 后另起行
AfterCaseLabel: false

# class 后的大括号是否换行
AfterClass: true

# 控制语句(if/for/while)后的大括号换行策略
AfterControlStatement: Always

# enum 后的大括号是否换行
AfterEnum: true

# extern block 后的大括号是否换行
AfterExternBlock: false
AfterFunction: true # 函数体大括号另起行

# 函数定义后的大括号是否换行
AfterFunction: true

# namespace 后的大括号是否换行
AfterNamespace: true

# ObjC 声明后的大括号是否换行
AfterObjCDeclaration: true

# struct 后的大括号是否换行
AfterStruct: true

# union 后的大括号是否换行
AfterUnion: false

# catch 前是否换行
BeforeCatch: true

# else 前是否换行
BeforeElse: true

# lambda 体前是否换行
BeforeLambdaBody: false

# do...while 中 while 前是否换行
BeforeWhile: false
IndentBraces: false # 不单独缩进大括号行

# 大括号行本身是否额外缩进
IndentBraces: false

# 空函数是否分裂成多行
SplitEmptyFunction: true

# 空记录(如空 struct)是否分裂成多行
SplitEmptyRecord: true

# 空命名空间是否分裂成多行
SplitEmptyNamespace: true

# 单行代码的最大列数(换行阈值)
ColumnLimit: 140
# switch 内 case 标签是否额外缩进
IndentCaseLabels: false

# 构造函数初始化列表的缩进宽度(可针对长列表调整可读性)
ConstructorInitializerIndentWidth: 8
# goto 标签是否额外缩进
IndentGotoLabels: false

# 折行缩进宽度(续行缩进
ContinuationIndentWidth: 8
# 是否强制插入花括号(单语句控制流也加花括号
InsertBraces: true

# ForEach 宏列表:告诉 clang-format 哪些宏应当当作循环处理(便于格式化块体)
ForEachMacros:
- "ARRAY_FOR_EACH"
- "ARRAY_FOR_EACH_PTR"
- "FOR_EACH"
# 文件末尾是否补换行
InsertNewlineAtEOF: true

# If 宏列表:把 CHECKIF 等宏视为 if 语句(影响括号和后续块处理)
IfMacros:
- "CHECKIF"
# 位域冒号前后空格策略
BitFieldColonSpacing: After

# 控制语句括号前空格策略(if (x))
SpaceBeforeParens: ControlStatementsExceptControlMacros

# 继承冒号前空格策略(主要影响 C++)
SpaceBeforeInheritanceColon: false

# include 文件的分类和排序优先级
# Regex: 正则匹配,Priority: 数字越小优先级越高(越先放)
# 连续宏定义对齐策略
AlignConsecutiveMacros:
# 是否启用连续宏对齐
Enabled: true

# 是否跨注释继续对齐
AcrossComments: true

# include 是否自动排序(Never 表示保持人工顺序)
SortIncludes: Never

# include 分类规则(数值越小优先级越高)
IncludeCategories:
# 项目内双引号头文件
- Regex: '^".*\.h"$'
Priority: 0

# C 标准库头文件
- Regex: '^<(assert|complex|ctype|errno|fenv|float|inttypes|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdint|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h>$'
Priority: 1
- Regex: '^\<Ryan/.*\.h\>$'

# Ryan 体系头文件
- Regex: '^<Ryan/.*\.h>$'
Priority: 2

# 兜底分类
- Regex: ".*"
Priority: 3

# case 标签是否缩进(true 会将 case 缩进到 switch 中)
# false -> case 与 switch 对齐(你原先设置 false)
IndentCaseLabels: false

# goto 标签是否缩进(false 表示标签在行首)
IndentGotoLabels: false

# 缩进宽度(通常与制表符策略配合使用)
IndentWidth: 8

# 自动插入大括号(即使单语句也插入 { })
# 这可以避免单行语句因为后续添加语句而引入 bug
InsertBraces: true

# 文件末尾自动插入换行
InsertNewlineAtEOF: true

# 继承冒号前是否加空格(False 表示不加空格:"class A: public B")
SpaceBeforeInheritanceColon: False

# 控制语句后是否加空格(这个值控制 if/for/while 等的格式)
# ControlStatementsExceptControlMacros -> 控制语句(非宏)前加空格:`if (cond)` 而非 `if(cond)`
SpaceBeforeParens: ControlStatementsExceptControlMacros
# 视为 foreach 语义的宏列表(用于正确缩进与换行)
ForEachMacros:
- RyanJsonArrayForEach
- RyanJsonObjectForEach

# 包含文件是否自动排序(Never 表示不排序)
SortIncludes: Never
# 视为 if 语义的宏列表
IfMacros:
- CHECKIF

# 缩进与续行使用制表符策略
# ForContinuationAndIndentation -> 续行与缩进使用制表符,其他空格仍按规则
UseTab: ForContinuationAndIndentation
# 视为属性的宏列表(影响断行与对齐)
AttributeMacros:
- __aligned
- __deprecated
- __packed
- __printf_like
- __syscall
- __syscall_always_inline
- __subsystem

# 对空白敏感的宏列表(多用于预处理器宏展开格式保持)
# 空白敏感宏:保持参数空格布局,避免被格式化破坏
WhitespaceSensitiveMacros:
- COND_CODE_0
- COND_CODE_1
Expand All @@ -153,11 +189,3 @@ WhitespaceSensitiveMacros:
- STRINGIFY
- Z_STRINGIFY
- DT_FOREACH_PROP_ELEM_SEP

# --------------------------
# 可选:降低 clang-format 拆行惩罚,使其更倾向于保留短 if/else 单行
# 下面两个值可以帮助把格式化后的多行 if/else 更可能压缩成单行(仅在 AllowShortIfStatementsOnASingleLine: Always 有效时可用)
# PenaltyBreakIfElse: 0
# PenaltyBreakStatement: 0

# 注:上面的 Penalty 设置是可选的,如果你发现 clang-format 依旧不把某些 if/else 压成单行,可以取消注释并试验效果。
12 changes: 10 additions & 2 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# 忽略外部包
externalModule/*
# 第三方代码:不做本仓风格重排,避免升级/同步时产生大 diff
/test/externalModule/**

# 生成目录:格式化无意义
/build/**
/.xmake/**
/coverage/**

# Fuzz 语料:不是源码
/test/fuzzer/corpus/**
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
# Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner'

Checks:
- "-*,clang-diagnostic-*,clang-analyzer-*,llvm-*,concurrency-*,performance-*,cert-*"
- "-*,clang-diagnostic-*,clang-analyzer-*,concurrency-*,performance-*,cert-*"
# 静默的窄化转换交给编译器来判断?
- 'llvm-*,-llvm-include-order'
- 'bugprone-*,-bugprone-easily-swappable-parameters'
- 'readability-identifier-naming'
- 'misc-*,-misc-const-correctness,-misc-no-recursion,-misc-include-cleaner'
Expand Down
10 changes: 10 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Index:
Background: Build # 开启后台索引

# 如果你的 compile_commands.json 不在根目录,需要在这里显式指定
CompileFlags:
CompilationDatabase: ".vscode"
Comment on lines +1 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check if .clangd file exists and read its content
if [ -f ".clangd" ]; then
  echo "=== .clangd file content ==="
  cat -n .clangd
else
  echo ".clangd file not found"
fi

Repository: Ryan-CW-Code/RyanJson

Length of output: 409


🏁 Script executed:

# Search for compile_commands.json in common locations
echo "=== Searching for compile_commands.json ==="
find . -name "compile_commands.json" -type f 2>/dev/null | head -20

Repository: Ryan-CW-Code/RyanJson

Length of output: 108


🏁 Script executed:

# Check if .vscode directory exists and list its contents
if [ -d ".vscode" ]; then
  echo "=== .vscode directory contents ==="
  ls -la .vscode/ 2>/dev/null | head -20
else
  echo ".vscode directory does not exist"
fi

Repository: Ryan-CW-Code/RyanJson

Length of output: 273


compile_commands.json 文件缺失。

CompilationDatabase 配置指向 ".vscode" 目录,但 compile_commands.json 在该目录(以及根目录)中都不存在。clangd 无法找到编译数据库,将无法正确索引和分析代码。需要生成 compile_commands.json 文件或将配置路径指向正确位置。

🤖 Prompt for AI Agents
In @.clangd around lines 1-6, The .clangd config points CompilationDatabase to
".vscode" but compile_commands.json is missing; fix by either generating a
compilation database (e.g., enable CMake's CMAKE_EXPORT_COMPILE_COMMANDS or run
bear/scan-build to create compile_commands.json) and placing it in the ".vscode"
directory, or update the CompilationDatabase field in .clangd to the actual
directory containing the generated compile_commands.json (or remove the explicit
setting to use the project root). Ensure the file is named exactly
compile_commands.json so clangd can discover it.


Diagnostics:
UnusedIncludes: None # 关键:这会关闭“未使用头文件”的提示
MissingIncludes: None # 可选:关闭“缺失头文件”的提示
Loading