MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / BuildModuleDef

Method BuildModuleDef

crates/bindings-cpp/src/internal/v10_builder.cpp:222–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222RawModuleDefV10 V10Builder::BuildModuleDef() const {
223 RawModuleDefV10 v10_module;
224
225 std::vector<RawTypeDefV10> types = types_;
226
227 std::vector<RawReducerDefV10> reducers = reducers_;
228 std::vector<RawProcedureDefV10> procedures = procedures_;
229
230 std::unordered_set<std::string> internal_functions;
231 for (const auto& lifecycle : lifecycle_reducers_) {
232 internal_functions.insert(lifecycle.function_name);
233 }
234 for (const auto& schedule : schedules_) {
235 internal_functions.insert(schedule.function_name);
236 }
237 for (auto& reducer : reducers) {
238 if (internal_functions.find(reducer.source_name) != internal_functions.end()) {
239 reducer.visibility = FunctionVisibility::Private;
240 }
241 }
242 for (auto& procedure : procedures) {
243 if (internal_functions.find(procedure.source_name) != internal_functions.end()) {
244 procedure.visibility = FunctionVisibility::Private;
245 }
246 }
247
248 RawModuleDefV10Section section_typespace;
249 section_typespace.set<0>(typespace_);
250 v10_module.sections.push_back(section_typespace);
251
252 if (!types.empty()) {
253 RawModuleDefV10Section section_types;
254 section_types.set<1>(std::move(types));
255 v10_module.sections.push_back(std::move(section_types));
256 }
257 if (!tables_.empty()) {
258 RawModuleDefV10Section section_tables;
259 section_tables.set<2>(tables_);
260 v10_module.sections.push_back(std::move(section_tables));
261 }
262 if (!reducers.empty()) {
263 RawModuleDefV10Section section_reducers;
264 section_reducers.set<3>(std::move(reducers));
265 v10_module.sections.push_back(std::move(section_reducers));
266 }
267 if (!procedures.empty()) {
268 RawModuleDefV10Section section_procedures;
269 section_procedures.set<4>(std::move(procedures));
270 v10_module.sections.push_back(std::move(section_procedures));
271 }
272 if (!views_.empty()) {
273 RawModuleDefV10Section section_views;
274 section_views.set<5>(views_);
275 v10_module.sections.push_back(std::move(section_views));
276 }
277 if (!schedules_.empty()) {
278 RawModuleDefV10Section section_schedules;
279 section_schedules.set<6>(schedules_);

Callers 1

SerializeModuleDefMethod · 0.80

Calls 6

push_backMethod · 0.80
insertMethod · 0.65
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected