Skip to content

Commit 6c011fb

Browse files
committed
libstd: Added std::mem::create_hidden_section()
1 parent 05da61f commit 6c011fb

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

lib/include/pl/api.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ namespace pl::api {
6767
*/
6868
struct Section {
6969
std::string name;
70+
bool hidden;
7071
std::vector<u8> data;
7172
};
7273

lib/include/pl/pattern_language.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ namespace pl {
413413

414414
[[nodiscard]] u64 getSectionSize(u64 id);
415415
[[nodiscard]] u64 getSectionCount() const;
416-
[[nodiscard]] u64 createSection(const std::string &name);
416+
[[nodiscard]] u64 createSection(const std::string &name, bool hidden = false);
417417
void removeSection(u64 id);
418418

419419
private:

lib/source/pl/lib/std/mem.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ namespace pl::lib::libstd::mem {
184184
return u128(ctx->getRuntime().createSection(name));
185185
});
186186

187+
/* create_hidden_section(name) -> id */
188+
runtime.addFunction(nsStdMem, "create_hidden_section", FunctionParameterCount::none(), [](Evaluator *ctx, auto) -> std::optional<Token::Literal> {
189+
return u128(ctx->getRuntime().createSection("", true));
190+
});
191+
187192
/* delete_section(id) */
188193
runtime.addFunction(nsStdMem, "delete_section", FunctionParameterCount::exactly(1), [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
189194
auto id = u64(params[0].toUnsigned());

lib/source/pl/pattern_language.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,11 @@ namespace pl {
495495
return this->m_sectionData->sections;
496496
}
497497

498-
u64 PatternLanguage::createSection(const std::string &name) {
498+
u64 PatternLanguage::createSection(const std::string &name, bool hidden) {
499499
auto id = this->m_sectionData->nextSectionId;
500500
this->m_sectionData->nextSectionId++;
501501

502-
this->m_sectionData->sections.insert({ id, { name, { } } });
502+
this->m_sectionData->sections.insert({ id, { name, hidden, { } } });
503503
return id;
504504
}
505505

0 commit comments

Comments
 (0)