Skip to content

Commit

Permalink
Add support for the config and storage API. Bump version to 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Sep 24, 2021
1 parent ed79271 commit 13ed348
Show file tree
Hide file tree
Showing 34 changed files with 28,162 additions and 98 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM wiiuenv/devkitppc:20210917
FROM wiiuenv/devkitppc:20210920

COPY --from=wiiuenv/wiiumodulesystem:20210917 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20210917 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libfunctionpatcher:20210109 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiumodulesystem:20210924 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiupluginsystem:20210924 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libfunctionpatcher:20210924 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libmappedmemory:20210924 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libwupsbackend:20210924 /artifacts $DEVKITPRO

WORKDIR project
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ WUT_ROOT := $(DEVKITPRO)/wut
TARGET := PluginBackend
BUILD := build
SOURCES := source \
source/fs \
source/config \
source/elfio \
source/patcher \
source/plugin \
Expand All @@ -41,9 +43,9 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
CXXFLAGS := $(CFLAGS) -std=c++20

ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld $(WUMSSPECS)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS)

LIBS := -lwums -lwut -lwups -lfunctionpatcher -lz
LIBS := -lwums -lwut -lwups -lfunctionpatcher -lmappedmemory -lfreetype -lbz2 -lpng -lz

#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level
Expand Down Expand Up @@ -93,7 +95,7 @@ export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))

export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
-I$(CURDIR)/$(BUILD) -I$(DEVKITPRO)/portlibs/ppc/include/freetype2

export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

Expand Down
1 change: 1 addition & 0 deletions source/PluginManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void PluginManagement::unloadPlugins(plugin_information_t *gPluginInformation, M
}

void PluginManagement::callInitHooks(plugin_information_t *pluginInformation) {
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_STORAGE);
CallHook(pluginInformation, WUPS_LOADER_HOOK_INIT_PLUGIN);
DEBUG_FUNCTION_LINE_VERBOSE("Done calling init hooks");
}
Expand Down
1 change: 1 addition & 0 deletions source/common/plugin_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct plugin_meta_info_t {
char license[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
char buildTimestamp[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
char descripion[MAXIMUM_PLUGIN_DESCRIPTION_LENGTH] = "";
char id[MAXIMUM_PLUGIN_META_FIELD_LENGTH] = "";
uint32_t size;
};

Expand Down
90 changes: 90 additions & 0 deletions source/config/WUPSConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/****************************************************************************
* Copyright (C) 2018-2021 Maschell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#pragma once

#include <string>
#include <vector>
#include <optional>
#include <wups/config.h>
#include "WUPSConfigCategory.h"
#include "utils/logger.h"

class WUPSConfig {
public:
explicit WUPSConfig(const std::string &name) {
this->name = name;
}

~WUPSConfig() {
for (auto &element : categories) {
delete element;
}
}

/**
\return Returns the name of this WUPSConfig
**/
std::string getName() {
return this->name;
}

/**
\brief Creates a new WUPSCategory add its to this WUPSConfig.
The category will be added to the end of the list.
This class holds responsibility for deleting the created instance.
\param categoryName: The name of the category that will be created.
\return On success, the created and inserted category will be returned.
**/
std::optional<WUPSConfigCategory *> addCategory(const std::string &categoryName) {
auto curCat = new WUPSConfigCategory(categoryName);
if (curCat == nullptr) {
return {};
}
categories.push_back(curCat);
return curCat;
}

/**
\brief Adds a given WUPSConfigCategory to this WUPSConfig.
The category will be added to the end of the list.
This class holds responsibility for deleting the created instance.
\param category: The category that will be added to this config.
\return On success, the inserted category will be returned.
On error NULL will be returned. In this case the caller still has the responsibility
for deleting the WUPSConfigCategory instance.
**/
WUPSConfigCategory *addCategory(WUPSConfigCategory *category) {
categories.push_back(category);
return category;
}

/**
\return Returns a vector with all categories.
**/
const std::vector<WUPSConfigCategory *> &getCategories() {
return this->categories;
}

private:
std::string name;
std::vector<WUPSConfigCategory *> categories = {};
};
73 changes: 73 additions & 0 deletions source/config/WUPSConfigCategory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/****************************************************************************
* Copyright (C) 2018-2021 Maschell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#pragma once

#include <string>
#include <vector>
#include <wups/config.h>
#include "WUPSConfigItem.h"

class WUPSConfigCategory {
public:
explicit WUPSConfigCategory(const std::string &name) {
this->name = name;
}

~WUPSConfigCategory() {
for (auto &element : items) {
delete element;
}
}

/**
\return Returns the name of this WUPSConfigCategory
**/
[[nodiscard]] const std::string &getName() const {
return this->name;
}

/**
\brief Adds a given WUPSConfigItem to this WUPSConfigCategory.
The item will be added to the end of the list.
This class holds responsibility for deleting the created instance.
\param item: The item that will be added to this config.
\return On success, true will be returned.
On error false will be returned. In this case the caller still has the responsibility
for deleting the WUPSConfigItem instance.
**/
[[nodiscard]] bool addItem(WUPSConfigItem *item) {
if(item != nullptr){
items.push_back(item);
return true;
}
return false;
}

/**
\return Returns a vector with all items.
**/
[[nodiscard]] const std::vector<WUPSConfigItem *> &getItems() const {
return this->items;
}

private:
std::string name;
std::vector<WUPSConfigItem *> items{};
};
81 changes: 81 additions & 0 deletions source/config/WUPSConfigCategoryExport.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <wums.h>
#include <wups/config.h>
#include "WUPSConfigCategory.h"
#include "../utils/logger.h"

int32_t WUPSConfigCategory_Create(WUPSConfigCategoryHandle *out, const char *name) {
if (name == nullptr || out == nullptr) {
return -1;
}

*out = (WUPSConfigCategoryHandle) new WUPSConfigCategory(name);
if (*out != 0) {
return 0;
}
return -2;
};

int32_t WUPSConfigCategory_Destroy(WUPSConfigCategoryHandle handle) {
if (handle == 0) {
return -1;
}

auto *config = reinterpret_cast<WUPSConfigCategory *>(handle);
delete config;
return 0;
};

int32_t WUPSConfigCategory_GetName(WUPSConfigCategoryHandle handle, char *out_buf, int32_t out_len) {
if (out_buf == nullptr) {
return -1;
}
auto *config = reinterpret_cast<WUPSConfigCategory *>(handle);
snprintf(out_buf, out_len, "%s", config->getName().c_str());
return 0;
}

int32_t WUPSConfigCategory_AddItem(WUPSConfigCategoryHandle handle, WUPSConfigItemHandle item_Handle) {
if (handle == 0 || item_Handle == 0) {
return -1;
}
auto *category = reinterpret_cast<WUPSConfigCategory *>(handle);
auto *item = reinterpret_cast<WUPSConfigItem *>(item_Handle);
if (category->addItem(item)) {
return 0;
}
return -2;
}
/*
int32_t WUPSConfigCategory_GetItemCount(WUPSConfigCategoryHandle handle, int32_t *item_count) {
if (handle == 0 || item_count == nullptr) {
return -1;
}
auto *config = reinterpret_cast<WUPSConfigCategory *>(handle);
*item_count = config->getItems().size();
return 0;
}
int32_t WUPSConfigCategory_GetItems(WUPSConfigCategoryHandle handle, WUPSConfigItemHandle *items_out, int32_t items_out_size) {
if (handle == 0 || items_out == nullptr || items_out_size == 0) {
return -1;
}
auto *config = reinterpret_cast<WUPSConfigCategory *>(handle);
auto items = config->getItems();
int32_t index = 0;
for (auto const &item: items) {
if (index >= items_out_size) {
break;
}
items_out[index] = (WUPSConfigItemHandle) item;
}
return 0;
}*/

WUMS_EXPORT_FUNCTION(WUPSConfigCategory_Create);
WUMS_EXPORT_FUNCTION(WUPSConfigCategory_Destroy);
WUMS_EXPORT_FUNCTION(WUPSConfigCategory_GetName);
WUMS_EXPORT_FUNCTION(WUPSConfigCategory_AddItem);
/*
WUMS_EXPORT_FUNCTION(WUPSConfigCategory_GetItemCount);
WUMS_EXPORT_FUNCTION(WUPSConfigCategory_GetItems);*/
Loading

0 comments on commit 13ed348

Please sign in to comment.