-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Example of using Meta's c++ JSI codegen #10745
base: main
Are you sure you want to change the base?
Conversation
* in a way that also verifies at compile time that the native module matches the interface required | ||
* by the TurboModule JS spec. | ||
*/ | ||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats wrong with it? -- This should be the NM2 spec for the same module. (We happen to be using the c++ JSI spec to implement it in this case rather than this one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it work? I do not see generated code with the custom attributes. The spec cannot be verified if there are no custom attributes.
We use this project file as a prototype for our Project templates. Could we duplicate this project to demo the JSI modules? I am not sure if we want to add dependencies on Folly and Boost if we use only NM2. Refers to: packages/sample-apps/windows/SampleLibraryCPP/SampleLibraryCPP.vcxproj:2 in 8e2b13b. [](commit_id = 8e2b13b, deletion_comment = False) |
@@ -0,0 +1,87 @@ | |||
/* | |||
* Copyright (c) Meta Platforms, Inc. and affiliates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thats ours... copy/paste error
Yes I agree, I would probably do that when this is for real. But for getting it up and running quickly this was eaiser. -- It also makes it easy to see the missing bits in the vcxproj, whereas having a whole new project it would be harder to see what was different from today to get it running. |
@@ -94,7 +95,7 @@ using SwitchShadowNode = ConcreteViewShadowNode< | |||
SwitchProps, | |||
SwitchEventEmitter>; | |||
|
|||
extern const char UnimplementedNativeViewComponentName[]; | |||
JSI_EXPORT extern const char UnimplementedNativeViewComponentName[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we export these:
JSI_EXPORT=; |
Yes, it makes sense. Thanks! In reply to: 1279342958 |
namespace facebook { | ||
namespace react { | ||
|
||
class JSI_EXPORT NativeMyJsiModuleCxxSpecJSI : public TurboModule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we put generated specs for all modules in a project into one file! It makes sense.
Extracted most of this change into #10909. This code should be turned into a separate project that shows an example of a C++ JSI turbomodule without combining it with the other samples. |
This is a draft PR to show some of the required work and decisions we need to make to support using Meta's C++ JSI codegen in react-native-windows projects.
This shows the required changes to make the SampleLibraryCpp project provide a JSI turbomodule based on Meta's C++ JSI codegen instead of the NM2 codegen.
To do this I added an additional generator to the list of generators that @react-native-windows/codegen runs. -- So that it runs the c++ JSI codegen in addition to the NM2 codegen. If we want to support this, we should decide if we want to always generate that, or have apps opt-in in their
codegenConfig
.Then there were changes required in
SampleLibraryCPP.vcxproj
to allow usage of Folly/boost which is required by the C++ JSI codegen. These changes would probably be something we'd want to generalize and provide to libraries.Microsoft Reviewers: Open in CodeFlow