static void namespace_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace) { KDEFINE_METHOD MethodData[] = { _Public|_Const|_Im, _F(NameSpace_GetNameSpace), KType_NameSpace, KType_NameSpace, KMethodName_("GetNameSpace"), 0, _Public|_Const|_Im, _F(NameSpace_GetParentNameSpace), KType_NameSpace, KType_NameSpace, KMethodName_("GetParentNameSpace"), 0, _Public, _F(NameSpace_DefineMacro2), KType_Boolean, KType_NameSpace, KMethodName_("DefineMacro"), 2, TP_name, TP_source, _Public, _F(NameSpace_DefineMacro), KType_Boolean, KType_NameSpace, KMethodName_("DefineMacro"), 3, TP_name, TP_paramsize, TP_source, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); }
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); }
static void object_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace) { KDEFINE_METHOD MethodData[] = { _Public|_Im|_Const|_Final, _F(Object_getTypeId), TY_int, TY_Object, MN_("getTypeId"), 0, _Public|_Hidden|_Im|_Const, _F(Object_instanceOf), TY_boolean, TY_Object, MN_("<:"), 1, TY_Object, FN_("type"), _Public|_Hidden|_Im|_Const|kMethod_SmartReturn, _F(Object_as), TY_Object, TY_Object, MN_("as"), 0, _Public|_Const|_Ignored, _F(NameSpace_AllowImplicitCoercion), TY_void, TY_NameSpace, MN_("AllowImplicitCoercion"), 1, TY_boolean, FN_("allow"), DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); }
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; }
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; }
static kbool_t openssl_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace) { static const char *names[] = { "MD5", "SHA1", }; KonohaClass *tbls[2]; static KDEFINE_CLASS Def = { .structname = "", .typeId = TY_newid, .init = RawPtr_Init, .free = RawPtr_Free, }; #define TY_MD5 tbls[0]->typeId #define TY_SHA1 tbls[1]->typeId int i; for (i = 0; i < 2; i++) { Def.structname = names[i]; tbls[i] = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &Def, trace); } int FN_x = FN_("x"); KDEFINE_METHOD MethodData[] = { _P, _F(kMD5_Init), TY_SHA1, TY_MD5, MN_("new"), 0, _P, _F(kMD5_Update), TY_int, TY_MD5, MN_("update"), 1, TY_String, FN_x, _P, _F(kMD5_Final), TY_String, TY_MD5, MN_("final"), 0, _P, _F(kSHA1_Init), TY_SHA1, TY_SHA1, MN_("new"), 0, _P, _F(kSHA1_Update), TY_int, TY_SHA1, MN_("update"), 1, TY_String, FN_x, _P, _F(kSHA1_Final), TY_String, TY_SHA1, MN_("final"), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return true; } static kbool_t openssl_ExportNameSpace(KonohaContext *kctx, kNameSpace *ns, kNameSpace *exportNS, int option, KTraceInfo *trace) { return true; } KDEFINE_PACKAGE *openssl_Init(void) { static KDEFINE_PACKAGE d = { KPACKNAME("openssl", "1.0"), .PackupNameSpace = openssl_PackupNameSpace, .ExportNameSpace = openssl_ExportNameSpace, }; return &d; }
static kbool_t dynamic_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace) { static KDEFINE_CLASS defDynamic = {0}; defDynamic.structname = "dynamic"; defDynamic.cflag = kClass_Final|kClass_TypeVar; KonohaClass *cDynamic = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defDynamic, trace); int TY_Dynamic = cDynamic->typeId; KDEFINE_METHOD MethodData[] = { _Public|_Im, _F(Dynamic_), TY_Object, TY_Dynamic, MN_(""), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return true; }
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); }
// -------------------------------------------------------------------------- static kbool_t ClosureModel_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace) { KDEFINE_SYNTAX SYNTAX[] = { { KSymbol_("function"), SYNFLAG_CTypeFunc, 0, Precedence_CStyleAssign, {SUGAR patternParseFunc}, {SUGARFUNC TypeCheck_Closure}}, { KSymbol_END, }, }; SUGAR kNameSpace_DefineSyntax(kctx, ns, SYNTAX, trace); SUGAR kSyntax_AddPattern(kctx, kSyntax_(ns, KSymbol_("function")), "\"function\" $Param [$Type] $Block", 0, NULL); KDEFINE_METHOD MethodData[] = { _Public|_Hidden, _F(Func_Create), KType_Func, KType_Func, KMethodName_("_Create"), 2, KType_Object, KFieldName_("env"), KType_Method, KFieldName_("mtd"), DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return true; }
static KonohaClass *loadcidClass(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace) { static KDEFINE_CLASS defcid = {0}; defcid.structname = "cid"; defcid.cflag = CFLAG_int; defcid.init = CT_(TY_int)->init; defcid.unbox = CT_(TY_int)->unbox; defcid.p = kcid_p; KonohaClass *ccid = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defcid, trace); KDEFINE_METHOD MethodData[] = { _Public|_Coercion|_Const, _F(Object_tocid), ccid->typeId, TY_Object, MN_to(ccid->typeId), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return ccid; }
static KonohaClass *defineSymbolClass(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace) { static KDEFINE_CLASS defSymbol = {0}; defSymbol.structname = "Symbol"; defSymbol.cflag = CFLAG_int; defSymbol.init = CT_(TY_int)->init; defSymbol.unbox = CT_(TY_int)->unbox; defSymbol.p = kSymbol_p; KonohaClass *cSymbol = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defSymbol, trace); KDEFINE_METHOD MethodData[] = { _Public|_Coercion|_Const, _F(String_toSymbol), cSymbol->typeId, TY_String, MN_to(cSymbol->typeId), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return cSymbol; }
static kbool_t array_defineMethod(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace) { KRequireKonohaCommonModule(trace); KImportPackageSymbol(ns, "cstyle", "[]", trace); KDEFINE_INT_CONST ClassData[] = { // add Array as available {"Array", VirtualType_KonohaClass, (uintptr_t)CT_(TY_Array)}, {NULL}, }; KLIB kNameSpace_LoadConstData(kctx, ns, KonohaConst_(ClassData), false/*isOverride*/, trace); KonohaClass *CT_ArrayT0 = CT_p0(kctx, CT_Array, TY_0); kattrtype_t TY_ArrayT0 = CT_ArrayT0->typeId; kparamtype_t p[] = {{TY_0}}; kattrtype_t TY_FuncMap = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_0 , 1, p))->typeId; kparamtype_t P_inject[] = {{TY_0},{TY_0}}; kattrtype_t TY_FuncInject = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_0 , 2, P_inject))->typeId; KDEFINE_METHOD MethodData[] = { _Public|_Im, _F(Array_get), TY_0, TY_Array, MN_("get"), 1, TY_int, FN_("index"), _Public, _F(Array_set), TY_void, TY_Array, MN_("set"), 2, TY_int, FN_("index"), TY_0, FN_("value"), _Public|_Im, _F(Array_removeAt), TY_0, TY_Array, MN_("removeAt"), 1, TY_int, FN_("index"), _Public|_Const, _F(Array_getSize), TY_int, TY_Array, MN_("getSize"), 0, _Public|_Const, _F(Array_getSize), TY_int, TY_Array, MN_("getlength"), 0, _Public, _F(Array_clear), TY_void, TY_Array, MN_("clear"), 0, _Public, _F(Array_Add1), TY_void, TY_Array, MN_("add"), 1, TY_0, FN_("value"), _Public, _F(Array_Push), TY_int, TY_Array, MN_("push"), 1, TY_0, FN_("value"), _Public, _F(Array_Pop), TY_0, TY_Array, MN_("pop"), 0, _Public, _F(Array_shift), TY_0, TY_Array, MN_("shift"), 0, _Public, _F(Array_unshift), TY_int, TY_Array, MN_("unshift"), 1, TY_0, FN_("value"), _Public, _F(Array_reverse), TY_Array, TY_Array, MN_("reverse"), 0, // _Public|_Im, _F(Array_map), TY_ArrayT0, TY_Array, MN_("map"), 1, TY_FuncMap, FN_("func"), // _Public|_Im, _F(Array_inject), TY_0, TY_Array, MN_("inject"), 1, TY_FuncInject, FN_("func"), _Public, _F(Array_concat), TY_ArrayT0, TY_Array, MN_("concat"), 1, TY_ArrayT0, FN_("a1"), _Public, _F(Array_indexOf), TY_int, TY_Array, MN_("indexOf"), 1, TY_0, FN_("value"), _Public, _F(Array_lastIndexOf), TY_int, TY_Array, MN_("lastIndexOf"), 1, TY_0, FN_("value"), // _Public, _F(Array_toString), TY_String, TY_Array, MN_("toString"), 0, _Public|_Im, _F(Array_new), TY_void, TY_Array, MN_("new"), 1, TY_int, FN_("size"), _Public, _F(Array_newArray), TY_Array, TY_Array, MN_("newArray"), 1, TY_int, FN_("size"), _Public|kMethod_Hidden, _F(Array_newList), TY_Array, TY_Array, MN_("[]"), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return true; }
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); }
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; }
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_ImportPackageSymbol, kNameSpace_ImportPackageSymbol, NULL); KSetKLibFunc(0, kNameSpace_GetConstNULL, kNameSpace_GetConstNULL, NULL); KDEFINE_METHOD MethodData[] = { _Public, _F(NameSpace_ImportPackage), TY_void, TY_NameSpace, MN_("import"), 1, TY_String, FN_("package"), _Public, _F(NameSpace_ImportPackageSymbol), TY_void, TY_NameSpace, MN_("import"), 2, TY_String, FN_("package"), TY_String, FN_("symbol"), _Public, _F(NameSpace_hate), TY_boolean, TY_NameSpace, MN_("hate"), 1, TY_String, FN_("symbol"), _Public, _F(NameSpace_loadScript), TY_void, TY_NameSpace, MN_("load"), 1, TY_String, FN_("filename"), _Public, _F(NameSpace_loadScript), TY_void, TY_NameSpace, MN_("include"), 1, TY_String, FN_("filename"), _Public, _F(NameSpace_useStaticFunc), TY_void, TY_NameSpace, MN_("useStaticFunc"), 1, TY_Object, FN_("class"), DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, NULL); }
KonohaContext* konoha_create(KonohaClass **cRequest) { struct KonohaFactory factory = {}; 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, "apache", trace); *cRequest = CT_Request; #define _P kMethod_Public #define _F(F) (intptr_t)(F) #define TY_Req (CT_Request->typeId) #define TY_Tbl (CT_AprTable->typeId) #define TY_TblEntry (CT_AprTableEntry->typeId) KonohaClass *CT_TblEntryArray = CT_p0(kctx, CT_Array, TY_TblEntry); ktype_t TY_TblEntryArray = CT_TblEntryArray->typeId; int FN_x = FN_("x"); KDEFINE_METHOD MethodData[] = { _P, _F(Request_puts), TY_void, TY_Req, MN_("puts"), 1, TY_String, FN_x, _P, _F(Request_getMethod), TY_String, TY_Req, MN_("getMethod"), 0, _P, _F(Request_getArgs), TY_String, TY_Req, MN_("getArgs"), 0, _P, _F(Request_getUri), TY_String, TY_Req, MN_("getUri"), 0, _P, _F(Request_getPathInfo), TY_String, TY_Req, MN_("getPathInfo"), 0, _P, _F(Request_getHandler), TY_String, TY_Req, MN_("getHandler"), 0, _P, _F(Request_setContentType), TY_void, TY_Req, MN_("setContentType"), 1, TY_String, FN_("type"), _P, _F(Request_setContentEncoding), TY_void, TY_Req, MN_("setContentEncoding"), 1, TY_String, FN_("enc"), _P, _F(Request_logError), TY_void, TY_Req, MN_("logError"), 3, TY_int, FN_("level"), TY_int, FN_("status"), TY_String, FN_("msg"), _P, _F(Request_getHeadersIn), TY_Tbl, TY_Req, MN_("getHeadersIn"), 0, _P, _F(Request_getHeadersOut), TY_Tbl, TY_Req, MN_("getHeadersOut"), 0, _P, _F(AprTable_Add), TY_void, TY_Tbl, MN_("add"), 2, TY_String, FN_("key"), TY_String, FN_("val"), _P, _F(AprTable_set), TY_void, TY_Tbl, MN_("set"), 2, TY_String, FN_("key"), TY_String, FN_("val"), _P, _F(AprTable_getElts), TY_TblEntryArray, TY_Tbl, MN_("getElts"), 0, _P, _F(AprTableEntry_getKey), TY_String, TY_TblEntry, MN_("getKey"), 0, _P, _F(AprTableEntry_getVal), TY_String, TY_TblEntry, MN_("getVal"), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); return kctx; }
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; }
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); }
static void LoadNameSpaceMethodData(KonohaContext *kctx, kNameSpace *ns, int TY_symbol, KTraceInfo *trace) { int FN_keyword = SYM_("keyword"); int FN_func = SYM_("func"); /* Func[Int, Token, String] */ kparamtype_t P_FuncTokenize[] = {{TY_Token}, {TY_String}}; int TY_FuncToken = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_int, 2, P_FuncTokenize))->typeId; /* Func[Int, Stmt, Int, Token[], Int, Int] */ kparamtype_t P_FuncPatternMatch[] = {{TY_Stmt}, {TY_int}, {TY_TokenArray}, {TY_int}, {TY_int}}; int TY_FuncPatternMatch = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_int, 5, P_FuncPatternMatch))->typeId; /* Func[Expr, Stmt, Token[], Int, Int, Int] */ kparamtype_t P_FuncExpression[] = {{TY_Stmt}, {TY_TokenArray}, {TY_int}, {TY_int}, {TY_int}}; int TY_FuncExpression = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_Expr, 5, P_FuncExpression))->typeId; /* Func[Boolean, Stmt, Gamma] */ kparamtype_t P_FuncStatement[] = {{TY_Stmt}, {TY_Gamma}}; int TY_FuncStatement = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_boolean, 2, P_FuncStatement))->typeId; /* Func[Expr, Stmt, Expr, Gamma, Int] */ kparamtype_t P_FuncTypeCheck[] = {{TY_Stmt}, {TY_Expr}, {TY_Gamma}, {TY_int}}; int TY_FuncTypeCheck = (KLIB KonohaClass_Generics(kctx, CT_Func, TY_Expr, 4, P_FuncTypeCheck))->typeId; //DBG_P("func=%s", TY_t(TY_FuncTypeCheck)); KDEFINE_METHOD MethodData[] = { _Public|_Im, _F(NameSpace_DefinedSyntax), TY_boolean, TY_NameSpace, MN_("definedSyntax"), 1, TY_symbol, FN_keyword, _Public|_Im, _F(NameSpace_DefinedLiteral), TY_boolean, TY_NameSpace, MN_("definedLiteral"), 1, TY_symbol, FN_keyword, _Public|_Im, _F(NameSpace_DefinedStatement), TY_boolean, TY_NameSpace, MN_("definedStatement"), 1, TY_symbol, FN_keyword, _Public|_Im, _F(NameSpace_DefinedExpression), TY_boolean, TY_NameSpace, MN_("definedExpression"), 1, TY_symbol, FN_keyword, _Public|_Im, _F(NameSpace_DefinedBinaryOperator), TY_boolean, TY_NameSpace, MN_("definedBinaryOperator"), 1, TY_symbol, FN_keyword, // _Public, _F(NameSpace_compileAllDefinedMethods), TY_void, TY_NameSpace, MN_("compileAllDefinedMethods"), 0, _Public, _F(NameSpace_setTokenFunc), TY_void, TY_NameSpace, MN_("setTokenFunc"), 3, TY_symbol, FN_keyword, TY_int, FN_("kchar"), TY_FuncToken, FN_func, _Public, _F(NameSpace_AddPatternMatch), TY_void, TY_NameSpace, MN_("addPatternMatch"), 2, TY_symbol, FN_keyword, TY_FuncPatternMatch, FN_func, _Public, _F(NameSpace_AddExpression), TY_void, TY_NameSpace, MN_("addExpression"), 2, TY_symbol, FN_keyword, TY_FuncExpression, FN_func, _Public, _F(NameSpace_AddTopLevelStatement), TY_void, TY_NameSpace, MN_("addTopLevelStatement"), 2, TY_symbol, FN_keyword, TY_FuncStatement, FN_func, _Public, _F(NameSpace_AddStatement), TY_void, TY_NameSpace, MN_("addStatement"), 2, TY_symbol, FN_keyword, TY_FuncStatement, FN_func, _Public, _F(NameSpace_AddTypeCheck), TY_void, TY_NameSpace, MN_("addTypeCheck"), 2, TY_symbol, FN_keyword, TY_FuncTypeCheck, FN_func, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); }
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); }
static void path_defineDIR(KonohaContext *kctx, kNameSpace *ns, KTraceInfo *trace) { KDEFINE_CLASS defDIR = {}; defDIR.structname = "DIR"; defDIR.typeId = TY_newid; defDIR.cstruct_size = sizeof(struct kDirVar); defDIR.cflag = kClass_Final; defDIR.init = kDir_Init; defDIR.reftrace = kDir_Reftrace; defDIR.free = kDir_Free; defDIR.p = kDir_p; KonohaClass *cDIR = KLIB kNameSpace_DefineClass(kctx, ns, NULL, &defDIR, trace); int TY_DIR = cDIR->typeId; KDEFINE_METHOD MethodData[] = { _Public|_Static|_C, _F(System_opendir), TY_DIR, TY_System, MN_("opendir"), 1, TY_String, FN_("dirname"), _Public, _F(DIR_close), TY_void, TY_DIR, MN_("close"), 0, _Public|_Iter, _F(DIR_readFileName), TY_String, TY_DIR, MN_("readFileName"), 0, _Public|_Iter, _F(DIR_readPath), TY_String, TY_DIR, MN_("readPath"), 0, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
static kbool_t sugar_PackupNameSpace(KonohaContext *kctx, kNameSpace *ns, int option, KTraceInfo *trace) { KonohaClass *cSymbol = defineSymbolClass(kctx, ns, trace); KonohaClass *ccid = loadcidClass(kctx, ns, trace); KDEFINE_INT_CONST ClassData[] = { // add Array as available {"Token", VirtualType_KonohaClass, (uintptr_t)CT_Token}, {"Stmt", VirtualType_KonohaClass, (uintptr_t)CT_Stmt}, {"Expr", VirtualType_KonohaClass, (uintptr_t)CT_Expr}, {"Block", VirtualType_KonohaClass, (uintptr_t)CT_Block}, {"Gamma", VirtualType_KonohaClass, (uintptr_t)CT_Gamma}, {"NameSpace", VirtualType_KonohaClass, (uintptr_t)CT_NameSpace}, {"symbol", VirtualType_KonohaClass, (uintptr_t)cSymbol}, {NULL}, }; KLIB kNameSpace_LoadConstData(kctx, ns, KonohaConst_(ClassData), 0); int TY_Symbol = cSymbol->typeId; sugar_defineTokenFunc(kctx, ns, TY_Symbol, trace); sugar_defineMessageMethod(kctx, ns, TY_Symbol, trace); int FN_buildid = FN_("buildid"), FN_key = FN_("key"), FN_defval = FN_("defval"); int FN_typeid = FN_("typeid"), FN_gma = FN_("gma"), FN_pol = FN_("pol"); int FN_msg = FN_("msg"); int FN_x = FN_("x"); int FN_tokenList = FN_("tokens"), FN_s = FN_("s"), FN_e = FN_("e"); int FN_expr = FN_("expr"); /* Array[String] */ kparamtype_t P_StringArray[] = {{TY_String}}; int TY_StringArray = (KLIB KonohaClass_Generics(kctx, CT_Array, TY_void, 1, P_StringArray))->typeId; ktype_t TY_symbol = cSymbol->typeId; ktype_t TY_cid = ccid->typeId; KDEFINE_METHOD MethodData[] = { /* Token */ _Public, _F(Token_new), TY_Token, TY_Token, MN_("new"), 1, TY_symbol, FN_key, _Public, _F(Token_setUnresolvedTokenType), TY_void, TY_Token, MN_("setUnresolvedTokenType"), 1, TY_symbol, FN_x, _Public, _F(Token_setText), TY_void, TY_Token, MN_("setText"), 1, TY_String, FN_x, _Public, _F(Token_setSubArray), TY_void, TY_Token, MN_("setSubArray"), 1, TY_StringArray, FN_x, // _Public, _F(Token_isTypeName), TY_boolean, TY_Token, MN_("isTypeName"), 0, _Public, _F(Token_isParenthesis), TY_boolean, TY_Token, MN_("isParenthesis"), 0, _Public, _F(Token_getText), TY_String, TY_Token, MN_("getText"), 0, _Public, _F(Token_isSymbol), TY_boolean, TY_Token, MN_("isSymbol"), 0, _Public, _F(Token_newUntypedExpr), TY_Expr, TY_Token, MN_("newUntypedExpr"), 0, _Public, _F(Token_isBeforeWhiteSpace), TY_boolean, TY_Token, MN_("isBeforeWhiteSpace"), 0, /* Stmt */ _Public, _F(Stmt_getBuild), TY_int, TY_Stmt, MN_("getBuild"), 0, _Public, _F(Stmt_setBuild), TY_void, TY_Stmt, MN_("setBuild"), 1, TY_int, FN_buildid, _Public, _F(Stmt_getBlock), TY_Block, TY_Stmt, MN_("getBlock"), 2, TY_symbol, FN_key, TY_Block, FN_defval, _Public, _F(Stmt_getToken), TY_Token, TY_Stmt, MN_("getToken"), 2, TY_symbol, FN_key, TY_Token, FN_defval, _Public, _F(Stmt_getExpr), TY_Expr, TY_Stmt, MN_("getExpr"), 2, TY_symbol, FN_key, TY_Expr, FN_defval, _Public, _F(Stmt_TypeCheckExpr), TY_boolean, TY_Stmt, MN_("TypeCheckExpr"), 3, TY_symbol, FN_key, TY_Gamma, FN_gma, TY_cid, FN_typeid, _Public, _F(Stmt_TypeCheckExprPol), TY_boolean, TY_Stmt, MN_("TypeCheckExpr"), 4, TY_symbol, FN_key, TY_Gamma, FN_gma, TY_cid, FN_typeid, TY_int, FN_pol, _Public, _F(Stmt_Message2rintError), TY_Expr, TY_Stmt, MN_("printError"), 1, TY_String, FN_msg, _Public, _F(Stmt_newExpr), TY_Expr, TY_Stmt, MN_("newExpr"), 3, TY_TokenArray, FN_tokenList, TY_int, FN_s, TY_int, FN_e, _Public, _F(Stmt_setType), TY_void, TY_Stmt, MN_("setType"), 1, TY_int, FN_x, // _Public, _F(kStmt_Message2arsedExpr), TY_Expr, TY_Stmt, MN_("parseExpr"), 3, TY_TokenArray, FN_tokenList, TY_int, FN_s, TY_int, FN_e, _Public, _F(Stmt_newUntypedCallStyleExpr2), TY_Expr, TY_Stmt, MN_("newUntypedCallStyleExpr"), 2, TY_Token, FN_("token"), TY_Expr, FN_("expr1"), _Public, _F(Stmt_newUntypedCallStyleExpr3), TY_Expr, TY_Stmt, MN_("newUntypedCallStyleExpr"), 3, TY_Token, FN_("token"), TY_Expr, FN_("expr1"), TY_Expr, FN_("expr2"), _Public, _F(Stmt_newUntypedCallStyleExpr4), TY_Expr, TY_Stmt, MN_("newUntypedCallStyleExpr"), 4, TY_Token, FN_("token"), TY_Expr, FN_("expr1"), TY_Expr, FN_("expr2"), TY_Expr, FN_("expr3"), _Public, _F(Stmt_newUntypedCallStyleExpr5), TY_Expr, TY_Stmt, MN_("newUntypedCallStyleExpr"), 5, TY_Token, FN_("token"), TY_Expr, FN_("expr1"), TY_Expr, FN_("expr2"), TY_Expr, FN_("expr3"), TY_Expr, FN_("expr4"), _Public, _F(Stmt_newUntypedCallStyleExpr6), TY_Expr, TY_Stmt, MN_("newUntypedCallStyleExpr"), 6, TY_Token, FN_("token"), TY_Expr, FN_("expr1"), TY_Expr, FN_("expr2"), TY_Expr, FN_("expr3"), TY_Expr, FN_("expr4"), TY_Expr, FN_("expr5"), _Public, _F(Stmt_newTypedCallExpr1), TY_Expr, TY_Stmt, MN_("newTypedCallExpr"), 4, TY_Gamma, FN_gma, TY_cid, FN_typeid, TY_symbol, FN_("methodName"), TY_Expr, FN_("firstExpr"), _Public, _F(Stmt_newTypedCallExpr2), TY_Expr, TY_Stmt, MN_("newTypedCallExpr"), 5, TY_Gamma, FN_gma, TY_cid, FN_typeid, TY_symbol, FN_("methodName"), TY_Expr, FN_("firstExpr"), TY_Expr, FN_("secondExpr"), _Public, _F(Stmt_rightJoinExpr), TY_Expr, TY_Stmt, MN_("rightJoinExpr"), 4, TY_Expr, FN_expr, TY_TokenArray, FN_tokenList, TY_int, FN_s, TY_int, FN_e, _Public, _F(Stmt_getTokenList), TY_TokenArray, TY_Stmt, MN_("getTokenList"), 2, TY_symbol, FN_key, TY_TokenArray, FN_defval, _Public, _F(Stmt_done), TY_void, TY_Stmt, MN_("done"), 0, _Public, _F(Stmt_setObject), TY_void, TY_Stmt, MN_("setExpr"), 2, TY_symbol, FN_key, TY_Expr, FN_expr, _Public, _F(Stmt_setObject), TY_void, TY_Stmt, MN_("setBlock"), 2, TY_symbol, FN_key, TY_Block, FN_("block"), _Public, _F(Stmt_declType), TY_boolean, TY_Stmt, MN_("declType"), 3, TY_Gamma, FN_gma, TY_cid, FN_typeid, TY_Expr, FN_("declExpr"), _Public, _F(Stmt_newBlock), TY_Block, TY_Stmt, MN_("newBlock"), 1, TY_String, FN_("macro"), /* Expr */ _Public, _F(Expr_getTermToken), TY_Token, TY_Expr, MN_("getTermToken"), 0, _Public, _F(Expr_setConstValue), TY_Expr, TY_Expr, MN_("setConstValue"), 1, TY_Object, FN_("value") | FN_COERCION, _Public, _F(Expr_setVariable), TY_Expr, TY_Expr, MN_("setVariable"), 4, TY_Gamma, FN_gma, TY_int, FN_buildid, TY_cid, FN_typeid, TY_int, FN_("index"), _Public, _F(Expr_newVariableExpr), TY_Expr, TY_Expr, MN_("new"), 4, TY_Gamma, FN_gma, TY_int, FN_buildid, TY_cid, FN_typeid, TY_int, FN_("index"), _Public, _F(Expr_new), TY_Expr, TY_Expr, MN_("new"), 1, TY_Object, FN_("value") | FN_COERCION, _Public, _F(Expr_setType), TY_void, TY_Expr, MN_("setType"), 2, TY_int, FN_buildid, TY_cid, FN_typeid, _Public, _F(kExpr_AddExpr), TY_Expr, TY_Expr, MN_("addExpr"), 1, TY_Expr, FN_expr, /* Block */ _Public, _F(Block_TypeCheckAll), TY_boolean, TY_Block, MN_("TypeCheckAll"), 1, TY_Gamma, FN_gma, /* Gamma */ _Public, _F(Gamma_declareLocalVariable), TY_int, TY_Gamma, MN_("declareLocalVariable"), 2, TY_cid, FN_typeid, TY_symbol, FN_key, DEND, }; KLIB kNameSpace_LoadMethodData(kctx, ns, MethodData, trace); LoadNameSpaceMethodData(kctx, ns, TY_symbol, trace); RENAMEME_InitNameSpace(kctx, ns, ns, trace); return true; }
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; }