Skip to content

Feat/react native hermes - #312

Closed
qalqi wants to merge 6 commits into
cocos:v4.0.0from
qalqi:feat/react-native-hermes
Closed

Feat/react native hermes#312
qalqi wants to merge 6 commits into
cocos:v4.0.0from
qalqi:feat/react-native-hermes

Conversation

@qalqi

@qalqi qalqi commented Aug 27, 2026

Copy link
Copy Markdown

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

qalqi added 6 commits August 20, 2026 22:19
Implements a complete se::* → facebook::jsi::* adapter so the upstream
Cocos Creator 4 native engine can run on the React Native Hermes runtime
instead of V8/SpiderMonkey.

Changes:
- config.h: add SCRIPT_ENGINE_HERMES = 7 constant
- SeApi.h: add #if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_HERMES include guard
- hermes/Base.h: JSI includes + HermesFinalizeFunc typedef
- hermes/HelperMacros.h: SE_BIND_FUNC / SE_BIND_PROP_GET/SET for JSI callbacks
- hermes/Utils.h/.cpp: bidirectional se::Value <-> jsi::Value conversion,
  native pointer embedding via jsi::NativeState
- hermes/Object.h/.cpp: full se::Object interface over jsi::Object
- hermes/Class.h/.cpp: se::Class proto registration -> jsi::Function constructors
- hermes/ScriptEngine.h/.cpp: se::ScriptEngine singleton with initWithRuntime(jsi::Runtime*)
- hermes/SeApi.h: aggregator header (mirrors v8/SeApi.h structure)

Usage: compile with -DSCRIPT_ENGINE_TYPE=7 in CMakeLists.txt when targeting
       a React Native Hermes context (react-native-uni-cocos package).
The Hermes JSI backend in the Cocos4 submodule was incomplete, causing
undefined symbols when linking libUniCocos.so for the Android wrapper.

- Class.cpp: implement Class::_setCtor(Object*) (was declared but never
  defined for the Hermes backend; only napi/jsvm/v8 provided it).
- Object.cpp: implement se::Object::getAllKeys, the bool
  getArrayLength(uint32_t*) overload, createExternalArrayBufferObject,
  and createProxyTarget. These mirror the existing getTypedArrayData /
  getArrayBufferData stubs already present in this file; they are JSB-only
  paths not reached by the Nitro/TypeGPU app.
- CMakeLists.txt: add the Hermes JSI include dir
  (cocos/bindings/jswrapper + REACT_NATIVE_JSI_DIR) to the cocos_engine
  target so bindings/manual sources compile under USE_SE_HERMES.
- Add toJsiValue/fromJsiValue to se::Value
- Add Hermes 4-arg State constructor
- Conditionally compile JSI conversions under SCRIPT_ENGINE_HERMES
- Fix toJsiValue/fromJsiValue to use se::Object::toJsiObject/createFromJsiObject
- Add public JSI interop methods to Hermes Object
- Fix namespace/constructor issues for Hermes backend
- Add toJsiValue/fromJsiValue to se::Value for Hermes backend
- Add Hermes 4-arg State constructor
- Add public JSI interop methods to Hermes Object
- Include config.h in Value.h for SCRIPT_ENGINE_HERMES guard
- Fix BigInt conversion for JSI (no public createBigIntFromInt64)
@qalqi qalqi closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant