Sfoglia il codice sorgente

Improve style of long function definitions

They're now split into multiple lines, and use c-style names.
Lucas Stadler 9 anni fa
parent
commit
ecac3984de
1 ha cambiato i file con 12 aggiunte e 9 eliminazioni
  1. 12 9
      c/ton/main.c

+ 12 - 9
c/ton/main.c

@ -19,13 +19,14 @@ void bootstrap(JSContextRef ctx, char *deps_file_path, char *goog_base_path);
19 19
20 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 25
		if (i > 0) {
25 26
			fprintf(stdout, " ");
26 27
		}
27 28
28
		JSStringRef str = to_string(ctx, arguments[i]);
29
		JSStringRef str = to_string(ctx, args[i]);
29 30
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
30 31
		fprintf(stdout, "%s", console_log_buf);
31 32
	}
@ -34,13 +35,14 @@ JSValueRef function_console_log(JSContextRef ctx, JSObjectRef function, JSObject
34 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 41
		if (i > 0) {
40 42
			fprintf(stderr, " ");
41 43
		}
42 44
43
		JSStringRef str = to_string(ctx, arguments[i]);
45
		JSStringRef str = to_string(ctx, args[i]);
44 46
		JSStringGetUTF8CString(str, console_log_buf, CONSOLE_LOG_BUF_SIZE);
45 47
		fprintf(stderr, "%s", console_log_buf);
46 48
	}
@ -49,9 +51,10 @@ JSValueRef function_console_error(JSContextRef ctx, JSObjectRef function, JSObje
49 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 58
		char path[100];
56 59
		path[0] = '\0';
57 60
		JSStringGetUTF8CString(path_str_ref, path, 100);