From 399bda52840161bf7d30c09eca061b4378b8f6e4 Mon Sep 17 00:00:00 2001 From: Gabriel Nunes Date: Tue, 4 Feb 2020 19:23:52 -0800 Subject: [PATCH] Fix errors in documentation for Function::callWithThis Summary: The documentation in two out of the three variants of `Function::callWithThis` incorrectly stated that the `this` value was to be `undefined` instead of set to `jsThis`, which contradicts the point of the `callWithThis` method existing in the first place. This diff fixes that issue. Changelog: [General] [Fixed] - Fix documentation comments for HermesJS's `Function::callWithThis` method to accurately reflect how `this` is handled. Reviewed By: jbower-fb Differential Revision: D19714074 fbshipit-source-id: 123688c1f7e578d6356bec54604fb6e30f06b0b1 --- ReactCommon/jsi/jsi/jsi.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ReactCommon/jsi/jsi/jsi.h b/ReactCommon/jsi/jsi/jsi.h index f336bec742ddaf..2309cdaf319e45 100644 --- a/ReactCommon/jsi/jsi/jsi.h +++ b/ReactCommon/jsi/jsi/jsi.h @@ -52,8 +52,8 @@ class StringBuffer : public Buffer { std::string s_; }; -/// PreparedJavaScript is a base class representing JavaScript which is in a form -/// optimized for execution, in a runtime-specific way. Construct one via +/// PreparedJavaScript is a base class representing JavaScript which is in a +/// form optimized for execution, in a runtime-specific way. Construct one via /// jsi::Runtime::prepareJavaScript(). /// ** This is an experimental API that is subject to change. ** class PreparedJavaScript { @@ -827,7 +827,7 @@ class Function : public Object { Value call(Runtime& runtime, Args&&... args) const; /// Calls the function with \c count \c args and \c jsThis value passed - /// as this value. + /// as the \c this value. Value callWithThis( Runtime& Runtime, const Object& jsThis, @@ -835,16 +835,14 @@ class Function : public Object { size_t count) const; /// Calls the function with a \c std::initializer_list of Value - /// arguments. The \c this value of the JS function will be - /// undefined. + /// arguments and \c jsThis passed as the \c this value. Value callWithThis( Runtime& runtime, const Object& jsThis, std::initializer_list args) const; /// Calls the function with any number of arguments similarly to - /// Object::setProperty(). The \c this value of the JS function - /// will be undefined. + /// Object::setProperty(), and with \c jsThis passed as the \c this value. template Value callWithThis(Runtime& runtime, const Object& jsThis, Args&&... args) const;