Exemplo n.º 1
0
static void path_defineAccessConst(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace)
{
	KDEFINE_INT_CONST intData[] = {
		/*for System.access*/
		{KDefineConstInt(R_OK)},
		{KDefineConstInt(W_OK)},
		{KDefineConstInt(X_OK)},
		{KDefineConstInt(F_OK)},
		{NULL} /* sentinel */
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(intData), trace);
}
Exemplo n.º 2
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.º 3
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.º 4
0
		_Public|_Const, _F(MecabNode_getLCAttr),   KType_Int,  KType_MecabNode, KMethodName_("getLCAttr"), 0,
		_Public|_Const, _F(MecabNode_getCharType), KType_Int,  KType_MecabNode, KMethodName_("getCharType"), 0,
		_Public|_Const, _F(MecabNode_getStat),     KType_Int,  KType_MecabNode, KMethodName_("getStat"), 0,
		_Public|_Const, _F(MecabNode_getID),       KType_Int,  KType_MecabNode, KMethodName_("getID"), 0,
		_Public|_Const, _F(MecabNode_isBest),      KType_Boolean,  KType_MecabNode, KMethodName_("isBest"), 0,
		//_Public|_Const, _F(MecabNode_alpha),       KType_Float,  KType_MecabNode, KMethodName_("alpha"), 0,
		//_Public|_Const, _F(MecabNode_beta),        KType_Float,  KType_MecabNode, KMethodName_("beta"), 0,
		//_Public|_Const, _F(MecabNode_prob),        KType_Float,  KType_MecabNode, KMethodName_("prob"), 0,
		_Public|_Const, _F(MecabNode_wcost),       KType_Int,  KType_MecabNode, KMethodName_("wcost"), 0,
		_Public|_Const, _F(MecabNode_cost),        KType_Int,  KType_MecabNode, KMethodName_("cost"), 0,
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);

	KDEFINE_INT_CONST IntData[] = {
			{KDefineConstInt(MECAB_NOR_NODE)},
			{KDefineConstInt(MECAB_UNK_NODE)},
			{KDefineConstInt(MECAB_BOS_NODE)},
			{KDefineConstInt(MECAB_EOS_NODE)},
			{}
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KConst_(IntData), trace);
	return true;
}

static kbool_t mecab_ExportNameSpace(KonohaContext *kctx, kNameSpace *ns, kNameSpace *exportNS, int option, KTraceInfo *trace)
{
	return true;
}

/* ======================================================================== */
Exemplo n.º 5
0
		_Public|_Static|_Const|_Im, _F(System_shutdown), TY_int, TY_System, MN_("shutdown"), 2, TY_int, FN_("fd"), TY_int, FN_("how"),
		_Public|_Static|_Const|_Im, _F(System_sockatmark), TY_int, TY_System, MN_("sockatmark"), 1, TY_int, FN_("fd"),
		_Public|_Static|_Const|_Im, _F(System_socket), TY_int, TY_System, MN_("socket"), 3, TY_int, FN_("family"), TY_int, FN_("type"), TY_int, FN_("protocol"),
		_Public|_Static|_Const|_Im, _F(System_socketpair), TY_int, TY_System, MN_("socketpair"), 4, TY_int, FN_("family"), TY_int, FN_("type"), TY_int, FN_("protocol"), TY_intArray, FN_("pairsock"),
		_Public|_Const|_Im, _F(SockAddr_new), TY_SockAddr, TY_SockAddr, MN_("new"), 0,
		// the function below uses Bytes
		// FIXME
//		_Public|_Static|_Const|_Im, _F(System_sendto), TY_int, TY_System, MN_("sendto"), 6, TY_int, FN_("socket"), TY_Bytes, FN_("msg"), TY_int, FN_("flag"), TY_String, FN_("dstIP"), TY_int, FN_("dstPort"), TY_int, FN_("family"),
//		_Public|_Static|_Const|_Im, _F(System_recv), TY_int, TY_System, MN_("recv"), 3, TY_int, FN_("fd"), TY_Bytes, FN_("buf"), TY_int, FN_("flags"),
//		_Public|_Static|_Const|_Im, _F(System_recvfrom), TY_int, TY_System, MN_("recvfrom"), 4, TY_int, FN_x, TY_Bytes, FN_y, TY_int, FN_z, TY_Map, FN_v,
//		_Public|_Static|_Const|_Im, _F(System_send), TY_int, TY_System, MN_("send"), 3, TY_int, FN_("fd"), TY_Bytes, FN_("msg"), TY_int, FN_("flags"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	KDEFINE_INT_CONST IntData[] = {
			{KDefineConstInt(PF_LOCAL)},
			{KDefineConstInt(PF_UNIX)},
			{KDefineConstInt(PF_INET)},
			{KDefineConstInt(PF_INET6)},
			{KDefineConstInt(PF_APPLETALK)},
#ifdef __linux___
			{KDefineConstInt(PF_PACKET)},
#endif
			{KDefineConstInt(AF_LOCAL)},
			{KDefineConstInt(AF_UNIX)},
			{KDefineConstInt(AF_INET)},
			{KDefineConstInt(AF_INET6)},
			{KDefineConstInt(AF_APPLETALK)},
#ifdef __linux___
			{KDefineConstInt(AF_PACKET)},
#endif
Exemplo n.º 6
0
static kbool_t fd_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace)
{
	KDEFINE_METHOD MethodData[] = {
		_Public|_Static, _F(System_lseek),     TY_int,     TY_System, MN_("lseek"),     3, TY_int, FN_("fd"), TY_int, FN_("offset"), TY_int, FN_("whence"),
		_Public|_Static, _F(System_ftruncate), TY_boolean, TY_System, MN_("ftruncate"), 2, TY_int, FN_("fd"), TY_int, FN_("length"),
		_Public|_Static, _F(System_fchmod),    TY_boolean, TY_System, MN_("fchmod"),    2, TY_int, FN_("fd"), TY_int, FN_("length"),
		_Public|_Static, _F(System_flock),     TY_boolean, TY_System, MN_("flock"),     2, TY_int, FN_("fd"), TY_int, FN_("operation"),
		_Public|_Static, _F(System_sync),      TY_boolean, TY_System, MN_("sync"),      1, TY_int, FN_("fd"),
		_Public|_Static, _F(System_fchown),    TY_boolean, TY_System, MN_("fchown"),    3, TY_int, FN_("pd"), TY_int, FN_("owner"),  TY_int, FN_("group"),
		_Public|_Static, _F(System_fsync),     TY_boolean, TY_System, MN_("fsync"),     1, TY_int, FN_("fd"),
		_Public|_Static|_Const|_Im, _F(System_getdtablesize), TY_int, TY_System, MN_("getdtablesize"), 0,
		_Public|_Static|_Im, _F(System_open),      TY_int,     TY_System, MN_("open"),   2, TY_String, FN_("pathname"), TY_int, FN_("flags"),
		_Public|_Static|_Im, _F(System_open_mode), TY_int,     TY_System, MN_("open"),   3, TY_String, FN_("pathname"), TY_int, FN_("flags"), TY_int, FN_("mode"),
		_Public|_Static|_Im, _F(System_fchdir),    TY_boolean, TY_System, MN_("fchdir"), 1, TY_int,    FN_("fd"),
		_Public|_Static|_Im, _F(System_isatty),    TY_boolean, TY_System, MN_("isatty"), 1, TY_int,    FN_("fd"),
		_Public|_Static|_Im, _F(System_ttyname),   TY_String, TY_System, MN_("ttyname"), 1, TY_int,    FN_("fd"),
		DEND,
	};
	KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace);
	KDEFINE_INT_CONST intData[] = {
		/*for System.lseek*/
		{KDefineConstInt(SEEK_SET)},
		{KDefineConstInt(SEEK_CUR)},
		{KDefineConstInt(SEEK_END)},
		/*for System.flock*/
		{KDefineConstInt(LOCK_SH)},
		{KDefineConstInt(LOCK_EX)},
		{KDefineConstInt(LOCK_UN)},
		{KDefineConstInt(LOCK_NB)},
		/*for System.open*/
		{KDefineConstInt(O_RDONLY)},
		{KDefineConstInt(O_WRONLY)},
		{KDefineConstInt(O_RDWR)},
		{KDefineConstInt(O_CREAT)},
		{KDefineConstInt(O_EXCL)},
		{KDefineConstInt(O_TRUNC)},
		{KDefineConstInt(O_APPEND)},
		{KDefineConstInt(O_NONBLOCK)},
		{KDefineConstInt(O_NDELAY)},
		{KDefineConstInt(O_NOCTTY)},
		{NULL}, /* sentinel */
	};
	KLIB kNameSpace_LoadConstData(kctx, ns, KonohaConst_(intData), 0);
	return true;
}
Exemplo n.º 7
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.º 8
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;
}