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

Simplified C++ macros and improved their comments #4568

Merged
2 commits merged into from
Apr 10, 2020
Merged

Simplified C++ macros and improved their comments #4568

2 commits merged into from
Apr 10, 2020

Conversation

vmoroz
Copy link
Member

@vmoroz vmoroz commented Apr 10, 2020

Some refactoring around the C++ NativeModule 2.0 macros used as custom attributes.
It helped to remove 3 header files and making the code look smaller.
In this PR we also changed/added comments for the macros in away that they are more friendly for VisualStudio IntelliSense and show the macro signature and parameters as the first line.

Microsoft Reviewers: Open in CodeFlow

@vmoroz vmoroz requested review from jonthysell, acoates-ms, NikoAri and a team April 10, 2020 20:59
@vmoroz vmoroz requested a review from a team as a code owner April 10, 2020 20:59
Copy link

@NikoAri NikoAri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@aeulitz
Copy link
Contributor

aeulitz commented Apr 10, 2020

#ifndef MICROSOFT_REACTNATIVE_STRUCTINFO

Out of curiosity: Why the include guards here, but not in, let's say, ModuleRegistration.h?


Refers to: vnext/Microsoft.ReactNative.Cxx/StructInfo.h:5 in 50419d1. [](commit_id = 50419d1, deletion_comment = False)

@vmoroz vmoroz added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label Apr 10, 2020
@ghost
Copy link

ghost commented Apr 10, 2020

Hello @vmoroz!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 60 minutes, a condition that will be fulfilled in about 32 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@vmoroz
Copy link
Member Author

vmoroz commented Apr 10, 2020

#ifndef MICROSOFT_REACTNATIVE_STRUCTINFO

Good point! I will add them to all other files in another PR.


In reply to: 612224982 [](ancestors = 612224982)


Refers to: vnext/Microsoft.ReactNative.Cxx/StructInfo.h:5 in 50419d1. [](commit_id = 50419d1, deletion_comment = False)


INTERNAL_REACT_RECOMPOSER_3((__VA_ARGS__, INTERNAL_REACT_FIELD_2_ARGS, INTERNAL_REACT_FIELD_1_ARG, ))

// REACT_STRUCT(structType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my education: Is this a known document format (e.g. something Doxygen supports)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not supported by Doxygen. It just makes more visible in the Visual Studio IntelliSense.


In reply to: 406953385 [](ancestors = 406953385)

// Arguments:
// - moduleStruct (required) - the struct name the macro is attached to.
// - moduleName (optional) - the module name visible to JavaScript. Default is the moduleStruct name.
// - eventEmitterName (optional) - the default event emitter name used by REACT_EVENT.
// Default is the RCTDeviceEventEmitter.
//
// REACT_MODULE annotates a C++ struct as a ReactNative module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REACT_MODULE [](start = 3, length = 12)

Nit: Given how overloaded terms like MODULE and INIT are, should we have more specific macro names? Perhaps encode the relation to native modules in the macro prefix somehow (e.g. "REACTNM_" instead of "REACT_")?

// Arguments:
// - structType (required) - the struct name the macro is attached to.
//
// REACT_STRUCT annotates a C++ struct that then can be serialized and deserialized with IJSValueReader and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REACT_STRUCT [](start = 3, length = 12)

Nit: Don't know if this is universally applicable, but a key example to what each one of these macros expands might make all this "magic" less cryptic :-)

@ghost ghost merged commit 5e9ec2a into microsoft:master Apr 10, 2020
asklar pushed a commit to asklar/react-native-windows that referenced this pull request Apr 10, 2020
* Simplified C++ macros and improved their comments

* Change files
ghost pushed a commit that referenced this pull request Apr 22, 2020
* Publish fix

* Creating new Microsoft.ReactNative.sln (#4535)

* Created new Microsoft.ReactNative.sln
* Update PR to build vnext/Microsoft.ReactNative.sln
* Add params to disable ReactUWP nuget pack during PR

* applying package updates ***NO_CI***

* Move playground app to use Microsoft.ReactNative (#4534)

* Move playground app to use Microsoft.ReactNative

* formatting

* Bunch of code review feedback

* Change files

* formatting

* Delete unneeded gitignore

* Minor removal of diff

* Minor changes to try to avoid having to update cert all the time

* Fix bundle command

* No need to build rntester seperately, the release build of playground will do it from msbuild

* Remove test property

* Bump beachball from 1.28.0 to 1.28.1 (#4539)

* applying package updates ***NO_CI***

* applying package updates ***NO_CI***

* Enabling managed unit tests in CI loop (#4532)

* Disable .net native for managed unit tests

* Change files

* Enable managed unit tests in ci loop

* re-merge unit test tasks, can't run arm anyway

* Remove prefer 32bit from 64bit flavors

* Update mstest dependencies

* Managed tests are separate again

* Add comment

* Add test adapter path

* x86 debug again

* Update test adapter folder

* Try again

* remove frameworkuap10

* Switch to appxrecipie

* Try to switch to installed version of vstest

* Remove installer task

* applying package updates ***NO_CI***

* Remove 'Delete Android SDK' from E2ETest (#4554)

* Enable WebSocketModule unit tests (#4538)

* Prototype mockable MessageQueueThread and JSExecutor

* Declare MockJSExecutor::CallFunctionFunctor

* Add missing using std::unique_ptr

* Use WebSocketModule::MethodId

* clang format

* Make WebSocketModule methods override instead of virtual.

* Allow WebSocketModule to use custom resource factory

* Rename *Impl to *Mock

* Move Instance mocks into separate source files

* Move Instance mocks into separate source files

* Change files

* clang format

* Define WebSocketModule::SetResourceFactory

* applying package updates ***NO_CI***

* Improve inner loop and error reporting (local CLI) (#4536)

-Surface msbuild errors (shows as undefined right now)
-downloading nuget with Invoke-WebRequest will usually take a long time because of the PS progress bar (which sadly gets updated for every byte), so I'm disabling the progress bar (it only takes a second to download when the progress bar is turned off)
retry once if nuget failed since if you cancel at just the right time, you could end up with a truncated nuget.exe and are wedged unless you know which file to delete. Learned that the hard way.
-factor out calling onto powershell functions
-we were not exposing whether the function failed or not

* applying package updates ***NO_CI***

* Don't set readyState on connection error (#4562)

* Don't set readyState on connection error

* Change files

* applying package updates ***NO_CI***

* Bump @babel/core from 7.8.4 to 7.9.0 (#4565)

* Simplified C++ macros and improved their comments (#4568)

* Simplified C++ macros and improved their comments

* Change files

* applying package updates ***NO_CI***

* Handle syntax errors in RedBox

* Change files

* format

* clean up

Co-authored-by: Andrew Coates (REDMOND) <acoates@microsoft.com>
Co-authored-by: Jon Thysell <jthysell@microsoft.com>
Co-authored-by: React-Native-Windows Bot <53619745+rnbot@users.noreply.github.com>
Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Julio César Rocha <JunielKatarn@users.noreply.github.com>
Co-authored-by: Vladimir Morozov <vmoroz@users.noreply.github.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants