• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ KReturn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中KReturn函数的典型用法代码示例。如果您正苦于以下问题:C++ KReturn函数的具体用法?C++ KReturn怎么用?C++ KReturn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了KReturn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Object_as

// @SmartReturn Object Object.as(Object target)
static KMETHOD Object_as(KonohaContext *kctx, KonohaStack *sfp)
{
	KonohaClass *selfClass = O_ct(sfp[0].asObject), *targetClass = KGetReturnType(sfp);
	kObject *returnValue;
	if(selfClass == targetClass || selfClass->isSubType(kctx, selfClass, targetClass)) {
		returnValue = sfp[0].asObject;
	}
	else {
		returnValue = KLIB Knull(kctx, targetClass);
	}
	sfp[K_RTNIDX].unboxValue = O_unbox(returnValue);
	KReturn(returnValue);
}
开发者ID:kkuramitsu,项目名称:minikonoha,代码行数:14,代码来源:object_glue.c


示例2: TypeCheck_to

static KMETHOD TypeCheck_to(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_TypeCheck(stmt, expr, gma, reqty);
	kExpr *targetExpr = SUGAR kStmt_TypeCheckExprAt(kctx, stmt, expr, 2, gma, TY_var, 0);
	kExpr *selfExpr   = SUGAR kStmt_TypeCheckExprAt(kctx, stmt, expr, 1, gma, targetExpr->ty, TypeCheckPolicy_NOCHECK);
	if(selfExpr != K_NULLEXPR && targetExpr != K_NULLEXPR) {
		KonohaClass *selfClass = CT_(selfExpr->ty), *targetClass = CT_(targetExpr->ty);
		if(selfExpr->ty == targetExpr->ty || selfClass->isSubType(kctx, selfClass, targetClass)) {
			kStmtExpr_Message(kctx, stmt, selfExpr, InfoTag, "no need: %s to %s", TY_t(selfExpr->ty), TY_t(targetExpr->ty));
			KReturn(selfExpr);
		}
		kNameSpace *ns = Stmt_ns(stmt);
		kMethod *mtd = KLIB kNameSpace_GetCoercionMethodNULL(kctx, ns, selfExpr->ty, targetExpr->ty);
		if(mtd == NULL) {
			mtd = KLIB kNameSpace_GetMethodByParamSizeNULL(kctx, ns, selfExpr->ty, MN_("to"), 0);
			DBG_ASSERT(mtd != NULL);  // because Object.to is found.
			if(mtd->typeId != selfExpr->ty) {
				KReturn(kStmtExpr_Message(kctx, stmt, selfExpr, ErrTag, "undefined coercion: %s to %s", TY_t(selfExpr->ty), TY_t(targetExpr->ty)));
			}
		}
		KReturn(SUGAR kStmtkExpr_TypeCheckCallParam(kctx, stmt, expr, mtd, gma, targetClass->typeId));
	}
}
开发者ID:doly,项目名称:minikonoha,代码行数:23,代码来源:object_glue.c


示例3: KSymbol_toString

//## @Public @Const @Immutable @Coercion String Symbol.toString();
static KMETHOD KSymbol_toString(KonohaContext *kctx, KonohaStack *sfp)
{
	ksymbol_t symbol = (ksymbol_t)sfp[0].intValue;
	kString *s = KSymbol_GetString(kctx, KSymbol_Unmask(symbol));
	if(KSymbol_Attr(symbol) != 0) {
		KBuffer wb;
		const char *prefix = KSymbol_prefixText(symbol);
		KLIB KBuffer_Init(&(kctx->stack->cwb), &wb);
		KLIB KBuffer_Write(kctx, &wb, prefix, strlen(prefix));
		KLIB KBuffer_Write(kctx, &wb, kString_text(s), kString_size(s));
		s = KLIB KBuffer_Stringfy(kctx, &wb, OnStack, StringPolicy_FreeKBuffer);
	}
	KReturn(s);
}
开发者ID:masakiishii,项目名称:konoha.js,代码行数:15,代码来源:parser.c


示例4: String_new_fromBytes_withDefaultDecode

//## String String.new(Bytes ba);
static KMETHOD String_new_fromBytes_withDefaultDecode(KonohaContext *kctx, KonohaStack *sfp)
{
	kBytes *ba = sfp[1].asBytes;
	kString *s = TS_EMPTY;
	if(ba->bytesize != 0) {
		KMakeTrace(trace, sfp);
		KBuffer wb;
		KLIB KBuffer_Init(&(kctx->stack->cwb), &wb);
		KBuffer_convertCharset(kctx, &wb, "UTF-8", I18NAPI systemCharset, ba->buf, ba->bytesize, trace);
		KLIB KBuffer_text(kctx, &wb, EnsureZero); /* String must be Null terminated */
		s = KLIB KBuffer_Stringfy(kctx, &wb, OnStack, StringPolicy_FreeKBuffer);
	}
	KReturn(s);
}
开发者ID:masakiishii,项目名称:minikonoha,代码行数:15,代码来源:Bytes_glue.c


示例5: Expression_Defined

static KMETHOD Expression_Defined(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_Expression(expr, tokenList, beginIdx, currentIdx, endIdx);
	kNameSpace *ns = kNode_ns(expr);
	if(beginIdx == currentIdx && beginIdx + 1 < endIdx) {
		kTokenVar *definedToken = tokenList->TokenVarItems[beginIdx];   // defined
		kTokenVar *pToken = tokenList->TokenVarItems[beginIdx+1];
		if(IS_Array(pToken->GroupTokenList)) {
			SUGAR kNode_Op(kctx, expr, definedToken, 0);
			FilterDefinedParam(kctx, ns, RangeGroup(pToken->GroupTokenList));
			KReturn(SUGAR AppendParsedNode(kctx, expr, RangeGroup(pToken->GroupTokenList), NULL, ParseExpressionOption, "("));
		}
	}
}
开发者ID:imasahiro,项目名称:konoha3,代码行数:14,代码来源:NameSpace_glue.c


示例6: System_stat

//## Stat System.stat(String path)
static KMETHOD System_stat(KonohaContext *kctx, KonohaStack *sfp)
{
	KMakeTrace(trace, sfp);
	char buffer[K_PATHMAX];
	kString *path = sfp[1].asString;
	const char *systemPath = PLATAPI I18NModule.formatSystemPath(kctx, buffer, sizeof(buffer), kString_text(path), kString_size(path), trace);
	struct stat buf = {}; /* zero */
	int ret = stat(systemPath, &buf);
	if(ret == -1) {
		int fault = KLIB DiagnosisFaultType(kctx, kString_GuessUserFault(path)|SystemError, trace);
		KTraceErrorPoint(trace, fault, "stat", LogText("path", kString_text(path)), LogErrno);
	}
	KReturn(KLIB new_kObject(kctx, OnStack, KGetReturnType(sfp), (uintptr_t)&buf));
}
开发者ID:masakiishii,项目名称:minikonoha,代码行数:15,代码来源:stat_glue.c


示例7: MecabNode_enext

// MecabNode MecabNode.enext()
static KMETHOD MecabNode_enext(KonohaContext *kctx, KonohaStack *sfp)
{
	struct _kMecabNode *node = (struct _kMecabNode *)sfp[0].asObject;
	mecab_node_t* enext = node->node->enext;
	struct _kMecabNode* ret;
	if(node != NULL) {
		ret = (struct _kMecabNode *)KLIB new_kObject(kctx, OnStack, KGetReturnType(sfp), 0);
		ret->node = enext;
		KReturn(ret);
	}
	else {
		KReturnDefaultValue();
	}
}
开发者ID:Kouhei-Moriya,项目名称:konoha3,代码行数:15,代码来源:mecab_glue.c


示例8: TypeCheck_to

static KMETHOD TypeCheck_to(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_TypeCheck2(stmt, expr, ns, reqc);
	kNode *targetNode = SUGAR TypeCheckNodeAt(kctx, expr, 2, ns, KClass_INFER, 0);
	kNode *selfNode   = SUGAR TypeCheckNodeAt(kctx, expr, 1, ns, KClass_(targetNode->attrTypeId), TypeCheckPolicy_NoCheck);
	if(selfNode != K_NULLNODE && targetNode != K_NULLNODE) {
		KClass *selfClass = KClass_(selfNode->attrTypeId), *targetClass = KClass_(targetNode->attrTypeId);
		if(selfNode->attrTypeId == targetNode->attrTypeId || selfClass->isSubType(kctx, selfClass, targetClass)) {
			SUGAR MessageNode(kctx, selfNode, NULL, ns, InfoTag, "no need: %s to %s", KType_text(selfNode->attrTypeId), KType_text(targetNode->attrTypeId));
			KReturn(selfNode);
		}
		kNameSpace *ns = kNode_ns(stmt);
		kMethod *mtd = KLIB kNameSpace_GetCoercionMethodNULL(kctx, ns, selfClass, targetClass);
		if(mtd == NULL) {
			mtd = KLIB kNameSpace_GetMethodByParamSizeNULL(kctx, ns, selfClass, KMethodName_("to"), 0, KMethodMatch_CamelStyle);
			DBG_ASSERT(mtd != NULL);  // because Object.to is found.
			if(mtd->typeId != selfClass->typeId) {
				KReturn(SUGAR MessageNode(kctx, selfNode, NULL, ns, ErrTag, "undefined coercion: %s to %s", KClass_text(selfClass), KClass_text(targetClass)));
			}
		}
		KReturn(SUGAR TypeCheckMethodParam(kctx, mtd, expr, ns, targetClass));
	}
}
开发者ID:masakiishii,项目名称:minikonoha,代码行数:23,代码来源:Object_glue.c


示例9: _set_value

static CMPIStatus _set_value(KValue* kv, KTag tag, const CMPIData* cd)
{
    /* Strip unused flags */
    tag = KTypeOf(tag) | (tag & KTAG_ARRAY);

    if (_cmpitype_to_ktag(cd->type) != tag)
    {
        KReturn(ERR_FAILED);
    }

    kv->exists = 1;

    if (cd->state & CMPI_nullValue)
    {
        kv->null = 1;
        kv->u.uint64 = 0;
        KReturn(OK);
    }
    else
    {
        kv->u.uint64 = cd->value.uint64;

        if (tag == KTYPE_STRING)
        {
            KString* ks = (KString*)kv;
            ks->chars = KChars(ks->value);
        }
        if (tag & KTAG_ARRAY)
        {
            KArray* ks = (KArray*)kv;
            ks->count = CMGetArrayCount(ks->value, NULL);
        }

        /* ATTN: validate references and instances */
        KReturn(OK);
    }
}
开发者ID:jubalh,项目名称:konkretcmpi,代码行数:37,代码来源:general.c


示例10: Array_shift

static KMETHOD Array_shift(KonohaContext *kctx, KonohaStack *sfp)
{
	kArray *a = sfp[0].asArray;
	struct _kAbstractArray *a2 = (struct _kAbstractArray *)a;
	if(kArray_isUnboxData(a)) {
		uintptr_t v = a->unboxItems[0];
		kArray_removeAt(kctx, a, 0);
		KReturnUnboxValue(v);
	}
	else {
		kObject *value = a2->a.ObjectItems[0];
		kArray_removeAt(kctx, a, 0);
		KReturn(value);
	}
}
开发者ID:hisaboh,项目名称:minikonoha,代码行数:15,代码来源:array_glue.c


示例11: KStackReturnTypeCheck

static void KStackReturnTypeCheck(KonohaContext *kctx, KonohaStack *sfp, kMethod *mtd, KClass *reqType, KClass *thisClass)
{
	if(!kMethod_Is(SmartReturn, mtd)) {
		KClass *returnType = kMethod_GetReturnType(mtd);
		returnType = returnType->realtype(kctx, returnType, thisClass);
		if(reqType == returnType || returnType->isSubType(kctx, returnType, reqType)) {
			if(KClass_Is(UnboxType, returnType) && !KClass_Is(UnboxType, reqType)) {
				KReturn(KLIB new_kObject(kctx, OnStack, returnType, sfp[K_RTNIDX].unboxValue));
			}
		}
		else {
			ThrowTypeError(kctx, sfp, -1);
		}
	}
}
开发者ID:stadaki,项目名称:konoha3,代码行数:15,代码来源:Prototype_glue.c


示例12: ResultSet_get

//## @SmartReturn Object ResultSet.get(String n);
static KMETHOD ResultSet_get(KonohaContext *kctx, KonohaStack *sfp)
{
	KClass *retClass = KGetReturnType(sfp);
	if(retClass->typeId == KType_Int) {
		ResultSet_getInt(kctx, sfp);
	} else if(retClass->typeId == KType_String) {
		ResultSet_getString(kctx, sfp);
	} else if(KDefinedKonohaCommonModule() && retClass->typeId == KType_float) {
		ResultSet_getFloat(kctx, sfp);
	} else {
		kObject *returnValue = KLIB Knull(kctx, retClass);
		KStackSetUnboxValue(sfp[K_RTNIDX].unboxValue, kObject_Unbox(returnValue));
		KReturn(returnValue);
	}
}
开发者ID:masakiishii,项目名称:minikonoha,代码行数:16,代码来源:sql_glue.c


示例13: Stmt_getTokenList

//## Token[] Stmt.getTokenList(symbol keyword, Token[] def);
static KMETHOD Stmt_getTokenList(KonohaContext *kctx, KonohaStack *sfp)
{
	kStmt    *stmt    = sfp[0].asStmt;
	ksymbol_t keyword = (ksymbol_t)sfp[1].intValue;
	kArray   *def     = sfp[2].asArray;
	kTokenArray *tokenList = (kTokenArray *)kStmt_GetObject(kctx, stmt, keyword, def);
	kTokenArray *ret;
	if(!IS_Array(tokenList)) {
		ret = new_(TokenArray, 0, OnStack);
		KLIB kArray_Add(kctx, ret, tokenList);
	}
	else {
		ret = tokenList;
	}
	KReturn(ret);
}
开发者ID:kkuramitsu,项目名称:minikonoha,代码行数:17,代码来源:sugar_glue.c


示例14: String_new_fromBytes_withSpecifiedDecode

//## String String.new(Bytes ba, String charset);
static KMETHOD String_new_fromBytes_withSpecifiedDecode(KonohaContext *kctx, KonohaStack *sfp)
{
	kBytes *ba = sfp[1].asBytes;
	kString *charset = sfp[2].asString;
	kString *s = TS_EMPTY;
	if(ba->bytesize != 0) {
		// At this point, we assuem 'ba' is null terminated.
		DBG_ASSERT(ba->buf[ba->bytesize] == '\0');
		KMakeTrace(trace, sfp);
		KBuffer wb;
		KLIB KBuffer_Init(&(kctx->stack->cwb), &wb);
		KBuffer_convertCharset(kctx, &wb, kString_text(charset), "UTF-8", ba->buf, ba->bytesize, trace);
		s = KLIB KBuffer_Stringfy(kctx, &wb, OnStack, StringPolicy_FreeKBuffer);
	}
	KReturn(s);
}
开发者ID:masakiishii,项目名称:minikonoha,代码行数:17,代码来源:Bytes_glue.c


示例15: Array_newArray

static KMETHOD Array_newArray(KonohaContext *kctx, KonohaStack *sfp)
{
	kArrayVar *a = (kArrayVar *)sfp[0].asObject;
	size_t asize = (size_t)sfp[1].intValue;
	a->bytemax = asize * sizeof(uintptr_t);
	kArray_SetSize(a, asize);
	a->ObjectItems = (kObject**)KCalloc_UNTRACE(a->bytemax, 1);
	if(!kArray_isUnboxData(a)) {
		size_t i;
		kObject *null = KLIB Knull(kctx, CT_(O_p0(a)));
		for(i = 0; i < asize; i++) {
			KFieldSet(a, a->ObjectItems[i], null);
		}
	}
	KReturn(a);
}
开发者ID:hisaboh,项目名称:minikonoha,代码行数:16,代码来源:array_glue.c


示例16: Array_concat

//## method Array<T> Array.concat(Array<T> a1);
static KMETHOD Array_concat(KonohaContext *kctx, KonohaStack *sfp)
{
	kArray *a0 = sfp[0].asArray;
	kArray *a1 = sfp[1].asArray;
	size_t i;
	if(kArray_isUnboxData(a1)) {
		for (i = 0; i < kArray_size(a1); i++){
			UnboxArray_Add(kctx, a0, a1->unboxItems[i]);
		}
	} else {
		for (i = 0; i < kArray_size(a1); i++){
			KLIB kArray_Add(kctx, a0, a1->ObjectItems[i]);
		}
	}
	KReturn(a0);
}
开发者ID:hisaboh,项目名称:minikonoha,代码行数:17,代码来源:array_glue.c


示例17: TypeCheck_Getter

static KMETHOD TypeCheck_Getter(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_TypeCheck(stmt, expr, gma, reqty);
	kToken *tkN = expr->cons->TokenItems[0];
	ksymbol_t fn = tkN->resolvedSymbol;
	kExpr *self = SUGAR kStmt_TypeCheckExprAt(kctx, stmt, expr, 1, gma, TY_var, 0);
	kNameSpace *ns = Stmt_ns(stmt);
	if(self != K_NULLEXPR) {
		kMethod *mtd = KLIB kNameSpace_GetGetterMethodNULL(kctx, ns, self->ty, fn, TY_var);
		if(mtd != NULL) {
			KFieldSet(expr->cons, expr->cons->MethodItems[0], mtd);
			KReturn(SUGAR kStmtkExpr_TypeCheckCallParam(kctx, stmt, expr, mtd, gma, reqty));
		}
		SUGAR kStmt_Message2(kctx, stmt, tkN, ErrTag, "undefined field: %s", S_text(tkN->text));
	}
}
开发者ID:doly,项目名称:minikonoha,代码行数:16,代码来源:class_glue.c


示例18: Statement_CStyleFor

static KMETHOD Statement_CStyleFor(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_TypeCheck(stmt, ns, reqc);
	int KSymbol_InitNode = KSymbol_("init"), KSymbol_IteratorNode = KSymbol_("Iterator");
	KDump(stmt);
	kNode *initNode = SUGAR TypeCheckNodeByName(kctx, stmt, KSymbol_InitNode, ns, KClass_void, TypeCheckPolicy_AllowEmpty);
	if(initNode != NULL) {
		kNode_Set(OpenBlock, initNode, true);
	}
	SUGAR TypeCheckNodeByName(kctx, stmt, KSymbol_IteratorNode, ns, KClass_void, TypeCheckPolicy_AllowEmpty);
	SUGAR TypeCheckNodeByName(kctx, stmt, KSymbol_ExprPattern, ns, KClass_Boolean, 0);
	kNode_Set(CatchContinue, stmt, true);  // set before TypeCheckAll
	kNode_Set(CatchBreak, stmt, true);
	//kNode_Set(RedoLoop, stmt, true);
	SUGAR TypeCheckNodeByName(kctx, stmt, KSymbol_BlockPattern, ns, KClass_void, 0);
	KReturn(kNode_Type(kctx, stmt, KNode_For, KType_void));
}
开发者ID:imasahiro,项目名称:konoha3,代码行数:17,代码来源:CStyleFor_glue.c


示例19: TypeCheck_Defined

static KMETHOD TypeCheck_Defined(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_TypeCheck2(stmt, expr, ns, reqc);
	size_t i;
	kbool_t isDefined = true;
	KParserContext *sugarContext = KGetParserContext(kctx);
	int popIsBlockingErrorMessage = sugarContext->isBlockedErrorMessage;
	sugarContext->isBlockedErrorMessage = true;
	for(i = 1; i < kArray_size(expr->NodeList); i++) {
		kNode *typedNode = SUGAR TypeCheckNodeAt(kctx, expr, i, ns, KClass_INFER, TypeCheckPolicy_AllowVoid);
		if(kNode_IsError(typedNode)) {
			isDefined = false;
			break;
		}
	}
	sugarContext->isBlockedErrorMessage = popIsBlockingErrorMessage;
	KReturn(SUGAR kNode_SetUnboxConst(kctx, expr, KType_Boolean, isDefined));
}
开发者ID:imasahiro,项目名称:konoha3,代码行数:18,代码来源:NameSpace_glue.c


示例20: String_toBytes

//## Bytes String.toBytes();
static KMETHOD String_toBytes(KonohaContext *kctx, KonohaStack *sfp)
{
	kString* thisString = sfp[0].asString;
	size_t size = kString_size(thisString);
	if(PLATAPI I18NModule.isSystemCharsetUTF8(kctx)) {
		KReturn(new_kBytes(kctx, OnStack, KGetReturnType(sfp), kString_text(thisString), size));
	}
	else {
		KMakeTrace(trace, sfp);
		KBuffer wb;
		KLIB KBuffer_Init(&(kctx->stack->cwb), &wb);
		KBuffer_convertCharset(kctx, &wb, I18NAPI systemCharset, "UTF-8", kString_text(thisString), size, trace);
		KReturnWith(
			new_kBytes(kctx, OnStack, KGetReturnType(sfp), KLIB KBuffer_text(kctx, &wb, NonZero), KBuffer_bytesize(&wb)),
			KLIB KBuffer_Free(&wb)
		);
	}
}
开发者ID:masakiishii,项目名称:minikonoha,代码行数:19,代码来源:Bytes_glue.c



注:本文中的KReturn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ KReturnFloatValue函数代码示例发布时间:2022-05-30
下一篇:
C++ KRIL_DEBUG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap