Просмотр исходного кода

Make console_log look like console_error

Lucas Stadler лет назад: 9
Родитель
Сommit
8d3c007a52
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      c/jsc-test.c

+ 3 - 3
c/jsc-test.c

12
JSValueRef console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
12
JSValueRef console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
13
	for (int i = 0; i < argumentCount; i++) {
13
	for (int i = 0; i < argumentCount; i++) {
14
		if (i > 0) {
14
		if (i > 0) {
15
			putchar(' ');
15
			fprintf(stdout, " ");
16
		}
16
		}
17
17
18
		JSStringRef str = to_string(ctx, arguments[i]);
18
		JSStringRef str = to_string(ctx, arguments[i]);
19
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
19
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
20
		printf("%s", console_log_buf);
20
		fprintf(stdout, "%s", console_log_buf);
21
	}
21
	}
22
	putchar('\n');
22
	fprintf(stdout, "\n");
23
23
24
	return JSValueMakeUndefined(ctx);
24
	return JSValueMakeUndefined(ctx);
25
}
25
}