knh_bool_t knh_write_ndata(Ctx *ctx, knh_OutputStream_t *w, knh_class_t cid, knh_ndata_t d)
{
	switch(cid) {
	case CLASS_Boolean:
		knh_write_bool(ctx, w, (int)d);
		return 1;
	case CLASS_Int:
		knh_write_ifmt(ctx, w, K_INT_FMT, d);
		return 1;
	case CLASS_Float:
		knh_write_ffmt(ctx, w, K_FLOAT_FMT, ((knh_float_t*)&d)[0]);
		return 1;
	}
	return 0;
}
Beispiel #2
0
void knh_write_sfp(CTX ctx, kOutputStream *w, ktype_t type, ksfp_t *sfp, int level)
{
	if(IS_Tunbox(type)) {
		if(IS_Tint(type)) {
			knh_write_ifmt(ctx, w, KINT_FMT, sfp[0].ivalue);
		}
		else if(IS_Tfloat(type)) {
			knh_write_ffmt(ctx, w, KFLOAT_FMT, sfp[0].fvalue);
		}
		else {
			knh_write_bool(ctx, w, sfp[0].bvalue);
		}
	}
	else {
		knh_write_Object(ctx, w, sfp[0].o, level);
	}
}