Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renames TM spec #12890

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Renames TM spec",
"packageName": "react-native-windows",
"email": "ericroz@meta.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

namespace Microsoft::ReactNative {

ReactNativeSpecs::PlatformConstantsWinSpec_PlatformConstantsWindows PlatformConstants::GetConstants() noexcept {
ReactNativeSpecs::PlatformConstantsWinSpec_PlatformConstantsWindows constants;
ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows PlatformConstants::GetConstants() noexcept {
ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows constants;

// We don't currently treat Native code differently in a test environment
constants.isTesting = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
// Licensed under the MIT License.
#pragma once

#include "codegen/NativePlatformConstantsWinSpec.g.h"
#include "codegen/NativePlatformConstantsWindowsSpec.g.h"
#include <NativeModules.h>

namespace Microsoft::ReactNative {

REACT_MODULE(PlatformConstants)
struct PlatformConstants {
using ModuleSpec = ReactNativeSpecs::PlatformConstantsWinSpec;
using ModuleSpec = ReactNativeSpecs::PlatformConstantsWindowsSpec;

REACT_GET_CONSTANTS(GetConstants)
ReactNativeSpecs::PlatformConstantsWinSpec_PlatformConstantsWindows GetConstants() noexcept;
ReactNativeSpecs::PlatformConstantsWindowsSpec_PlatformConstantsWindows GetConstants() noexcept;
};

} // namespace Microsoft::ReactNative
81 changes: 0 additions & 81 deletions vnext/codegen/NativePlatformConstantsWinSpec.g.h

This file was deleted.

81 changes: 81 additions & 0 deletions vnext/codegen/NativePlatformConstantsWindowsSpec.g.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

/*
* This file is auto-generated from a NativeModule spec file in js.
*
* This is a C++ Spec class that should be used with MakeTurboModuleProvider to register native modules
* in a way that also verifies at compile time that the native module matches the interface required
* by the TurboModule JS spec.
*/
#pragma once

#include <NativeModules.h>
#include <tuple>

namespace Microsoft::ReactNativeSpecs {

struct PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion {
double major;
double minor;
double patch;
std::optional<std::string> prerelease;
};

struct PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion {
double major;
double minor;
double patch;
};

struct PlatformConstantsWindowsSpec_PlatformConstantsWindows {
bool isTesting;
std::optional<bool> isDisableAnimations;
PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion reactNativeVersion;
PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion reactNativeWindowsVersion;
double osVersion;
};


inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion*) noexcept {
winrt::Microsoft::ReactNative::FieldMap fieldMap {
{L"major", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::major},
{L"minor", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::minor},
{L"patch", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::patch},
{L"prerelease", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeVersion::prerelease},
};
return fieldMap;
}

inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion*) noexcept {
winrt::Microsoft::ReactNative::FieldMap fieldMap {
{L"major", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion::major},
{L"minor", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion::minor},
{L"patch", &PlatformConstantsWindowsSpec_PlatformConstantsWindows_reactNativeWindowsVersion::patch},
};
return fieldMap;
}

inline winrt::Microsoft::ReactNative::FieldMap GetStructInfo(PlatformConstantsWindowsSpec_PlatformConstantsWindows*) noexcept {
winrt::Microsoft::ReactNative::FieldMap fieldMap {
{L"isTesting", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::isTesting},
{L"isDisableAnimations", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::isDisableAnimations},
{L"reactNativeVersion", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::reactNativeVersion},
{L"reactNativeWindowsVersion", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::reactNativeWindowsVersion},
{L"osVersion", &PlatformConstantsWindowsSpec_PlatformConstantsWindows::osVersion},
};
return fieldMap;
}

struct PlatformConstantsWindowsSpec : winrt::Microsoft::ReactNative::TurboModuleSpec {
static constexpr auto methods = std::tuple{

};

template <class TModule>
static constexpr void ValidateModule() noexcept {
constexpr auto methodCheckResults = CheckMethods<TModule, PlatformConstantsWindowsSpec>();


}
};

} // namespace Microsoft::ReactNativeSpecs
8 changes: 4 additions & 4 deletions vnext/codegen/rnwcoreJSI-generated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1924,15 +1924,15 @@ NativePlatformConstantsIOSCxxSpecJSI::NativePlatformConstantsIOSCxxSpecJSI(std::
: TurboModule("PlatformConstants", jsInvoker) {
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativePlatformConstantsIOSCxxSpecJSI_getConstants};
}
static jsi::Value __hostFunction_NativePlatformConstantsWinCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativePlatformConstantsWinCxxSpecJSI *>(&turboModule)->getConstants(
static jsi::Value __hostFunction_NativePlatformConstantsWindowsCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativePlatformConstantsWindowsCxxSpecJSI *>(&turboModule)->getConstants(
rt
);
}

NativePlatformConstantsWinCxxSpecJSI::NativePlatformConstantsWinCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
NativePlatformConstantsWindowsCxxSpecJSI::NativePlatformConstantsWindowsCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("PlatformConstants", jsInvoker) {
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativePlatformConstantsWinCxxSpecJSI_getConstants};
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativePlatformConstantsWindowsCxxSpecJSI_getConstants};
}
static jsi::Value __hostFunction_NativePushNotificationManagerIOSCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativePushNotificationManagerIOSCxxSpecJSI *>(&turboModule)->getConstants(
Expand Down
14 changes: 7 additions & 7 deletions vnext/codegen/rnwcoreJSI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5677,17 +5677,17 @@ struct PlatformConstantsPlatformConstantsWindowsBridging {
}
};

class JSI_EXPORT NativePlatformConstantsWinCxxSpecJSI : public TurboModule {
class JSI_EXPORT NativePlatformConstantsWindowsCxxSpecJSI : public TurboModule {
protected:
NativePlatformConstantsWinCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
NativePlatformConstantsWindowsCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);

public:
virtual jsi::Object getConstants(jsi::Runtime &rt) = 0;

};

template <typename T>
class JSI_EXPORT NativePlatformConstantsWinCxxSpec : public TurboModule {
class JSI_EXPORT NativePlatformConstantsWindowsCxxSpec : public TurboModule {
public:
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
return delegate_.get(rt, propName);
Expand All @@ -5696,15 +5696,15 @@ class JSI_EXPORT NativePlatformConstantsWinCxxSpec : public TurboModule {
static constexpr std::string_view kModuleName = "PlatformConstants";

protected:
NativePlatformConstantsWinCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule(std::string{NativePlatformConstantsWinCxxSpec::kModuleName}, jsInvoker),
NativePlatformConstantsWindowsCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule(std::string{NativePlatformConstantsWindowsCxxSpec::kModuleName}, jsInvoker),
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}

private:
class Delegate : public NativePlatformConstantsWinCxxSpecJSI {
class Delegate : public NativePlatformConstantsWindowsCxxSpecJSI {
public:
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
NativePlatformConstantsWinCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {}
NativePlatformConstantsWindowsCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {}

jsi::Object getConstants(jsi::Runtime &rt) override {
static_assert(
Expand Down
4 changes: 2 additions & 2 deletions vnext/overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,9 @@
},
{
"type": "derived",
"file": "src-win/src/private/specs/modules/NativePlatformConstantsWin.js",
"file": "src-win/src/private/specs/modules/NativePlatformConstantsWindows.js",
"baseFile": "packages/react-native/src/private/specs/modules/NativePlatformConstantsAndroid.js",
"baseHash": "b4a125d9134f33aeaba9e06988e18cbb0b4e9e9c"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* @flow strict
*/

export * from '../../src/private/specs/modules/NativePlatformConstantsWin';
import NativePlatformConstantsWin from '../../src/private/specs/modules/NativePlatformConstantsWin';
export * from '../../src/private/specs/modules/NativePlatformConstantsWindows';
import NativePlatformConstantsWin from '../../src/private/specs/modules/NativePlatformConstantsWindows';
export default NativePlatformConstantsWin;