feat: add SCF format library and rename components to SCC prefix
- Introduce new SCF (SCC Format) library with header, implementation, and test files - SCF is a minimal executable/linkable format focused on internal linking with external symbol import/export abstraction - Rename lexer and lex_parser packages from 'smcc_' to 'scc_' prefix for consistency - Update hashmap implementation to use 'scc_' prefix for types and structures - Add build configuration for new format library with dependencies on libcore and libutils
This commit is contained in:
@@ -18,14 +18,14 @@
|
||||
* 组合哈希表和专用内存分配器实现的高效字符串存储池
|
||||
*/
|
||||
typedef struct strpool {
|
||||
hashmap_t ht; /**< 哈希表用于快速查找已存储字符串 */
|
||||
} strpool_t;
|
||||
scc_hashtable_t ht; /**< 哈希表用于快速查找已存储字符串 */
|
||||
} scc_strpool_t;
|
||||
|
||||
/**
|
||||
* @brief 初始化字符串池
|
||||
* @param pool 字符串池实例指针
|
||||
*/
|
||||
void init_strpool(strpool_t *pool);
|
||||
void scc_strpool_init(scc_strpool_t *pool);
|
||||
|
||||
/**
|
||||
* @brief 驻留字符串到池中
|
||||
@@ -36,7 +36,7 @@ void init_strpool(strpool_t *pool);
|
||||
* @note 返回值生命周期与字符串池一致
|
||||
* @note 重复插入相同字符串会返回已有指针
|
||||
*/
|
||||
const char *strpool_intern(strpool_t *pool, const char *str);
|
||||
const char *scc_strpool_intern(scc_strpool_t *pool, const char *str);
|
||||
|
||||
/**
|
||||
* @brief 销毁字符串池
|
||||
@@ -45,6 +45,25 @@ const char *strpool_intern(strpool_t *pool, const char *str);
|
||||
* @warning 销毁后已获取的字符串指针将失效
|
||||
* @note 会自动释放所有驻留字符串内存
|
||||
*/
|
||||
void strpool_destroy(strpool_t *pool);
|
||||
void scc_strpool_drop(scc_strpool_t *pool);
|
||||
|
||||
/**
|
||||
* @typedef scc_hashtable_iter_fn
|
||||
* @brief 哈希表迭代回调函数类型
|
||||
* @param key 当前键指针
|
||||
* @param value 当前值指针
|
||||
* @param context 用户上下文指针
|
||||
* @return 返回非0停止迭代
|
||||
*/
|
||||
typedef int (*scc_strpool_iter_fn)(const char *key, char *value, void *context);
|
||||
|
||||
/**
|
||||
* @brief 遍历字符串表所有有效条目
|
||||
* @param ht 字符串表实例指针
|
||||
* @param iter_func 迭代回调函数
|
||||
* @param context 用户上下文指针
|
||||
*/
|
||||
void scc_strpool_foreach(scc_strpool_t *pool, scc_strpool_iter_fn iter_func,
|
||||
void *context);
|
||||
|
||||
#endif /* __SCC_STRPOOL_H__ */
|
||||
|
||||
Reference in New Issue
Block a user