示例#1
0
文件: system.c 项目: shidasan/konoha2
kfileid_t knh_getURI(CTX, kbytes_t t)
{
	OLD_LOCK(_ctx, LOCK_SYSTBL, NULL);
	kindex_t idx = knh_DictSet_index(_ctx->share->urnDictSet, t);
	if(idx == -1) {
		kString *s = new_kString(t.text, t.len, SPOL_POOL);
		idx = kArray_size(_ctx->share->urns);
		knh_DictSet_set(_ctx, ctx->share->urnDictSet, s, idx);
		kArray_add(ctx->share->urns, s);
		KNH_NTRACE2(_ctx, "konoha:newfileid", K_OK, KNH_LDATA(LOG_s("urn", S_text(s)), LOG_i("fileid", idx)));
	}
	else {
		idx = knh_DictSet_valueAt(_ctx->share->urnDictSet, idx);
	}
	OLD_UNLOCK(_ctx, LOCK_SYSTBL, NULL);
	return (kfileid_t)idx;
}
示例#2
0
kuri_t knh_getURI(CTX ctx, kbytes_t t)
{
    OLD_LOCK(ctx, LOCK_SYSTBL, NULL);
    kindex_t idx = knh_DictSet_index(ctx->share->urnDictSet, t);
    if(idx == -1) {
        kString *s = new_String2(ctx, CLASS_String, t.text, t.len, SPOL_POOLALWAYS);
        idx = knh_Array_size(ctx->share->urns);
        knh_DictSet_set(ctx, ctx->share->urnDictSet, s, idx);
        knh_Array_add(ctx, ctx->share->urns, s);
        KNH_NTRACE2(ctx, "konoha:newuri", K_OK, KNH_LDATA(LOG_s("urn", S_totext(s)), LOG_i("uri", idx)));
    }
    else {
        idx = knh_DictSet_valueAt(ctx->share->urnDictSet, idx);
    }
    OLD_UNLOCK(ctx, LOCK_SYSTBL, NULL);
    return (kuri_t)idx;
}
示例#3
0
文件: system.c 项目: shidasan/konoha2
static ksymbol_t getSymbol(CTX, kbytes_t n, ksymbol_t def)
{
	OLD_LOCK(_ctx, LOCK_SYSTBL, NULL);
	kindex_t idx = knh_DictSet_index(_ctx->share->symbolDictCaseSet, n);
	if(idx == -1) {
		if(def == FN_NEWID) {
			idx = addSymbol(_ctx, n);
		}
		else {
			idx = def - MN_OPSIZE;
		}
	}
	else {
		idx = knh_DictSet_valueAt(_ctx->share->symbolDictCaseSet, idx) - 1;
	}
	OLD_UNLOCK(_ctx, LOCK_SYSTBL, NULL);
	return (ksymbol_t)idx + MN_OPSIZE;
}