Example #1
0
static kbool_t iterator_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequireKonohaCommonModule(trace);
	if(KClass_Iterator == NULL) {
		kparamtype_t IteratorParam = {KType_Object};
		KDEFINE_CLASS defIterator = {0};
		SETSTRUCTNAME(defIterator, Iterator);
		defIterator.cflag  = KClassFlag_Iterator;
		defIterator.init   = Iterator_Init;
		defIterator.cparamsize  = 1;
		defIterator.cParamItems = &IteratorParam;

		KClass_Iterator = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defIterator, trace);
		KClass_StringIterator = KClass_p0(kctx, KClass_Iterator, KType_String);
		KClass_GenericIterator = KClass_p0(kctx, KClass_Iterator, KType_0);
	}

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Iterator_hasNext), KType_Boolean, KType_Iterator, KMethodName_("hasNext"), 0,
		_Public, _F(Iterator_next), KType_0, KType_Iterator, KMethodName_("next"), 0,
		_Public, _F(Array_toIterator),  KType_GenericIterator, KType_Array, KMethodName_("toIterator"), 0,
		_Public, _F(String_toIterator), KType_StringIterator, KType_String, KMethodName_("toIterator"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
static kbool_t konoha_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_CLASS defKonohaFactory = {0};
	SETSTRUCTNAME(defKonohaFactory, KonohaFactory);
	defKonohaFactory.init = kKonohaFactory_Init;
	defKonohaFactory.free = kKonohaFactory_Free;
	KDEFINE_CLASS defKonoha = {0};
	SETSTRUCTNAME(defKonoha, Konoha);
	defKonoha.init = kKonoha_Init;
	defKonoha.free = kKonoha_Free;

	KClass *cKonohaFactory = KLIB KClass_define(kctx, ns->packageId, NULL, &defKonohaFactory, trace);
	KClass *cKonoha =  KLIB KClass_define(kctx, ns->packageId, NULL, &defKonoha, trace);
	int KType_KonohaFactory = cKonohaFactory->typeId, KType_Konoha = cKonoha->typeId;

	KDEFINE_METHOD MethodData[] = {
		kMethod_Public, _F(KonohaFactory_new), KType_KonohaFactory, KType_KonohaFactory, KMethodName_("new"), 0,
		kMethod_Public, _F(KonohaFactory_loadModule), KType_Boolean, KType_KonohaFactory, KMethodName_("loadModule"), 1, KType_String, KFieldName_("name"),
		kMethod_Public, _F(KonohaFactory_create), KType_Konoha, KType_KonohaFactory, KMethodName_("create"), 0,
		kMethod_Public, _F(Konoha_loadScript), KType_Boolean, KType_Konoha, KMethodName_("loadScript"), 1, KType_String, KFieldName_("filename"),
		kMethod_Public, _F(Konoha_eval), KType_Konoha, KType_Konoha, KMethodName_("eval"), 1, KType_String, KFieldName_("script"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
Example #3
0
static kbool_t bytes_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequireKonohaCommonModule(trace);
	//KImportPackageSymbol(ns, "cstyle", "$SingleQuotedChar", trace);
	if(KClass_Bytes == NULL) {
		KDEFINE_CLASS defBytes = {0};
		SETSTRUCTNAME(defBytes, Bytes);
		defBytes.cflag   = KClassFlag_Final;
		defBytes.free    = kBytes_Free;
		defBytes.init    = kBytes_Init;
		defBytes.format       = kBytes_format;
		KClass_Bytes = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defBytes, trace);
	}
	int FN_index = KFieldName_("index");
	int FN_c     = KFieldName_("c");
	int FN_size  = KFieldName_("size");
	KDEFINE_METHOD MethodData[] = {
		_Public,     _F(Bytes_new),     KType_Bytes,  KType_Bytes, KMethodName_("new"),     1, KType_Int, FN_size,
		_Public|_Im, _F(Bytes_getSize), KType_Int,    KType_Bytes, KMethodName_("getSize"), 0,
		_Public|_Im, _F(Bytes_get),     KType_Int,    KType_Bytes, KMethodName_("get"),     1, KType_Int, FN_index,
		_Public,     _F(Bytes_Set),     KType_void,   KType_Bytes, KMethodName_("set"),     2, KType_Int, FN_index, KType_Int, FN_c,
		_Public,     _F(Bytes_SetAll),  KType_void,   KType_Bytes, KMethodName_("setAll"),  1, KType_Int, FN_c,
		_Public|_Im|_Coercion, _F(String_toBytes), KType_Bytes, KType_String, KMethodName_To(KType_Bytes),   0,
		//_Public|_Im|_Coercion, _F(Bytes_toString), KType_String, KType_Bytes,  KMethodName_To(KType_String),  0,
		//_Public|_Const, _F(Bytes_encodeTo),   KType_Bytes,  KType_Bytes,  KMethodName_("encodeTo"),    1, KType_String, FN_encoding,
		//_Public|_Const, _F(Bytes_decodeFrom),   KType_String, KType_Bytes,  KMethodName_("decodeFrom"),    1, KType_String, FN_encoding,
		_Public, _F(String_new_fromBytes_withDefaultDecode),      KType_String, KType_String, KMethodName_("new"), 1, KType_Bytes, KFieldName_("ba"),
		_Public, _F(String_new_fromBytes_withSpecifiedDecode),    KType_String, KType_String, KMethodName_("new"), 2, KType_Bytes, KFieldName_("ba"), KType_String, KFieldName_("charset"),
		_Public, _F(String_new_fromSubBytes_withDefaultDecode),   KType_String, KType_String, KMethodName_("new"), 3, KType_Bytes, KFieldName_("ba"), KType_Int,    KFieldName_("offset"), KType_Int, KFieldName_("length"),
		_Public, _F(String_new_fromSubBytes_withSpecifiedDecode), KType_String, KType_String, KMethodName_("new"), 4, KType_Bytes, KFieldName_("ba"), KType_Int,    KFieldName_("offset"), KType_Int, KFieldName_("length"), KType_String, KFieldName_("charset"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
Example #4
0
static kbool_t Libevent_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	/* Class Definition */
	KDEFINE_CLASS defLibevent = {0};
	SETSTRUCTNAME(defLibevent, Libevent);
	defLibevent.cflag     = KClassFlag_Final;
	defLibevent.init      = Libevent_Init;
	defLibevent.free      = Libevent_Free;
	KClass *LibeventClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defLibevent, trace);

	int KType_Libevent = LibeventClass->typeId;

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Libevent_new), KType_Libevent, KType_Libevent, KMethodName_("new"), 0,
		_Public, _F(Libevent_dispatch), KType_Libevent, KType_Libevent, KMethodName_("dispatch"), 0,
		_Public, _F(Libevent_event_add), KType_Int, KType_Libevent, KMethodName_("event_add"), 2, KType_Object, KFieldName_("timeval"),
		_Public, _F(Libevent_event_del), KType_Int, KType_Libevent, KMethodName_("event_del"), 1,



#ifdef	CUTCUT
		_Public, _F(Person_say), KType_String, KType_Person, KMethodName_("say"), 0,
#endif
		DEND, /* <= sentinel */
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	return true;
}
Example #5
0
static void Syntax_defineMessageMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Node_Message), KType_Node, KType_Node, KMethodName_("Message"), 2, TP_level, TP_message,
		_Public, _F(NodeToken_Message), KType_Node, KType_Node, KMethodName_("Message"), 3, TP_level, TP_token, TP_message,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #6
0
static void prototype_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	int FN_key = KFieldName_("key"), FN_value = KFieldName_("value");
	KDEFINE_METHOD MethodData[] = {
		_Public|_Im|_Const|kMethod_SmartReturn|_Final, _F(Prototype_get), KType_Object, KType_Prototype, KMethodName_("get"), 1, KType_Symbol, FN_key,
		_Public|_Final, _F(Prototype_SetObject), KType_void, KType_Prototype, KMethodName_("set"), 2, KType_Symbol, FN_key, KType_Object, FN_value,
		_Public|_Final, _F(Prototype_SetInt), KType_void, KType_Prototype, KMethodName_("set"), 2, KType_Symbol, FN_key, KType_Int, FN_value,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #7
0
static void namespace_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Im, _F(NameSpace_GetNameSpace), KType_NameSpace, KType_NameSpace, KMethodName_("GetNameSpace"), 0,
		_Public|_Const|_Im, _F(NameSpace_GetParentNameSpace), KType_NameSpace, KType_NameSpace, KMethodName_("GetParentNameSpace"), 0,
		_Public, _F(NameSpace_DefineMacro2), KType_Boolean, KType_NameSpace, KMethodName_("DefineMacro"), 2, TP_name, TP_source,
		_Public, _F(NameSpace_DefineMacro), KType_Boolean, KType_NameSpace, KMethodName_("DefineMacro"), 3, TP_name, TP_paramsize, TP_source,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #8
0
static void class_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Ignored, _F(NameSpace_AllowImplicitField), KType_void, KType_NameSpace, KMethodName_("AllowImplicitField"), 1, KType_Boolean, KFieldName_("allow"),
		_Public|_Const, _F(NameSpace_AddMethodDecl), KType_void, KType_NameSpace, KMethodName_("AddMethodDecl"), 1, KType_Node, KFieldName_("node"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #9
0
static kbool_t i_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(NameSpace_man), KType_void, KType_NameSpace, KMethodName_("man"), 1, KType_Object, KFieldName_("x"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
Example #10
0
static void object_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Im|_Const|_Final, _F(Object_getTypeId), KType_Int, KType_Object, KMethodName_("getTypeId"), 0,
		_Public|_Hidden|_Im|_Const|_Final, _F(Object_instanceOf), KType_Boolean, KType_Object, KMethodName_("instanceof"), 1, KType_Object, KFieldName_("type"),
		_Public|_Hidden|_Im|_Const|kMethod_SmartReturn|_Final, _F(Object_as), KType_Object, KType_Object, KMethodName_("as"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #11
0
static void path_defineDIR(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_CLASS defDIR = {};
	defDIR.structname = "DIR";
	defDIR.typeId = KTypeAttr_NewId;
	defDIR.cstruct_size = sizeof(struct kDirVar);
	defDIR.cflag = KClassFlag_Final;
	defDIR.init  = kDir_Init;
	defDIR.reftrace  = kDir_Reftrace;
	defDIR.free  = kDir_Free;
	defDIR.format     = kDir_format;
	KClass *cDIR = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defDIR, trace);
	int KType_DIR = cDIR->typeId;
	KDEFINE_METHOD MethodData[] = {
		_Public|_Static|_C, _F(System_opendir),   KType_DIR,    KType_System, KMethodName_("opendir"),  1, KType_String, KFieldName_("dirname"),
		_Public,            _F(DIR_close),        KType_void,   KType_DIR,    KMethodName_("close"), 0,
		_Public|_Iter,      _F(DIR_readFileName), KType_String, KType_DIR,    KMethodName_("readFileName"), 0,
		_Public|_Iter,      _F(DIR_readPath),     KType_String, KType_DIR,    KMethodName_("readPath"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #12
0
static kbool_t console_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KDEFINE_CLASS defConsole = {0};
	SETSTRUCTNAME(defConsole, Console);
	defConsole.cflag = KClassFlag_Final | KClassFlag_Singleton;

	KClass *cConsole = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defConsole, trace);
	int KType_Console = cConsole->typeId;

	KDEFINE_METHOD MethodData[] = {
		_Public|_Static, _F(Console_notify), KType_void, KType_Console, KMethodName_("notify"), 1, KType_String, KFieldName_("message"),
		_Public|_Static, _F(Console_readLine), KType_String, KType_Console, KMethodName_("readLine"), 1, KType_String, KFieldName_("message"),
		_Public|_Static, _F(Console_inputUserApproval), KType_Boolean, KType_Console, KMethodName_("inputUserApproval"), 4,
		    KType_String, KFieldName_("message"), KType_String, KFieldName_("yes"), KType_String, KFieldName_("no"), KType_Boolean, KFieldName_("defval"),
		_Public|_Static, _F(Console_inputUserPassword), KType_String, KType_Console, KMethodName_("inputUserPassword"), 1, KType_String, KFieldName_("message"),
		_Public|_Static, _F(Console_inputUserPassword0), KType_String, KType_Console, KMethodName_("inputUserPassword"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	return true;
}
Example #13
0
static kbool_t Exception_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Exception_new), KType_Exception,  KType_Exception, KMethodName_("new"), 0, _Public|_Hidden, _F(System_throw), KType_void,  KType_System, KMethodName_("throw"), 1, KType_Exception, KFieldName_("e"),
		_Public|_Hidden, _F(System_getThrownException), KType_Exception, KType_System, KMethodName_("getThrownException"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	KDEFINE_SYNTAX SYNTAX[] = {
		{ KSymbol_("try"), SYNFLAG_CTypeFunc, 0, 0, {SUGAR patternParseFunc}, {SUGARFUNC Statement_try}},
		{ KSymbol_("catch"), SYNFLAG_CTypeFunc, 0, 0, {SUGAR patternParseFunc}, {SUGARFUNC Statement_catch}},
		{ KSymbol_("finally"), SYNFLAG_CTypeFunc, 0, 0, {SUGAR patternParseFunc}, {SUGARFUNC Statement_finally}},
		{ KSymbol_END, },
	};
	SUGAR kNameSpace_DefineSyntax(kctx, ns, SYNTAX, trace);

	SUGAR kSyntax_AddPattern(kctx, kSyntax_(ns, KSymbol_("try")), "\"try\" $Node [ \"catch\" \"(\" $Type $Symbol \")\" catch: $Node ] [ \"finally\" finally: $Node ]", 0, trace);
	SUGAR kSyntax_AddPattern(kctx, kSyntax_(ns, KSymbol_("catch")), "\"catch\" \"(\" $Type $Symbol \")\" $Node", 0, trace);
	SUGAR kSyntax_AddPattern(kctx, kSyntax_(ns, KSymbol_("finally")), "\"finally\" $Node", 0, trace);

	return true;
}
Example #14
0
// --------------------------------------------------------------------------
static kbool_t ClosureModel_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KDEFINE_SYNTAX SYNTAX[] = {
		{ KSymbol_("function"), SYNFLAG_CTypeFunc, 0, Precedence_CStyleAssign, {SUGAR patternParseFunc}, {SUGARFUNC TypeCheck_Closure}},
		{ KSymbol_END, },
	};
	SUGAR kNameSpace_DefineSyntax(kctx, ns, SYNTAX, trace);
	SUGAR kSyntax_AddPattern(kctx, kSyntax_(ns, KSymbol_("function")), "\"function\" $Param [$Type] $Block", 0, NULL);

	KDEFINE_METHOD MethodData[] = {
		_Public|_Hidden, _F(Func_Create), KType_Func, KType_Func, KMethodName_("_Create"), 2, KType_Object, KFieldName_("env"), KType_Method, KFieldName_("mtd"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	return true;
}
Example #15
0
static kbool_t FuelVM_VisitMethodCallNode(KonohaContext *kctx, KBuilder *builder, kNode *expr, void *thunk)
{
	kMethod *mtd = CallNode_getMethod(expr);
	DBG_ASSERT(IS_Method(mtd));
	enum TypeId Type = ConvertToTypeId(kctx, expr->attrTypeId);
	if(mtd->mn == KMethodName_("box")) {
		Type = ToBoxType(Type);
	}

	/*
	 * [CallExpr] := this.method(arg1, arg2, ...)
	 * expr->NodeList = [method, this, arg1, arg2, ...]
	 **/
	INode *Inst;
	if((Inst = CreateSpecialInstruction(kctx, builder, mtd, expr, thunk)) != 0) {
		INode_setType(Inst, Type);
		builder->Value = Inst;
		return true;
	}
	int i, s = kMethod_Is(Static, mtd) ? 2 : 1;
	int argc = CallExpr_getArgCount(expr);
	INode *Params[argc+2];

	if(kMethod_Is(Static, mtd)) {
		kObject *obj = KLIB Knull(kctx, KClass_(mtd->typeId));
		INode *Self = CreateObject(BLD(builder), mtd->typeId, (void *) obj);
		Params[1] = Self;
	}
	for (i = s; i < argc + 2; i++) {
		kNode *exprN = kNode_At(expr, i);
		DBG_ASSERT(IS_Node(exprN));
		SUGAR VisitNode(kctx, builder, exprN, thunk);
		INode *Node = FuelVM_getExpression(builder);
		assert(Node->Type != TYPE_void);
		Params[i] = Node;
	}

	INode *MtdObj = CreateObject(BLD(builder), KType_Method, (void *) mtd);
	enum CallOp Op = (kMethod_Is(Virtual, mtd)) ? VirtualCall : DefaultCall;
	Params[0] = MtdObj;
	kNode *stmt = expr->Parent;
	assert(IS_Node(stmt));
	Inst = CreateICall(BLD(builder), Type, Op, kNode_uline(stmt), Params, argc + 2);
	builder->Value = Inst;
	return true;
}
Example #16
0
static KMETHOD TypeCheck_as(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(selfClass->typeId == targetClass->typeId || selfClass->isSubType(kctx, selfClass, targetClass)) {
			KReturn(selfNode);
		}
		if(selfClass->isSubType(kctx, targetClass, selfClass)) {
			kNameSpace *ns = kNode_ns(stmt);
			kMethod *mtd = KLIB kNameSpace_GetMethodByParamSizeNULL(kctx, ns, KClass_Object, KMethodName_("as"), 0, KMethodMatch_CamelStyle);
			DBG_ASSERT(mtd != NULL);
			KReturn(SUGAR TypeCheckMethodParam(kctx, mtd, expr, ns, targetClass));
		}
		KReturn(SUGAR MessageNode(kctx, selfNode, NULL, ns, ErrTag, "unable to downcast: %s as %s", KType_text(selfNode->attrTypeId), KType_text(targetNode->attrTypeId)));
	}
}
Example #17
0
static int konoha_handler(request_rec *r)
{
    //konoha_config_t *conf = ap_get_module_config(
    //		r->server->module_config, &konoha_module);
    if(strcmp(r->handler, "konoha-script")) {
        return DECLINED;
    }
    //if(r->method_number != M_GET) {
    //	 TODO
    //	return HTTP_METHOD_NOT_ALLOWED;
    //}
    KClass *cRequest;
    KonohaContext* konoha = konoha_create(&cRequest, 1);
    //assert(cRequest != NULL);
    r->content_encoding = "utf-8";
    ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, "filename=%s", r->filename);
    if(Konoha_LoadScript(konoha, r->filename)) {
        return DECLINED;
    }

    KonohaContext *kctx = konoha;
    kNameSpace *ns = KNULL(NameSpace);
    kMethod *mtd = KLIB kNameSpace_GetMethodByParamSizeNULL(kctx, ns, KClass_System, KMethodName_("handler"), -1, KMethodMatch_NoOption);  // fixme
    if(mtd == NULL) {
        ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, "System.handler() not found");
        return -1;
    }

    /* XXX: We assume Request Object may not be freed by GC */
    kObject *req_obj = KLIB new_kObject(kctx, OnStack, cRequest, (uintptr_t)r);
    BEGIN_UnusedStack(lsfp);
    KStackSetObjectValue(lsfp[K_CALLDELTA+0].asObject, K_NULL);
    KStackSetObjectValue(lsfp[K_CALLDELTA+1].asObject, req_obj);
    {
        KonohaStack *sfp = lsfp + K_CALLDELTA;
        KStackSetMethodAll(sfp, KLIB Knull(kctx, KClass_Int), 0/*UL*/, mtd, 1);
        KStackCall(sfp);
    }
    END_UnusedStack();
    int ret = lsfp[0].intValue;
    Konoha_Destroy(konoha);
    return ret;
}
Example #18
0
static KMETHOD TypeCheck_InstanceOf(KonohaContext *kctx, KonohaStack *sfp)
{
	VAR_TypeCheck2(stmt, expr, ns, reqc);
	/* selfNode and targetNode allow void type
	 * e.g. "'a' instanceof void" */
	kNode *selfNode   = SUGAR TypeCheckNodeAt(kctx, expr, 1, ns, KClass_INFER, TypeCheckPolicy_AllowVoid);
	kNode *targetNode = SUGAR TypeCheckNodeAt(kctx, expr, 2, ns, KClass_INFER, TypeCheckPolicy_AllowVoid);
	if(selfNode != K_NULLNODE && targetNode != K_NULLNODE) {
		KClass *selfClass = KClass_(selfNode->attrTypeId), *targetClass = KClass_(targetNode->attrTypeId);
		if(KClass_Is(Final, selfClass)) {
			kbool_t staticSubType = (selfClass == targetClass || selfClass->isSubType(kctx, selfClass, targetClass));
			KReturn(SUGAR kNode_SetUnboxConst(kctx, expr, KType_Boolean, staticSubType));
		}
		kNameSpace *ns = kNode_ns(stmt);
		kMethod *mtd = KLIB kNameSpace_GetMethodByParamSizeNULL(kctx, ns, KClass_Object, KMethodName_("instanceof"), 1, KMethodMatch_NoOption);
		DBG_ASSERT(mtd != NULL);
		kNode *classValue = SUGAR kNode_SetConst(kctx, expr->NodeList->NodeVarItems[2], NULL, KLIB Knull(kctx, targetClass));
		KFieldSet(expr->NodeList, expr->NodeList->NodeItems[2], classValue);
		KReturn(SUGAR TypeCheckMethodParam(kctx, mtd, expr, ns, KClass_Boolean));
	}
}
Example #19
0
static kbool_t FuelVM_VisitFunctionNode(KonohaContext *kctx, KBuilder *builder, kNode *expr, void *thunk)
{
	/*
	 * [FunctionExpr] := new Function(method, env1, env2, ...)
	 * expr->NodeList = [method, defObj, env1, env2, ...]
	 **/
	enum TypeId Type;
	kMethod *mtd = CallNode_getMethod(expr);
	kObject *obj = expr->NodeList->ObjectItems[1];
	INode *MtdObj = CreateObject(BLD(builder), KType_Method, (void *) mtd);

	Type = ConvertToTypeId(kctx, kObject_class(obj)->typeId);
	INode *NewEnv  = CreateNew(BLD(builder), 0, Type);

	size_t i, ParamSize = kArray_size(expr->NodeList)-2;
	for(i = 0; i < ParamSize; i++) {
		kNode *envN = kNode_At(expr, i+2);
		enum TypeId FieldType = ConvertToTypeId(kctx, envN->attrTypeId);
		INode *Node = CreateField(BLD(builder), FieldScope, FieldType, NewEnv, i);
		SUGAR VisitNode(kctx, builder, envN, thunk);
		CreateUpdate(BLD(builder), Node, FuelVM_getExpression(builder));
	}

	Type = ConvertToTypeId(kctx, expr->attrTypeId);
	INode *NewFunc = CreateNew(BLD(builder), 0, Type);

	kNameSpace *ns = kNode_ns(expr);
	mtd =  KLIB kNameSpace_GetMethodByParamSizeNULL(kctx, ns, KClass_Func, KMethodName_("_Create"), 2, KMethodMatch_NoOption);

	INode *CallMtd = CreateObject(BLD(builder), KType_Method, (void *) mtd);
	INode *Params[4];
	Params[0] = CallMtd;
	Params[1] = NewFunc;
	Params[2] = NewEnv;
	Params[3] = MtdObj;
	builder->Value = CreateICall(BLD(builder), Type, DefaultCall, kNode_uline(expr), Params, 4);

	return true;
}
Example #20
0
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));
	}
}
Example #21
0
void LoadDefaultSugarMethod(KonohaContext *kctx, kNameSpace *ns)
{
	KSetKLibFunc(0, ReportScriptMessage,           TRACE_ReportScriptMessage,           NULL);
	KSetKLibFunc(0, kNameSpace_RequirePackage,      kNameSpace_RequirePackage,      NULL);
	KSetKLibFunc(0, kNameSpace_ImportPackage,       kNameSpace_ImportPackage,       NULL);
	KSetKLibFunc(0, kNameSpace_LoadScript,          kNameSpace_LoadScript,          NULL);
	KSetKLibFunc(0, kNameSpace_GetConstNULL,        kNameSpace_GetConstNULL,        NULL);
	KDEFINE_METHOD MethodData[] = {
		_Public|_Compilation, _F(NameSpace_DefineConst), KType_Boolean, KType_NameSpace, KMethodName_("DefineConst"), 2, KType_Symbol, KFieldName_("symbol"), KType_Object, KFieldName_("value"),
		_Public|_Compilation, _F(NameSpace_ImportPackage), KType_void, KType_NameSpace, KMethodName_("import"), 1, KType_String, KFieldName_("package"),
		_Public, _F(NameSpace_hate), KType_Boolean, KType_NameSpace, KMethodName_("hate"), 1, KType_String, KFieldName_("symbol"),
		_Public|_Compilation, _F(NameSpace_loadScript), KType_void, KType_NameSpace, KMethodName_("load"), 1, KType_String, KFieldName_("filename"),
		_Public|_Compilation, _F(NameSpace_loadScript), KType_void, KType_NameSpace, KMethodName_("include"), 1, KType_String, KFieldName_("filename"),
		_Public, _F(NameSpace_useStaticFunc), KType_void, KType_NameSpace, KMethodName_("UseStaticFunc"), 1, KType_Object, KFieldName_("class"),
		_Public|_Coercion|_Const|_Imm, _F(String_toSymbol), KType_Symbol, KType_String, KMethodName_To(KType_Symbol), 0,
		_Public|_Coercion|_Const|_Imm, _F(KSymbol_toString), KType_String, KType_Symbol, KMethodName_To(KType_String), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, NULL);
}
Example #22
0
static kbool_t float_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KRequireKonohaCommonModule(trace);
	if(KClass_Float == NULL) {
		KDEFINE_CLASS defFloat = {0};
		SETUNBOXNAME(defFloat, float);
		defFloat.cstruct_size = sizeof(kFloat);
		defFloat.cflag = KClassFlag_int;
		defFloat.init = kFloat_Init;
		defFloat.p     = kFloat_p;
		KClass_Float = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defFloat, trace);
	}
	int FN_x = KFieldName_("x");
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Im, _F(Float_opPlus), KType_float, KType_float, KMethodName_("+"), 0,
		_Public|_Const|_Im, _F(Float_opADD), KType_float, KType_float, KMethodName_("+"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opADD), KType_float, KType_Int, KMethodName_("+"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opSUB), KType_float, KType_float, KMethodName_("-"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opSUB), KType_float, KType_Int, KMethodName_("-"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opMUL), KType_float, KType_float, KMethodName_("*"), 1, KType_float, FN_x,
		_Public|_Im, _F(Float_opDIV), KType_float, KType_float, KMethodName_("/"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opEQ),  KType_Boolean, KType_float, KMethodName_("=="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opNEQ), KType_Boolean, KType_float, KMethodName_("!="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opLT),  KType_Boolean, KType_float, KMethodName_("<"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opLTE), KType_Boolean, KType_float, KMethodName_("<="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opGT),  KType_Boolean, KType_float, KMethodName_(">"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Float_opGTE), KType_Boolean, KType_float, KMethodName_(">="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opMUL), KType_float, KType_Int, KMethodName_("*"), 1, KType_float, FN_x,
		_Public|_Im, _F(Int_opDIV), KType_float, KType_Int, KMethodName_("/"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opEQ),  KType_Boolean, KType_Int, KMethodName_("=="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opNEQ), KType_Boolean, KType_Int, KMethodName_("!="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opLT),  KType_Boolean, KType_Int, KMethodName_("<"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opLTE), KType_Boolean, KType_Int, KMethodName_("<="), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opGT),  KType_Boolean, KType_Int, KMethodName_(">"), 1, KType_float, FN_x,
		_Public|_Const|_Im, _F(Int_opGTE), KType_Boolean, KType_Int, KMethodName_(">="), 1, KType_float, FN_x,

		_Public|_Const|_Im|_Coercion, _F(Float_toInt), KType_Int, KType_float, KMethodName_To(KType_Int), 0,
		_Public|_Const|_Im|_Coercion, _F(Int_toFloat), KType_float, KType_Int, KMethodName_To(KType_float), 0,
		_Public|_Const|_Im, _F(Float_toString), KType_String, KType_float, KMethodName_To(KType_String), 0,
		_Public|_Const|_Im, _F(String_toFloat), KType_float, KType_String, KMethodName_To(KType_float), 0,
		_Public|_Const|_Im, _F(Float_opMINUS), KType_float, KType_float, KMethodName_("-"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	KDEFINE_FLOAT_CONST FloatData[] = {
		{"FLOAT_EPSILON", KType_float, DBL_EPSILON},
		{"Infinity", KType_float, INFINITY},
		{"NaN", KType_float, NAN},
		{NULL} /* sentinel */
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(FloatData), trace);
	return true;
}
Example #23
0
static kbool_t process_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	kparamtype_t p = {KType_Int};
	KClass *cintArray = KLIB KClass_Generics(kctx, KClass_(KType_Array), KType_void, 1, &p);
#define KType_IntArray (cintArray->typeId)

	KDEFINE_METHOD MethodData[] = {
		_Public|_Static, _F(System_getpid), KType_Int, KType_System, KMethodName_("getpid"), 0,
		_Public|_Static, _F(System_getppid), KType_Int, KType_System, KMethodName_("getppid"), 0,
		_Public|_Static, _F(System_getuid), KType_Int, KType_System, KMethodName_("getuid"), 0,
		_Public|_Static, _F(System_geteuid), KType_Int, KType_System, KMethodName_("geteuid"), 0,
		_Public|_Static, _F(System_getgid), KType_Int, KType_System, KMethodName_("getgid"), 0,
		_Public|_Static, _F(System_getegid), KType_Int, KType_System, KMethodName_("getegid"), 0,
		_Public|_Static, _F(System_getpgid), KType_Int, KType_System, KMethodName_("getpgid"), 1, KType_Int, KFieldName_("pid"),
		_Public|_Static, _F(System_Setpgid), KType_Int, KType_System, KMethodName_("setpgid"), 2, KType_Int, KFieldName_("pid"), KType_Int, KFieldName_("pgid"),
		_Public|_Static, _F(System_getpriority), KType_Int, KType_System, KMethodName_("getpriority"), 2, KType_Int, KFieldName_("which"), KType_Int, KFieldName_("who"),
		_Public|_Static, _F(System_Setpriority), KType_Int, KType_System, KMethodName_("setpriority"), 3, KType_Int, KFieldName_("which"), KType_Int, KFieldName_("who"), KType_Int, KFieldName_("priority"),
		_Public|_Static, _F(System_getgroups), KType_Int, KType_System, KMethodName_("getgroups"), 2, KType_Int, KFieldName_("size"), KType_IntArray, KFieldName_("list[]"),
		_Public|_Static, _F(System_Setgroups), KType_Int, KType_System, KMethodName_("setgroups"), 2, KType_Int, KFieldName_("size"), KType_IntArray, KFieldName_("*list"),
		_Public|_Static, _F(System_fork), KType_Int, KType_System, KMethodName_("fork"), 0,
		_Public|_Static, _F(System_wait), KType_Int, KType_System, KMethodName_("wait"), 0,
		_Public|_Static, _F(System_waitpid), KType_Int, KType_System, KMethodName_("wait"), 2, KType_Int, KFieldName_("pid"), KType_Int, KFieldName_("options"),
		_Public|_Static, _F(System_Setuid), KType_Int, KType_System, KMethodName_("setuid"), 1, KType_Int, KFieldName_("uid"),
		_Public|_Static, _F(System_Seteuid), KType_Int, KType_System, KMethodName_("seteuid"), 1, KType_Int, KFieldName_("euid"),
		_Public|_Static, _F(System_Setreuid), KType_Int, KType_System, KMethodName_("setreuid"), 2, KType_Int, KFieldName_("ruid"), KType_Int, KFieldName_("euid"),
		_Public|_Static, _F(System_Setgid), KType_Int, KType_System, KMethodName_("setgid"), 1, KType_Int, KFieldName_("gid"),
		_Public|_Static, _F(System_Setegid), KType_Int, KType_System, KMethodName_("setguid"), 1, KType_Int, KFieldName_("egid"),
		_Public|_Static, _F(System_Setregid), KType_Int, KType_System, KMethodName_("setrguid"), 2, KType_Int, KFieldName_("rgid"), KType_Int, KFieldName_("egid"),
		_Public|_Static, _F(System_Setsid), KType_Int, KType_System, KMethodName_("setsid"), 0,
		_Public|_Static, _F(System_getsid), KType_Int, KType_System, KMethodName_("getsid"), 1, KType_Int, KFieldName_("pid"),
		_Public|_Static, _F(System_sleep), KType_Int, KType_System, KMethodName_("sleep"), 1, KType_Int, KFieldName_("sec"),
		_Public|_Static, _F(System_usleep), KType_Boolean, KType_System, KMethodName_("usleep"), 1, KType_Int, KFieldName_("usec"),
		_Public|_Static, _F(System_system), KType_Int, KType_System, KMethodName_("system"), 1, KType_String, KFieldName_("command"),
		_Public|_Static, _F(System_getenv), KType_String, KType_System, KMethodName_("getenv"), 1, KType_String, KFieldName_("name"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	KDEFINE_INT_CONST intData[] = {
		{KDefineConstInt(SIGHUP)},
		{KDefineConstInt(SIGINT)},
		{KDefineConstInt(SIGABRT)},
		{KDefineConstInt(SIGKILL)},
		/*for System.setpriority*/
		{KDefineConstInt(PRIO_PROCESS)},
		{KDefineConstInt(PRIO_PGRP)},
		{KDefineConstInt(PRIO_USER)},
		{}
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(intData), trace);
	return true;
}
Example #24
0
static void Syntax_defineNodeMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	int FN_key = KFieldName_("key"), FN_defval = KFieldName_("defval");
	KDEFINE_METHOD MethodData[] = {
		/* Block */
		_Public|_Const, _F(Node_new), KType_Node, KType_Node, KMethodName_("new"), 1, KType_NameSpace, KFieldName_("namespace"),
		_Public, _F(Node_ParseNewNode), KType_Node, KType_Node, KMethodName_("ParseNewNode"), 4, TP_tokens, TP_begin, TP_end, KType_Boolean, KFieldName_("isMetaPattern"),
		_Public, _F(Node_GetNodeList), KType_NodeArray, KType_Node, KMethodName_("GetNodeList"), 0,
		_Public, _F(Node_GetParentNode), KType_Node, KType_Node, KMethodName_("GetParentNode"), 0,

		_Public, _F(Node_opEQ), KType_Boolean, KType_Node, KMethodName_("=="), 1, KType_Node, KFieldName_("other"),
		_Public, _F(Node_TypeCheckNode), KType_Node, KType_Node, KMethodName_("TypeCheckNode"), 3, TP_kw, TP_type, TP_pol,
		_Public, _F(Node_TypeCheckNodeAt), KType_Node, KType_Node, KMethodName_("TypeCheckNodeAt"), 3, TP_pos, TP_type, TP_pol,
		_Public, _F(Node_SetType), KType_void, KType_Node, KMethodName_("SetType"), 1, TP_type,
		_Public|_Im, _F(Node_GetType), KType_Int, KType_Node, KMethodName_("GetType"), 0,
		_Public, _F(Node_LookupNode), KType_Node, KType_Node, KMethodName_("lookupNode"), 1, TP_kw,
//////		_Public, _F(MessageNodearsedNode), KType_Node, KType_Node, KMethodName_("parseNode"), 3, KType_TokenArray, FN_tokenList, KType_Int, FN_s, KType_Int, FN_e,
		_Public, _F(Node_Op1), KType_Node, KType_Node, KMethodName_("Op"), 1, TP_token,
		_Public, _F(Node_Op2), KType_Node, KType_Node, KMethodName_("Op"), 2, TP_token, TP_ArgNode(1),
		_Public, _F(Node_Op3), KType_Node, KType_Node, KMethodName_("Op"), 3, TP_token, TP_ArgNode(1), TP_ArgNode(2),
//		_Public, _F(Node_Op4), KType_Node, KType_Node, KMethodName_("Op"), 4, TP_token, TP_ArgNode(1), TP_ArgNode(2), TP_ArgNode(3),
//		_Public, _F(Node_Op5), KType_Node, KType_Node, KMethodName_("Op"), 5, TP_token, TP_ArgNode(1), TP_ArgNode(2), TP_ArgNode(3), TP_ArgNode(4),
//		_Public, _F(Node_Op6), KType_Node, KType_Node, KMethodName_("Op"), 6, TP_token, TP_ArgNode(1), TP_ArgNode(2), TP_ArgNode(3), TP_ArgNode(4), TP_ArgNode(5),
//		_Public, _F(Node_Op7), KType_Node, KType_Node, KMethodName_("Op"), 7, TP_token, TP_ArgNode(1), TP_ArgNode(2), TP_ArgNode(3), TP_ArgNode(4), TP_ArgNode(5), TP_ArgNode(6),
////		_Public, _F(Node_rightJoinNode), KType_Node, KType_Node, KMethodName_("rightJoinNode"), 4, KType_Node, FN_expr, KType_TokenArray, FN_tokenList, KType_Int, FN_s, KType_Int, FN_e,
		_Public, _F(Node_getObject), KType_Node, KType_Node, KMethodName_("getNode"), 1, KType_Symbol, FN_key,
		_Public, _F(Node_getTokenList), KType_TokenArray, KType_Node, KMethodName_("getTokenList"), 2, KType_Symbol, FN_key, KType_TokenArray, FN_defval,
		_Public, _F(Node_getToken), KType_Token, KType_Node, KMethodName_("getToken"), 2, KType_Symbol, FN_key, KType_Token, FN_defval,
		_Public, _F(Node_done), KType_void, KType_Node, KMethodName_("done"), 0,
		_Public, _F(Node_keywordIs), KType_Boolean, KType_Node, KMethodName_("keywordIs"), 1, KType_Symbol, FN_key,
		_Public, _F(Node_getNameSpace), KType_NameSpace, KType_Node, KMethodName_("getNameSpace"), 0,
		_Public, _F(Node_AddNode), KType_Node, KType_Node, KMethodName_("addNode"), 1, KType_Node, KFieldName_("node"),
		_Public, _F(Node_InsertAfter), KType_Node, KType_Node, KMethodName_("insertAfter"), 2, KType_Node, KFieldName_("target"), KType_Node, KFieldName_("node"),

		/* Expr */
		_Public, _F(Node_getTermToken), KType_Token, KType_Node, KMethodName_("getTermToken"), 0,
		_Public, _F(Node_setConstValue), KType_Node, KType_Node, KMethodName_("setConstValue"), 1, KType_Object, KFieldName_("value") | KTypeAttr_Coercion,

		_Public, _F(Node_AddParsedObject), KType_void, KType_Node, KMethodName_("AddParsedObject"), 2, TP_kw, KType_Object, KFieldName_("obj"),
		_Public, _F(Node_AppendParsedNode), KType_Node, KType_Node, KMethodName_("AppendParsedNode"), 4, TP_tokens, TP_begin, TP_end, KType_String, KFieldName_("requiredTokenText"),
		_Public, _F(Node_newMethodNode1), KType_Node, KType_Node, KMethodName_("newMethodNode"), 3, TP_type, TP_kw, TP_ArgNode(1),
		_Public, _F(Node_newMethodNode2), KType_Node, KType_Node, KMethodName_("newMethodNode"), 4, TP_type, TP_kw, TP_ArgNode(1), TP_ArgNode(2),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #25
0
static void stat_defineClassAndMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_CLASS defStat = {};
	defStat.structname = "FileStatus";
	defStat.typeId = KTypeAttr_NewId;
	defStat.cstruct_size = sizeof(struct kFileStatusVar);
	defStat.cflag = KClassFlag_Final;
	defStat.init  = kFileStatus_Init;
	defStat.free  = kFileStatus_Free;
	defStat.format     = kFileStatus_format;
	KClass *cStat = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defStat, trace);
	int KType_Stat = cStat->typeId;
	KDEFINE_METHOD MethodData[] = {
		_Public|_Static, _F(System_stat),  KType_Stat, KType_System, KMethodName_("stat"), 1, KType_String, KFieldName_("path"),
		_Public|_Static, _F(System_lstat), KType_Stat, KType_System, KMethodName_("lstat"), 1, KType_String, KFieldName_("path"),
		_Public|_Static, _F(System_fstat), KType_Stat, KType_System, KMethodName_("fstat"), 1, KType_Int, KFieldName_("fd"),
		_Public|_Const|_Im, _F(Stat_getdev), KType_Int, KType_Stat, KMethodName_("getdev"), 0,
		_Public|_Const|_Im, _F(Stat_getino), KType_Int, KType_Stat, KMethodName_("getino"), 0,
		_Public|_Const|_Im, _F(Stat_getmode), KType_Int, KType_Stat, KMethodName_("getmode"), 0,
		_Public|_Const|_Im, _F(Stat_getnlink), KType_Int, KType_Stat, KMethodName_("getnlink"), 0,
		_Public|_Const|_Im, _F(Stat_getuid), KType_Int, KType_Stat, KMethodName_("getuid"), 0,
		_Public|_Const|_Im, _F(Stat_getgid), KType_Int, KType_Stat, KMethodName_("getgid"), 0,
		_Public|_Const|_Im, _F(Stat_getsize), KType_Int, KType_Stat, KMethodName_("getsize"), 0,
		_Public|_Const|_Im, _F(Stat_getatime), KType_Int, KType_Stat, KMethodName_("getatime"), 0,
		_Public|_Const|_Im, _F(Stat_getmtime), KType_Int, KType_Stat, KMethodName_("getmtime"), 0,
		_Public|_Const|_Im, _F(Stat_getctime), KType_Int, KType_Stat, KMethodName_("getctime"), 0,
#ifdef HAVE_STRUKClass_STAT_ST_RDEV
		_Public|_Const|_Im, _F(Stat_getrdev), KType_Int, KType_Stat, KMethodName_("getrdev"), 0,
#endif /* HAVE_STRUKClass_STAT_ST_RDEV */
#ifdef HAVE_STRUKClass_STAT_ST_BLOCKS
		_Public|_Const|_Im, _F(Stat_getblocks), KType_Int, KType_Stat, KMethodName_("getblocks"), 0,
#endif /* HAVE_STRUKClass_STAT_ST_BLOCKS */
#ifdef HAVE_STRUKClass_STAT_ST_BLKSIZE
		_Public|_Const|_Im, _F(Stat_getblksize), KType_Int, KType_Stat, KMethodName_("getblksize"), 0,
#endif /* HAVE_STRUKClass_STAT_ST_BLKSIZE */
#ifdef HAVE_STRUKClass_STAT_ST_FLAGS
		_Public|_Const|_Im, _F(Stat_getflags), KType_Int, KType_Stat, KMethodName_("getflags"), 0,
#endif /* HAVE_STRUKClass_STAT_ST_FLAGS */
#ifdef HAVE_STRUKClass_STAT_ST_GEN
		_Public|_Const|_Im, _F(Stat_getgen), KType_Int, KType_Stat, KMethodName_("getgen"), 0,
#endif /* HAVE_STRUKClass_STAT_ST_GEN */
#ifdef HAVE_STRUKClass_STAT_ST_BIRTHTIME
		_Public|_Const|_Im, _F(Stat_getbirthtime), KType_Int, KType_Stat, KMethodName_("getbirthtime"), 0,
#endif /* HAVE_STRUKClass_STAT_ST_BIRTHTIME */

		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Example #26
0
static kbool_t curl_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequireKonohaCommonModule(trace);
	KRequirePackage("Type.File", trace);

	KDEFINE_CLASS defCurl = {
		STRUCTNAME(Curl),
		.cflag = KClassFlag_Final,
		.init = kCurl_Init,
		.reftrace = kCurl_Reftrace,
		.free = kCurl_Free,
	};
	KClass *cCurl = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defCurl, trace);

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Curl_new), KType_Curl, KType_Curl, KMethodName_("new"), 0,
		_Public, _F(Curl_SetOptBoolean), KType_void, KType_Curl, KMethodName_("setOpt"), 2, KType_Int, KFieldName_("option"), KType_Boolean, KFieldName_("data"),
		_Public, _F(Curl_SetOptInt),     KType_void, KType_Curl, KMethodName_("setOpt"), 2, KType_Int, KFieldName_("option"), KType_Int,     KFieldName_("data"),
		_Public, _F(Curl_SetOptString),  KType_void, KType_Curl, KMethodName_("setOpt"), 2, KType_Int, KFieldName_("option"), KType_String,  KFieldName_("data"),
		_Public, _F(Curl_SetOptFile),    KType_void, KType_Curl, KMethodName_("setOpt"), 2, KType_Int, KFieldName_("option"), KType_File,    KFieldName_("data"),
		_Public, _F(Curl_appendHeader), KType_void, KType_Curl, KMethodName_("appendHeader"), 1, KType_String, KFieldName_("header"),
		_Public, _F(Curl_perform), KType_Boolean, KType_Curl, KMethodName_("perform"), 0,
		_Public, _F(Curl_receiveString), KType_String, KType_Curl, KMethodName_("receiveString"), 0,
		_Public|_Im, _F(Curl_getInfo), KType_Object/*FIXME KType_Dynamic*/, KType_Curl, KMethodName_("getInfo"), 1, KType_Int, KFieldName_("type"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	KDEFINE_INT_CONST IntData[] = {
		{KDefineConstInt(CURLOPT_AUTOREFERER)},
		{KDefineConstInt(CURLOPT_COOKIESESSION)},
		{KDefineConstInt(CURLOPT_CRLF)},
		{KDefineConstInt(CURLOPT_DNS_USE_GLOBAL_CACHE)},
		{KDefineConstInt(CURLOPT_FAILONERROR)},
		{KDefineConstInt(CURLOPT_FILETIME)},
		{KDefineConstInt(CURLOPT_FOLLOWLOCATION)},
		{KDefineConstInt(CURLOPT_FORBID_REUSE)},
		{KDefineConstInt(CURLOPT_FRESH_CONNECT)},
		{KDefineConstInt(CURLOPT_FTP_USE_EPRT)},
		{KDefineConstInt(CURLOPT_FTP_USE_EPSV)},
		{KDefineConstInt(CURLOPT_FTPAPPEND)},
		{KDefineConstInt(CURLOPT_FTPLISTONLY)},
		{KDefineConstInt(CURLOPT_HEADER)},
		{KDefineConstInt(CURLOPT_HTTPGET)},
		{KDefineConstInt(CURLOPT_HTTPPROXYTUNNEL)},
		{KDefineConstInt(CURLOPT_NETRC)},
		{KDefineConstInt(CURLOPT_NOBODY)},
		{KDefineConstInt(CURLOPT_NOPROGRESS)},
		{KDefineConstInt(CURLOPT_NOSIGNAL)},
		{KDefineConstInt(CURLOPT_POST)},
		{KDefineConstInt(CURLOPT_PUT)},
		{KDefineConstInt(CURLOPT_SSL_VERIFYPEER)},
		{KDefineConstInt(CURLOPT_TRANSFERTEXT)},
		{KDefineConstInt(CURLOPT_UNRESTRICTED_AUTH)},
		{KDefineConstInt(CURLOPT_UPLOAD)},
		{KDefineConstInt(CURLOPT_VERBOSE)},
		{KDefineConstInt(CURLOPT_BUFFERSIZE)},
		{KDefineConstInt(CURLOPT_CLOSEPOLICY)},
		{KDefineConstInt(CURLOPT_CONNECTTIMEOUT)},
		{KDefineConstInt(CURLOPT_DNS_CACHE_TIMEOUT)},
		{KDefineConstInt(CURLOPT_FTPSSLAUTH)},
		{KDefineConstInt(CURLOPT_HTTP_VERSION)},
		{KDefineConstInt(CURLOPT_HTTPAUTH)},
		{KDefineConstInt(CURLAUTH_ANY)},
		{KDefineConstInt(CURLAUTH_ANYSAFE)},
		{KDefineConstInt(CURLOPT_INFILESIZE)},
		{KDefineConstInt(CURLOPT_LOW_SPEED_LIMIT)},
		{KDefineConstInt(CURLOPT_LOW_SPEED_TIME)},
		{KDefineConstInt(CURLOPT_MAXCONNECTS)},
		{KDefineConstInt(CURLOPT_MAXREDIRS)},
		{KDefineConstInt(CURLOPT_PORT)},
		{KDefineConstInt(CURLOPT_PROXYAUTH)},
		{KDefineConstInt(CURLOPT_PROXYPORT)},
		{KDefineConstInt(CURLOPT_PROXYTYPE)},
		{KDefineConstInt(CURLOPT_RESUME_FROM)},
		{KDefineConstInt(CURLOPT_SSL_VERIFYHOST)},
		{KDefineConstInt(CURLOPT_SSLVERSION)},
		{KDefineConstInt(CURLOPT_TIMECONDITION)},
		{KDefineConstInt(CURLOPT_TIMEOUT)},
		{KDefineConstInt(CURLOPT_TIMEVALUE)},
		{KDefineConstInt(CURLOPT_CAINFO)},
		{KDefineConstInt(CURLOPT_CAPATH)},
		{KDefineConstInt(CURLOPT_COOKIE)},
		{KDefineConstInt(CURLOPT_COOKIEFILE)},
		{KDefineConstInt(CURLOPT_COOKIEJAR)},
		{KDefineConstInt(CURLOPT_CUSTOMREQUEST)},
		{KDefineConstInt(CURLOPT_ENCODING)},
		{KDefineConstInt(CURLOPT_FTPPORT)},
		{KDefineConstInt(CURLOPT_INTERFACE)},
		{KDefineConstInt(CURLOPT_KRB4LEVEL)},
		{KDefineConstInt(CURLOPT_POSTFIELDS)},
		{KDefineConstInt(CURLOPT_PROXY)},
		{KDefineConstInt(CURLOPT_PROXYUSERPWD)},
		{KDefineConstInt(CURLOPT_RANDOM_FILE)},
		{KDefineConstInt(CURLOPT_RANGE)},
		{KDefineConstInt(CURLOPT_REFERER)},
		{KDefineConstInt(CURLOPT_SSL_CIPHER_LIST)},
		{KDefineConstInt(CURLOPT_SSLCERT)},
		{KDefineConstInt(CURLOPT_SSLCERTTYPE)},
		{KDefineConstInt(CURLOPT_SSLENGINE)},
		{KDefineConstInt(CURLOPT_SSLENGINE_DEFAULT)},
		{KDefineConstInt(CURLOPT_SSLKEY)},
		{KDefineConstInt(CURLOPT_SSLKEYTYPE)},
		{KDefineConstInt(CURLOPT_URL)},
		{KDefineConstInt(CURLOPT_USERAGENT)},
		{KDefineConstInt(CURLOPT_USERPWD)},
		{KDefineConstInt(CURLOPT_FILE)},
		{KDefineConstInt(CURLOPT_WRITEDATA)},
		{KDefineConstInt(CURLOPT_READDATA)},
		{KDefineConstInt(CURLOPT_STDERR)},
		{KDefineConstInt(CURLOPT_WRITEHEADER)},
		{KDefineConstInt(CURLINFO_HEADER_SIZE)},
		{KDefineConstInt(CURLINFO_REQUEST_SIZE)},
		{KDefineConstInt(CURLINFO_REDIRECT_TIME)},
		{KDefineConstInt(CURLINFO_TOTAL_TIME)},
		{KDefineConstInt(CURLINFO_NAMELOOKUP_TIME)},
		{KDefineConstInt(CURLINFO_CONNECT_TIME)},
		{KDefineConstInt(CURLINFO_PRETRANSFER_TIME)},
		{KDefineConstInt(CURLINFO_STARTTRANSFER_TIME)},
		{KDefineConstInt(CURLINFO_SIZE_UPLOAD)},
		{KDefineConstInt(CURLINFO_SIZE_DOWNLOAD)},
		{KDefineConstInt(CURLINFO_SPEED_DOWNLOAD)},
		{KDefineConstInt(CURLINFO_SPEED_UPLOAD)},
		{KDefineConstInt(CURLINFO_EFFECTIVE_URL)},
		{KDefineConstInt(CURLINFO_CONTENT_TYPE)},
		{} // end of const data
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(IntData), trace);
	return true;
}
Example #27
0
KonohaContext* konoha_create(KClass **cRequest, int verbose_debug)
{
    struct KonohaFactory factory = {};
    factory.verbose_debug = verbose_debug;
    int argc = 0;
    char *argv[1] = {0};
    KonohaFactory_SetDefaultFactory(&factory, PosixFactory, argc, argv);
    ApacheFactory(&factory);
    KonohaContext* kctx = KonohaFactory_CreateKonoha(&factory);
    KBaseTrace(trace);
    kNameSpace *ns = KNULL(NameSpace);
    KImportPackage(ns, "Lib.Apache", trace);
    *cRequest = KClass_Request;
#define KType_Req  (KClass_Request->typeId)
#define KType_Tbl  (KClass_AprTable->typeId)
#define KType_TblEntry  (KClass_AprTableEntry->typeId)

    KClass *KClass_TblEntryArray = KClass_p0(kctx, KClass_Array, KType_TblEntry);
    ktypeattr_t KType_TblEntryArray = KClass_TblEntryArray->typeId;

    int FN_x = KFieldName_("x");
    KDEFINE_METHOD MethodData[] = {
        _Public, _F(Request_puts), KType_void, KType_Req, KMethodName_("puts"), 1, KType_String, FN_x,
        _Public, _F(Request_getMethod), KType_String, KType_Req, KMethodName_("getMethod"), 0,
        _Public, _F(Request_getArgs), KType_String, KType_Req, KMethodName_("getArgs"), 0,
        _Public, _F(Request_getUri), KType_String, KType_Req, KMethodName_("getUri"), 0,
        _Public, _F(Request_getPathInfo), KType_String, KType_Req, KMethodName_("getPathInfo"), 0,
        _Public, _F(Request_getHandler), KType_String, KType_Req, KMethodName_("getHandler"), 0,
        _Public, _F(Request_SetContentType), KType_void, KType_Req, KMethodName_("setContentType"), 1, KType_String, KFieldName_("type"),
        _Public, _F(Request_SetContentEncoding), KType_void, KType_Req, KMethodName_("setContentEncoding"), 1, KType_String, KFieldName_("enc"),
        _Public, _F(Request_logError), KType_void, KType_Req, KMethodName_("logError"), 3, KType_Int, KFieldName_("level"), KType_Int, KFieldName_("status"), KType_String, KFieldName_("msg"),
        _Public, _F(Request_getHeadersIn), KType_Tbl, KType_Req, KMethodName_("getHeadersIn"), 0,
        _Public, _F(Request_getHeadersOut), KType_Tbl, KType_Req, KMethodName_("getHeadersOut"), 0,
        _Public, _F(AprTable_Add), KType_void, KType_Tbl, KMethodName_("add"), 2, KType_String, KFieldName_("key"), KType_String, KFieldName_("val"),
        _Public, _F(AprTable_Set), KType_void, KType_Tbl, KMethodName_("set"), 2, KType_String, KFieldName_("key"), KType_String, KFieldName_("val"),
        _Public, _F(AprTable_getElts), KType_TblEntryArray, KType_Tbl, KMethodName_("getElts"), 0,
        _Public, _F(AprTableEntry_getKey), KType_String, KType_TblEntry, KMethodName_("getKey"), 0,
        _Public, _F(AprTableEntry_getVal), KType_String, KType_TblEntry, KMethodName_("getVal"), 0,
        DEND,
    };
    KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
    return kctx;
}
Example #28
0
		.init = Tagger_Init,
		.free = Tagger_Free,
	};

	static KDEFINE_CLASS MecabNodeDef = {
		STRUCTNAME(MecabNode),
		.cflag = KClassFlag_Final,
		.init = MecabNode_Init,
		.free = MecabNode_Free,
	};

	KClass *cTagger = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &TaggerDef, trace);
	KClass *cMecabNode = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &MecabNodeDef, trace);

	KDEFINE_METHOD MethodData[] = {
		_Public|_Const, _F(Tagger_new),         KType_Tagger,  KType_Tagger, KMethodName_("new"),   0,
		_Public|_Const, _F(Tagger_Parse),       KType_String,  KType_Tagger, KMethodName_("parse"), 1, KType_String, KFieldName_("input"),
		_Public|_Const, _F(Tagger_NBestParse),  KType_String,  KType_Tagger, KMethodName_("NBestParse"), 2, KType_Int, KFieldName_("n"), KType_String, KFieldName_("input"),
		_Public|_Const, _F(Tagger_NBestInit),   KType_String,  KType_Tagger, KMethodName_("NBestInit"), 1, KType_String, KFieldName_("input"),
		_Public|_Const, _F(Tagger_NBestNext),   KType_String,  KType_Tagger, KMethodName_("NBestNext"), 0,
		_Public|_Const, _F(Tagger_ParseToNode), KType_MecabNode,  KType_Tagger, KMethodName_("parseToNode"), 1, KType_String, KFieldName_("input"),
		_Public|_Const, _F(Tagger_destroy),     KType_void,    KType_Tagger, KMethodName_("destroy"), 0,

		_Public|_Const, _F(MecabNode_next),        KType_MecabNode,  KType_MecabNode, KMethodName_("next"), 0,
		_Public|_Const, _F(MecabNode_prev),        KType_MecabNode,  KType_MecabNode, KMethodName_("prev"), 0,
		_Public|_Const, _F(MecabNode_enext),       KType_MecabNode,  KType_MecabNode, KMethodName_("enext"), 0,
		_Public|_Const, _F(MecabNode_bnext),       KType_MecabNode,  KType_MecabNode, KMethodName_("bnext"), 0,
		_Public|_Const, _F(MecabNode_getSurface),  KType_String,  KType_MecabNode, KMethodName_("getSurface"), 0,
		_Public|_Const, _F(MecabNode_getFeature),  KType_String,  KType_MecabNode, KMethodName_("getFeature"), 0,
		_Public|_Const, _F(MecabNode_getLength),   KType_Int,  KType_MecabNode, KMethodName_("getLength"), 0,
		_Public|_Const, _F(MecabNode_getRLength),  KType_Int,  KType_MecabNode, KMethodName_("getRLength"), 0,
Example #29
0
static kbool_t path_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	//	KRequireKonohaCommonModel(trace);
	KDEFINE_METHOD MethodData[] = {
		_Public|_Static|_C, _F(System_getcwd),   KType_String,  KType_System, KMethodName_("getcwd"), 0,
		_Public|_Static|_C, _F(System_realpath), KType_String,  KType_System, KMethodName_("realpath"),  1, KType_String, KFieldName_("path"),
		_Public|_Static|_C, _F(System_chdir),    KType_Boolean, KType_System, KMethodName_("chdir"),  1, KType_String, KFieldName_("path"),
		_Public|_Static|_C, _F(System_chroot),   KType_Boolean, KType_System, KMethodName_("chroot"), 1, KType_String, KFieldName_("path"),

		_Public|_Static|_C, _F(System_umask),    KType_Int,     KType_System, KMethodName_("umask"),  1, KType_Int,    KFieldName_("mode"),
		_Public|_Static|_C, _F(System_chmod),    KType_Boolean, KType_System, KMethodName_("chmod"),  2, KType_String, KFieldName_("path"), KType_Int, KFieldName_("mode"),
		_Public|_Static|_C, _F(System_access),   KType_Boolean, KType_System, KMethodName_("access"), 2, KType_String, KFieldName_("path"), KType_Int, KFieldName_("mode"),
		_Public|_Static|_C, _F(System_chown),    KType_Boolean, KType_System, KMethodName_("chown"),  3, KType_String, KFieldName_("path"), KType_Int, KFieldName_("owner"), KType_Int, KFieldName_("group"),
		_Public|_Static|_C, _F(System_lchown),   KType_Boolean, KType_System, KMethodName_("lchown"), 3, KType_String, KFieldName_("path"), KType_Int, KFieldName_("owner"), KType_Int, KFieldName_("group"),

		_Public|_Static|_C, _F(System_link),     KType_Boolean, KType_System, KMethodName_("link"), 2, KType_String, KFieldName_("oldpath"), KType_String, KFieldName_("newpath"),
		_Public|_Static|_C, _F(System_unlink),   KType_Boolean, KType_System, KMethodName_("unlink"), 1, KType_String, KFieldName_("path"),
		_Public|_Static|_C, _F(System_rename),   KType_Boolean, KType_System, KMethodName_("rename"), 2, KType_String, KFieldName_("oldpath"), KType_String, KFieldName_("newpath"),
		_Public|_Static|_C, _F(System_symlink),  KType_Boolean, KType_System, KMethodName_("symlink"), 2, KType_String, KFieldName_("oldpath"), KType_String, KFieldName_("newpath"),
		_Public|_Static|_C, _F(System_readlink), KType_String,  KType_System, KMethodName_("readlink"), 1, KType_String, KFieldName_("path"),

		// isdir() is not posix api
		_Public|_Static,    _F(System_isDir),    KType_Boolean, KType_System, KMethodName_("isdir"),    1, KType_String, KFieldName_("path"),
		_Public|_Static|_C, _F(System_mkdir),    KType_Boolean, KType_System, KMethodName_("mkdir"),    2, KType_String, KFieldName_("path"), KType_Int, KFieldName_("mode"),
		_Public|_Static|_C, _F(System_rmdir),    KType_Boolean, KType_System, KMethodName_("rmdir"),    1, KType_String, KFieldName_("path"),
		_Public|_Static|_C, _F(System_truncate), KType_Boolean, KType_System, KMethodName_("truncate"), 2, KType_String, KFieldName_("path"), KType_Int, KFieldName_("length"),

//		_Public|_Static, _F(System_stat),  KType_Stat, KType_System, KMethodName_("stat"), 1, KType_String, KFieldName_("path"),
//		_Public|_Static, _F(System_lstat), KType_Stat, KType_System, KMethodName_("lstat"), 1, KType_String, KFieldName_("path"),

		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	path_defineAccessConst(kctx, ns, trace);
	path_defineDIR(kctx, ns, trace);
	return true;
}
Example #30
0
static kbool_t Complex_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequirePackage("Type.Float", trace);
	KDEFINE_CLASS defComplex = {0};
	SETSTRUCTNAME(defComplex, Complex);
	defComplex.cflag     = KClassFlag_Final;
	defComplex.init      = kComplex_Init;
	defComplex.free      = kComplex_Free;
	KClass *ComplexClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defComplex, trace);

	int KType_Complex = ComplexClass->typeId;
	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Complex_new),     KType_Complex, KType_Complex, KMethodName_("new"),   2, KType_float, KFieldName_("real"), KType_float, KFieldName_("imaginary"),
		_Public, _F(Complex_csin),    KType_float, KType_Complex, KMethodName_("csin"),    0,
		_Public, _F(Complex_csinf),   KType_float, KType_Complex, KMethodName_("csinf"),   0,
		_Public, _F(Complex_csinl),   KType_float, KType_Complex, KMethodName_("csinl"),   0,
		_Public, _F(Complex_ccos),    KType_float, KType_Complex, KMethodName_("ccos"),    0,
		_Public, _F(Complex_ccosf),   KType_float, KType_Complex, KMethodName_("ccosf"),   0,
		_Public, _F(Complex_ccosl),   KType_float, KType_Complex, KMethodName_("ccosl"),   0,
		_Public, _F(Complex_ctan),    KType_float, KType_Complex, KMethodName_("ctan"),    0,
		_Public, _F(Complex_ctanf),   KType_float, KType_Complex, KMethodName_("ctanf"),   0,
		_Public, _F(Complex_ctanl),   KType_float, KType_Complex, KMethodName_("ctanl"),   0,
		_Public, _F(Complex_casin),   KType_float, KType_Complex, KMethodName_("casin"),   0,
		_Public, _F(Complex_casinf),  KType_float, KType_Complex, KMethodName_("casinf"),  0,
		_Public, _F(Complex_casinl),  KType_float, KType_Complex, KMethodName_("casinl"),  0,
		_Public, _F(Complex_cacos),   KType_float, KType_Complex, KMethodName_("cacos"),   0,
		_Public, _F(Complex_cacosf),  KType_float, KType_Complex, KMethodName_("cacosf"),  0,
		_Public, _F(Complex_cacosl),  KType_float, KType_Complex, KMethodName_("cacosl"),  0,
		_Public, _F(Complex_catan),   KType_float, KType_Complex, KMethodName_("catan"),   0,
		_Public, _F(Complex_catanf),  KType_float, KType_Complex, KMethodName_("catanf"),  0,
		_Public, _F(Complex_catanl),  KType_float, KType_Complex, KMethodName_("catanl"),  0,
		_Public, _F(Complex_csinh),   KType_float, KType_Complex, KMethodName_("csinh"),   0,
		_Public, _F(Complex_csinhf),  KType_float, KType_Complex, KMethodName_("csinhf"),  0,
		_Public, _F(Complex_csinhl),  KType_float, KType_Complex, KMethodName_("csinhl"),  0,
		_Public, _F(Complex_ccosh),   KType_float, KType_Complex, KMethodName_("ccosh"),   0,
		_Public, _F(Complex_ccoshf),  KType_float, KType_Complex, KMethodName_("ccoshf"),  0,
		_Public, _F(Complex_ccoshl),  KType_float, KType_Complex, KMethodName_("ccoshl"),  0,
		_Public, _F(Complex_ctanh),   KType_float, KType_Complex, KMethodName_("ctanh"),   0,
		_Public, _F(Complex_ctanhf),  KType_float, KType_Complex, KMethodName_("ctanhf"),  0,
		_Public, _F(Complex_ctanhl),  KType_float, KType_Complex, KMethodName_("ctanhl"),  0,
		_Public, _F(Complex_casinh),  KType_float, KType_Complex, KMethodName_("casinh"),  0,
		_Public, _F(Complex_casinhf), KType_float, KType_Complex, KMethodName_("casinhf"), 0,
		_Public, _F(Complex_casinhl), KType_float, KType_Complex, KMethodName_("casinhl"), 0,
		_Public, _F(Complex_cacosh),  KType_float, KType_Complex, KMethodName_("cacosh"),  0,
		_Public, _F(Complex_cacoshf), KType_float, KType_Complex, KMethodName_("cacoshf"), 0,
		_Public, _F(Complex_cacoshl), KType_float, KType_Complex, KMethodName_("cacoshl"), 0,
		_Public, _F(Complex_catanh),  KType_float, KType_Complex, KMethodName_("catanh"),  0,
		_Public, _F(Complex_catanhf), KType_float, KType_Complex, KMethodName_("catanhf"), 0,
		_Public, _F(Complex_catanhl), KType_float, KType_Complex, KMethodName_("catanhl"), 0,
		_Public, _F(Complex_cexp),    KType_float, KType_Complex, KMethodName_("cexp"),    0,
		_Public, _F(Complex_cexpf),   KType_float, KType_Complex, KMethodName_("cexpf"),   0,
		_Public, _F(Complex_cexpl),   KType_float, KType_Complex, KMethodName_("cexpl"),   0,
		_Public, _F(Complex_clog),    KType_float, KType_Complex, KMethodName_("clog"),    0,
		_Public, _F(Complex_clogf),   KType_float, KType_Complex, KMethodName_("clogf"),   0,
		_Public, _F(Complex_clogl),   KType_float, KType_Complex, KMethodName_("clogl"),   0,
		_Public, _F(Complex_cabs),    KType_float, KType_Complex, KMethodName_("cabs"),    0,
		_Public, _F(Complex_cabsf),   KType_float, KType_Complex, KMethodName_("cabsf"),   0,
		_Public, _F(Complex_cabsl),   KType_float, KType_Complex, KMethodName_("cabsl"),   0,
		_Public, _F(Complex_csqrt),   KType_float, KType_Complex, KMethodName_("csqrt"),   0,
		_Public, _F(Complex_csqrtf),  KType_float, KType_Complex, KMethodName_("csqrtf"),  0,
		_Public, _F(Complex_csqrtl),  KType_float, KType_Complex, KMethodName_("csqrtl"),  0,
		_Public, _F(Complex_cpow),    KType_float, KType_Complex, KMethodName_("cpow"),    2, KType_float,   KFieldName_("real"), KType_float, KFieldName_("imaginary"),
		_Public, _F(Complex_cpowf),   KType_float, KType_Complex, KMethodName_("cpowf"),   2, KType_float,   KFieldName_("real"), KType_float, KFieldName_("imaginary"),
		_Public, _F(Complex_cpowl),   KType_float, KType_Complex, KMethodName_("cpowl"),   2, KType_float,   KFieldName_("real"), KType_float, KFieldName_("imaginary"),
		_Public, _F(Complex_creal),   KType_float, KType_Complex, KMethodName_("creal"),   0,
		_Public, _F(Complex_crealf),  KType_float, KType_Complex, KMethodName_("crealf"),  0,
		_Public, _F(Complex_creall),  KType_float, KType_Complex, KMethodName_("creall"),  0,
		_Public, _F(Complex_cimag),   KType_float, KType_Complex, KMethodName_("cimag"),   0,
		_Public, _F(Complex_cimagf),  KType_float, KType_Complex, KMethodName_("cimagf"),  0,
		_Public, _F(Complex_cimagl),  KType_float, KType_Complex, KMethodName_("cimagl"),  0,
		_Public, _F(Complex_carg),    KType_float, KType_Complex, KMethodName_("carg"),    0,
		_Public, _F(Complex_cargf),   KType_float, KType_Complex, KMethodName_("cargf"),   0,
		_Public, _F(Complex_cargl),   KType_float, KType_Complex, KMethodName_("cargl"),   0,
		_Public, _F(Complex_conj),    KType_Complex, KType_Complex, KMethodName_("conj"),  0,
		_Public, _F(Complex_conjf),   KType_Complex, KType_Complex, KMethodName_("conjf"), 0,
		_Public, _F(Complex_conjl),   KType_Complex, KType_Complex, KMethodName_("conjl"), 0,
		DEND, /* <= sentinel */
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	return true;
}