Skip to content

Conversation

@ZihanChen-MSFT
Copy link
Contributor

@ZihanChen-MSFT ZihanChen-MSFT commented May 26, 2020

  • Create JsiReader and JsiWriter for interface IJSValueReader and IJSValueWriter.
  • Try to keep exactly the same behavior as DynamicReader and DynamicWriter, with a little change, because JSI doesn't support int64_t, and doesn't differentiate integer and double.
  • The code is not tested, I will finish the unit test in another pull request after I figure out how to run dynamic and jsi in ComponentTests.
  • Before ReactHost, ABICxxModule and ABIViewManager have a turbo module version, JsiReader and JsiWriter will not be called in the project.
Microsoft Reviewers: Open in CodeFlow

@ZihanChen-MSFT ZihanChen-MSFT requested a review from a team as a code owner May 26, 2020 20:52
@ZihanChen-MSFT ZihanChen-MSFT added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label May 26, 2020
@ghost
Copy link

ghost commented May 26, 2020

Hello @ZihanChen-MSFT!

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 10 hours. 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

vmoroz commented May 26, 2020

Could you add unit tests?

@ZihanChen-MSFT
Copy link
Contributor Author

Could you add unit tests?

Before getting ChakraRuntime run in the ComponentTests project, it is not possible to write unit test. I will investigate about this in the short future.

Copy link
Member

@vmoroz vmoroz left a comment

Choose a reason for hiding this comment

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

:shipit:

<DependentUpon>IReactNotificationService.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="JsiReader.cpp">
Copy link
Member

Choose a reason for hiding this comment

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

<ClC [](start = 4, length = 4)

It seems that the PR is missing changes to the MS.RN.vcsproj.filters file.

Copy link
Contributor Author

@ZihanChen-MSFT ZihanChen-MSFT May 26, 2020

Choose a reason for hiding this comment

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

Visual Studio doesn't change the filters file, the reason could be that, all added files have already been made depending on idl files in vcxproj, so there is nothing to be added to filters.

} else if (value.isString() || value.isBool() || value.isNumber()) {
m_currentPrimitiveValue = {m_runtime, value};
} else {
m_currentPrimitiveValue = facebook::jsi::Value::null();
Copy link
Member

Choose a reason for hiding this comment

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

Should we assert that we have exhaused the options?
I.e. add cases for undefined and null. i.e. internally JSI has:

  enum ValueKind {
    UndefinedKind,
    NullKind,
    BooleanKind,
    NumberKind,
    SymbolKind,
    StringKind,
    ObjectKind,
    PointerKind = SymbolKind,
  };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in DynamicReader, everything that is not recognizable becomes null. Here I use the same logic. For anything that is not an Object, it will be store in m_currentPrimitiveValue. In here everything other than Object/String/Boolean/Number, becomes null.

if (obj.isArray(m_runtime)) {
m_containers.push_back(obj.getArray(m_runtime));
} else {
m_containers.push_back({m_runtime, std::move(obj)});
Copy link
Member

Choose a reason for hiding this comment

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

not sure about the design, but functions would fall into this case as well. Should we have a check for that?
i.e. use:

  /// \return true iff the Object is callable.  If so, then \c
  /// getFunction will succeed.
  bool isFunction(Runtime& runtime) const {
    return runtime.isFunction(*this);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case properties of Function will get enumerated. There are still other cases, you are not able to check all system classes. But this is fine, if users use our codegen, they won't be able to do this in TypeScript.

Copy link
Member

@dannyvv dannyvv left a comment

Choose a reason for hiding this comment

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

:shipit:

@ghost ghost merged commit ed809a4 into microsoft:master May 27, 2020
@dannyvv dannyvv linked an issue Jun 2, 2020 that may be closed by this pull request
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.

Implement JSIReader/JSIWriter

3 participants