Example of using Meta's c++ JSI codegen#10745
Example of using Meta's c++ JSI codegen#10745acoates-ms wants to merge 20 commits intomicrosoft:mainfrom
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.
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.
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.
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. |
| SwitchEventEmitter>; | ||
|
|
||
| extern const char UnimplementedNativeViewComponentName[]; | ||
| JSI_EXPORT extern const char UnimplementedNativeViewComponentName[]; |
There was a problem hiding this comment.
There was a problem hiding this comment.
I dont think we export these:
|
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.
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.vcxprojto 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