Skip to content

Commit

Permalink
compile with fake interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtum committed Oct 25, 2024
1 parent ac9e189 commit ebf9b52
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 110 deletions.
3 changes: 2 additions & 1 deletion PluginSkeletonGenerator/PluginSkeletonGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PluginGenerator:
def __init__(self, blueprint_data) -> None:
self.blueprint_data = blueprint_data
self.directory = self.blueprint_data.plugin_name
os.makedirs(self.blueprint_data.plugin_name, exist_ok=True)
os.makedirs(self.blueprint_data.plugin_name, exist_ok=False)
self.indenter = Indenter()

def load_template(self, template_name):
Expand Down Expand Up @@ -55,6 +55,7 @@ def generate_conf_in(self):

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
def main():
print('[NOTE]: The output from this generator is a skeleton, therefore it uses example methods. Please correct the generated methods accordingly!')
menu.menu()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
if __name__ == "__main__":
Expand Down
260 changes: 177 additions & 83 deletions PluginSkeletonGenerator/file_data.py

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions PluginSkeletonGenerator/help.txt

This file was deleted.

6 changes: 4 additions & 2 deletions PluginSkeletonGenerator/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def display_settings(
print(f"JSONRPC Functionality: {jsonrpc}")
print(f"JSONRPC Interfaces: {jsonrpc_interface if jsonrpc else 'N/A'} ")
print(f"Out Of Process: {out_of_process}")
print(f"Plugin specific configuration: {plugin_config}")

"""
print(f"Subsystem Support: {subsystems}")
print(f"Subsystem Preconditions: {preconditions if subsystems else 'N/A'} ")
Expand Down Expand Up @@ -135,7 +137,7 @@ def user_comrpc(out_of_process, comrpc_interfaces, jsonrpc_interfaces, notificat
correctName = correctExtension
# CorrectName at this point will always return the correct interface name without the '.h'
while True:
comrpc_confirm = input(f"The name of the interface in {tempName} is (enter to confirm or type the correct interface name) {correctName}: ")
comrpc_confirm = input(f"The name of the interface in {tempName} is {correctName} (enter to confirm or type the correct interface name): ")
if comrpc_confirm:
correctInitial = Utils.check_correct_comrpc(comrpc_confirm)
if not correctInitial:
Expand Down Expand Up @@ -167,7 +169,7 @@ def user_comrpc(out_of_process, comrpc_interfaces, jsonrpc_interfaces, notificat

def user_jsonrpc(comrpc_interface, jsonrpc_interfaces):

json_tag = get_boolean_input("Does your plugin require JSON-RPC functionality (@JSON tag): (Enter Y or N)\n")
json_tag = get_boolean_input("Does your plugin require JSON-RPC functionality (@json tag): (Enter Y or N)\n")
if json_tag:
jsonrpc_interface = Utils.replace_comrpc_to_jsonrpc(comrpc_interface)
jsonrpc_interfaces.append(jsonrpc_interface)
Expand Down
2 changes: 2 additions & 0 deletions PluginSkeletonGenerator/templates/.cmake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")

set(PLUGIN_{{PLUGIN_NAME_CAPS}}_STARTMODE "Activated" CACHE STRING "Automatically start {{PLUGIN_NAME}} plugin")
{{SET_MODE}}
{{SET_CONFIG}}

if(BUILD_REFERENCE)
~INDENT_INCREASE~
Expand All @@ -43,6 +44,7 @@ find_package(CompileSettingsDebug CONFIG REQUIRED)
add_library(${MODULE_NAME} SHARED
~INDENT_INCREASE~
{{SOURCE_FILES}}
Module.cpp
~INDENT_DECREASE~
)

Expand Down
2 changes: 2 additions & 0 deletions PluginSkeletonGenerator/templates/.plugin_conf_in.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
startmode = {{PLUGIN_STARTMODE}}

{{CONFIG}}

{{OOP_ROOT}}
2 changes: 1 addition & 1 deletion PluginSkeletonGenerator/templates/.plugin_header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ namespace Plugin {
~INDENT_DECREASE~
private:
~INDENT_INCREASE~
{{USING_CONTAINER}}
// Include the correct member variables for your plugin:
// Note this is only an example, you are responsible for adding the correct members:
uint32_t _example;

PluginHost::IShell* _service;
{{MEMBER_IMPL}}
~INDENT_DECREASE~
};
Expand Down
15 changes: 9 additions & 6 deletions PluginSkeletonGenerator/templates/.plugin_implementation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@
* limitations under the License.
*/

#pragma once

#include "Module.h"
{{COMRPC_INTERFACE_INCLUDES}}

namespace Thunder {
namespace Plugin {
~INDENT_INCREASE~
SERVICE_REGISTRATION({{PLUGIN_NAME}}Implementation, 1, 0)

class {{PLUGIN_NAME}}Implementation {{OOP_INHERITED_CLASS}} {
public:
~INDENT_INCREASE~
{{PLUGIN_NAME}}Implementation(const {{PLUGIN_NAME}}Implementation&) = delete;
{{PLUGIN_NAME}}Implementation& operator=(const {{PLUGIN_NAME}}Implementation&) = delete;
{{PLUGIN_NAME}}({{PLUGIN_NAME}}&&) = delete;
{{PLUGIN_NAME}}& operator=({{PLUGIN_NAME}}&&) = delete;
{{PLUGIN_NAME}}Implementation({{PLUGIN_NAME}}Implementation&&) = delete;
{{PLUGIN_NAME}}Implementation& operator=({{PLUGIN_NAME}}Implementation&&) = delete;

{{PLUGIN_NAME}}Implementation()
~INDENT_INCREASE~
Expand All @@ -41,6 +39,8 @@ namespace Plugin {
{
}
~{{PLUGIN_NAME}}Implementation() override = default;

{{CONFIG_CLASS}}
~INDENT_DECREASE~
public:
~INDENT_INCREASE~
Expand All @@ -56,13 +56,16 @@ namespace Plugin {
~INDENT_DECREASE~
private:
~INDENT_INCREASE~
{{CONFIG_CLASS}}
{{USING_CONTAINER}}

{{NOTIFY_METHOD}}
// Note: test is just an example...
uint32_t _test;
{{OOP_MEMBERS}}
~INDENT_DECREASE~
};

SERVICE_REGISTRATION({{PLUGIN_NAME}}Implementation, 1, 0)
~INDENT_DECREASE~
} // Plugin
} // Thunder
6 changes: 3 additions & 3 deletions PluginSkeletonGenerator/templates/.plugin_source.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Plugin {
// Controls
{}
~INDENT_DECREASE~
)
);
~INDENT_DECREASE~
}

Expand All @@ -54,9 +54,9 @@ void {{PLUGIN_NAME}}::Deinitialize({{VARIABLE_NOT_USED}}PluginHost::IShell* serv
~INDENT_DECREASE~
}

string {{PLUGIN_NAME}}::Information() {
string {{PLUGIN_NAME}}::Information() const {
~INDENT_INCREASE~
return string()
return string();
~INDENT_DECREASE~
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

ASSERT(_service == service);

service->Unregister(&_notification);
{{UNREGISTER_NOTIFICATION}}

{{DEINITIALIZE}}

ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);

// The process can disappear in the meantime...
if (connection != nullptr) {
~INDENT_INCREASE~
// But if it did not dissapear in the meantime, forcefully terminate it. Shoot to kill
// But if it did not disappear in the meantime, forcefully terminate it. Shoot to kill
connection->Terminate();
connection->Release();
~INDENT_DECREASE~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ string message;

ASSERT(_service == nullptr);
ASSERT(service != nullptr);
ASSERT(_implementation == nullptr);
{{ASSERT_IMPL}}
ASSERT(_connectionId == 0);

_service = service;
_service->AddRef();
_service->Register(&_notification);
{{REGISTER_NOTIFICATION}}

// Example
_impl{{COMRPC}} = service->Root<Exchange::{{COMRPC}}>(_connectionId, 2000, _T("{{PLUGIN_NAME}}Implementation"));
if (_impl{{COMRPC}} == nullptr) {
_impl{{COMRPC[1:]}} = service->Root<Exchange::{{COMRPC}}>(_connectionId, 2000, _T("{{PLUGIN_NAME}}Implementation"));
if (_impl{{COMRPC[1:]}} == nullptr) {
~INDENT_INCREASE~
message = _T("Couldn't create instance of impl{{COMRPC}}");
message = _T("Couldn't create instance of impl{{COMRPC[1:]}}");
~INDENT_DECREASE~
} else {
{{NESTED_QUERY}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <core/core.h>
#include <plugins/plugins.h>
#include <messaging/messaging.h>

#undef EXTERNAL
#define EXTERNAL
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public:
~INDENT_INCREASE~
Core::JSON::String Example;
~INDENT_DECREASE~
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ private:
~INDENT_INCREASE~
{{PLUGIN_NAME}}& _parent;
~INDENT_DECREASE~
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ uint32_t Configure(PluginHost::IShell* service) override {
~INDENT_INCREASE~
Config config;
config.FromString(service->ConfigLine());
TRACE(Trace::Information, (_T("This is just an example: [%s]\n)"), config.Example));
~INDENT_DECREASE~
}
return Core::ERROR_NONE;
Expand Down
28 changes: 28 additions & 0 deletions PluginSkeletonGenerator/tests/IHello.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "Module.h"

namespace Thunder {
namespace Exchange {

// @json 1.0.0 @uncompliant:extended
struct EXTERNAL IHello: virtual public Core::IUnknown {
enum { ID = ID_VOLUMECONTROL };

// @event @uncompliant:extended // NOTE: extended format is deprecated!! Do not just copy this line!
struct EXTERNAL INotification : virtual public Core::IUnknown {
enum { ID = ID_VOLUMECONTROL_NOTIFICATION };

~INotification() override = default;
virtual void IHelloNotification() {};
};

~IHello() override = default;

virtual void Register(IHello::INotification* sink) {};
virtual void Unregister(const IHello::INotification* sink) {};

virtual uint32_t IHelloMethod1() = 0;
};
}
}

0 comments on commit ebf9b52

Please sign in to comment.