示例#1
0
文件: i.c 项目: shinpei/konoha-wand
static void knh_write_Method(CTX ctx, knh_OutputStream_t *w, const knh_ClassTBL_t *ct, knh_Method_t *o)
{
	knh_write_TAB(ctx, w);
	if(Method_isAbstract(o)) {
		knh_write_ascii(ctx, w, "@Abstract ");
	}
	knh_write_type(ctx, w, knh_type_tocid(ctx, knh_ParamArray_rtype(DP(o)->mp), ct->cid));
	knh_putc(ctx, w, ' ');
	if(Method_isStatic(o)) {
		knh_write_ascii(ctx, w, S_tochar(ct->sname));
		knh_putc(ctx, w, '.');
	}
	knh_write_mn(ctx, w, SP(o)->mn);
	knh_putc(ctx, w, '(');
	size_t i;
	for(i = 0; i < knh_Method_psize(o); i++) {
		knh_param_t *p = knh_ParamArray_get(DP(o)->mp, i);
		if(i > 0) {
			knh_write_delim(ctx, w);
		}
		knh_write_type(ctx, w, knh_type_tocid(ctx, p->type, ct->cid));
		knh_putc(ctx, w, ' ');
		knh_write_ascii(ctx, w, FN__(p->fn));
	}
	if(ParamArray_isVARGs(DP(o)->mp)) {
		knh_write_delim(ctx, w);
		knh_write_dots(ctx, w);
	}
	knh_putc(ctx, w, ')');
	knh_write_EOL(ctx, w);
}
示例#2
0
文件: hashapi.c 项目: matsuu/konoha
void knh_HashMap__k(Ctx *ctx, knh_Hash_t *o, OutputStream *w, String *m)
{
	size_t pos = 0, c = 0;
	size_t max = (KNH_HASH_TABLESIZE / o->hashop->size) * DP(o)->tables_size;
	knh_putc(ctx, w, '{');
	while(pos < max) {
		knh_hashentry_t *e = knh_hashentry_at((knh_Hash_t*)o, pos);
		if(e != NULL) {
			if(c > 0) {
				knh_write_delim(ctx,w);
			}
			knh_format(ctx, w, METHODN__k, e->key, KNH_NULL);
			knh_putc(ctx, w, ':');
			knh_putc(ctx, w, ' ');
			knh_format(ctx, w, METHODN__k, e->value, KNH_NULL);
			c++;
		}
		pos++;
	}
	knh_putc(ctx, w, '}');
}