Skip to content

Commit

Permalink
[0.69] Fix RuntimeOptions for RNW Desktop (#10016) (#10033)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoroz committed May 28, 2022
1 parent 2102487 commit 59a037b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix RuntimeOptions for RNW Desktop",
"packageName": "react-native-windows",
"email": "vmorozov@microsoft.com",
"dependentChangeType": "patch"
}
9 changes: 6 additions & 3 deletions vnext/Shared/RuntimeOptions.cpp
Expand Up @@ -94,7 +94,7 @@ void __cdecl MicrosoftReactSetRuntimeOptionString(const char *name, const char *
g_runtimeOptionStrings.erase(name);
}

const bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept {
bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept {
scoped_lock lock{g_runtimeOptionsMutex};
auto itr = g_runtimeOptionInts.find(name);
if (itr != g_runtimeOptionInts.end())
Expand All @@ -103,7 +103,7 @@ const bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept
return false;
}

const int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexcept {
int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexcept {
scoped_lock lock{g_runtimeOptionsMutex};
auto itr = g_runtimeOptionInts.find(name);
if (itr != g_runtimeOptionInts.end())
Expand All @@ -112,7 +112,10 @@ const int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexce
return 0;
}

void MicrosoftReactGetRuntimeOptionString(const char *name, MicrosoftReactGetStringCallback callBack, void *state) {
void __cdecl MicrosoftReactGetRuntimeOptionString(
const char *name,
MicrosoftReactGetStringCallback callBack,
void *state) {
scoped_lock lock{g_runtimeOptionsMutex};
auto itr = g_runtimeOptionStrings.find(name);
if (itr != g_runtimeOptionStrings.cend()) {
Expand Down
17 changes: 14 additions & 3 deletions vnext/Shared/RuntimeOptions.h
Expand Up @@ -3,6 +3,10 @@

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

/// <summary>
/// Sets a global boolean value identified by an arbitrary string.
/// </summary>
Expand All @@ -26,14 +30,14 @@ void __cdecl MicrosoftReactSetRuntimeOptionString(const char *name, const char *
/// </summary>
/// <param name="name">Global boolean key</param>
/// <returns>Value stored for the given key, or false if the entry doesn't exist (default)</returns>
const bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept;
bool __cdecl MicrosoftReactGetRuntimeOptionBool(const char *name) noexcept;

/// <summary>
/// Retrieves a global boolean value for the given key.
/// </summary>
/// <param name="name">Global key</param>
/// <returns>Value stored for the given key, or 0 if the entry doesn't exist (default)</returns>
const int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexcept;
int32_t __cdecl MicrosoftReactGetRuntimeOptionInt(const char *name) noexcept;

/// <param name="buffer">String contents. nullptr if none found</param>
/// <param name="length">String length. 0 if none found</param>
Expand All @@ -46,4 +50,11 @@ typedef void(__cdecl *MicrosoftReactGetStringCallback)(const char *buffer, size_
/// <param name="name">Global key</param>
/// <param name="callBack">Handler used to access the obtained string</param>
/// <param name="state">Arbitrary data to pass on to or retrieve from callBack</param>
void MicrosoftReactGetRuntimeOptionString(const char *name, MicrosoftReactGetStringCallback callBack, void *state);
void __cdecl MicrosoftReactGetRuntimeOptionString(
const char *name,
MicrosoftReactGetStringCallback callBack,
void *state);

#ifdef __cplusplus
}
#endif

0 comments on commit 59a037b

Please sign in to comment.