diff --git a/.github/workflows/native-unit-test.yml b/.github/workflows/native-unit-test.yml index 4a1d3635fc..d394037468 100644 --- a/.github/workflows/native-unit-test.yml +++ b/.github/workflows/native-unit-test.yml @@ -1,4 +1,4 @@ -name: Run Tests +name: Run Unit Tests on: pull_request: diff --git a/native/cocos/bindings/jswrapper/State.cpp b/native/cocos/bindings/jswrapper/State.cpp index aae833cac9..d4c5581914 100644 --- a/native/cocos/bindings/jswrapper/State.cpp +++ b/native/cocos/bindings/jswrapper/State.cpp @@ -25,7 +25,6 @@ ****************************************************************************/ #include "State.h" -#include "Object.h" namespace se { @@ -48,24 +47,4 @@ State::~State() { SAFE_DEC_REF(_thisObject); } -void *State::nativeThisObject() const { - return _thisObject != nullptr ? _thisObject->getPrivateData() : nullptr; -} - -Object *State::thisObject() { - // _nativeThisObject in Static method will be nullptr - // assert(_thisObject != nullptr); - return _thisObject; -} - -const ValueArray &State::args() const { - if (_args != nullptr) { - return *(_args); - } - return EmptyValueArray; -} - -Value &State::rval() { - return _retVal; -} } // namespace se diff --git a/native/cocos/bindings/jswrapper/State.h b/native/cocos/bindings/jswrapper/State.h index 0d8405f330..aa794fef9a 100644 --- a/native/cocos/bindings/jswrapper/State.h +++ b/native/cocos/bindings/jswrapper/State.h @@ -26,6 +26,7 @@ #pragma once +#include "Object.h" #include "PrivateObject.h" #include "Value.h" @@ -42,25 +43,37 @@ public: * @brief Gets void* pointer of `this` object's private data. * @return A void* pointer of `this` object's private data. */ - void *nativeThisObject() const; + inline void *nativeThisObject() const { + return _thisObject != nullptr ? _thisObject->getPrivateData() : nullptr; + } /** * @brief Gets the arguments of native binding functions or accesstors. * @return The arguments of native binding functions or accesstors. */ - const ValueArray &args() const; + inline const ValueArray &args() const { + return _args != nullptr ? (*_args) : EmptyValueArray; + } /** * @brief Gets the JavaScript `this` object wrapped in se::Object. * @return The JavaScript `this` object wrapped in se::Object. */ - Object *thisObject(); + inline Object *thisObject() const { + return _thisObject; + } /** * @brief Gets the return value reference. Used for setting return value for a function. * @return The return value reference. */ - Value &rval(); + inline const Value &rval() const { + return _retVal; + } + + inline Value &rval() { + return _retVal; + } // Private API used in wrapper /**