Exemplo n.º 1
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;
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
static kMethod *new_FieldSetter(KonohaContext *kctx, kArray *gcstack, ktypeattr_t cid, kmethodn_t sym, ktypeattr_t ty, int idx)
{
	kmethodn_t mn = KMethodName_ToSetter(sym);
	KMethodFunc f = (KType_Is(UnboxType, ty)) ? KMethodFunc_UnboxFieldSetter : KMethodFunc_ObjectFieldSetter;
	kparamtype_t p = {ty, KFieldName_("x")};
	kMethod *mtd = KLIB new_kMethod(kctx, gcstack, kMethod_Public, cid, mn, f);
	KLIB kMethod_SetParam(kctx, mtd, ty, 1, &p);
	((kMethodVar *)mtd)->delta = idx;   // FIXME
	return mtd;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
0
static void kNameSpace_InitParam(KonohaContext *kctx, kNameSpace *ns, struct KGammaLocalData *env, kParam *pa, KClass *envCt)
{
	size_t i;
	env->localScope.varItems[0].attrTypeId = envCt->typeId;
	env->localScope.varItems[0].name = KFieldName_("env");
	for(i = 0; i < pa->psize; i++) {
		const kparamtype_t *pn = (pa->paramtypeItems)+i;
		env->localScope.varItems[i+1].name       = pn->name;
		env->localScope.varItems[i+1].attrTypeId = pn->attrTypeId;
	}
	env->localScope.varsize += pa->psize + 1;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
static kbool_t math_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequirePackage("Type.Float", trace);
	static KDEFINE_CLASS MathDef = {0};
	MathDef.cflag = KClassFlag_Singleton|KClassFlag_Final;
	MathDef.structname = "Math"; /*structname*/
	MathDef.typeId = KTypeAttr_NewId; /*cid*/

	KClass *cMath = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &MathDef, trace);
	int FN_x = KFieldName_("x");
	int FN_y = KFieldName_("y");
	KDEFINE_METHOD MethodData[] = {
			_Public|_Const|_Static, _F(Math_abs), KType_Int, KType_Math, KMethodName_("abs"), 1, KType_Int, FN_x,
			_Public|_Const|_Static, _F(Math_fabs), KType_float, KType_Math, KMethodName_("fabs"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_pow), KType_float, KType_Math, KMethodName_("pow"), 2, KType_float, FN_x, KType_float, FN_y,
			_Public|_Const|_Static, _F(Math_ldexp), KType_float, KType_Math, KMethodName_("ldexp"), 2, KType_float, FN_x, KType_Int, FN_y,
			_Public|_Const|_Static, _F(Math_modf), KType_float, KType_Math, KMethodName_("modf"), 2, KType_float, FN_x, KType_float, FN_y,
			_Public|_Const|_Static, _F(Math_frexp), KType_float, KType_Math, KMethodName_("frexp"), 2, KType_float, FN_x, KType_Int, FN_y,
			_Public|_Const|_Static, _F(Math_fmod), KType_float, KType_Math, KMethodName_("fmod"), 2, KType_float, FN_x, KType_float, FN_y,
			_Public|_Const|_Static, _F(Math_ceil), KType_float, KType_Math, KMethodName_("ceil"), 1, KType_float, FN_x,
#ifdef K_USING_WIN32_
			_Public, _F(Math_round), KType_float, KType_Math, KMethodName_("round"), 1, KType_float, FN_x,
			_Public, _F(Math_nearByInt), KType_float, KType_Math, KMethodName_("nearByInt"), 1, KType_float, FN_x,
#endif
			_Public|_Const|_Static, _F(Math_floor), KType_float, KType_Math, KMethodName_("floor"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_sqrt), KType_float, KType_Math, KMethodName_("sqrt"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_exp), KType_float, KType_Math, KMethodName_("exp"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_log10), KType_float, KType_Math, KMethodName_("log10"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_log), KType_float, KType_Math, KMethodName_("log"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_sin), KType_float, KType_Math, KMethodName_("sin"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_cos), KType_float, KType_Math, KMethodName_("cos"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_tan), KType_float, KType_Math, KMethodName_("tan"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_asin), KType_float, KType_Math, KMethodName_("asin"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_acos), KType_float, KType_Math, KMethodName_("acos"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_atan), KType_float, KType_Math, KMethodName_("atan"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_atan2), KType_float, KType_Math, KMethodName_("atan2"), 2, KType_float, FN_x, KType_float, FN_y,
			_Public|_Const|_Static, _F(Math_sinh), KType_float, KType_Math, KMethodName_("sinh"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_cosh), KType_float, KType_Math, KMethodName_("cosh"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_tanh), KType_float, KType_Math, KMethodName_("tanh"), 1, KType_float, FN_x,
#if defined(K_USING_WIN32_)
			_Public|_Const|_Static, _F(Math_asinh), KType_float, KType_Math, KMethodName_("asinh"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_acosh), KType_float, KType_Math, KMethodName_("acosh"), 1, KType_float, FN_x,
			_Public|_Const|_Static, _F(Math_atanh), KType_float, KType_Math, KMethodName_("atanh"), 1, KType_float, FN_x,
#endif
			_Public, _F(Math_random), KType_float, KType_Math, KMethodName_("random"), 0,
			DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	KDEFINE_FLOAT_CONST FloatData[] = {
			{MATH_(E)},
			{MATH_(LOG2E)},
			{MATH_(LOG10E)},
			{MATH_(LN2)},
			{MATH_(LN10)},
			{MATH_(PI)},
			{MATH_(SQRT2)},
			{}
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(FloatData), trace);
	return true;
}
Exemplo n.º 10
0
static kbool_t xml_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KRequireKonohaCommonModel(trace);
	KDEFINE_CLASS defXml = {
		STRUCTNAME(XmlReader),
		.cflag = KClassFlag_Final,
		.init = XmlReader_init,
		.free = XmlReader_free,
		.reftrace = XmlReader_reftrace,
	};
	KClass *cXmlReader = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defXml, trace);
#define KType_XmlReader     cXmlReader->typeId


	KDEFINE_METHOD MethodData[] = {
		_Public, _F(XmlReader_new),                  KType_XmlReader,     KType_XmlReader,    KMethodName_("new"),                  1, KType_String, KFieldName_("path"),
		_Public, _F(XmlReader_close),                KType_void,    KType_XmlReader,    KMethodName_("close"),                0,
		_Public, _F(XmlReader_getQuoteChar),         KType_String,  KType_XmlReader,    KMethodName_("getQuoteChar"),         0,
		_Public, _F(XmlReader_read),                 KType_Boolean, KType_XmlReader,    KMethodName_("read"),                 0,
		_Public, _F(XmlReader_readState),            KType_Int,     KType_XmlReader,    KMethodName_("readState"),            0,
		_Public, _F(XmlReader_nodeType),             KType_Int,     KType_XmlReader,    KMethodName_("nodeType"),             0,
		_Public, _F(XmlReader_isNamespaceDecl),      KType_Boolean, KType_XmlReader,    KMethodName_("isNamespaceDecl"),      0,
		_Public, _F(XmlReader_isEmptyElement),       KType_Boolean, KType_XmlReader,    KMethodName_("isEmptyElement"),       0,
		_Public, _F(XmlReader_hasAttributes),        KType_Boolean, KType_XmlReader,    KMethodName_("hasAttributes"),        0,
		_Public, _F(XmlReader_hasValue),             KType_Boolean, KType_XmlReader,    KMethodName_("hasValue"),             0,
		_Public, _F(XmlReader_getDepth),             KType_Int,     KType_XmlReader,    KMethodName_("getDepth"),             0,
		_Public, _F(XmlReader_getAttributeCount),    KType_Int,     KType_XmlReader,    KMethodName_("getAttributeCount"),    0,
		_Public, _F(XmlReader_moveToFirstAttribute), KType_Boolean, KType_XmlReader,    KMethodName_("moveToFirstAttribute"), 0,
		_Public, _F(XmlReader_moveToNextAttribute),  KType_Boolean, KType_XmlReader,    KMethodName_("moveToNextAttribute"),  0,
		_Public, _F(XmlReader_moveToElement),        KType_Boolean, KType_XmlReader,    KMethodName_("moveToElement"),        0,
		_Public, _F(XmlReader_constBaseUri),         KType_String,  KType_XmlReader,    KMethodName_("constBaseUri"),         0,
		_Public, _F(XmlReader_constEncoding),        KType_String,  KType_XmlReader,    KMethodName_("constEncoding"),        0,
		_Public, _F(XmlReader_constValue),           KType_String,  KType_XmlReader,    KMethodName_("constValue"),           0,
		_Public, _F(XmlReader_constNamespaceUri),    KType_String,  KType_XmlReader,    KMethodName_("constNamespaceUri"),    0,
		_Public, _F(XmlReader_constLocalName),       KType_String,  KType_XmlReader,    KMethodName_("constLocalName"),       0,
		_Public, _F(XmlReader_constName),            KType_String,  KType_XmlReader,    KMethodName_("constName"),            0,
		_Public, _F(XmlReader_constXmlLang),         KType_String,  KType_XmlReader,    KMethodName_("constXmlLang"),         0,
		_Public, _F(XmlReader_constPrefix),          KType_String,  KType_XmlReader,    KMethodName_("constPrefix"),          0,
		_Public, _F(XmlReader_getAttribute),         KType_String,  KType_XmlReader,    KMethodName_("getAttribute"),         0,
		_Public, _F(XmlReader_getAttributeNo),       KType_String,  KType_XmlReader,    KMethodName_("getAttributeNo"),       1, KType_Int, KFieldName_("no"),
		_Public, _F(XmlReader_getAttributeNs),       KType_String,  KType_XmlReader,    KMethodName_("getAttributeNs"),       2, KType_String, KFieldName_("ns"), KType_String, KFieldName_("name"),
		_Public, _F(XmlReader_lookupNameSpace),      KType_String,  KType_XmlReader,    KMethodName_("lookupNameSpace"),      1, KType_String, KFieldName_("ns"),
		_Public, _F(XmlReader_normalization),        KType_Int,     KType_XmlReader,    KMethodName_("normalization"),        0,

		_Public, _F(String_convertToXml),            KType_XmlReader,     KType_String, KMethodName_("convertToXml"),         0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	KDEFINE_INT_CONST IntData[] = {
		{KDefineConstInt(XML_READER_TYPE_NONE)},
		{KDefineConstInt(XML_READER_TYPE_ELEMENT)},
		{KDefineConstInt(XML_READER_TYPE_ATTRIBUTE)},
		{KDefineConstInt(XML_READER_TYPE_TEXT)},
		{KDefineConstInt(XML_READER_TYPE_CDATA)},
		{KDefineConstInt(XML_READER_TYPE_ENTITY_REFERENCE)},
		{KDefineConstInt(XML_READER_TYPE_ENTITY)},
		{KDefineConstInt(XML_READER_TYPE_PROCESSING_INSTRUCTION)},
		{KDefineConstInt(XML_READER_TYPE_COMMENT)},
		{KDefineConstInt(XML_READER_TYPE_DOCUMENT)},
		{KDefineConstInt(XML_READER_TYPE_DOCUMENT_TYPE)},
		{KDefineConstInt(XML_READER_TYPE_DOCUMENT_FRAGMENT)},
		{KDefineConstInt(XML_READER_TYPE_NOTATION)},
		{KDefineConstInt(XML_READER_TYPE_WHITESPACE)},
		{KDefineConstInt(XML_READER_TYPE_SIGNIFICANT_WHITESPACE)},
		{KDefineConstInt(XML_READER_TYPE_END_ELEMENT)},
		{KDefineConstInt(XML_READER_TYPE_END_ENTITY)},
		{KDefineConstInt(XML_READER_TYPE_XML_DECLARATION)},
		{} // end of const data
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(IntData), trace);
	return true;
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
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;
}
Exemplo n.º 14
0
// --------------------------------------------------------------------------

#define KType_SockAddr         cSockAddr->typeId

#define KDefineConstInt(T) #T, KType_Int, T

static kbool_t socket_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KDEFINE_CLASS defSockAddr = {
		STRUCTNAME(SockAddr),
		.cflag = KClassFlag_Final,
		.init = SockAddr_Init,
		.free = SockAddr_Free,
	};
	KClass *cSockAddr = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defSockAddr, trace);
	kparamtype_t pi = {KType_Int, KFieldName_("intValue")};
	KClass *KClass_IntArray = KLIB KClass_Generics(kctx, KClass_Array, KType_Int, 1, &pi);
	ktypeattr_t KType_IntArray = KClass_IntArray->typeId;

	KDEFINE_METHOD MethodData[] = {
		_Public|_Static|_Const|_Im, _F(System_accept), KType_Int, KType_System, KMethodName_("accept"), 2, KType_Int, KFieldName_("fd"), KType_SockAddr, KFieldName_("sockaddr"),
		_Public|_Static|_Const|_Im, _F(System_bind), KType_Int, KType_System, KMethodName_("bind"), 4, KType_Int, KFieldName_("fd"), KType_String, KFieldName_("srcIP"), KType_Int, KFieldName_("srcPort"), KType_Int, KFieldName_("family"),
		_Public|_Static|_Const|_Im, _F(System_close), KType_Int, KType_System, KMethodName_("close"), 1, KType_Int, KFieldName_("fd"),
		_Public|_Static|_Const|_Im, _F(System_connect), KType_Int, KType_System, KMethodName_("connect"), 4, KType_Int, KFieldName_("fd"), KType_String, KFieldName_("dstIP"), KType_Int, KFieldName_("dstPort"), KType_Int, KFieldName_("family"),
		_Public|_Static|_Const|_Im, _F(System_listen), KType_Int, KType_System, KMethodName_("listen"), 2, KType_Int, KFieldName_("fd"), KType_Int, KFieldName_("backlog"),
//		_Public|_Static|_Const|_Im, _F(System_getsockname), KType_Map KType_System, KMethodName_("getsockname"),1, KType_Int, KFieldName_("fd"),
		_Public|_Static|_Const|_Im, _F(System_getsockopt), KType_Int, KType_System, KMethodName_("getsockopt"), 2, KType_Int, KFieldName_("fd"), KType_Int, KFieldName_("opt"),
		_Public|_Static|_Const|_Im, _F(System_Setsockopt), KType_Int, KType_System, KMethodName_("setsockopt"), 3, KType_Int, KFieldName_("fd"), KType_Int, KFieldName_("opt"), KType_Int, KFieldName_("value"),
//		_Public|_Static|_Const|_Im, _F(System_getpeername), KType_Map, KType_System, KMethodName_("getpeername"), 1, KType_Int, KFieldName_("fd"),
//		_Public|_Static, _F(System_Select), KType_Int, KType_System, KMethodName_("select"), 5, KType_IntArray, KFieldName_("readsocks"), KType_IntArray, KFieldName_("writesocks"), KType_IntArray, KFieldName_("exceptsocks"), KType_Int, KFieldName_("timeoutSec"), KType_Int, KFieldName_("timeoutUSec"),
		_Public|_Static|_Const|_Im, _F(System_shutdown), KType_Int, KType_System, KMethodName_("shutdown"), 2, KType_Int, KFieldName_("fd"), KType_Int, KFieldName_("how"),
Exemplo n.º 15
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;
}
Exemplo n.º 16
0
static kbool_t Libevent_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	/* Class Definition */
	/* If you want to create Generic class like Array<T>, see konoha.map package */
	// cevent_base
	KDEFINE_CLASS defcevent_base = {0};
	SETSTRUCTNAME(defcevent_base, cevent_base);
	defcevent_base.cflag     = KClassFlag_Final;	//must be final in C
	defcevent_base.init      = cevent_base_Init;
	defcevent_base.free      = cevent_base_Free;
	KClass *cevent_baseClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defcevent_base, trace);

	// cevent
	KDEFINE_CLASS defcevent = {0};
	SETSTRUCTNAME(defcevent, cevent);
	defcevent.cflag     = KClassFlag_Final;
	defcevent.init      = cevent_Init;
//	defcevent.reftrace  = cevent_Reftrace;
	defcevent.free      = cevent_Free;
	KClass *ceventClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defcevent, trace);

	// cbufferevent
	KDEFINE_CLASS defcbufferevent = {0};
	SETSTRUCTNAME(defcbufferevent, cbufferevent);
	defcbufferevent.cflag     = KClassFlag_Final;
	defcbufferevent.init      = cbufferevent_Init;
//	defcbufferevent.reftrace  = cbufferevent_Reftrace;
	defcbufferevent.free      = cbufferevent_Free;
	KClass *cbuffereventClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defcbufferevent, trace);

	// eventCBArg
	KDEFINE_CLASS defeventCBArg = {0};
	SETSTRUCTNAME(defeventCBArg, eventCBArg);
	defeventCBArg.cflag     = KClassFlag_Final;
	defeventCBArg.init      = eventCBArg_Init;
	defeventCBArg.reftrace  = eventCBArg_Reftrace;
	defeventCBArg.free      = eventCBArg_Free;
	KClass *eventCBArgClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defeventCBArg, trace);

	// buffereventCBArg
	KDEFINE_CLASS defbuffereventCBArg = {0};
	SETSTRUCTNAME(defbuffereventCBArg, buffereventCBArg);
	defbuffereventCBArg.cflag     = KClassFlag_Final;
	defbuffereventCBArg.init      = buffereventCBArg_Init;
	defbuffereventCBArg.reftrace  = buffereventCBArg_Reftrace;
	defbuffereventCBArg.free      = buffereventCBArg_Free;
	KClass *buffereventCBArgClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defbuffereventCBArg, trace);

	// ctimeval
	KDEFINE_CLASS defctimeval = {0};
	SETSTRUCTNAME(defctimeval, ctimeval);
	defctimeval.cflag     = KClassFlag_Final;
	defctimeval.init      = ctimeval_Init;
	KClass *ctimevalClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defctimeval, trace);

	// Sockaddr_in
	KDEFINE_CLASS defSockaddr_in = {0};
	SETSTRUCTNAME(defSockaddr_in, Sockaddr_in);
	defSockaddr_in.cflag     = KClassFlag_Final;
	defSockaddr_in.init      = Sockaddr_in_Init;
	KClass *Sockaddr_inClass = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defSockaddr_in, trace);


	/* You can define methods with the following procedures. */
	int KType_cevent_base = cevent_baseClass->typeId;
	int KType_cevent = ceventClass->typeId;
	int KType_cbufferevent = cbuffereventClass->typeId;
	int KType_eventCBArg = eventCBArgClass->typeId;
	int KType_buffereventCBArg = buffereventCBArgClass->typeId;
	int KType_ctimeval = ctimevalClass->typeId;
	int KType_Sockaddr_in = Sockaddr_inClass->typeId;

	/* define Generics parameter for callback method */
	//eventCB_p
	kparamtype_t eventCB_p[] = {{KType_Int, 0}, {KType_Int, 0}, {KType_Object, 0}};
	KClass *ceventCBfunc = KLIB KClass_Generics(kctx, KClass_Func, KType_void, 3, eventCB_p);
	int KType_ceventCBfunc = ceventCBfunc->typeId;
	//bev_dataCB_p
	kparamtype_t bev_dataCB_p[] = {{KType_cbufferevent, 0}, {KType_Object, 0}};
	KClass *Cbev_dataCBfunc = KLIB KClass_Generics(kctx, KClass_Func, KType_void, 2, bev_dataCB_p);
	int KType_Cbev_dataCBfunc = Cbev_dataCBfunc->typeId;
	//bev_eventCB_p
	kparamtype_t bev_eventCB_p[] = {{KType_cbufferevent, 0}, {KType_Int, 0}, {KType_Object, 0}};
	KClass *Cbev_eventCBfunc = KLIB KClass_Generics(kctx, KClass_Func, KType_void, 3, bev_eventCB_p);
	int KType_Cbev_eventCBfunc = Cbev_eventCBfunc->typeId;

	KDEFINE_METHOD MethodData[] = {
		// System class
		_Public|_Static, _F(System_evutil_make_socket_nonblocking), KType_Int, KType_System, KMethodName_("evutil_make_socket_nonblocking"), 1, KType_Int, KFieldName_("fd"),

		// cevent_base
		_Public, _F(cevent_base_new), KType_cevent_base, KType_cevent_base, KMethodName_("new"), 0,
		_Public, _F(cevent_base_event_dispatch), KType_Int, KType_cevent_base, KMethodName_("event_dispatch"), 0,

		// cevent
		_Public, _F(cevent_new), KType_cevent, KType_cevent, KMethodName_("new"), 4, KType_cevent_base, KFieldName_("cevent_base"), KType_Int, KFieldName_("evd"), KType_Int, KFieldName_("event"), KType_eventCBArg, KFieldName_("CBarg"),
		_Public, _F(cevent_event_add), KType_Int, KType_cevent, KMethodName_("event_add"), 1, KType_ctimeval, KFieldName_("timeval"),
		_Public, _F(cevent_event_del), KType_Int, KType_cevent, KMethodName_("event_del"), 0,
		_Public, _F(cevent_getID), KType_Int, KType_cevent, KMethodName_("getID"), 0, 
		_Public, _F(cevent_getEvents), KType_Int, KType_cevent, KMethodName_("getEvents"), 0, 

		// cbufferevent
		_Public, _F(cbufferevent_new), KType_cbufferevent, KType_cbufferevent, KMethodName_("new"), 3, KType_cevent_base, KFieldName_("cevent_base"), KType_Int, KFieldName_("evd"), KType_Int, KFieldName_("options"),
		_Public, _F(cbufferevent_setcb), KType_void, KType_cbufferevent, KMethodName_("bufferevent_setcb"), 1, KType_buffereventCBArg, KFieldName_("buffereventCBArg"),
		_Public, _F(cbufferevent_socket_connect), KType_Int, KType_cbufferevent, KMethodName_("bufferevent_socket_connect"), 1, KType_Sockaddr_in, KFieldName_("sockaddr"),
		_Public, _F(cbufferevent_enable), KType_Int, KType_cbufferevent, KMethodName_("bufferevent_enable"), 1, KType_Int, KFieldName_("event"),
		_Public, _F(cbufferevent_write), KType_Int, KType_cbufferevent, KMethodName_("bufferevent_write"), 1, KType_Bytes, KFieldName_("writebuffer"),
		_Public, _F(cbufferevent_read), KType_Int, KType_cbufferevent, KMethodName_("bufferevent_read"), 1, KType_Bytes, KFieldName_("readbuffer"),

		// eventCBArg
		_Public, _F(eventCBArg_new), KType_eventCBArg, KType_eventCBArg, KMethodName_("new"), 2, KType_ceventCBfunc, KFieldName_("konoha_CB"), KType_Object, KFieldName_("CBarg"),

		// buffereventCBArg
		_Public, _F(buffereventCBArg_new), KType_buffereventCBArg, KType_buffereventCBArg, KMethodName_("new"), 4, KType_Cbev_dataCBfunc, KFieldName_("readCB"), KType_Cbev_dataCBfunc, KFieldName_("writeCB"), KType_Cbev_eventCBfunc, KFieldName_("eventCB"), KType_Object, KFieldName_("CBarg"),

		// ctimeval
		_Public, _F(ctimeval_new), KType_ctimeval, KType_ctimeval, KMethodName_("new"), 2, KType_Int, KFieldName_("tv_sec"), KType_Int, KFieldName_("tv_usec"),

		// Sockaddr_in
		_Public, _F(Sockaddr_in_new), KType_Sockaddr_in, KType_Sockaddr_in, KMethodName_("new"), 3, KType_Int, KFieldName_("family"), KType_Int, KFieldName_("addr"), KType_Int, KFieldName_("port"),

		DEND, /* <= sentinel */
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);


	KDEFINE_INT_CONST IntData[] = {
		// === for event_new() ===
		{KDefineConstInt(EV_TIMEOUT)},
		{KDefineConstInt(EV_READ)},
		{KDefineConstInt(EV_WRITE)},
		{KDefineConstInt(EV_SIGNAL)},
		{KDefineConstInt(EV_PERSIST)},
		{KDefineConstInt(EV_ET)},

		// === for bufferevent ===
		// bufferevent.h
		{KDefineConstInt(BEV_EVENT_READING)},
		{KDefineConstInt(BEV_EVENT_WRITING)},
		{KDefineConstInt(BEV_EVENT_EOF)},
		{KDefineConstInt(BEV_EVENT_ERROR)},
		{KDefineConstInt(BEV_EVENT_TIMEOUT)},
		{KDefineConstInt(BEV_EVENT_CONNECTED)},

		// bufferevent.h: enum bufferevent_options
		{KDefineConstInt(BEV_OPT_CLOSE_ON_FREE)},
		{KDefineConstInt(BEV_OPT_THREADSAFE)},
		{KDefineConstInt(BEV_OPT_DEFER_CALLBACKS)},
		{KDefineConstInt(BEV_OPT_UNLOCK_CALLBACKS)},

		{KDefineConstInt(AF_INET)},// TODO should be implement in posix.socket package

		{} /* <= sentinel */
	};

	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(IntData), trace);

	return true;
}
Exemplo n.º 17
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);
}
Exemplo n.º 18
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;
}
Exemplo n.º 19
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);
}
Exemplo n.º 20
0
static kbool_t python_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	python_Init_count++;
	if(python_Init_count == 1) {
		Py_Initialize();
	}

	static KDEFINE_CLASS PythonDef = {
			STRUCTNAME(PyObject),
			.cflag = 0,
			.init = kPyObject_Init,
			.free = kPyObject_Free,
			.p    = kPyObject_p,
	};

	KClass *cPython = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &PythonDef, trace);
	int KType_PyObject = cPython->typeId;
	KDEFINE_METHOD MethodData[] = {
		_Public|_Const|_Im|_Coercion, _F(PyObject_toBoolean), KType_Boolean, KType_PyObject, KMethodName_To(KType_Boolean), 0,
		_Public|_Const|_Im|_Coercion, _F(Boolean_toPyObject), KType_PyObject, KType_Boolean, KMethodName_To(KType_PyObject), 0,
		_Public|_Const|_Im|_Coercion, _F(PyObject_toInt), KType_Int, KType_PyObject, KMethodName_To(KType_Int), 0,
		_Public|_Const|_Im|_Coercion, _F(Int_toPyObject), KType_PyObject, KType_Int, KMethodName_To(KType_PyObject), 0,
		_Public|_Const|_Im|_Coercion, _F(PyObject_toString), KType_String, KType_PyObject, KMethodName_To(KType_String), 0,
		_Public|_Const|_Im|_Coercion, _F(String_toPyObject), KType_PyObject, KType_String, KMethodName_To(KType_PyObject), 0,
		//_Public,                      _F(Array_Add), KType_void, KType_Array, KMethodName_("add"), 1, KType_0, KFieldName_("value"),
		// [TODO] add following konoha class.
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toList), KType_Array, KType_PyObject, KMethodName_To(KType_Array), 0,
		//_Public|_Const|_Im|_Coercion, _F(Array_toPyObject), KType_PyObject, KType_Array, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toComplex), KType_Complex, KType_PyObject, KMethodName_To(KType_Complex), 0,
		//_Public|_Const|_Im|_Coercion, _F(Complex_toPyObject), KType_PyObject, KType_Complex, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toBuffer), KType_Buffer, KType_PyObject, KMethodName_To(KType_Buffer), 0,
		//_Public|_Const|_Im|_Coercion, _F(Buffer_toPyObject), KType_PyObject, KType_Buffer, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toTuple), KType_Tuple, KType_PyObject, KMethodName_To(KType_Tuple), 0,
		//_Public|_Const|_Im|_Coercion, _F(Tuple_toPyObject), KType_PyObject, KType_Tuple, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toDict), KType_Dict, KType_PyObject, KMethodName_To(KType_Dict), 0,
		//_Public|_Const|_Im|_Coercion, _F(Dict_toPyObject), KType_PyObject, KType_Dict, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toClass), KType_Class, KType_PyObject, KMethodName_To(KType_Class), 0,
		//_Public|_Const|_Im|_Coercion, _F(Class_toPyObject), KType_PyObject, KType_Class, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_asFunction), KType_Function, KType_PyObject, KMethodName_To(KType_Function), 0,
		//_Public|_Const|_Im|_Coercion, _F(Function_toPyObject), KType_PyObject, KType_Function, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_asMethod), KType_Method, KType_PyObject, KMethodName_To(KType_Method), 0,
		//_Public|_Const|_Im|_Coercion, _F(Method_toPyObject), KType_PyObject, KType_Method, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toFile), KType_File, KType_PyObject, KMethodName_To(KType_File), 0,
		//_Public|_Const|_Im|_Coercion, _F(File_toPyObject), KType_PyObject, KType_File, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toModule), KType_Module, KType_PyObject, KMethodName_To(KType_Module), 0,
		//_Public|_Const|_Im|_Coercion, _F(Module_toPyObject), KType_PyObject, KType_Module, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toSeqIter), KType_SeqIter, KType_PyObject, KMethodName_To(KType_SeqIter), 0,
		//_Public|_Const|_Im|_Coercion, _F(SeqIter_toPyObject), KType_PyObject, KType_SeqIter, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toSlice), KType_Slice, KType_PyObject, KMethodName_To(KType_Slice), 0,
		//_Public|_Const|_Im|_Coercion, _F(Slice_toPyObject), KType_PyObject, KType_Slice, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toWeakref), KType_Weakref, KType_PyObject, KMethodName_To(KType_Weakref), 0,
		//_Public|_Const|_Im|_Coercion, _F(Weakref_toPyObject), KType_PyObject, KType_Weakref, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toCapsule), KType_Capsule, KType_PyObject, KMethodName_To(KType_Capsule), 0,
		//_Public|_Const|_Im|_Coercion, _F(Capsule_toPyObject), KType_PyObject, KType_Capsule, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toCell), KType_Cell, KType_PyObject, KMethodName_To(KType_Cell), 0,
		//_Public|_Const|_Im|_Coercion, _F(Cell_toPyObject), KType_PyObject, KType_Cell, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toGen), KType_Gen, KType_PyObject, KMethodName_To(KType_Gen), 0,
		//_Public|_Const|_Im|_Coercion, _F(Gen_toPyObject), KType_PyObject, KType_Gen, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(Date_toPyObject), KType_PyObject, KType_Date, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toDate), KType_Date, KType_PyObject, KMethodName_To(KType_Date), 0,
		//_Public|_Const|_Im|_Coercion, _F(Set_toPyObject), KType_PyObject, KType_Set, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toSet), KType_Set, KType_PyObject, KMethodName_To(KType_Set), 0,
		//_Public|_Const|_Im|_Coercion, _F(Code_toPyObject), KType_PyObject, KType_Code, KMethodName_To(KType_PyObject), 0,
		//_Public|_Const|_Im|_Coercion, _F(PyObject_toCode), KType_Code, KType_PyObject, KMethodName_To(KType_Code), 0,
		_Public|_Im, _F(Python_Eval), KType_Boolean, KType_System, KFieldName_("pyEval"), 1, KType_String, KFieldName_("script"),
		_Public|_Im, _F(PyObject_import), KType_PyObject, KType_PyObject, KFieldName_("import"), 1, KType_String, KFieldName_("name"),
		_Public|_Im, _F(PyObject_), KType_PyObject, KType_PyObject, 0, 1, KType_PyObject, 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	if(KDefinedKonohaCommonModule() == true && KClass_Float != NULL) {
		KDEFINE_METHOD MethodData[] = {
			_Public|_Const|_Im|_Coercion, _F(PyObject_toFloat), KType_float, KType_PyObject, KMethodName_To(KType_float), 0,
			_Public|_Const|_Im|_Coercion, _F(Float_toPyObject), KType_PyObject, KType_float, KMethodName_To(KType_PyObject), 0,
			DEND,
		};
		KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	}
	return true;
}
Exemplo n.º 21
0
static void file_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Static|_Const, _F(File_scriptPath), KType_String, KType_File, KMethodName_("scriptPath"), 1, KType_String, KFieldName_("filename"),
		_Public, _F(File_SetWriterCharset), KType_void, KType_File, KMethodName_("setWriterCharset"), 1, KType_String, KFieldName_("charset"),
		_Public, _F(File_SetReaderCharset), KType_void, KType_File, KMethodName_("setReaderCharset"), 1, KType_String, KFieldName_("charset"),

		_Public, _F(File_new), KType_File, KType_File, KMethodName_("new"), 2, KType_String, KFieldName_("filename"), KType_String, KFieldName_("mode"),
		_Public, _F(File_close), KType_void, KType_File, KMethodName_("close"), 0,
		_Public, _F(File_getc), KType_Int, KType_File, KMethodName_("getc"), 0,
		_Public, _F(File_putc), KType_void, KType_File, KMethodName_("putc"), 1, KType_Int, KFieldName_("char"),
		_Public, _F(File_readLine), KType_String, KType_File, KMethodName_("readLine"), 0,
		_Public, _F(File_print), KType_String, KType_File, KMethodName_("print"), 1, KType_String | KTypeAttr_Coercion, KFieldName_("str"),
		_Public, _F(File_println), KType_void, KType_File, KMethodName_("println"), 1, KType_String | KTypeAttr_Coercion, KFieldName_("str"),
		_Public, _F(File_println0), KType_void, KType_File, KMethodName_("println"), 0,
		_Public, _F(File_flush), KType_void, KType_File, KMethodName_("flush"), 0,

		_Public|_Const|_Im, _F(FILE_isatty), KType_Boolean, KType_File, KMethodName_("isatty"), 0,
		_Public|_Const|_Im, _F(FILE_getfileno), KType_Int, KType_File, KMethodName_("getfileno"), 0,

		_Public, _F(File_read),   KType_Int, KType_File, KMethodName_("read"), 1, KType_Bytes, KFieldName_("buf"),
		_Public, _F(File_read3),  KType_Int, KType_File, KMethodName_("read"), 3, KType_Bytes, KFieldName_("buf"), KType_Int, KFieldName_("offset"), KType_Int, KFieldName_("len"),
		_Public, _F(File_Write),  KType_Int, KType_File, KMethodName_("write"), 1, KType_Bytes, KFieldName_("buf"),
		_Public, _F(File_Write3), KType_Int, KType_File, KMethodName_("write"), 3, KType_Bytes, KFieldName_("buf"), KType_Int, KFieldName_("offset"), KType_Int, KFieldName_("len"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
}
Exemplo n.º 22
0
static kbool_t date_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KDEFINE_CLASS defDate = {0};
	SETSTRUCTNAME(defDate, Date);
	defDate.cflag = KClassFlag_Final;

	KClass *cDate = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defDate, trace);

	KDEFINE_METHOD MethodData[] = {
		_Public, _F(Date_new0), KType_Date, KType_Date, KMethodName_("new"), 0,
		_Public, _F(Date_new1), KType_Date, KType_Date, KMethodName_("new"), 1, KType_Int, KFieldName_("milliseconds"),
//		_Public, _F(Date_new2), KType_Date, KType_Date, KMethodName_("new"), 1, KType_String, KFieldName_("dateString"),
		_Public, _F(Date_new3), KType_Date, KType_Date, KMethodName_("new"), 7, KType_Int, KFieldName_("year"), KType_Int, KFieldName_("month"), KType_Int, KFieldName_("day"), KType_Int, KFieldName_("hour"), KType_Int, KFieldName_("minutes"), KType_Int, KFieldName_("seconds"), KType_Int, KFieldName_("milliseconds"),
		_Public|_Im, _F(Date_getDate), KType_Int, KType_Date, KMethodName_("getDate"), 0,
		_Public|_Im, _F(Date_getDay), KType_Int, KType_Date, KMethodName_("getDay"), 0,
		_Public|_Im, _F(Date_getFullYear), KType_Int, KType_Date, KMethodName_("getFullYear"), 0,
		_Public|_Im, _F(Date_getHours), KType_Int, KType_Date, KMethodName_("getHours"), 0,
		_Public|_Im, _F(Date_getMilliseconds), KType_Int, KType_Date, KMethodName_("getMilliseconds"), 0,
		_Public|_Im, _F(Date_getMinutes), KType_Int, KType_Date, KMethodName_("getMinutes"), 0,
		_Public|_Im, _F(Date_getMonth), KType_Int, KType_Date, KMethodName_("getMonth"), 0,
		_Public|_Im, _F(Date_getSeconds), KType_Int, KType_Date, KMethodName_("getSeconds"), 0,
		_Public|_Im, _F(Date_getTime), KType_Int, KType_Date, KMethodName_("getTime"), 0,
		_Public|_Im, _F(Date_getTimezoneOffset), KType_Int, KType_Date, KMethodName_("getTimezoneOffset"), 0,
		_Public|_Im, _F(Date_getUTCDate), KType_Int, KType_Date, KMethodName_("getUTCDate"), 0,
		_Public|_Im, _F(Date_getUTCDay), KType_Int, KType_Date, KMethodName_("getUTCDay"), 0,
		_Public|_Im, _F(Date_getUTCFullYear), KType_Int, KType_Date, KMethodName_("getUTCFullYear"), 0,
		_Public|_Im, _F(Date_getUTCHours), KType_Int, KType_Date, KMethodName_("getUTCHours"), 0,
		_Public|_Im, _F(Date_getUTCMilliseconds), KType_Int, KType_Date, KMethodName_("getUTCMilliseconds"), 0,
		_Public|_Im, _F(Date_getUTCMinutes), KType_Int, KType_Date, KMethodName_("getUTCMinutes"), 0,
		_Public|_Im, _F(Date_getUTCMonth), KType_Int, KType_Date, KMethodName_("getUTCMonth"), 0,
		_Public|_Im, _F(Date_getUTCSeconds), KType_Int, KType_Date, KMethodName_("getUTCSeconds"), 0,
		_Public|_Im, _F(Date_getYear), KType_Int, KType_Date, KMethodName_("getYear"), 0,
//		_Public|_Static, _F(Date_Parse), KType_Int, KType_Date, KMethodName_("parse"), 1, KType_String, KFieldName_("dateString"),
		_Public, _F(Date_SetDate), KType_Int, KType_Date, KMethodName_("setDate"), 1, KType_Int, KFieldName_("date"),
		_Public, _F(Date_SetFullYear), KType_Int, KType_Date, KMethodName_("setFullYear"), 1, KType_Int, KFieldName_("year"),
		_Public, _F(Date_SetHours), KType_Int, KType_Date, KMethodName_("setHours"), 1, KType_Int, KFieldName_("hours"),
		_Public, _F(Date_SetMilliseconds), KType_Int, KType_Date, KMethodName_("setMilliseconds"), 1, KType_Int, KFieldName_("milliseconds"),
		_Public, _F(Date_SetMinutes), KType_Int, KType_Date, KMethodName_("setMinutes"), 1, KType_Int, KFieldName_("minutes"),
		_Public, _F(Date_SetMonth), KType_Int, KType_Date, KMethodName_("setMonth"), 1, KType_Int, KFieldName_("month"),
		_Public, _F(Date_SetSeconds), KType_Int, KType_Date, KMethodName_("setSeconds"), 1, KType_Int, KFieldName_("seconds"),
		_Public, _F(Date_SetTime), KType_Int, KType_Date, KMethodName_("setTime"), 1, KType_Int, KFieldName_("milliseconds"),
		_Public, _F(Date_SetUTCDate), KType_Int, KType_Date, KMethodName_("setUTCDate"), 1, KType_Int, KFieldName_("date"),
		_Public, _F(Date_SetUTCFullYear), KType_Int, KType_Date, KMethodName_("setUTCFullYear"), 1, KType_Int, KFieldName_("year"),
		_Public, _F(Date_SetUTCHours), KType_Int, KType_Date, KMethodName_("setUTCHours"), 1, KType_Int, KFieldName_("hours"),
		_Public, _F(Date_SetUTCMilliseconds), KType_Int, KType_Date, KMethodName_("setUTCMilliseconds"), 1, KType_Int, KFieldName_("milliseconds"),
		_Public, _F(Date_SetUTCMinutes), KType_Int, KType_Date, KMethodName_("setUTCMinutes"), 1, KType_Int, KFieldName_("minutes"),
		_Public, _F(Date_SetUTCMonth), KType_Int, KType_Date, KMethodName_("setUTCMonth"), 1, KType_Int, KFieldName_("month"),
		_Public, _F(Date_SetUTCSeconds), KType_Int, KType_Date, KMethodName_("setUTCSeconds"), 1, KType_Int, KFieldName_("seconds"),
		_Public, _F(Date_SetYear), KType_Int, KType_Date, KMethodName_("setYear"), 1, KType_Int, KFieldName_("year"),
		_Public, _F(Date_toDateString), KType_String, KType_Date, KMethodName_("toDateString"), 0,
		_Public, _F(Date_toGMTString), KType_String, KType_Date, KMethodName_("toGMTString"), 0,
		_Public, _F(Date_toISOString), KType_String, KType_Date, KMethodName_("toISOString"), 0,
//		_Public, _F(Date_toJSON), KType_Json, KType_Date, KMethodName_("toJSON"), 0,
		_Public, _F(Date_toLocaleDateString), KType_String, KType_Date, KMethodName_("toLocaleDateString"), 0,
		_Public, _F(Date_toLocaleTimeString), KType_String, KType_Date, KMethodName_("toLocaleTimeString"), 0,
		_Public, _F(Date_toLocaleString), KType_String, KType_Date, KMethodName_("toLocaleString"), 0,
		_Public, _F(Date_toLocaleString), KType_String, KType_Date, KMethodName_("toString"), 0,
		_Public, _F(Date_toLocaleTimeString), KType_String, KType_Date, KMethodName_("toTimeString"), 0,
		_Public, _F(Date_toGMTString), KType_String, KType_Date, KMethodName_("toUTCString"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	return true;
}
Exemplo n.º 23
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;
}
Exemplo n.º 24
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;
}
Exemplo n.º 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);
}
Exemplo n.º 26
0
	static KDEFINE_CLASS ResultSetDef = {
		STRUCTNAME(ResultSet),
		.cflag = KClassFlag_Final,
		.init = kResultSet_Init,
		.free = kResultSet_Free,
		.reftrace = kResultSet_Reftrace,
		.format = kResultSet_format,
	};

	KClass *cConnection = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &ConnectionDef, trace);
	KClass *cResultSet = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &ResultSetDef, trace);

	KDEFINE_METHOD MethodData[] = {
		/* Connection method */
		_Public, _F(Connection_new), KType_Connection, KType_Connection, KMethodName_("new"), 1, KType_String, KFieldName_("dbname"),
		_Public, _F(Connection_close), KType_void, KType_Connection, KMethodName_("close"), 0,
		_Public, _F(Connection_query), KType_ResultSet, KType_Connection, KMethodName_("query"), 1, KType_String, KFieldName_("query"),
#ifdef HAVE_MYSQL
		_Public, _F(Connection_getInsertId), KType_Int, KType_Connection, KMethodName_("getInsertId"), 0,
#endif

		/* ResultSet method */
		_Public, _F(ResultSet_getInt), KType_Int, KType_ResultSet, KMethodName_("getInt"), 1, KType_String, KFieldName_("query"),
		_Public, _F(ResultSet_getBoolean), KType_Boolean, KType_ResultSet, KMethodName_("getBoolean"), 1, KType_String, KFieldName_("query"),
		_Public, _F(ResultSet_getFloat), KType_float, KType_ResultSet, KMethodName_("getFloat"), 1, KType_String, KFieldName_("query"),
		_Public, _F(ResultSet_getString), KType_String, KType_ResultSet, KMethodName_("getString"), 1, KType_String, KFieldName_("query"),
		_Public|kMethod_SmartReturn, _F(ResultSet_get), KType_Object, KType_ResultSet, KMethodName_("get"), 1, KType_String, KFieldName_("query"),
		_Public, _F(ResultSet_next), KType_Boolean, KType_ResultSet, KMethodName_("next"), 0,
		_Public, _F(ResultSet_getSize), KType_Int, KType_ResultSet, KMethodName_("getSize"), 0,
		_Public, _F(ResultSet_getName), KType_String, KType_ResultSet, KMethodName_("getName"), 1, KType_Int, KFieldName_("idx"),
Exemplo n.º 27
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;
}
Exemplo n.º 28
0
		.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,
		_Public|_Const, _F(MecabNode_getRCAttr),   KType_Int,  KType_MecabNode, KMethodName_("getRCAttr"), 0,
Exemplo n.º 29
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;
}
Exemplo n.º 30
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);
}