
static JSValue js_file_putc(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
{
	int val=0;
	FILE *f = JS_GetOpaque(this_val, file_class_id);
	if (!f || !argc) return GF_JS_EXCEPTION(ctx);

	if (JS_IsString(argv[0])) {
		const char *string = JS_ToCString(ctx, argv[0]);
		if (!string) return GF_JS_EXCEPTION(ctx);
		val = string[0];
		JS_FreeCString(ctx, string);
	} else {
		if (JS_ToInt32(ctx, &val, argv[0])) return GF_JS_EXCEPTION(ctx);
	}
	gf_fputc(val, f);
	return JS_UNDEFINED;

static JSValue js_file_putc(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
{
	int val=0;
	FILE *f = JS_GetOpaque(this_val, file_class_id);
	if (!f || !argc) return GF_JS_EXCEPTION(ctx);

	if (JS_IsString(argv[0])) {
		const char *string = JS_ToCString(ctx, argv[0]);
		if (!string) return GF_JS_EXCEPTION(ctx);
		val = string[0];
		JS_FreeCString(ctx, string);
	} else {
		if (JS_ToInt32(ctx, &val, argv[0])) return GF_JS_EXCEPTION(ctx);
	}
	gf_fputc(val, f);
	return JS_UNDEFINED;