//## void Token.setSubArray(String[] sub); static KMETHOD Token_setSubArray(KonohaContext *kctx, KonohaStack *sfp) { kTokenVar *tk = (kTokenVar *) sfp[0].asToken; kArray *sub = sfp[1].asArray; KFieldSet(tk, tk->subTokenList, sub); KReturnVoid(); }
//## Expr Stmt.AddParsedObject(keyword nameid, Object obj); static KMETHOD Stmt_AddParsedObject(KonohaContext *kctx, KonohaStack *sfp) { kStmt *stmt = sfp[0].asStmt; ksymbol_t symbol = (ksymbol_t)sfp[1].intValue; SUGAR kStmt_AddParsedObject(kctx, stmt, symbol, sfp[2].asObject); KReturnVoid(); }
// ##void Request.setContentEncoding(String enc); static KMETHOD Request_SetContentEncoding(KonohaContext *kctx, KonohaStack *sfp) { kRequest *self = (kRequest *) sfp[0].asObject; kString *enc = sfp[1].asString; self->r->content_encoding = apr_pstrdup(self->r->pool, kString_text(enc)); KReturnVoid(); }
//## void JSONArray.append(JSON json); static KMETHOD kJSONArray_append(KonohaContext *kctx, KonohaStack *sfp) { JSON obj = ((kJSON *)sfp[0].asObject)->json; JSON val = ((kJSON *)sfp[1].asObject)->json; JSONArray_append(obj, val); KReturnVoid(); }
//## @Native void File.putc(int ch); static KMETHOD File_putc(KonohaContext *kctx, KonohaStack *sfp) { kFile *file = (kFile *)sfp[0].asObject; KMakeTrace(trace, sfp); TRACE_fputc(kctx, file, sfp[1].intValue, trace); KReturnVoid(); }
// ## void Request.puts(String s) static KMETHOD Request_puts(KonohaContext *kctx, KonohaStack *sfp) { kRequest *self = (kRequest *) sfp[0].asObject; kString *data = sfp[1].asString; ap_rputs(kString_text(data), self->r); KReturnVoid(); }
//## void Bytes.setAll(int c); static KMETHOD Bytes_SetAll(KonohaContext *kctx, KonohaStack *sfp) { kBytes *ba = sfp[0].asBytes; int bytesize = ba->bytesize; memset(ba->buf, sfp[1].intValue, bytesize); KReturnVoid(); }
// ## void Request.setContentType(String type); static KMETHOD Request_SetContentType(KonohaContext *kctx, KonohaStack *sfp) { kRequest *self = (kRequest *) sfp[0].asObject; kString *type = sfp[1].asString; self->r->content_type = apr_pstrdup(self->r->pool, kString_text(type)); KReturnVoid(); }
//## void Token.setText(String text); static KMETHOD Token_setText(KonohaContext *kctx, KonohaStack *sfp) { kTokenVar *tk = (kTokenVar *) sfp[0].asToken; kString *text = sfp[1].asString; KFieldSet(tk, tk->text, text); KReturnVoid(); }
//## void Curl.appendHeader(String headers); static KMETHOD Curl_appendHeader(KonohaContext *kctx, KonohaStack *sfp) { kCurl* kcurl = (kCurl *)sfp[0].asObject; const char *h = kString_text(sfp[1].asString); kcurl->headers = curl_slist_append(kcurl->headers, h); KReturnVoid(); }
//## void Stmt.setExpr(symbol key, Expr expr); //## void Stmt.setBlock(symbol key, Block block); static KMETHOD Stmt_setObject(KonohaContext *kctx, KonohaStack *sfp) { kStmt *stmt = sfp[0].asStmt; ksymbol_t key = (ksymbol_t)sfp[1].intValue; kObject *obj = sfp[2].asObject; kStmt_setObject(kctx, stmt, key, obj); KReturnVoid(); }
//## @Native void Mutex.lock() static KMETHOD Mutex_lock(KonohaContext *kctx, KonohaStack *sfp) { kMutex *m = (kMutex *)sfp[0].asObject; // TODO inc gcCounter pthread_mutex_lock(&m->mutex); // TODO dec gcCounter KReturnVoid(); }
//## @Native void XmlReader.close(); static KMETHOD XmlReader_close(KonohaContext *kctx, KonohaStack *sfp) { xmlTextReaderPtr reader = getRawXmlReader(sfp[0]); if(reader != NULL) { xmlTextReaderClose(reader); } KReturnVoid(); }
//## void Token.setKeyword(symbol keyword); static KMETHOD Token_setUnresolvedTokenType(KonohaContext *kctx, KonohaStack *sfp) { kTokenVar *tk = (kTokenVar *) sfp[0].asToken; ksymbol_t keyword = (ksymbol_t)sfp[1].intValue; tk->unresolvedTokenType = keyword; DBG_P("setkeyword=%s%s", PSYM_t(keyword)); KReturnVoid(); }
//## void Bytes.set(int index, int c); static KMETHOD Bytes_Set(KonohaContext *kctx, KonohaStack *sfp) { kBytes *ba = sfp[0].asBytes; size_t n = (size_t)sfp[1].intValue; KCheckIndex(n, ba->bytesize); ba->buf[n] = sfp[2].intValue; KReturnVoid(); }
// ## void AprTable.set(String key, String val) static KMETHOD AprTable_Set(KonohaContext *kctx, KonohaStack *sfp) { kAprTable *self = (kAprTable *) sfp[0].asObject; const char *key = kString_text(sfp[1].asString); const char *val = kString_text(sfp[2].asString); apr_table_set(self->tbl, key, val); KReturnVoid(); }
// ## void Request.logRerror(int level, int status, String msg); static KMETHOD Request_logError(KonohaContext *kctx, KonohaStack *sfp) { kRequest *self = (kRequest *) sfp[0].asObject; int level = sfp[1].intValue; apr_status_t status = (apr_status_t)sfp[2].intValue; const char *msg = kString_text(sfp[3].asString); ap_log_rerror(APLOG_MARK, level, status, self->r, msg, NULL); KReturnVoid(); }
//## void cbufferevent.setcb(buffereventCBArg cbarg); static KMETHOD cbufferevent_setcb(KonohaContext *kctx, KonohaStack *sfp) { kcbufferevent *bev = (kcbufferevent *)sfp[0].asObject; kbuffereventCBArg *cbArg = (kbuffereventCBArg *)sfp[1].asObject; KFieldSet(cbArg, cbArg->cbev, bev); bufferevent_setcb(bev->bev, Cbev_readCB_1st, Cbev_writeCB_1st, Cbev_eventCB_1st, cbArg); KReturnVoid(); }
//## @Native void File.close(); static KMETHOD File_close(KonohaContext *kctx, KonohaStack *sfp) { kFile *file = (kFile *)sfp[0].asObject; if(file->fp != NULL) { KMakeTrace(trace, sfp); kFile_close(kctx, file, trace); } KReturnVoid(); }
//## @Native void Thread.join(); static KMETHOD Thread_join(KonohaContext *kctx, KonohaStack *sfp) { kThread *t = (kThread *)sfp[0].asObject; void *v; // TODO inc gcCounter pthread_join(t->thread, &v); // TODO dec gcCounter KReturnVoid(); }
//## @Native void Cond.wait(Mutex m) static KMETHOD Cond_wait(KonohaContext *kctx, KonohaStack *sfp) { kCond *c = (kCond *)sfp[0].asObject; kMutex *m = (kMutex *)sfp[1].asObject; // TODO inc gcCounter pthread_cond_wait(&c->cond, &m->mutex); // TODO dec gcCounter KReturnVoid(); }
//## @Public void NameSpace.AddMethodDecl(Node methodNode); static KMETHOD NameSpace_AddMethodDecl(KonohaContext *kctx, KonohaStack *sfp) { kNameSpace *ns = sfp[0].asNameSpace; kSyntax *syn = SUGAR kNameSpace_GetSyntax(kctx, ns, KSymbol_("$MethodDecl")); kFunc *fo = syn->TypeFuncNULL; kNode *methodNode = (kNode *) sfp[1].asObject; CallTypeFunc(kctx, fo, methodNode, ns, K_NULL); KReturnVoid(); }
//## void Expr.setType(int build, cid typeid); static KMETHOD Expr_setType(KonohaContext *kctx, KonohaStack *sfp) { kExprVar *expr = (kExprVar *)sfp[0].asExpr; kexpr_t build = (kexpr_t)sfp[1].intValue; ktype_t cid = (ktype_t)sfp[2].intValue; expr->build = build; expr->ty = cid; KReturnVoid(); }
//## void Json.setArray(String key, Json[] a); static KMETHOD Json_setArray(KonohaContext *kctx, KonohaStack *sfp) { json_t* obj = ((struct _kJson *)sfp[0].asObject)->obj; CHECK_JSON(obj, KReturnDefaultObjectValue()); const char *key = S_text(sfp[1].asString); kArrayVar* a = (kArrayVar *)sfp[2].asArray; json_t *ja = (json_t *)a->ObjectItems; json_object_set(obj, key, ja); KReturnVoid(); }
//## void JSON.set(String key, JSON value); static KMETHOD kJSON_set(KonohaContext *kctx, KonohaStack *sfp) { kString *s = sfp[1].asString; JSON obj, key, val; obj = ((kJSON *)sfp[0].asObject)->json; val = ((kJSON *)sfp[2].asObject)->json; key = JSONString_new(S_text(s), S_size(s)); JSONObject_set(obj, key, val); KReturnVoid(); }
//## void NameSpace.useStaticFunc(Object o); static KMETHOD NameSpace_useStaticFunc(KonohaContext *kctx, KonohaStack *sfp) { KMakeTrace(trace, sfp); KonohaClass *ct = O_ct(sfp[1].asObject); kNameSpace *ns = sfp[0].asNameSpace; kNameSpace_SetStaticFunction(kctx, ns, ct->methodList_OnGlobalConstList, ct->typeId, trace); while(ns != NULL) { kNameSpace_SetStaticFunction(kctx, ns, ns->methodList_OnList, ct->typeId, trace); ns = ns->parentNULL; } KReturnVoid(); }
//## void Json.setJson(String key, Json value); static KMETHOD Json_setJson(KonohaContext *kctx, KonohaStack *sfp) { json_t* obj = ((struct _kJson *)sfp[0].asObject)->obj; CHECK_JSON(obj, KReturnDefaultObjectValue()); const char *key = S_text(sfp[1].asString); json_t* val = ((struct _kJson *)sfp[2].asObject)->obj; CHECK_JSON(val, KReturnDefaultObjectValue()); int ret = json_object_set(obj, key, val); if(ret < 0) { DBG_P("[WARNING] Json set cannnot set target object"); KReturnDefaultObjectValue(); } KReturnVoid(); }
//## void Json[].add(Json json); static KMETHOD JsonArray_add(KonohaContext *kctx, KonohaStack *sfp) { kArrayVar *a = (kArrayVar *)sfp[0].asObject; json_t* ja = (json_t *)a->ObjectItems; if(!json_is_array(ja)) { DBG_P("[ERROR]: Object is not Json Array."); //KLIB KonohaRuntime_raise(kctx, 1, sfp, pline, msg); KReturnDefaultObjectValue(); } struct _kJson *json = (struct _kJson *)sfp[1].asObject; json_array_append(ja, json->obj); json_incref(json->obj); KReturnVoid(); }
//## 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(); }
//## void Curl.setOpt(int type, FILE data); static KMETHOD Curl_SetOptFile(KonohaContext *kctx, KonohaStack *sfp) { kCurl* kcurl = (kCurl *)sfp[0].asObject; CURLoption curlopt = (CURLoption)sfp[1].intValue; switch(curlopt) { case CURLOPT_FILE: case CURLOPT_STDERR: case CURLOPT_WRITEHEADER: { kFile *file = (kFile *)sfp[2].asObject; curl_easy_setopt(kcurl->curl, curlopt, file->fp); } default: { KMakeTrace(trace, sfp); KTraceErrorPoint(trace, SoftwareFault, "curl_easy_setopt", LogWrongOption(curlopt)); } }/*switch*/ KReturnVoid(); }