Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change name of structs in API, change C++ API to avoid shared_ptr #9

Merged
merged 9 commits into from
Mar 23, 2024
Merged
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,32 @@ on:
push:
branches:
- main
- '*-dev'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
clang-format-lib:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./include ./source
build-lib:
runs-on: ubuntu-22.04
needs: clang-format-lib
steps:
- uses: actions/checkout@v3
- name: build binary
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
build-and-push-image:
runs-on: ubuntu-latest
needs: [build-lib]
permissions:
contents: read
packages: write
Expand All @@ -24,9 +42,10 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{date 'YYYYMMDD'}}-{{sha}}
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
type=raw,value={{branch}}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}}
type=raw,value={{date 'YYYYMMDD'}},enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ghcr.io/wiiu-env/devkitppc:20230621
FROM ghcr.io/wiiu-env/devkitppc:20231112

COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:0.8.0-dev-20240302-3b5cc2f /artifacts $DEVKITPRO

WORKDIR tmp_build
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.buildlocal
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM ghcr.io/wiiu-env/devkitppc:20230621
FROM ghcr.io/wiiu-env/devkitppc:20231112

WORKDIR project
18 changes: 9 additions & 9 deletions include/wups_backend/PluginContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
#include "PluginMetaInformation.h"

namespace WUPSBackend {
class PluginContainer {
class PluginContainer {

public:
PluginContainer(std::shared_ptr<PluginData> data, std::shared_ptr<PluginMetaInformation> metaInfo);
public:
PluginContainer(PluginData data, PluginMetaInformation metaInfo);

[[nodiscard]] const std::shared_ptr<PluginMetaInformation> &getMetaInformation() const;
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const;

[[nodiscard]] const std::shared_ptr<PluginData> &getPluginData() const;
[[nodiscard]] const PluginData &getPluginData() const;

private:
const std::shared_ptr<PluginData> pluginData;
const std::shared_ptr<PluginMetaInformation> metaInformation;
};
private:
PluginData pluginData;
PluginMetaInformation metaInformation;
};
} // namespace WUPSBackend
24 changes: 15 additions & 9 deletions include/wups_backend/PluginData.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@
#include <wups_backend/import_defines.h>

namespace WUPSBackend {
class PluginData {
class PluginData {

public:
explicit PluginData(uint32_t handle);
~PluginData();
public:
explicit PluginData(uint32_t handle);

[[nodiscard]] uint32_t getHandle() const {
return handle;
}
PluginData(const PluginData &) = delete;

uint32_t handle;
};
PluginData(PluginData &&src) noexcept;

~PluginData();

PluginData &operator=(PluginData &&src) noexcept;

[[nodiscard]] uint32_t getHandle() const;

private:
uint32_t mHandle;
};
} // namespace WUPSBackend
142 changes: 55 additions & 87 deletions include/wups_backend/PluginMetaInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,91 +22,59 @@
#include <vector>

namespace WUPSBackend {
class PluginMetaInformation {
public:
[[nodiscard]] const std::string &getName() const {
return name;
}

[[nodiscard]] const std::string &getAuthor() const {
return this->author;
}

[[nodiscard]] const std::string &getVersion() const {
return this->version;
}

[[nodiscard]] const std::string &getLicense() const {
return this->license;
}

[[nodiscard]] const std::string &getBuildTimestamp() const {
return this->buildtimestamp;
}

[[nodiscard]] const std::string &getDescription() const {
return this->description;
}

[[nodiscard]] const std::string &getStorageId() const {
return this->storageId;
}

[[nodiscard]] size_t getSize() const {
return this->size;
}

PluginMetaInformation(std::string name,
std::string author,
std::string version,
std::string license,
std::string buildtimestamp,
std::string description,
std::string storageId,
size_t size);

private:
PluginMetaInformation() = default;

void setName(std::string name_) {
this->name = std::move(name_);
}

void setAuthor(std::string author_) {
this->author = std::move(author_);
}

void setVersion(std::string version_) {
this->version = std::move(version_);
}

void setLicense(std::string license_) {
this->license = std::move(license_);
}

void setBuildTimestamp(std::string buildtimestamp_) {
this->buildtimestamp = std::move(buildtimestamp_);
}

void setDescription(std::string description_) {
this->description = std::move(description_);
}

void setStorageId(std::string storageId_) {
this->storageId = std::move(storageId_);
}

void setSize(size_t size_) {
this->size = size_;
}

std::string name;
std::string author;
std::string version;
std::string license;
std::string buildtimestamp;
std::string description;
std::string storageId;
size_t size{};
};
class PluginMetaInformation {
public:
[[nodiscard]] const std::string &getName() const {
return name;
}

[[nodiscard]] const std::string &getAuthor() const {
return this->author;
}

[[nodiscard]] const std::string &getVersion() const {
return this->version;
}

[[nodiscard]] const std::string &getLicense() const {
return this->license;
}

[[nodiscard]] const std::string &getBuildTimestamp() const {
return this->buildtimestamp;
}

[[nodiscard]] const std::string &getDescription() const {
return this->description;
}

[[nodiscard]] const std::string &getStorageId() const {
return this->storageId;
}

[[nodiscard]] size_t getSize() const {
return this->size;
}

PluginMetaInformation(std::string_view name,
std::string_view author,
std::string_view version,
std::string_view license,
std::string_view buildtimestamp,
std::string_view description,
std::string_view storageId,
size_t size);

private:
PluginMetaInformation() = default;

std::string name;
std::string author;
std::string version;
std::string license;
std::string buildtimestamp;
std::string description;
std::string storageId;
size_t size{};
};
} // namespace WUPSBackend
22 changes: 13 additions & 9 deletions include/wups_backend/PluginUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
#include <optional>

namespace WUPSBackend {
class PluginUtils {
public:
static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForBuffer(char *buffer, size_t size);

static std::optional<std::unique_ptr<PluginMetaInformation>> getMetaInformationForPath(const std::string &path);
const char *GetStatusStr(PluginBackendApiErrorType err);

static std::vector<std::unique_ptr<PluginContainer>> getLoadedPlugins(uint32_t maxSize);
namespace PluginUtils {

static std::optional<std::unique_ptr<PluginContainer>> getPluginForPath(const std::string &path);
std::optional<PluginMetaInformation> getMetaInformationForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err);

static std::optional<std::unique_ptr<PluginContainer>> getPluginForBuffer(char *buffer, size_t size);
std::optional<PluginMetaInformation> getMetaInformationForPath(const std::string &path, PluginBackendApiErrorType &err);

static int32_t LoadAndLinkOnRestart(const std::vector<std::unique_ptr<PluginContainer>> &plugins);
};
std::vector<PluginContainer> getLoadedPlugins(PluginBackendApiErrorType &err);

std::optional<PluginContainer> getPluginForPath(const std::string &path, PluginBackendApiErrorType &err);

std::optional<PluginContainer> getPluginForBuffer(char *buffer, size_t size, PluginBackendApiErrorType &err);

PluginBackendApiErrorType LoadAndLinkOnRestart(const std::vector<PluginContainer> &plugins);

} // namespace PluginUtils
} // namespace WUPSBackend
26 changes: 11 additions & 15 deletions include/wups_backend/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,33 @@ PluginBackendApiErrorType WUPSBackend_DeInitLibrary();

const char *WUPSBackend_GetStatusStr(PluginBackendApiErrorType status);

PluginBackendApiErrorType WUPSBackend_GetSectionInformationForPlugin(plugin_container_handle handle, plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count);
PluginBackendApiErrorType WUPSBackend_GetSectionInformationForPlugin(wups_backend_plugin_container_handle handle, wups_backend_plugin_section_info *plugin_section_list, uint32_t buffer_size, uint32_t *out_count);

PluginBackendApiErrorType WUPSBackend_GetApiVersion(WUPSBackendAPIVersion *outVersion);

PluginBackendApiErrorType WUPSBackend_GetNumberOfLoadedPlugins(uint32_t *out_count);

PluginBackendApiErrorType WUPSBackend_WillReloadPluginsOnNextLaunch(bool *out);

PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(plugin_container_handle handle, void **textAddress, void **dataAddress);
PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(wups_backend_plugin_container_handle handle, void **textAddress, void **dataAddress);

PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);

PluginBackendApiErrorType WUPSBackend_DeletePluginData(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);
PluginBackendApiErrorType WUPSBackend_DeletePluginData(const wups_backend_plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size);

PluginBackendApiErrorType WUPSBackend_LoadPluginAsData(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_data_handle *out);
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(wups_backend_plugin_data_handle *output, const char *path);

PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(plugin_data_handle *output, const char *path);
PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(wups_backend_plugin_data_handle *output, char *buffer, size_t size);

PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size);
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(wups_backend_plugin_information *output, const char *path);

PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformation(GetPluginInformationInputType inputType, const char *path, char *buffer, size_t size, plugin_information *output);
PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(wups_backend_plugin_information *output, char *buffer, size_t size);

PluginBackendApiErrorType WUPSBackend_WUPSGetPluginMetaInformationByPath(plugin_information *output, const char *path);
PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const wups_backend_plugin_container_handle *plugin_container_handle_list, const wups_backend_plugin_data_handle *plugin_data_list, uint32_t buffer_size);

PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size);
PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const wups_backend_plugin_container_handle *plugin_container_handle_list, wups_backend_plugin_information *plugin_information_list, uint32_t buffer_size);

PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const plugin_data_handle *plugin_data_list, uint32_t buffer_size);

PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size);

PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);
PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const wups_backend_plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version);

#ifdef __cplusplus
}
Expand Down
Loading
Loading