From dca579592923a1e70a49b4412687893ca986ff69 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 12 Jul 2013 22:55:44 +0300 Subject: [PATCH] Plugin API: Add RmReplaceVariables function --- Library/Export.cpp | 11 +++++++++++ Library/Exports.def | 2 ++ Plugins/API/RainmeterAPI.cs | 9 +++++++++ Plugins/API/RainmeterAPI.h | 2 ++ Plugins/API/x32/Rainmeter.lib | Bin 3860 -> 4168 bytes Plugins/API/x64/Rainmeter.lib | Bin 3748 -> 4070 bytes 6 files changed, 24 insertions(+) diff --git a/Library/Export.cpp b/Library/Export.cpp index 870a772e..43fc0fbc 100644 --- a/Library/Export.cpp +++ b/Library/Export.cpp @@ -46,6 +46,17 @@ double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue) return parser.ReadFloat(measure->GetName(), option, defValue); } +LPCWSTR __stdcall RmReplaceVariables(void* rm, LPCWSTR str) +{ + NULLCHECK(str); + + MeasurePlugin* measure = (MeasurePlugin*)rm; + ConfigParser& parser = measure->GetMeterWindow()->GetParser(); + g_Buffer = str; + parser.ReplaceVariables(g_Buffer); + return g_Buffer.c_str(); +} + LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath) { NULLCHECK(relativePath); diff --git a/Library/Exports.def b/Library/Exports.def index 5a3edafd..6ca08df6 100644 --- a/Library/Exports.def +++ b/Library/Exports.def @@ -2,8 +2,10 @@ LIBRARY EXPORTS ; Note: If new functions are added, the Rainmeter.lib files in Plugins\API\x32 and Plugins\API\x64 ; must be replaced by the corresponding file in Library\x32\Release and Library\x64\Release. + ; Set 'true' in Rainmeter.props first to minimize the .lib size. RmReadString RmReadFormula + RmReplaceVariables RmPathToAbsolute RmExecute RmGet diff --git a/Plugins/API/RainmeterAPI.cs b/Plugins/API/RainmeterAPI.cs index d75e4a7c..a98db1df 100644 --- a/Plugins/API/RainmeterAPI.cs +++ b/Plugins/API/RainmeterAPI.cs @@ -44,6 +44,9 @@ namespace Rainmeter [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)] private extern static unsafe double RmReadFormula(void* rm, char* option, double defValue); + [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)] + private extern static unsafe char* RmReplaceVariables(void* rm, char* str); + [DllImport("Rainmeter.dll", CharSet = CharSet.Auto)] private extern static unsafe char* RmPathToAbsolute(void* rm, char* relativePath); @@ -87,6 +90,12 @@ namespace Rainmeter return (int)RmReadFormula((void*)m_Rm, ToUnsafe(option), defValue); } + public unsafe string ReplaceVariables(string str) + { + char* value = RmReplaceVariables((void*)m_Rm, ToUnsafe(str)); + return new string(value); + } + public unsafe string GetMeasureName() { char* value = (char*)RmGet((void*)m_Rm, 0); diff --git a/Plugins/API/RainmeterAPI.h b/Plugins/API/RainmeterAPI.h index 61b4beb7..d74d08b3 100644 --- a/Plugins/API/RainmeterAPI.h +++ b/Plugins/API/RainmeterAPI.h @@ -39,6 +39,8 @@ LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR LIBRARY_EXPORT double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue); +LIBRARY_EXPORT LPCWSTR __stdcall RmReplaceVariables(void* rm, LPCWSTR str); + LIBRARY_EXPORT LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath); LIBRARY_EXPORT void __stdcall RmExecute(void* skin, LPCWSTR command); diff --git a/Plugins/API/x32/Rainmeter.lib b/Plugins/API/x32/Rainmeter.lib index 54c30b1c966d6c447f8b9f8fb9e74c7bcd2d4732..740250c62d737fdbdaa4223c00d3e279b3db9ce2 100644 GIT binary patch delta 1014 zcma))PiWIn9LK+DoAxCyNdrR*lg;1+#|~~?-Qp->)rp8@&JMH_wpgXeq+?s%#Y@GL zSK)amcV?H^HYRMw9der+6PD zCCM@%V4I|m+M`!bjASYztyFGbuB=z;n~mC|`rTS{t@f}{e_ARn-&nlr-CMj;^+oAE zJa27%(;LK9>=`Gz4P{=5&+JY`Gut%up$a(ESycnt7BEii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