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:
@@ -1,11 +1,11 @@
|
||||
#include <core_log.h>
|
||||
#include <core_stream.h>
|
||||
|
||||
#ifndef __SMCC_CORE_NO_MEM_PROBE_STREAM__
|
||||
#ifndef __SCC_CORE_NO_MEM_PROBE_STREAM__
|
||||
|
||||
static int mem_probe_stream_consume(core_probe_stream_t *_stream) {
|
||||
static int mem_probe_stream_consume(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (stream->curr_pos >= stream->data_length) {
|
||||
return core_stream_eof;
|
||||
@@ -19,9 +19,9 @@ static int mem_probe_stream_consume(core_probe_stream_t *_stream) {
|
||||
return (int)ch;
|
||||
}
|
||||
|
||||
static int mem_probe_stream_peek(core_probe_stream_t *_stream) {
|
||||
static int mem_probe_stream_peek(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (stream->probe_pos >= stream->data_length) {
|
||||
return core_stream_eof;
|
||||
@@ -31,9 +31,9 @@ static int mem_probe_stream_peek(core_probe_stream_t *_stream) {
|
||||
return (int)(unsigned char)stream->data[stream->probe_pos];
|
||||
}
|
||||
|
||||
static int mem_probe_stream_next(core_probe_stream_t *_stream) {
|
||||
static int mem_probe_stream_next(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (stream->probe_pos >= stream->data_length) {
|
||||
return core_stream_eof;
|
||||
@@ -45,9 +45,9 @@ static int mem_probe_stream_next(core_probe_stream_t *_stream) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void mem_probe_stream_sync(core_probe_stream_t *_stream) {
|
||||
static void mem_probe_stream_sync(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
// 移动头指针到探针位置(消费已查看的字符)
|
||||
if (stream->probe_pos > stream->curr_pos) {
|
||||
@@ -55,9 +55,9 @@ static void mem_probe_stream_sync(core_probe_stream_t *_stream) {
|
||||
}
|
||||
}
|
||||
|
||||
static cbool mem_probe_stream_back(core_probe_stream_t *_stream) {
|
||||
static cbool mem_probe_stream_back(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
// 只能回退一个字符,且不能回退到探针位置之前
|
||||
if (stream->curr_pos == 0 || stream->curr_pos <= stream->probe_pos) {
|
||||
@@ -68,10 +68,10 @@ static cbool mem_probe_stream_back(core_probe_stream_t *_stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static usize mem_probe_stream_read_buf(core_probe_stream_t *_stream,
|
||||
static usize mem_probe_stream_read_buf(scc_probe_stream_t *_stream,
|
||||
char *buffer, usize count) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (buffer == null) {
|
||||
LOG_WARN("Buffer is null");
|
||||
@@ -82,7 +82,7 @@ static usize mem_probe_stream_read_buf(core_probe_stream_t *_stream,
|
||||
usize to_read = (remaining < count) ? remaining : count;
|
||||
|
||||
if (to_read > 0) {
|
||||
smcc_memcpy(buffer, stream->data + stream->curr_pos, to_read);
|
||||
scc_memcpy(buffer, stream->data + stream->curr_pos, to_read);
|
||||
stream->curr_pos += to_read;
|
||||
// 更新探针位置
|
||||
if (stream->probe_pos < stream->curr_pos) {
|
||||
@@ -96,36 +96,36 @@ static usize mem_probe_stream_read_buf(core_probe_stream_t *_stream,
|
||||
return to_read;
|
||||
}
|
||||
|
||||
static void mem_probe_stream_reset(core_probe_stream_t *_stream) {
|
||||
static void mem_probe_stream_reset(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
// 重置探针位置到头指针位置
|
||||
stream->probe_pos = stream->curr_pos;
|
||||
}
|
||||
|
||||
static cbool mem_probe_stream_is_at_end(core_probe_stream_t *_stream) {
|
||||
static cbool mem_probe_stream_is_at_end(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
return stream->curr_pos >= stream->data_length;
|
||||
}
|
||||
|
||||
static void mem_probe_stream_destroy(core_probe_stream_t *_stream) {
|
||||
static void mem_probe_stream_destroy(scc_probe_stream_t *_stream) {
|
||||
Assert(_stream != null);
|
||||
core_mem_probe_stream_t *stream = (core_mem_probe_stream_t *)_stream;
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
cstring_free(&stream->stream.name);
|
||||
scc_cstring_free(&stream->stream.name);
|
||||
|
||||
if (stream->owned) {
|
||||
smcc_free((void *)stream->data);
|
||||
scc_free((void *)stream->data);
|
||||
stream->data = 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) {
|
||||
if (stream == null || data == null) {
|
||||
LOG_ERROR("param error");
|
||||
return null;
|
||||
@@ -138,13 +138,13 @@ core_probe_stream_t *core_mem_probe_stream_init(core_mem_probe_stream_t *stream,
|
||||
|
||||
stream->owned = need_copy;
|
||||
if (need_copy) {
|
||||
char *buf = (char *)smcc_malloc(length);
|
||||
char *buf = (char *)scc_malloc(length);
|
||||
if (buf == null) {
|
||||
LOG_ERROR("malloc error");
|
||||
return null;
|
||||
}
|
||||
|
||||
smcc_memcpy(buf, data, length);
|
||||
scc_memcpy(buf, data, length);
|
||||
stream->data = buf;
|
||||
} else {
|
||||
stream->data = data;
|
||||
@@ -153,7 +153,7 @@ core_probe_stream_t *core_mem_probe_stream_init(core_mem_probe_stream_t *stream,
|
||||
stream->curr_pos = 0;
|
||||
stream->probe_pos = 0;
|
||||
|
||||
stream->stream.name = cstring_from_cstr("mem_probe_stream");
|
||||
stream->stream.name = scc_cstring_from_cstr("mem_probe_stream");
|
||||
|
||||
// 设置函数指针
|
||||
stream->stream.consume = mem_probe_stream_consume;
|
||||
@@ -166,7 +166,7 @@ core_probe_stream_t *core_mem_probe_stream_init(core_mem_probe_stream_t *stream,
|
||||
stream->stream.is_at_end = mem_probe_stream_is_at_end;
|
||||
stream->stream.drop = mem_probe_stream_destroy;
|
||||
|
||||
return (core_probe_stream_t *)stream;
|
||||
return (scc_probe_stream_t *)stream;
|
||||
}
|
||||
|
||||
#endif /* __SMCC_CORE_NO_MEM_PROBE_STREAM__ */
|
||||
#endif /* __SCC_CORE_NO_MEM_PROBE_STREAM__ */
|
||||
|
||||
Reference in New Issue
Block a user