From 0b57333dd8019f8874590a1d0dc5e5184c7b157f Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 4 Feb 2012 13:00:49 +0000 Subject: [PATCH] Added C++ plugin SDK. --- Library/Export.h | 87 +------------- Plugins/API/{Rainmeter.cs => RainmeterAPI.cs} | 0 Plugins/API/RainmeterAPI.h | 109 ++++++++++++++++++ 3 files changed, 110 insertions(+), 86 deletions(-) rename Plugins/API/{Rainmeter.cs => RainmeterAPI.cs} (100%) create mode 100644 Plugins/API/RainmeterAPI.h diff --git a/Library/Export.h b/Library/Export.h index f6776ad0..db3e90df 100644 --- a/Library/Export.h +++ b/Library/Export.h @@ -19,95 +19,10 @@ #ifndef __EXPORT_H__ #define __EXPORT_H__ -#ifdef LIBRARY_EXPORTS -#define LIBRARY_EXPORT EXTERN_C -#else -#define LIBRARY_EXPORT EXTERN_C __declspec(dllimport) -#endif // LIBRARY_EXPORTS - -#define PLUGIN_EXPORT EXTERN_C __declspec(dllexport) - -// -// Exported functions -// - -#ifdef __cplusplus -LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE); -#else -LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures); -#endif // __cplusplus - -LIBRARY_EXPORT double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue); - -LIBRARY_EXPORT LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath); - -LIBRARY_EXPORT void __stdcall RmExecute(void* skin, LPCWSTR command); - -LIBRARY_EXPORT void* __stdcall RmGet(void* rm, int type); - -enum RmGetType -{ - RMG_MEASURENAME = 0, - RMG_SKIN = 1, - RMG_SETTINGSFILE = 2 -}; - -LIBRARY_EXPORT BOOL LSLog(int type, LPCWSTR unused, LPCWSTR message); +#include "../Plugins/API/RainmeterAPI.h" /* DEPRECATED */ LIBRARY_EXPORT __declspec(deprecated) LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue); /* DEPRECATED */ LIBRARY_EXPORT __declspec(deprecated) LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data); -// -// Wrapper functions -// - -#ifndef LIBRARY_EXPORTS -__inline LPCWSTR RmReadPath(void* rm, LPCWSTR option, LPCWSTR defValue) -{ - LPCWSTR relativePath = RmReadString(rm, option, defValue, TRUE); - return RmPathToAbsolute(rm, relativePath); -} - -__inline int RmReadInt(void* rm, LPCWSTR option, int defValue) -{ - LPCWSTR value = RmReadString(rm, option, L"", TRUE); - return (*value) ? _wtoi(value) : defValue; -} - -__inline double RmReadDouble(void* rm, LPCWSTR option, double defValue) -{ - LPCWSTR value = RmReadString(rm, option, L"", TRUE); - return (*value) ? wcstod(value, NULL) : defValue; -} - -__inline LPCWSTR RmGetMeasureName(void* rm) -{ - return (LPCWSTR)RmGet(rm, RMG_MEASURENAME); -} - -__inline LPCWSTR RmGetSettingsFile() -{ - return (LPCWSTR)RmGet(NULL, RMG_SETTINGSFILE); -} - -__inline void* RmGetSkin(void* rm) -{ - return (void*)RmGet(rm, RMG_SKIN); -} - -__inline void RmLog(int level, LPCWSTR message) -{ - LSLog(level, NULL, message); -} - -enum LOGLEVEL -{ - LOG_ERROR = 1, - LOG_WARNING = 2, - LOG_NOTICE = 3, - LOG_DEBUG = 4 -}; -#endif // LIBRARY_EXPORTS - #endif diff --git a/Plugins/API/Rainmeter.cs b/Plugins/API/RainmeterAPI.cs similarity index 100% rename from Plugins/API/Rainmeter.cs rename to Plugins/API/RainmeterAPI.cs diff --git a/Plugins/API/RainmeterAPI.h b/Plugins/API/RainmeterAPI.h new file mode 100644 index 00000000..06e1989b --- /dev/null +++ b/Plugins/API/RainmeterAPI.h @@ -0,0 +1,109 @@ +/* + Copyright (C) 2011 Kimmo Pekkola, Birunthan Mohanathas + + 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 2 + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __RAINMETERAPI_H__ +#define __RAINMETERAPI_H__ + +#ifdef LIBRARY_EXPORTS +#define LIBRARY_EXPORT EXTERN_C +#else +#define LIBRARY_EXPORT EXTERN_C __declspec(dllimport) +#endif // LIBRARY_EXPORTS + +#define PLUGIN_EXPORT EXTERN_C __declspec(dllexport) + +// +// Exported functions +// + +#ifdef __cplusplus +LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE); +#else +LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures); +#endif // __cplusplus + +LIBRARY_EXPORT double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue); + +LIBRARY_EXPORT LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath); + +LIBRARY_EXPORT void __stdcall RmExecute(void* skin, LPCWSTR command); + +LIBRARY_EXPORT void* __stdcall RmGet(void* rm, int type); + +enum RmGetType +{ + RMG_MEASURENAME = 0, + RMG_SKIN = 1, + RMG_SETTINGSFILE = 2 +}; + +LIBRARY_EXPORT BOOL LSLog(int type, LPCWSTR unused, LPCWSTR message); + +// +// Wrapper functions +// + +#ifndef LIBRARY_EXPORTS +__inline LPCWSTR RmReadPath(void* rm, LPCWSTR option, LPCWSTR defValue) +{ + LPCWSTR relativePath = RmReadString(rm, option, defValue, TRUE); + return RmPathToAbsolute(rm, relativePath); +} + +__inline int RmReadInt(void* rm, LPCWSTR option, int defValue) +{ + LPCWSTR value = RmReadString(rm, option, L"", TRUE); + return (*value) ? _wtoi(value) : defValue; +} + +__inline double RmReadDouble(void* rm, LPCWSTR option, double defValue) +{ + LPCWSTR value = RmReadString(rm, option, L"", TRUE); + return (*value) ? wcstod(value, NULL) : defValue; +} + +__inline LPCWSTR RmGetMeasureName(void* rm) +{ + return (LPCWSTR)RmGet(rm, RMG_MEASURENAME); +} + +__inline LPCWSTR RmGetSettingsFile() +{ + return (LPCWSTR)RmGet(NULL, RMG_SETTINGSFILE); +} + +__inline void* RmGetSkin(void* rm) +{ + return (void*)RmGet(rm, RMG_SKIN); +} + +__inline void RmLog(int level, LPCWSTR message) +{ + LSLog(level, NULL, message); +} + +enum LOGLEVEL +{ + LOG_ERROR = 1, + LOG_WARNING = 2, + LOG_NOTICE = 3, + LOG_DEBUG = 4 +}; +#endif // LIBRARY_EXPORTS + +#endif