Skip to content

Commit c45ddf0

Browse files
authored
Merge pull request svaarala#2424 from svaarala/reformat-source-2
Reformat some source files with clang-format (2)
2 parents 335b9be + 4cc7e0a commit c45ddf0

27 files changed

Lines changed: 1776 additions & 1583 deletions

src-input/duk_bi_json.c

Lines changed: 336 additions & 360 deletions
Large diffs are not rendered by default.

src-input/duk_bi_math.c

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ DUK_LOCAL double duk__trunc(double x) {
141141
return x >= 0.0 ? DUK_FLOOR(x) : DUK_CEIL(x);
142142
#endif
143143
}
144-
#endif /* DUK_USE_ES6 */
144+
#endif /* DUK_USE_ES6 */
145145

146146
DUK_LOCAL double duk__round_fixed(double x) {
147147
/* Numbers half-way between integers must be rounded towards +Infinity,
@@ -256,51 +256,23 @@ DUK_LOCAL double duk__atan2_fixed(double x, double y) {
256256

257257
return DUK_ATAN2(x, y);
258258
}
259-
#endif /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
259+
#endif /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
260260

261261
/* order must match constants in genbuiltins.py */
262262
DUK_LOCAL const duk__one_arg_func duk__one_arg_funcs[] = {
263263
#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS)
264-
duk__fabs,
265-
duk__acos,
266-
duk__asin,
267-
duk__atan,
268-
duk__ceil,
269-
duk__cos,
270-
duk__exp,
271-
duk__floor,
272-
duk__log,
273-
duk__round_fixed,
274-
duk__sin,
275-
duk__sqrt,
276-
duk__tan,
264+
duk__fabs, duk__acos, duk__asin, duk__atan, duk__ceil, duk__cos, duk__exp,
265+
duk__floor, duk__log, duk__round_fixed, duk__sin, duk__sqrt, duk__tan,
277266
#if defined(DUK_USE_ES6)
278-
duk__cbrt,
279-
duk__log2,
280-
duk__log10,
281-
duk__trunc
267+
duk__cbrt, duk__log2, duk__log10, duk__trunc
282268
#endif
283-
#else /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
284-
DUK_FABS,
285-
DUK_ACOS,
286-
DUK_ASIN,
287-
DUK_ATAN,
288-
DUK_CEIL,
289-
DUK_COS,
290-
DUK_EXP,
291-
DUK_FLOOR,
292-
DUK_LOG,
293-
duk__round_fixed,
294-
DUK_SIN,
295-
DUK_SQRT,
296-
DUK_TAN,
269+
#else /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
270+
DUK_FABS, DUK_ACOS, DUK_ASIN, DUK_ATAN, DUK_CEIL, DUK_COS, DUK_EXP,
271+
DUK_FLOOR, DUK_LOG, duk__round_fixed, DUK_SIN, DUK_SQRT, DUK_TAN,
297272
#if defined(DUK_USE_ES6)
298-
duk__cbrt,
299-
duk__log2,
300-
duk__log10,
301-
duk__trunc
273+
duk__cbrt, duk__log2, duk__log10, duk__trunc
302274
#endif
303-
#endif /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
275+
#endif /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
304276
};
305277

306278
/* order must match constants in genbuiltins.py */
@@ -335,7 +307,7 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_twoarg_shared(duk_hthread *thr) {
335307

336308
DUK_ASSERT(fun_idx >= 0);
337309
DUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(duk__two_arg_funcs) / sizeof(duk__two_arg_func)));
338-
arg1 = duk_to_number(thr, 0); /* explicit ordered evaluation to match coercion semantics */
310+
arg1 = duk_to_number(thr, 0); /* explicit ordered evaluation to match coercion semantics */
339311
arg2 = duk_to_number(thr, 1);
340312
fun = duk__two_arg_funcs[fun_idx];
341313
duk_push_number(thr, (duk_double_t) fun((double) arg1, (double) arg2));
@@ -421,7 +393,7 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_hypot(duk_hthread *thr) {
421393
duk_push_number(thr, (duk_double_t) DUK_SQRT(sum) * max);
422394
return 1;
423395
}
424-
#endif /* DUK_USE_ES6 */
396+
#endif /* DUK_USE_ES6 */
425397

426398
#if defined(DUK_USE_ES6)
427399
DUK_INTERNAL duk_ret_t duk_bi_math_object_sign(duk_hthread *thr) {
@@ -430,7 +402,7 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_sign(duk_hthread *thr) {
430402
d = duk_to_number(thr, 0);
431403
if (duk_double_is_nan(d)) {
432404
DUK_ASSERT(duk_is_nan(thr, -1));
433-
return 1; /* NaN input -> return NaN */
405+
return 1; /* NaN input -> return NaN */
434406
}
435407
if (duk_double_equals(d, 0.0)) {
436408
/* Zero sign kept, i.e. -0 -> -0, +0 -> +0. */
@@ -439,7 +411,7 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_sign(duk_hthread *thr) {
439411
duk_push_int(thr, (d > 0.0 ? 1 : -1));
440412
return 1;
441413
}
442-
#endif /* DUK_USE_ES6 */
414+
#endif /* DUK_USE_ES6 */
443415

444416
#if defined(DUK_USE_ES6)
445417
DUK_INTERNAL duk_ret_t duk_bi_math_object_clz32(duk_hthread *thr) {
@@ -459,7 +431,7 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_clz32(duk_hthread *thr) {
459431
DUK_ASSERT(i <= 32);
460432
duk_push_uint(thr, i);
461433
return 1;
462-
#else /* DUK_USE_PREFER_SIZE */
434+
#else /* DUK_USE_PREFER_SIZE */
463435
i = 0;
464436
x = duk_to_uint32(thr, 0);
465437
if (x & 0xffff0000UL) {
@@ -495,9 +467,9 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_clz32(duk_hthread *thr) {
495467
DUK_ASSERT(i <= 32);
496468
duk_push_uint(thr, i);
497469
return 1;
498-
#endif /* DUK_USE_PREFER_SIZE */
470+
#endif /* DUK_USE_PREFER_SIZE */
499471
}
500-
#endif /* DUK_USE_ES6 */
472+
#endif /* DUK_USE_ES6 */
501473

502474
#if defined(DUK_USE_ES6)
503475
DUK_INTERNAL duk_ret_t duk_bi_math_object_imul(duk_hthread *thr) {
@@ -514,6 +486,6 @@ DUK_INTERNAL duk_ret_t duk_bi_math_object_imul(duk_hthread *thr) {
514486
duk_push_i32(thr, (duk_int32_t) z);
515487
return 1;
516488
}
517-
#endif /* DUK_USE_ES6 */
489+
#endif /* DUK_USE_ES6 */
518490

519-
#endif /* DUK_USE_MATH_BUILTIN */
491+
#endif /* DUK_USE_MATH_BUILTIN */

src-input/duk_bi_number.c

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ DUK_LOCAL duk_double_t duk__push_this_number_plain(duk_hthread *thr) {
1919
goto done;
2020
}
2121
h = duk_get_hobject(thr, -1);
22-
if (!h ||
23-
(DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) {
22+
if (!h || (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) {
2423
DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(thr, -1)));
2524
DUK_ERROR_TYPE(thr, "number expected");
2625
DUK_WO_NORETURN(return 0.0;);
2726
}
2827
duk_xget_owndataprop_stridx_short(thr, -1, DUK_STRIDX_INT_VALUE);
2928
DUK_ASSERT(duk_is_number(thr, -1));
3029
DUK_DDD(DUK_DDDPRINT("number object: %!T, internal value: %!T",
31-
(duk_tval *) duk_get_tval(thr, -2), (duk_tval *) duk_get_tval(thr, -1)));
30+
(duk_tval *) duk_get_tval(thr, -2),
31+
(duk_tval *) duk_get_tval(thr, -1)));
3232
duk_remove_m2(thr);
3333

34-
done:
34+
done:
3535
return duk_get_number(thr, -1);
3636
}
3737

@@ -80,9 +80,9 @@ DUK_INTERNAL duk_ret_t duk_bi_number_constructor(duk_hthread *thr) {
8080
DUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(h_this) == DUK_HOBJECT_CLASS_NUMBER);
8181
DUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(h_this));
8282

83-
duk_dup_0(thr); /* -> [ val obj val ] */
83+
duk_dup_0(thr); /* -> [ val obj val ] */
8484
duk_xdef_prop_stridx_short(thr, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE);
85-
return 0; /* no return value -> don't replace created value */
85+
return 0; /* no return value -> don't replace created value */
8686
}
8787

8888
DUK_INTERNAL duk_ret_t duk_bi_number_prototype_value_of(duk_hthread *thr) {
@@ -104,10 +104,7 @@ DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_string(duk_hthread *thr) {
104104

105105
n2s_flags = 0;
106106

107-
duk_numconv_stringify(thr,
108-
radix /*radix*/,
109-
0 /*digits*/,
110-
n2s_flags /*flags*/);
107+
duk_numconv_stringify(thr, radix /*radix*/, 0 /*digits*/, n2s_flags /*flags*/);
111108
return 1;
112109
}
113110

@@ -145,16 +142,12 @@ DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_fixed(duk_hthread *thr) {
145142
goto use_to_string;
146143
}
147144

148-
n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT |
149-
DUK_N2S_FLAG_FRACTION_DIGITS;
145+
n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT | DUK_N2S_FLAG_FRACTION_DIGITS;
150146

151-
duk_numconv_stringify(thr,
152-
10 /*radix*/,
153-
frac_digits /*digits*/,
154-
n2s_flags /*flags*/);
147+
duk_numconv_stringify(thr, 10 /*radix*/, frac_digits /*digits*/, n2s_flags /*flags*/);
155148
return 1;
156149

157-
use_to_string:
150+
use_to_string:
158151
DUK_ASSERT_TOP(thr, 2);
159152
duk_to_string(thr, -1);
160153
return 1;
@@ -170,7 +163,7 @@ DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_exponential(duk_hthread *thr)
170163
d = duk__push_this_number_plain(thr);
171164

172165
frac_undefined = duk_is_undefined(thr, 0);
173-
duk_to_int(thr, 0); /* for side effects */
166+
duk_to_int(thr, 0); /* for side effects */
174167

175168
c = (duk_small_int_t) DUK_FPCLASSIFY(d);
176169
if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {
@@ -179,16 +172,12 @@ DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_exponential(duk_hthread *thr)
179172

180173
frac_digits = (duk_small_int_t) duk_to_int_check_range(thr, 0, 0, 20);
181174

182-
n2s_flags = DUK_N2S_FLAG_FORCE_EXP |
183-
(frac_undefined ? 0 : DUK_N2S_FLAG_FIXED_FORMAT);
175+
n2s_flags = DUK_N2S_FLAG_FORCE_EXP | (frac_undefined ? 0 : DUK_N2S_FLAG_FIXED_FORMAT);
184176

185-
duk_numconv_stringify(thr,
186-
10 /*radix*/,
187-
frac_digits + 1 /*leading digit + fractions*/,
188-
n2s_flags /*flags*/);
177+
duk_numconv_stringify(thr, 10 /*radix*/, frac_digits + 1 /*leading digit + fractions*/, n2s_flags /*flags*/);
189178
return 1;
190179

191-
use_to_string:
180+
use_to_string:
192181
DUK_ASSERT_TOP(thr, 2);
193182
duk_to_string(thr, -1);
194183
return 1;
@@ -213,7 +202,7 @@ DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_precision(duk_hthread *thr) {
213202
}
214203
DUK_ASSERT_TOP(thr, 2);
215204

216-
duk_to_int(thr, 0); /* for side effects */
205+
duk_to_int(thr, 0); /* for side effects */
217206

218207
c = (duk_small_int_t) DUK_FPCLASSIFY(d);
219208
if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {
@@ -222,16 +211,12 @@ DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_precision(duk_hthread *thr) {
222211

223212
prec = (duk_small_int_t) duk_to_int_check_range(thr, 0, 1, 21);
224213

225-
n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT |
226-
DUK_N2S_FLAG_NO_ZERO_PAD;
214+
n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT | DUK_N2S_FLAG_NO_ZERO_PAD;
227215

228-
duk_numconv_stringify(thr,
229-
10 /*radix*/,
230-
prec /*digits*/,
231-
n2s_flags /*flags*/);
216+
duk_numconv_stringify(thr, 10 /*radix*/, prec /*digits*/, n2s_flags /*flags*/);
232217
return 1;
233218

234-
use_to_string:
219+
use_to_string:
235220
/* Used when precision is undefined; also used for NaN (-> "NaN"),
236221
* and +/- infinity (-> "Infinity", "-Infinity").
237222
*/
@@ -257,16 +242,16 @@ DUK_INTERNAL duk_ret_t duk_bi_number_check_shared(duk_hthread *thr) {
257242
d = duk_get_number(thr, 0);
258243

259244
switch (magic) {
260-
case 0: /* isFinite() */
245+
case 0: /* isFinite() */
261246
ret = duk_double_is_finite(d);
262247
break;
263-
case 1: /* isInteger() */
248+
case 1: /* isInteger() */
264249
ret = duk_double_is_integer(d);
265250
break;
266-
case 2: /* isNaN() */
251+
case 2: /* isNaN() */
267252
ret = duk_double_is_nan(d);
268253
break;
269-
default: /* isSafeInteger() */
254+
default: /* isSafeInteger() */
270255
DUK_ASSERT(magic == 3);
271256
ret = duk_double_is_safe_integer(d);
272257
}
@@ -275,6 +260,6 @@ DUK_INTERNAL duk_ret_t duk_bi_number_check_shared(duk_hthread *thr) {
275260
duk_push_boolean(thr, ret);
276261
return 1;
277262
}
278-
#endif /* DUK_USE_ES6 */
263+
#endif /* DUK_USE_ES6 */
279264

280-
#endif /* DUK_USE_NUMBER_BUILTIN */
265+
#endif /* DUK_USE_NUMBER_BUILTIN */

0 commit comments

Comments
 (0)