Feat/react native hermes - #312
Closed
qalqi wants to merge 6 commits into
Closed
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: