Skip to content

Commit

Permalink
feat: optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
futrime committed Dec 30, 2023
1 parent 28c5914 commit 262f718
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Thank you for your contribution to the repository.
Before submitting this PR, please make sure:

- [ ] Your code builds clean without any errors or warnings
- [ ] Your code follows [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
- [ ] Your code follows [LeviLamina C++ Style Guide](https://github.com/LiteLDev/LeviLamina/wiki/CPP-Style-Guide)
- [ ] You have tested all functions
- [ ] You have not used code without license
- [ ] You have added statement for third-party code
18 changes: 0 additions & 18 deletions src/DllMain.cpp

This file was deleted.

43 changes: 43 additions & 0 deletions src/better_suicide/DllMain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <exception>

#include <ll/api/plugin/Plugin.h>

#include "Plugin.h"

namespace plugins {

// The global plugin instance.
Plugin* plugin = nullptr;

extern "C" {
_declspec(dllexport) bool ll_plugin_load(ll::plugin::Plugin& self) {
try {
plugin = new Plugin(self);

} catch (const std::exception& e) {
self.getLogger().error(e.what());

return false;
}

return true;
}

_declspec(dllexport) bool ll_plugin_enable(ll::plugin::Plugin&) {
if (plugin == nullptr) {
return false;
}

return plugin->enable();
}

_declspec(dllexport) bool ll_plugin_disable(ll::plugin::Plugin&) {
if (plugin == nullptr) {
return false;
}

return plugin->disable();
}
}

} // namespace plugins
23 changes: 23 additions & 0 deletions src/better_suicide/Plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "Plugin.h"

#include <ll/api/plugin/Plugin.h>

namespace plugins {

Plugin::Plugin(ll::plugin::Plugin& self) : mSelf(self) {
// Code for loading the plugin goes here.
}

bool Plugin::enable() {
// Code for enabling the plugin goes here.

return true;
}

bool Plugin::disable() {
// Code for disabling the plugin goes here.

return true;
}

} // namespace plugins
31 changes: 31 additions & 0 deletions src/better_suicide/Plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <ll/api/plugin/Plugin.h>

namespace plugins {

class Plugin {
public:
Plugin(ll::plugin::Plugin& self);

Plugin(const Plugin&) = delete;

Plugin(const Plugin&&) = delete;

Plugin& operator=(const Plugin&) = delete;

Plugin& operator=(const Plugin&&) = delete;

~Plugin() = default;

/// @return True if the plugin is enabled successfully.
bool enable();

/// @return True if the plugin is disabled successfully.
bool disable();

private:
ll::plugin::Plugin& mSelf;
};

} // namespace plugins
64 changes: 0 additions & 64 deletions src/plugin/Plugin.cpp

This file was deleted.

54 changes: 0 additions & 54 deletions src/plugin/Plugin.h

This file was deleted.

0 comments on commit 262f718

Please sign in to comment.