Skip to content

Commit fcd3fb6

Browse files
committed
use utki::unique_ref
1 parent 67f6f5a commit fcd3fb6

File tree

16 files changed

+32
-34
lines changed

16 files changed

+32
-34
lines changed

src/ruis/res/font.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ utki::shared_ref<res::font> res::font::load(
9898
fi.set_path(get_property_value(p).string);
9999
} else if (p.value == "bold") {
100100
// NOLINTNEXTLINE(bugprone-unused-return-value, "false positive")
101-
file_bold = fi.spawn(get_property_value(p).string);
101+
file_bold = fi.spawn(get_property_value(p).string).to_unique_ptr();
102102
} else if (p.value == "italic") {
103103
// NOLINTNEXTLINE(bugprone-unused-return-value, "false positive")
104-
file_italic = fi.spawn(get_property_value(p).string);
104+
file_italic = fi.spawn(get_property_value(p).string).to_unique_ptr();
105105
} else if (p.value == "bold_italic") {
106106
// NOLINTNEXTLINE(bugprone-unused-return-value, "false positive")
107-
file_bold_italic = fi.spawn(get_property_value(p).string);
107+
file_bold_italic = fi.spawn(get_property_value(p).string).to_unique_ptr();
108108
}
109109
}
110110

src/ruis/resource_loader.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ constexpr const char* wording_include_subdirs = "include_subdirs";
3535

3636
decltype(resource_loader::res_packs)::const_iterator resource_loader::mount_res_pack(const fsif::file& fi)
3737
{
38-
ASSERT(!fi.is_open())
38+
utki::assert(!fi.is_open(), SL);
3939

4040
std::string dir = fi.dir();
4141

@@ -44,7 +44,7 @@ decltype(resource_loader::res_packs)::const_iterator resource_loader::mount_res_
4444
}
4545

4646
auto script = tml::read(fi);
47-
ASSERT(!fi.is_open())
47+
utki::assert(!fi.is_open(), SL);
4848

4949
// handle includes
5050
for (auto& p : script) {
@@ -72,8 +72,7 @@ decltype(resource_loader::res_packs)::const_iterator resource_loader::mount_res_
7272
std::move(script)
7373
);
7474

75-
ASSERT(this->res_packs.back().fi)
76-
ASSERT(!this->res_packs.back().script.empty())
75+
utki::assert(!this->res_packs.back().script.empty(), SL);
7776

7877
return std::prev(this->res_packs.end());
7978
}
@@ -88,7 +87,7 @@ void resource_loader::res_pack_entry::add_to_cache(
8887
std::string_view id
8988
) const
9089
{
91-
ASSERT(!utki::contains(this->cache, id))
90+
utki::assert(!utki::contains(this->cache, id), SL);
9291

9392
this->cache.insert(std::make_pair(
9493
id, //
@@ -117,7 +116,7 @@ const tml::forest* resource_loader::res_pack_entry::find_resource_in_script(std:
117116
id
118117
);
119118
if (j != this->script.end()) {
120-
ASSERT(j->value.string == id)
119+
utki::assert(j->value.string == id, SL);
121120
return &j->children;
122121
}
123122

src/ruis/resource_loader.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class resource_loader
8181
res_pack_entry(const res_pack_entry&) = delete;
8282
res_pack_entry& operator=(const res_pack_entry&) = delete;
8383

84-
std::unique_ptr<const fsif::file> fi;
84+
utki::unique_ref<const fsif::file> fi;
8585

8686
// TODO: use std::map/std::unordered_map?
8787
tml::forest script;
@@ -202,11 +202,10 @@ utki::shared_ref<const resource_type> resource_loader::load(std::string_view id)
202202
}
203203

204204
try {
205-
ASSERT(res_pack.fi)
206205
auto resource = resource_type::load(
207206
*this, //
208207
*desc,
209-
*res_pack.fi
208+
res_pack.fi
210209
);
211210

212211
// resource need to know its id so that it would be possible to reload the resource

tests/align/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class application : public ruisapp::application{
326326
}
327327
))
328328
{
329-
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
329+
this->window.gui.init_standard_widgets(this->get_res_file("../../res/ruis_res/").get());
330330

331331
this->window.gui.set_root(make_layout(this->window.gui.context));
332332

tests/app/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class application : public ruisapp::application{
7474

7575
auto& gui = this->window.gui;
7676

77-
gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
77+
gui.init_standard_widgets(this->get_res_file("../../res/ruis_res/").get());
7878

79-
gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
79+
gui.context.get().loader().mount_res_pack(this->get_res_file("res/").get());
8080
// this->ResMan().MountResPack(ruis::ZipFile::New(fsif::FSFile::New("res.zip")));
8181

8282
auto c = make_root_widget(gui.context);

tests/app2/src/application.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ application::application() :
3232
}),
3333
window(this->make_window({.dims = {1024, 800}}))
3434
{
35-
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
35+
this->window.gui.init_standard_widgets(this->get_res_file("../../res/ruis_res/").get());
3636

3737
this->window.gui.context.get().localization.get() =
38-
ruis::localization(tml::read(*this->get_res_file("res/localization/en.tml")));
38+
ruis::localization(tml::read(this->get_res_file("res/localization/en.tml").get()));
3939

40-
this->window.gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
40+
this->window.gui.context.get().loader().mount_res_pack(this->get_res_file("res/").get());
4141

4242
// clang-format off
4343
auto kp = ruis::make::key_proxy(

tests/app2/src/gui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ utki::shared_ref<ruis::window> make_selection_box_window(
328328
// std::cout << "new localization = " << lng << std::endl;
329329

330330
app.window.gui.context.get().localization.get() =
331-
ruis::localization(tml::read(*app.get_res_file(utki::cat("res/localization/", lng, ".tml"))));
331+
ruis::localization(tml::read(app.get_res_file(utki::cat("res/localization/", lng, ".tml")).get()));
332332
app.window.gui.get_root().reload();
333333
});
334334
};

tests/aspect_ratio_proxy/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class application : public ruisapp::application{
2828
this->quit();
2929
};
3030

31-
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
31+
this->window.gui.init_standard_widgets(this->get_res_file("../../res/ruis_res/").get());
3232

3333
auto ctx = this->window.gui.context;
3434

tests/book/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class application : public ruisapp::application{
4040
this->quit();
4141
};
4242

43-
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
43+
this->window.gui.init_standard_widgets(this->get_res_file("../../res/ruis_res/").get());
4444

45-
this->window.gui.context.get().loader().mount_res_pack(*this->get_res_file("res/"));
45+
this->window.gui.context.get().loader().mount_res_pack(this->get_res_file("res/").get());
4646

4747
auto& ctx = this->window.gui.context;
4848

tests/busy/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class application : public ruisapp::application{
2525
this->quit();
2626
};
2727

28-
this->window.gui.init_standard_widgets(*this->get_res_file("../../res/ruis_res/"));
28+
this->window.gui.init_standard_widgets(this->get_res_file("../../res/ruis_res/"));
2929

3030
auto c = make_root_gui(this->window.gui.context);
3131
this->window.gui.set_root(c);

0 commit comments

Comments
 (0)