Esempio n. 1
0
//## 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();
}
Esempio n. 2
0
//## 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();
}
Esempio n. 3
0
// ##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();
}
Esempio n. 4
0
//## 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();
}
Esempio n. 5
0
//## @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();
}
Esempio n. 6
0
// ## 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();
}
Esempio n. 7
0
//## 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();
}
Esempio n. 8
0
// ## 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();
}
Esempio n. 9
0
//## 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();
}
Esempio n. 10
0
//## 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();
}
Esempio n. 11
0
//## 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();
}
Esempio n. 12
0
//## @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();
}
Esempio n. 13
0
//## @Native void XmlReader.close();
static KMETHOD XmlReader_close(KonohaContext *kctx, KonohaStack *sfp)
{
	xmlTextReaderPtr reader = getRawXmlReader(sfp[0]);
	if(reader != NULL) {
		xmlTextReaderClose(reader);
	}
	KReturnVoid();
}
Esempio n. 14
0
//## 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();
}
Esempio n. 15
0
//## 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();
}
Esempio n. 16
0
// ## 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();
}
Esempio n. 17
0
// ## 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();
}
Esempio n. 18
0
//## 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();
}
Esempio n. 19
0
//## @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();
}
Esempio n. 20
0
//## @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();
}
Esempio n. 21
0
//## @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();
}
Esempio n. 22
0
//## @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();
}
Esempio n. 23
0
//## 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();
}
Esempio n. 24
0
//## 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();
}
Esempio n. 25
0
//## 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();
}
Esempio n. 26
0
//## 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();
}
Esempio n. 27
0
//## 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();
}
Esempio n. 28
0
//## 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();
}
Esempio n. 29
0
//## 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();
}
Esempio n. 30
0
//## 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();
}