Skip to content

Commit 12b418e

Browse files
committed
Rename the old Fn/FnMut/FnOnce to BoxFn/BoxFnMut/BoxFnOnce
1 parent 4441e71 commit 12b418e

File tree

16 files changed

+381
-375
lines changed

16 files changed

+381
-375
lines changed

subdoc/lib/database.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct FunctionElement : public CommentElement {
145145
return sus::none();
146146
}
147147

148-
void for_each_comment(sus::fn::FnMut<void(Comment&)>& fn) { fn(comment); }
148+
void for_each_comment(sus::fn::BoxFnMut<void(Comment&)>& fn) { fn(comment); }
149149
};
150150

151151
struct FieldElement : public CommentElement {
@@ -186,7 +186,7 @@ struct FieldElement : public CommentElement {
186186
return sus::none();
187187
}
188188

189-
void for_each_comment(sus::fn::FnMut<void(Comment&)>& fn) { fn(comment); }
189+
void for_each_comment(sus::fn::BoxFnMut<void(Comment&)>& fn) { fn(comment); }
190190
};
191191

192192
struct NamespaceId {
@@ -323,7 +323,7 @@ struct RecordElement : public TypeElement {
323323
return out;
324324
}
325325

326-
void for_each_comment(sus::fn::FnMut<void(Comment&)>& fn) {
326+
void for_each_comment(sus::fn::BoxFnMut<void(Comment&)>& fn) {
327327
fn(comment);
328328
for (auto& [k, e] : records) e.for_each_comment(fn);
329329
for (auto& [k, e] : fields) e.for_each_comment(fn);
@@ -426,7 +426,7 @@ struct NamespaceElement : public CommentElement {
426426
return out;
427427
}
428428

429-
void for_each_comment(sus::fn::FnMut<void(Comment&)>& fn) {
429+
void for_each_comment(sus::fn::BoxFnMut<void(Comment&)>& fn) {
430430
fn(comment);
431431
for (auto& [k, e] : namespaces) e.for_each_comment(fn);
432432
for (auto& [k, e] : records) e.for_each_comment(fn);
@@ -461,7 +461,7 @@ struct Database {
461461
sus::Vec<Comment*> to_resolve;
462462
{
463463
sus::Vec<Comment*>* to_resolve_ptr = &to_resolve;
464-
sus::fn::FnMut<void(Comment&)> fn = sus_bind_mut(
464+
sus::fn::BoxFnMut<void(Comment&)> fn = sus_bind_mut(
465465
sus_store(sus_unsafe_pointer(to_resolve_ptr)), [&](Comment& c) {
466466
if (c.attrs.inherit.is_some()) {
467467
to_resolve_ptr->push(&c);

subdoc/lib/run_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct RunOptions {
3838
exclude_path_patterns = sus::move(r);
3939
return sus::move(*this);
4040
}
41-
RunOptions set_on_tu_complete(sus::fn::Fn<void(clang::ASTContext&)> fn) && {
41+
RunOptions set_on_tu_complete(sus::fn::BoxFn<void(clang::ASTContext&)> fn) && {
4242
on_tu_complete = sus::some(sus::move(fn));
4343
return sus::move(*this);
4444
}
@@ -53,7 +53,7 @@ struct RunOptions {
5353
///
5454
/// Used for tests to observe the AST and test subdoc methods that act on
5555
/// things from the AST.
56-
sus::Option<sus::fn::Fn<void(clang::ASTContext&)>> on_tu_complete;
56+
sus::Option<sus::fn::BoxFn<void(clang::ASTContext&)>> on_tu_complete;
5757
};
5858

5959
} // namespace subdoc

subspace/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ target_sources(subspace PUBLIC
4545
"containers/array.h"
4646
"containers/slice.h"
4747
"containers/vec.h"
48-
"fn/__private/fn_storage.h"
48+
"fn/__private/box_fn_storage.h"
4949
"fn/callable.h"
5050
"fn/fn.h"
51-
"fn/fn_bind.h"
52-
"fn/fn_defn.h"
53-
"fn/fn_impl.h"
51+
"fn/bind.h"
52+
"fn/box_fn_defn.h"
53+
"fn/box_fn_impl.h"
5454
"fn/stackfn_defn.h"
5555
"iter/__private/into_iterator_archetype.h"
5656
"iter/__private/iterator_end.h"
@@ -151,7 +151,7 @@ add_executable(subspace_unittests
151151
"construct/from_unittest.cc"
152152
"construct/into_unittest.cc"
153153
"construct/default_unittest.cc"
154-
"fn/fn_unittest.cc"
154+
"fn/box_fn_unittest.cc"
155155
"fn/stackfn_unittest.cc"
156156
"iter/iterator_unittest.cc"
157157
"mem/addressof_unittest.cc"

subspace/containers/array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "subspace/containers/__private/slice_iter.h"
2828
#include "subspace/containers/slice.h"
2929
#include "subspace/fn/callable.h"
30-
#include "subspace/fn/fn_defn.h"
30+
#include "subspace/fn/box_fn_defn.h"
3131
#include "subspace/macros/compiler.h"
3232
#include "subspace/marker/unsafe.h"
3333
#include "subspace/mem/clone.h"

subspace/fn/__private/fn_storage.h renamed to subspace/fn/__private/box_fn_storage.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,40 @@
1818

1919
namespace sus::fn::__private {
2020

21-
struct FnStorageVtableBase {};
21+
struct BoxFnStorageVtableBase {};
2222

23-
struct FnStorageBase {
23+
struct BoxFnStorageBase {
2424
// Should be to a static lifetime pointee.
25-
Option<const FnStorageVtableBase&> vtable = Option<const FnStorageVtableBase&>::none();
25+
Option<const BoxFnStorageVtableBase&> vtable = Option<const BoxFnStorageVtableBase&>::none();
2626
};
2727

2828
template <class R, class... CallArgs>
29-
struct FnStorageVtable final : public FnStorageVtableBase {
30-
R (*call_once)(__private::FnStorageBase&&, CallArgs...);
31-
R (*call_mut)(__private::FnStorageBase&, CallArgs...);
32-
R (*call)(const __private::FnStorageBase&, CallArgs...);
29+
struct BoxFnStorageVtable final : public BoxFnStorageVtableBase {
30+
R (*call_once)(__private::BoxFnStorageBase&&, CallArgs...);
31+
R (*call_mut)(__private::BoxFnStorageBase&, CallArgs...);
32+
R (*call)(const __private::BoxFnStorageBase&, CallArgs...);
3333
};
3434

3535
template <class F>
36-
class FnStorage final : public FnStorageBase {
36+
class BoxFnStorage final : public BoxFnStorageBase {
3737
public:
38-
constexpr FnStorage(F&& callable) : callable_(::sus::move(callable)) {}
38+
constexpr BoxFnStorage(F&& callable) : callable_(::sus::move(callable)) {}
3939

4040
template <class R, class... CallArgs>
41-
static R call(const FnStorageBase& self_base, CallArgs... callargs) {
42-
const auto& self = static_cast<const FnStorage&>(self_base);
41+
static R call(const BoxFnStorageBase& self_base, CallArgs... callargs) {
42+
const auto& self = static_cast<const BoxFnStorage&>(self_base);
4343
return self.callable_(forward<CallArgs>(callargs)...);
4444
}
4545

4646
template <class R, class... CallArgs>
47-
static R call_mut(FnStorageBase& self_base, CallArgs... callargs) {
48-
auto& self = static_cast<FnStorage&>(self_base);
47+
static R call_mut(BoxFnStorageBase& self_base, CallArgs... callargs) {
48+
auto& self = static_cast<BoxFnStorage&>(self_base);
4949
return self.callable_(forward<CallArgs>(callargs)...);
5050
}
5151

5252
template <class R, class... CallArgs>
53-
static R call_once(FnStorageBase&& self_base, CallArgs... callargs) {
54-
auto&& self = static_cast<FnStorage&&>(self_base);
53+
static R call_once(BoxFnStorageBase&& self_base, CallArgs... callargs) {
54+
auto&& self = static_cast<BoxFnStorage&&>(self_base);
5555
return ::sus::move(self.callable_)(forward<CallArgs>(callargs)...);
5656
}
5757

subspace/fn/fn_bind.h renamed to subspace/fn/bind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <type_traits>
1818

1919
#include "subspace/fn/callable.h"
20-
#include "subspace/fn/fn_defn.h"
20+
#include "subspace/fn/box_fn_defn.h"
2121
#include "subspace/macros/__private/compiler_bugs.h"
2222
#include "subspace/macros/eval_macro.h"
2323
#include "subspace/macros/for_each.h"

0 commit comments

Comments
 (0)