feat: rename core types to scc prefix for consistency

Updated type names from `core_*` to `scc_*` across lex_parser and stream modules to maintain naming consistency within the SCC codebase. This includes changes to function signatures and internal usage of types like `core_probe_stream_t`, `core_pos_t`, and `cstring_t` to their `scc_*` counterparts.
This commit is contained in:
zzy
2025-12-11 13:00:29 +08:00
parent 35c13ee30a
commit d88fa3b8d3
33 changed files with 741 additions and 745 deletions

View File

@@ -1,5 +1,5 @@
#ifndef __SMCC_CORE_STR_H__
#define __SMCC_CORE_STR_H__
#ifndef __SCC_CORE_STR_H__
#define __SCC_CORE_STR_H__
#include "core_impl.h"
#include "core_log.h"
@@ -7,21 +7,21 @@
/**
* @brief 动态字符串结构体
* @attention 创建的字符串对象需要使用 cstring_free 释放
* @attention 创建的字符串对象需要使用 scc_cstring_free 释放
*/
typedef struct cstring {
typedef struct scc_cstring {
usize size; /**< 字符串当前大小(包括结尾的'\0'*/
usize cap; /**< 分配的容量 */
char *data; /**< 实际存储数据的指针 */
} cstring_t;
} scc_cstring_t;
/**
* @brief 创建一个新的空动态字符串对象
*
* @return cstring_t 初始化后的对象
*/
static inline cstring_t cstring_new(void) {
return (cstring_t){.data = null, .size = 0, .cap = 0};
static inline scc_cstring_t scc_cstring_new(void) {
return (scc_cstring_t){.data = null, .size = 0, .cap = 0};
}
/**
@@ -30,9 +30,9 @@ static inline cstring_t cstring_new(void) {
* @param s 输入的 C 风格字符串
* @return cstring_t 新建对象,包含输入字符串的副本
*/
static inline cstring_t cstring_from_cstr(const char *s) {
static inline scc_cstring_t scc_cstring_from_cstr(const char *s) {
if (s == null) {
return cstring_new();
return scc_cstring_new();
}
usize len = 0;
@@ -40,12 +40,12 @@ static inline cstring_t cstring_from_cstr(const char *s) {
while (*p++)
len++;
char *data = (char *)smcc_malloc(len + 1);
char *data = (char *)scc_malloc(len + 1);
Assert(data != null);
smcc_memcpy(data, s, len);
scc_memcpy(data, s, len);
data[len] = '\0';
return (cstring_t){.size = len + 1, .cap = len + 1, .data = data};
return (scc_cstring_t){.size = len + 1, .cap = len + 1, .data = data};
}
/**
@@ -53,12 +53,12 @@ static inline cstring_t cstring_from_cstr(const char *s) {
*
* @param str 要被释放的字符串指针
*/
static inline void cstring_free(cstring_t *str) {
static inline void scc_cstring_free(scc_cstring_t *str) {
if (str == null) {
return;
}
if (str->cap != 0 && str->data != null) {
smcc_free(str->data);
scc_free(str->data);
str->data = null;
}
str->size = 0;
@@ -72,8 +72,8 @@ static inline void cstring_free(cstring_t *str) {
* @param data 要追加的 C 字符串指针
* @param len 要追加的 C 字符串长度
*/
static inline void cstring_append_cstr(cstring_t *str, const char *data,
usize len) {
static inline void scc_cstring_append_cstr(scc_cstring_t *str, const char *data,
usize len) {
if (str == null || data == null || len == 0) {
return;
}
@@ -96,14 +96,14 @@ static inline void cstring_append_cstr(cstring_t *str, const char *data,
// FIXME 处理溢出情况
}
char *new_data = (char *)smcc_realloc(str->data, new_cap);
char *new_data = (char *)scc_realloc(str->data, new_cap);
Assert(new_data != null);
str->data = new_data;
str->cap = new_cap;
}
smcc_memcpy(str->data + str->size - 1, data, len);
scc_memcpy(str->data + str->size - 1, data, len);
str->size += len;
str->data[str->size - 1] = '\0'; // 保证 C 字符串兼容性
}
@@ -114,8 +114,9 @@ static inline void cstring_append_cstr(cstring_t *str, const char *data,
* @param str 目标动态字符串指针
* @param other 要追加的动态字符串指针
*/
static inline void cstring_append(cstring_t *str, const cstring_t *other) {
cstring_append_cstr(str, other->data, other->size - 1);
static inline void scc_cstring_append(scc_cstring_t *str,
const scc_cstring_t *other) {
scc_cstring_append_cstr(str, other->data, other->size - 1);
}
/**
@@ -124,8 +125,8 @@ static inline void cstring_append(cstring_t *str, const cstring_t *other) {
* @param str 目标动态字符串指针
* @param ch 要追加的字符
*/
static inline void cstring_append_ch(cstring_t *str, char ch) {
cstring_append_cstr(str, &ch, 1);
static inline void scc_cstring_append_ch(scc_cstring_t *str, char ch) {
scc_cstring_append_cstr(str, &ch, 1);
}
/**
@@ -134,7 +135,7 @@ static inline void cstring_append_ch(cstring_t *str, char ch) {
* @param str 动态字符串指针
* @return usize 字符串实际长度
*/
static inline usize cstring_len(const cstring_t *str) {
static inline usize scc_cstring_len(const scc_cstring_t *str) {
return str ? str->size - 1 : 0;
}
@@ -144,7 +145,7 @@ static inline usize cstring_len(const cstring_t *str) {
* @param str 动态字符串指针
* @return cbool
*/
static inline cbool cstring_is_empty(const cstring_t *str) {
static inline cbool scc_cstring_is_empty(const scc_cstring_t *str) {
return str == null || str->size == 0;
}
@@ -153,7 +154,7 @@ static inline cbool cstring_is_empty(const cstring_t *str) {
*
* @param str 动态字符串指针
*/
static inline void cstring_clear(cstring_t *str) {
static inline void scc_cstring_clear(scc_cstring_t *str) {
if (str) {
str->size = 1;
if (str->data) {
@@ -168,11 +169,11 @@ static inline void cstring_clear(cstring_t *str) {
* @param str 动态字符串指针
* @return char* 返回指向内部缓冲区的 C 风格字符串指针
*/
static inline char *cstring_as_cstr(const cstring_t *str) {
static inline char *scc_cstring_as_cstr(const scc_cstring_t *str) {
if (str == null || str->data == null) {
return "";
}
return str->data;
}
#endif /* __SMCC_CORE_STR_H__ */
#endif /* __SCC_CORE_STR_H__ */