Skip to content

Commit 8cf3e35

Browse files
committed
feat!: add result to language module interface
1 parent b3db82d commit 8cf3e35

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

include/plugify/language_module.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,20 @@ namespace plugify {
5757

5858
/**
5959
* @brief Shutdown the language module.
60+
* @return Result of the s.
6061
*/
61-
virtual void Shutdown() = 0;
62+
virtual Result<void> Shutdown() = 0;
6263

6364
/**
6465
* @brief Handle actions to be performed on each frame.
6566
* @param deltaTime The time delta since the last update.
6667
*/
67-
virtual void OnUpdate(std::chrono::milliseconds deltaTime) = 0;
68+
virtual Result<void> OnUpdate(std::chrono::milliseconds deltaTime) = 0;
6869

6970
/**
7071
* @brief
7172
*/
72-
// virtual void OnPluginInitialize(const Extension& plugin) = 0;
73+
// virtual Result<void> OnPluginInitialize(const Extension& plugin) = 0;
7374

7475
/**
7576
* @brief Handle plugin load event.
@@ -82,26 +83,26 @@ namespace plugify {
8283
* @brief Handle plugin start event.
8384
* @param plugin Ref to the started plugin.
8485
*/
85-
virtual void OnPluginStart(const Extension& plugin) = 0;
86+
virtual Result<void> OnPluginStart(const Extension& plugin) = 0;
8687

8788
/**
8889
* @brief Handle plugin update event.
8990
* @param plugin Ref to the started plugin.
9091
* @param deltaTime The time delta since the last update.
9192
*/
92-
virtual void OnPluginUpdate(const Extension& plugin, std::chrono::milliseconds deltaTime) = 0;
93+
virtual Result<void> OnPluginUpdate(const Extension& plugin, std::chrono::milliseconds deltaTime) = 0;
9394

9495
/**
9596
* @brief Handle plugin end event.
9697
* @param plugin Ref to the ended plugin.
9798
*/
98-
virtual void OnPluginEnd(const Extension& plugin) = 0;
99+
virtual Result<void> OnPluginEnd(const Extension& plugin) = 0;
99100

100101
/**
101102
* @brief Handle method export event.
102103
* @param plugin Ref to the plugin exporting a method.
103104
*/
104-
virtual void OnMethodExport(const Extension& plugin) = 0;
105+
virtual Result<void> OnMethodExport(const Extension& plugin) = 0;
105106

106107
/**
107108
* @brief Determine if language module is build with debugging mode.

src/core/extension_loader.hpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ namespace plugify {
139139
return {};
140140
}
141141
auto result = SafeCall<void>("OnUpdate", module.GetName(), [&] {
142-
module.GetLanguageModule()->OnUpdate(deltaTime);
143-
return Result<void>{};
142+
return module.GetLanguageModule()->OnUpdate(deltaTime);
144143
});
145144
_extensionLifecycle->OnUpdate(module, deltaTime);
146145
return result;
@@ -151,8 +150,7 @@ namespace plugify {
151150

152151
if (auto* languageModule = module.GetLanguageModule()) {
153152
result = SafeCall<void>("Shutdown", module.GetName(), [&] {
154-
languageModule->Shutdown();
155-
return Result<void>{};
153+
return languageModule->Shutdown();
156154
});
157155
module.SetLanguageModule(nullptr);
158156
}
@@ -210,8 +208,7 @@ namespace plugify {
210208
return {};
211209
}
212210
auto result = SafeCall<void>("OnPluginStart", plugin.GetName(), [&] {
213-
plugin.GetLanguageModule()->OnPluginStart(plugin);
214-
return Result<void>{};
211+
return plugin.GetLanguageModule()->OnPluginStart(plugin);
215212
});
216213
_extensionLifecycle->OnStart(plugin);
217214
return result;
@@ -223,8 +220,7 @@ namespace plugify {
223220
return {};
224221
}
225222
auto result = SafeCall<void>("OnPluginEnd", plugin.GetName(), [&] {
226-
plugin.GetLanguageModule()->OnPluginEnd(plugin);
227-
return Result<void>{};
223+
return plugin.GetLanguageModule()->OnPluginEnd(plugin);
228224
});
229225
_extensionLifecycle->OnEnd(plugin);
230226
return result;
@@ -236,8 +232,7 @@ namespace plugify {
236232
return {};
237233
}
238234
auto result = SafeCall<void>("OnPluginUpdate", plugin.GetName(), [&] {
239-
plugin.GetLanguageModule()->OnPluginUpdate(plugin, deltaTime);
240-
return Result<void>{};
235+
return plugin.GetLanguageModule()->OnPluginUpdate(plugin, deltaTime);
241236
});
242237
_extensionLifecycle->OnUpdate(plugin, deltaTime);
243238
return result;
@@ -260,8 +255,7 @@ namespace plugify {
260255
return {};
261256
}
262257
auto result = SafeCall<void>("OnMethodExport", module.GetName(), [&] {
263-
module.GetLanguageModule()->OnMethodExport(plugin);
264-
return Result<void>{};
258+
return module.GetLanguageModule()->OnMethodExport(plugin);
265259
});
266260
//_lifecycle->OnExport(module, plugin);
267261
return result;

src/core/manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ struct Manager::Impl {
234234
break;
235235
}
236236
}
237-
238237
if (!result) {
239238
logger->Log(result.error(), Severity::Error);
240239
}

0 commit comments

Comments
 (0)