static void eventCBArg_Init(KonohaContext *kctx, kObject *o, void *conf) { struct eventCBArg *cbarg = (struct eventCBArg *) o; cbarg->kctx = NULL; KFieldInit(cbarg, cbarg->kcb, K_NULL); KFieldInit(cbarg, cbarg->arg, K_NULL); }
static void buffereventCBArg_Init(KonohaContext *kctx, kObject *o, void *conf) { struct buffereventCBArg *bcbarg = (struct buffereventCBArg *) o; bcbarg->kctx = NULL; enum e_buffereventCB i; for (i = BEV_ReadCB; i < NUM_BuffereventCB; i++){ KFieldInit(bcbarg, bcbarg->kcb[i], K_NULL); } KFieldInit(bcbarg, bcbarg->cbev, K_NULL); KFieldInit(bcbarg, bcbarg->arg, K_NULL); }
//## FILE FILE.new(String path, String mode); static KMETHOD File_new(KonohaContext *kctx, KonohaStack *sfp) { KMakeTrace(trace, sfp); char buffer[K_PATHMAX]; kString *path = sfp[1].asString; const char *systemPath = I18NAPI formatSystemPath(kctx, buffer, sizeof(buffer), kString_text(path), kString_size(path), trace); const char *mode = kString_text(sfp[2].asString); FILE *fp = fopen(systemPath, mode); kFile *file = (kFile *) sfp[0].asObject; if(fp == NULL) { int fault = KLIB DiagnosisFaultType(kctx, kString_GuessUserFault(path)|SystemError, trace); KTraceErrorPoint(trace, fault, "fopen", LogText("filename", kString_text(path)), LogText("mode", mode), LogErrno); KLIB KRuntime_raise(kctx, KException_("IO"), fault, NULL, sfp); } if(mode[0] == 'w' || mode[0] == 'a' || mode[1] == '+') { KTraceChangeSystemPoint(trace, "fopen", LogFileName(kString_text(path)), LogText("mode", mode)); } file->fp = fp; KFieldInit(file, file->PathInfoNULL, path); if(!I18NAPI isSystemCharsetUTF8(kctx)) { if(mode[0] == 'w' || mode[0] == 'a' || mode[1] == '+') { file->writerIconv = I18NAPI iconvUTF8ToSystemCharset(kctx, trace); } else { file->readerIconv = I18NAPI iconvSystemCharsetToUTF8(kctx, trace); } } KReturn(file); }
static void Iterator_Init(KonohaContext *kctx, kObject *o, void *conf) { kIterator *itr = (kIterator *)o; int isUnboxEntry = TY_isUnbox(O_ct(itr)->p0); KFieldInit(itr, itr->source, K_NULL); itr->current_pos = 0; itr->hasNext = Nothing_hasNext; itr->setNextResult = isUnboxEntry ? Nothing_setNextResultUnbox : Nothing_setNextResult; }
static void kResultSet_Init(KonohaContext *kctx, kObject *o, void *conf) { kResultSet *rs = (kResultSet *)o; if(conf != NULL) { KFieldInit(rs, rs->connectionNULL, (kConnection *) conf); } else { rs->connectionNULL = NULL; } rs->qcur = NULL; rs->column_size = 0; rs->column = NULL; rs->rowidx = 0; rs->driver = NULL; }
static kFile* new_File(KonohaContext *kctx, kArray *gcstack, FILE *fp, const char *pathInfo, size_t len, KTraceInfo *trace) { kFile *file = new_(File, fp, gcstack); file->fp = fp; KFieldInit(file, file->PathInfoNULL, KLIB new_kString(kctx, OnField, pathInfo, len, StringPolicy_ASCII|StringPolicy_TEXT)); kFile_Set(ChangeLessStream, file, true); if(!I18NAPI isSystemCharsetUTF8(kctx)) { if(fp == stdin) { file->readerIconv = I18NAPI iconvSystemCharsetToUTF8(kctx, trace); } else { file->writerIconv = I18NAPI iconvUTF8ToSystemCharset(kctx, trace); } } return file; }
//## void Curl.setOpt(int type, String data); static KMETHOD Curl_SetOptString(KonohaContext *kctx, KonohaStack *sfp) { kCurl* kcurl = (kCurl *)sfp[0].asObject; CURLoption curlopt = (CURLoption)sfp[1].intValue; switch(curlopt) { case CURLOPT_URL: { KFieldInit(kcurl, kcurl->URLInfoNULL, sfp[2].asString); } case CURLOPT_CAINFO: case CURLOPT_CAPATH: case CURLOPT_COOKIE: case CURLOPT_COOKIEFILE: /* filename */ case CURLOPT_COOKIEJAR: case CURLOPT_CUSTOMREQUEST: //case CURLOPT_EGBSOCKET: case CURLOPT_ENCODING: case CURLOPT_FTPPORT: case CURLOPT_INTERFACE: case CURLOPT_KRB4LEVEL: case CURLOPT_POSTFIELDS: case CURLOPT_PROXY: case CURLOPT_PROXYUSERPWD: case CURLOPT_RANDOM_FILE: case CURLOPT_RANGE: case CURLOPT_REFERER: case CURLOPT_SSL_CIPHER_LIST: case CURLOPT_SSLCERT: //case CURLOPT_SSLCERTPASSWD: case CURLOPT_SSLCERTTYPE: case CURLOPT_SSLENGINE: case CURLOPT_SSLENGINE_DEFAULT: case CURLOPT_SSLKEY: //case CURLOPT_SSLKEYPASSWD: case CURLOPT_SSLKEYTYPE: case CURLOPT_USERAGENT: case CURLOPT_USERPWD: { curl_easy_setopt(kcurl->curl, curlopt, kString_text(sfp[2].asString)); break; } default: { KMakeTrace(trace, sfp); KTraceErrorPoint(trace, SoftwareFault, "curl_easy_setopt", LogWrongOption(curlopt)); } }/*switch*/ KReturnVoid(); }
static KMETHOD Array_Pop(KonohaContext *kctx, KonohaStack *sfp) { kArray *a = sfp[0].asArray; if(kArray_size(a) == 0) KReturnDefaultValue(); size_t n = kArray_size(a) - 1; if(kArray_isUnboxData(a)) { uintptr_t v = a->unboxItems[n]; a->unboxItems[n] = 0; kArray_SetSize(a, n); KReturnUnboxValue(v); } else { struct _kAbstractArray *a2 = (struct _kAbstractArray *)a; kObject *value = a2->a.ObjectItems[n]; kObject** null = NULL; KFieldInit(a2, a2->a.ObjectItems[n], null); a2->a.bytesize = n * sizeof(uintptr_t); KReturn(value); } }
static void ResultSet_SetText(KonohaContext *kctx, kResultSet *rs, unsigned Idx, const char *text, size_t len) { rs->column[Idx].type = KType_String; KFieldInit(rs, rs->column[Idx].val.asString, KLIB new_kString(kctx, GcUnsafe, text, len, 0)); }
static void kThread_Init(KonohaContext *kctx, kObject *o, void *conf) { kThread *t = (kThread *)o; KFieldInit(t, t->func, K_NULL); //KFieldInit(t, t->args, K_NULL); }