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:
@@ -6,8 +6,8 @@
|
||||
#include "core_mem.h"
|
||||
#include "core_str.h"
|
||||
|
||||
struct core_probe_stream;
|
||||
typedef struct core_probe_stream core_probe_stream_t;
|
||||
struct scc_probe_stream;
|
||||
typedef struct scc_probe_stream scc_probe_stream_t;
|
||||
|
||||
#define core_stream_eof (-1)
|
||||
|
||||
@@ -18,90 +18,90 @@ typedef struct core_probe_stream core_probe_stream_t;
|
||||
* 尾指针只能向前移动,用于查看而不消费。
|
||||
* 头指针可以前进或单次后退,但不能一直后退到尾指针后面。
|
||||
*/
|
||||
struct core_probe_stream {
|
||||
cstring_t name;
|
||||
struct scc_probe_stream {
|
||||
scc_cstring_t name;
|
||||
|
||||
/// @brief 消费头指针处的字符(移动头指针)
|
||||
int (*consume)(core_probe_stream_t *stream);
|
||||
int (*consume)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 查看当前探针位置的字符,不移动任何指针
|
||||
int (*peek)(core_probe_stream_t *stream);
|
||||
int (*peek)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 移动探针位置并返回字符
|
||||
int (*next)(core_probe_stream_t *stream);
|
||||
int (*next)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 移动头指针到探针位置
|
||||
void (*sync)(core_probe_stream_t *stream);
|
||||
void (*sync)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 重置探针位置到头指针位置
|
||||
void (*reset)(core_probe_stream_t *stream);
|
||||
void (*reset)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 回退一个字符(单次后退,头指针后退一步)
|
||||
cbool (*back)(core_probe_stream_t *stream);
|
||||
cbool (*back)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 读取指定数量的字符到缓冲区
|
||||
usize (*read_buf)(core_probe_stream_t *stream, char *buffer, usize count);
|
||||
usize (*read_buf)(scc_probe_stream_t *stream, char *buffer, usize count);
|
||||
|
||||
/// @brief 检查是否到达流末尾
|
||||
cbool (*is_at_end)(core_probe_stream_t *stream);
|
||||
cbool (*is_at_end)(scc_probe_stream_t *stream);
|
||||
|
||||
/// @brief 销毁流并释放资源
|
||||
void (*drop)(core_probe_stream_t *stream);
|
||||
void (*drop)(scc_probe_stream_t *stream);
|
||||
};
|
||||
|
||||
static inline int core_probe_stream_consume(core_probe_stream_t *self) {
|
||||
static inline int scc_probe_stream_consume(scc_probe_stream_t *self) {
|
||||
return self->consume(self);
|
||||
}
|
||||
|
||||
static inline int core_probe_stream_peek(core_probe_stream_t *self) {
|
||||
static inline int scc_probe_stream_peek(scc_probe_stream_t *self) {
|
||||
return self->peek(self);
|
||||
}
|
||||
|
||||
static inline int core_probe_stream_next(core_probe_stream_t *self) {
|
||||
static inline int scc_probe_stream_next(scc_probe_stream_t *self) {
|
||||
return self->next(self);
|
||||
}
|
||||
|
||||
static inline void core_probe_stream_sync(core_probe_stream_t *self) {
|
||||
static inline void scc_probe_stream_sync(scc_probe_stream_t *self) {
|
||||
self->sync(self);
|
||||
}
|
||||
|
||||
static inline cbool core_probe_stream_back(core_probe_stream_t *self) {
|
||||
static inline cbool scc_probe_stream_back(scc_probe_stream_t *self) {
|
||||
return self->back(self);
|
||||
}
|
||||
|
||||
static inline void core_probe_stream_reset(core_probe_stream_t *self) {
|
||||
static inline void scc_probe_stream_reset(scc_probe_stream_t *self) {
|
||||
self->reset(self);
|
||||
}
|
||||
|
||||
static inline usize core_probe_stream_read_buf(core_probe_stream_t *self,
|
||||
char *buffer, usize count) {
|
||||
static inline usize scc_probe_stream_read_buf(scc_probe_stream_t *self,
|
||||
char *buffer, usize count) {
|
||||
return self->read_buf(self, buffer, count);
|
||||
}
|
||||
|
||||
static inline cbool core_probe_stream_is_at_end(core_probe_stream_t *self) {
|
||||
static inline cbool scc_probe_stream_is_at_end(scc_probe_stream_t *self) {
|
||||
return self->is_at_end(self);
|
||||
}
|
||||
|
||||
static inline cbool core_probe_stream_has_more(core_probe_stream_t *self) {
|
||||
static inline cbool scc_probe_stream_has_more(scc_probe_stream_t *self) {
|
||||
return !self->is_at_end(self);
|
||||
}
|
||||
|
||||
static inline void core_probe_stream_drop(core_probe_stream_t *self) {
|
||||
static inline void scc_probe_stream_drop(scc_probe_stream_t *self) {
|
||||
self->drop(self);
|
||||
}
|
||||
|
||||
#ifndef __SMCC_CORE_NO_MEM_PROBE_STREAM__
|
||||
#ifndef __SCC_NO_MEM_PROBE_STREAM__
|
||||
/**
|
||||
* @brief 内存探针流结构
|
||||
*/
|
||||
typedef struct core_mem_probe_stream {
|
||||
core_probe_stream_t stream;
|
||||
typedef struct scc_mem_probe_stream {
|
||||
scc_probe_stream_t stream;
|
||||
const char *data;
|
||||
usize data_length;
|
||||
usize curr_pos; // 当前读取位置
|
||||
usize probe_pos; // 探针位置(用于peek)
|
||||
cbool owned; // 是否拥有数据(需要释放)
|
||||
} core_mem_probe_stream_t;
|
||||
} scc_mem_probe_stream_t;
|
||||
|
||||
/**
|
||||
* @brief 初始化内存探针流
|
||||
@@ -112,9 +112,9 @@ typedef struct core_mem_probe_stream {
|
||||
* @param need_copy 是否需要复制数据
|
||||
* @return core_probe_stream_t* 成功返回流指针,失败返回NULL
|
||||
*/
|
||||
core_probe_stream_t *core_mem_probe_stream_init(core_mem_probe_stream_t *stream,
|
||||
const char *data, usize length,
|
||||
cbool need_copy);
|
||||
scc_probe_stream_t *scc_mem_probe_stream_init(scc_mem_probe_stream_t *stream,
|
||||
const char *data, usize length,
|
||||
cbool need_copy);
|
||||
#endif
|
||||
|
||||
#endif /* __SMCC_CORE_PROBE_STREAM_H__ */
|
||||
|
||||
Reference in New Issue
Block a user