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

Improve style of long function definitions

They're now split into multiple lines, and use c-style names.
Lucas Stadler лет назад: 9
Родитель
Сommit
ecac3984de
1 измененных файлов с 12 добавлено и 9 удалено
  1. 12 9
      c/ton/main.c

+ 12 - 9
c/ton/main.c

19
19
20
char* get_contents(char *path);
20
char* get_contents(char *path);
21
21
22
JSValueRef function_console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
23
	for (int i = 0; i < argumentCount; i++) {
22
JSValueRef function_console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef this_object,
23
		size_t argc, const JSValueRef args[], JSValueRef* exception) {
24
	for (int i = 0; i < argc; i++) {
24
		if (i > 0) {
25
		if (i > 0) {
25
			fprintf(stdout, " ");
26
			fprintf(stdout, " ");
26
		}
27
		}
27
28
28
		JSStringRef str = to_string(ctx, arguments[i]);
29
		JSStringRef str = to_string(ctx, args[i]);
29
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
30
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
30
		fprintf(stdout, "%s", console_log_buf);
31
		fprintf(stdout, "%s", console_log_buf);
31
	}
32
	}
34
	return JSValueMakeUndefined(ctx);
35
	return JSValueMakeUndefined(ctx);
35
}
36
}
36
37
37
JSValueRef function_console_error(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
38
	for (int i = 0; i < argumentCount; i++) {
38
JSValueRef function_console_error(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
39
		size_t argc, const JSValueRef args[], JSValueRef* exception) {
40
	for (int i = 0; i < argc; i++) {
39
		if (i > 0) {
41
		if (i > 0) {
40
			fprintf(stderr, " ");
42
			fprintf(stderr, " ");
41
		}
43
		}
42
44
43
		JSStringRef str = to_string(ctx, arguments[i]);
45
		JSStringRef str = to_string(ctx, args[i]);
44
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
46
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
45
		fprintf(stderr, "%s", console_log_buf);
47
		fprintf(stderr, "%s", console_log_buf);
46
	}
48
	}
49
	return JSValueMakeUndefined(ctx);
51
	return JSValueMakeUndefined(ctx);
50
}
52
}
51
53
52
JSValueRef function_import_script(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
53
	if (argumentCount == 1 && JSValueGetType(ctx, arguments[0]) == kJSTypeString) {
54
		JSStringRef path_str_ref = JSValueToStringCopy(ctx, arguments[0], NULL);
54
JSValueRef function_import_script(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
55
		size_t argc, const JSValueRef args[], JSValueRef* exception) {
56
	if (argc == 1 && JSValueGetType(ctx, args[0]) == kJSTypeString) {
57
		JSStringRef path_str_ref = JSValueToStringCopy(ctx, args[0], NULL);
55
		char path[100];
58
		char path[100];
56
		path[0] = '\0';
59
		path[0] = '\0';
57
		JSStringGetUTF8CString(path_str_ref, path, 100);
60
		JSStringGetUTF8CString(path_str_ref, path, 100);