Skip to content

Commit a045eaa

Browse files
authored
Run clang-format over more files (#10689)
We were already running it over most `*.c` files and other ones but forgot the `*.hh` and `*.cc` extensions which are being used for C++ bindings, so add those in and then run the formatter.
1 parent 56b928f commit a045eaa

File tree

25 files changed

+140
-149
lines changed

25 files changed

+140
-149
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
with:
8181
submodules: true
8282
- run: |
83-
git ls-files '*.h' '*.c' '*.cpp' | \
83+
git ls-files '*.h' '*.c' '*.cpp' '*.hh' '*.cc' | \
8484
grep -v wasmtime-platform.h | \
8585
grep -v wasm.h | \
8686
xargs clang-format-18 --dry-run --Werror --verbose

crates/c-api/include/wasmtime.hh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,13 @@ public:
310310
bool> = true>
311311
Result<std::monostate> func_new(std::string_view module,
312312
std::string_view name, const FuncType &ty,
313-
F&& f) {
313+
F &&f) {
314314

315315
auto *error = wasmtime_linker_define_func(
316316
ptr.get(), module.data(), module.length(), name.data(), name.length(),
317-
ty.ptr.get(), Func::raw_callback<std::remove_reference_t<F>>, std::make_unique<std::remove_reference_t<F>>(std::forward<F>(f)).release(),
317+
ty.ptr.get(), Func::raw_callback<std::remove_reference_t<F>>,
318+
std::make_unique<std::remove_reference_t<F>>(std::forward<F>(f))
319+
.release(),
318320
Func::raw_finalize<std::remove_reference_t<F>>);
319321

320322
if (error != nullptr) {
@@ -330,15 +332,17 @@ public:
330332
std::enable_if_t<WasmHostFunc<F>::Params::valid, bool> = true,
331333
std::enable_if_t<WasmHostFunc<F>::Results::valid, bool> = true>
332334
Result<std::monostate> func_wrap(std::string_view module,
333-
std::string_view name, F&& f) {
335+
std::string_view name, F &&f) {
334336
using HostFunc = WasmHostFunc<F>;
335337
auto params = HostFunc::Params::types();
336338
auto results = HostFunc::Results::types();
337339
auto ty = FuncType::from_iters(params, results);
338340
auto *error = wasmtime_linker_define_func_unchecked(
339341
ptr.get(), module.data(), module.length(), name.data(), name.length(),
340342
ty.ptr.get(), Func::raw_callback_unchecked<std::remove_reference_t<F>>,
341-
std::make_unique<std::remove_reference_t<F>>(std::forward<F>(f)).release(), Func::raw_finalize<std::remove_reference_t<F>>);
343+
std::make_unique<std::remove_reference_t<F>>(std::forward<F>(f))
344+
.release(),
345+
Func::raw_finalize<std::remove_reference_t<F>>);
342346

343347
if (error != nullptr) {
344348
return Error(error);

crates/c-api/include/wasmtime/config.hh

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -368,29 +368,31 @@ public:
368368
wasmtime_config_wasm_memory64_set(ptr.get(), enable);
369369
}
370370

371-
/// \brief Configures whether the WebAssembly Garbage Collection proposal will be enabled
371+
/// \brief Configures whether the WebAssembly Garbage Collection proposal will
372+
/// be enabled
372373
///
373374
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_gc
374-
void wasm_gc(bool enable) {
375-
wasmtime_config_wasm_gc_set(ptr.get(), enable);
376-
}
375+
void wasm_gc(bool enable) { wasmtime_config_wasm_gc_set(ptr.get(), enable); }
377376

378-
/// \brief Configures whether the WebAssembly function references proposal will be enabled
377+
/// \brief Configures whether the WebAssembly function references proposal
378+
/// will be enabled
379379
///
380380
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_function_references
381381
void wasm_function_references(bool enable) {
382382
wasmtime_config_wasm_function_references_set(ptr.get(), enable);
383383
}
384384

385-
/// \brief Configures whether the WebAssembly wide arithmetic proposal will be enabled
385+
/// \brief Configures whether the WebAssembly wide arithmetic proposal will be
386+
/// enabled
386387
///
387388
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_wide_arithmetic
388389
void wasm_wide_arithmetic(bool enable) {
389390
wasmtime_config_wasm_wide_arithmetic_set(ptr.get(), enable);
390391
}
391392

392393
#ifdef WASMTIME_FEATURE_COMPONENT_MODEL
393-
/// \brief Configures whether the WebAssembly component model proposal will be enabled
394+
/// \brief Configures whether the WebAssembly component model proposal will be
395+
/// enabled
394396
///
395397
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_component_model
396398
void wasm_component_model(bool enable) {
@@ -399,7 +401,8 @@ public:
399401
#endif // WASMTIME_FEATURE_COMPONENT_MODEL
400402

401403
#ifdef WASMTIME_FEATURE_PARALLEL_COMPILATION
402-
/// \brief Configure whether wasmtime should compile a module using multiple threads.
404+
/// \brief Configure whether wasmtime should compile a module using multiple
405+
/// threads.
403406
///
404407
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.parallel_compilation
405408
void parallel_compilation(bool enable) {
@@ -468,7 +471,8 @@ public:
468471
wasmtime_config_memory_reservation_set(ptr.get(), size);
469472
}
470473

471-
/// \brief Configures the size of the bytes to reserve beyond the end of linear memory to grow into.
474+
/// \brief Configures the size of the bytes to reserve beyond the end of
475+
/// linear memory to grow into.
472476
///
473477
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.memory_reservation_for_growth
474478
void memory_reservation_for_growth(size_t size) {
@@ -482,7 +486,8 @@ public:
482486
wasmtime_config_memory_guard_size_set(ptr.get(), size);
483487
}
484488

485-
/// \brief Configures whether the base pointer of linear memory is allowed to move.
489+
/// \brief Configures whether the base pointer of linear memory is allowed to
490+
/// move.
486491
///
487492
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.memory_may_move
488493
void memory_may_move(bool enable) {
@@ -535,13 +540,13 @@ public:
535540
#endif // WASMTIME_FEATURE_CACHE
536541

537542
private:
538-
template <typename T>
539-
static void raw_finalize(void *env) {
543+
template <typename T> static void raw_finalize(void *env) {
540544
std::unique_ptr<T> ptr(reinterpret_cast<T *>(env));
541545
}
542546

543547
template <typename M>
544-
static uint8_t *raw_get_memory(void *env, size_t *byte_size, size_t *byte_capacity) {
548+
static uint8_t *raw_get_memory(void *env, size_t *byte_size,
549+
size_t *byte_capacity) {
545550
M *memory = reinterpret_cast<M *>(env);
546551
return memory->get_memory(byte_size, byte_capacity);
547552
}
@@ -556,19 +561,16 @@ private:
556561
}
557562

558563
template <typename T>
559-
static wasmtime_error_t *raw_new_memory(
560-
void *env, const wasm_memorytype_t *ty, size_t minimum, size_t maximum,
561-
size_t reserved_size_in_bytes, size_t guard_size_in_bytes,
562-
wasmtime_linear_memory_t *memory_ret)
563-
{
564+
static wasmtime_error_t *
565+
raw_new_memory(void *env, const wasm_memorytype_t *ty, size_t minimum,
566+
size_t maximum, size_t reserved_size_in_bytes,
567+
size_t guard_size_in_bytes,
568+
wasmtime_linear_memory_t *memory_ret) {
564569
using Memory = typename T::Memory;
565570
T *creator = reinterpret_cast<T *>(env);
566-
Result<Memory> result = creator->new_memory(
567-
MemoryType::Ref(ty),
568-
minimum,
569-
maximum,
570-
reserved_size_in_bytes,
571-
guard_size_in_bytes);
571+
Result<Memory> result =
572+
creator->new_memory(MemoryType::Ref(ty), minimum, maximum,
573+
reserved_size_in_bytes, guard_size_in_bytes);
572574
if (!result) {
573575
return result.err().release();
574576
}
@@ -581,22 +583,19 @@ private:
581583
}
582584

583585
public:
584-
585586
/// \brief Configures a custom memory creator for this configuration and
586587
/// eventual Engine.
587588
///
588589
/// This can be used to use `creator` to allocate linear memories for the
589590
/// engine that this configuration will be used for.
590-
template<typename T>
591-
void host_memory_creator(T creator) {
591+
template <typename T> void host_memory_creator(T creator) {
592592
wasmtime_memory_creator_t config = {0};
593-
config.env = std::make_unique<T>(creator).release();
593+
config.env = std::make_unique<T>(creator).release();
594594
config.finalizer = raw_finalize<T>;
595595
config.new_memory = raw_new_memory<T>;
596596
wasmtime_config_host_memory_creator_set(ptr.get(), &config);
597597
}
598598

599-
600599
#ifdef WASMTIME_FEATURE_POOLING_ALLOCATOR
601600
/// \brief Enables and configures the pooling allocation strategy.
602601
///

crates/c-api/include/wasmtime/engine.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ public:
6161
} // namespace wasmtime
6262

6363
#endif // WASMTIME_ENGINE_HH
64-

crates/c-api/include/wasmtime/error.hh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public:
6262
Trace trace() const;
6363

6464
/// Release ownership of this error, acquiring the underlying C raw pointer.
65-
wasmtime_error_t *release() {
66-
return ptr.release();
67-
}
65+
wasmtime_error_t *release() { return ptr.release(); }
6866
};
6967

7068
/// \brief Used to print an error.

crates/c-api/include/wasmtime/extern.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#ifndef WASMTIME_EXTERN_HH
66
#define WASMTIME_EXTERN_HH
77

8-
#include <wasmtime/extern.h>
98
#include <variant>
9+
#include <wasmtime/extern.h>
1010

1111
namespace wasmtime {
1212

crates/c-api/include/wasmtime/func.hh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <wasmtime/span.hh>
1212
#include <wasmtime/store.hh>
1313
#include <wasmtime/trap.hh>
14-
#include <wasmtime/types/val.hh>
1514
#include <wasmtime/types/func.hh>
15+
#include <wasmtime/types/val.hh>
1616
#include <wasmtime/val.hh>
1717

1818
namespace wasmtime {
@@ -49,7 +49,9 @@ namespace detail {
4949

5050
/// A "trait" for native types that correspond to WebAssembly types for use with
5151
/// `Func::wrap` and `TypedFunc::call`
52-
template <typename T> struct WasmType { static const bool valid = false; };
52+
template <typename T> struct WasmType {
53+
static const bool valid = false;
54+
};
5355

5456
/// Helper macro to define `WasmType` definitions for primitive types like
5557
/// int32_t and such.
@@ -577,11 +579,11 @@ public:
577579
storage;
578580
wasmtime_val_raw_t *ptr = storage.data();
579581
if (ptr == nullptr)
580-
ptr = reinterpret_cast<wasmtime_val_raw_t*>(alignof(wasmtime_val_raw_t));
582+
ptr = reinterpret_cast<wasmtime_val_raw_t *>(alignof(wasmtime_val_raw_t));
581583
WasmTypeList<Params>::store(cx, ptr, params);
582584
wasm_trap_t *trap = nullptr;
583-
auto *error = wasmtime_func_call_unchecked(
584-
cx.raw_context(), &f.func, ptr, storage.size(), &trap);
585+
auto *error = wasmtime_func_call_unchecked(cx.raw_context(), &f.func, ptr,
586+
storage.size(), &trap);
585587
if (error != nullptr) {
586588
return TrapError(Error(error));
587589
}

crates/c-api/include/wasmtime/module.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,3 @@ public:
188188
} // namespace wasmtime
189189

190190
#endif // WASMTIME_MODULE_HH
191-

crates/c-api/include/wasmtime/span.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,3 @@ private:
9999
} // namespace wasmtime
100100

101101
#endif // WASMTIME_SPAN_HH
102-

crates/c-api/include/wasmtime/types/memory.hh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,34 +120,34 @@ public:
120120
Builder() : _min(0), _memory64(false), _shared(false) {}
121121

122122
/// \brief Configure the minimum size, in pages, of linear memory.
123-
Builder& min(uint64_t min) {
123+
Builder &min(uint64_t min) {
124124
_min = min;
125125
return *this;
126126
}
127127

128128
/// \brief Configure the maximal size, in pages, of linear memory.
129-
Builder& max(std::optional<uint64_t> max) {
129+
Builder &max(std::optional<uint64_t> max) {
130130
_max = max;
131131
return *this;
132132
}
133133

134134
/// \brief Configure whether this is a 64-bit linear memory.
135-
Builder& memory64(bool enable) {
135+
Builder &memory64(bool enable) {
136136
_memory64 = enable;
137137
return *this;
138138
}
139139

140140
/// \brief Configure whether this is a shared linear memory.
141-
Builder& shared(bool enable) {
141+
Builder &shared(bool enable) {
142142
_shared = enable;
143143
return *this;
144144
}
145145

146146
/// \brief Construct the final `MemoryType` value.
147147
MemoryType build() const {
148-
return MemoryType(wasmtime_memorytype_new(
149-
_min, _max.has_value(), _max.has_value() ? *_max : 0,
150-
_memory64, _shared));
148+
return MemoryType(wasmtime_memorytype_new(_min, _max.has_value(),
149+
_max.has_value() ? *_max : 0,
150+
_memory64, _shared));
151151
}
152152
};
153153
};

0 commit comments

Comments
 (0)