reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 2a812b5c4995cd2444ab912a11668a5c278203a9
parent 385891cd48efbd2c5e2a35c5632bd6cff015e1b6
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu,  1 Jun 2017 22:19:16 -0400

api: create AboutRepository function

Diffstat:
Msrc/api.cpp | 18++++++++++++++++--
Msrc/api.hpp | 5+++++
Msrc/main.cpp | 3++-
3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/api.cpp b/src/api.cpp @@ -18,15 +18,18 @@ #include "api.hpp" #include <boost/preprocessor.hpp> -#include <cstdint> -#include <cstdio> #include <reaper_plugin_functions.h> +#include "reapack.hpp" +#include "remote.hpp" #include "version.hpp" +using namespace API; using namespace std; +ReaPack *API::reapack = nullptr; + #define API_PREFIX "ReaPack_" APIDef::APIDef(const APIFunc *func) @@ -77,6 +80,17 @@ void APIDef::unregister(const char *key, void *ptr) "APIdef_" API_PREFIX #name, (void *)name::definition, \ } +DEFINE_API(bool, AboutRepository, ((const char*, repoName)), + "Show the about dialog of the given repository. Returns true on success.", +{ + if(const Remote &repo = reapack->remote(repoName)) { + reapack->about(repo); + return true; + } + + return false; +}); + DEFINE_API(bool, CompareVersions, ((const char*, ver1))((const char*, ver2)) ((int*, resultOut))((char*, errorOut))((int, errorOut_sz)), "Compare version numbers. Returns 0 if both versions are equal," diff --git a/src/api.hpp b/src/api.hpp @@ -18,6 +18,8 @@ #ifndef REAPACK_API_HPP #define REAPACK_API_HPP +class ReaPack; + struct APIFunc { const char *cKey; void *cImpl; @@ -41,7 +43,10 @@ private: }; namespace API { + extern APIFunc AboutRepository; extern APIFunc CompareVersions; + + extern ReaPack *reapack; }; #endif diff --git a/src/main.cpp b/src/main.cpp @@ -160,6 +160,7 @@ static void setupActions() static void setupAPI() { + reapack->setupAPI(&API::AboutRepository); reapack->setupAPI(&API::CompareVersions); } @@ -184,7 +185,7 @@ extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT( if(!checkLocation(instance)) return 0; - reapack = new ReaPack(instance); + reapack = API::reapack = new ReaPack(instance); setupActions(); setupAPI();