mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
* fixed #12151: [optimization] Functions in se::State should be inlined * Update native-unit-test.yml
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: <Native> Run Tests
|
||||
name: <Native> Run Unit Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user