diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.h b/native/cocos/bindings/manual/jsb_conversions_spec.h index f87c420324..12d265e895 100644 --- a/native/cocos/bindings/manual/jsb_conversions_spec.h +++ b/native/cocos/bindings/manual/jsb_conversions_spec.h @@ -386,6 +386,12 @@ bool DownloadTask_to_seval(const cc::network::DownloadTask &v, se::Value *ret); //bool nativevalue_to_se(const cc::TypedArray &typedArray, se::Value &to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) // NOLINT bool nativevalue_to_se(const cc::ArrayBuffer &arrayBuffer, se::Value &to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) // NOLINT +inline bool nativevalue_to_se(cc::ArrayBuffer *arrayBuffer, se::Value &to, se::Object *ctx) { // NOLINT(readability-identifier-naming) // NOLINT + if (arrayBuffer == nullptr) { + return false; + } + return nativevalue_to_se(*arrayBuffer, to, ctx); +} inline bool nativevalue_to_se(const ccstd::vector &from, se::Value &to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) se::HandleObject array{se::Object::createTypedArray(se::Object::TypedArrayType::INT8, from.data(), from.size())}; diff --git a/native/cocos/core/assets/BufferAsset.h b/native/cocos/core/assets/BufferAsset.h index 93f05a8d7e..433a4da525 100644 --- a/native/cocos/core/assets/BufferAsset.h +++ b/native/cocos/core/assets/BufferAsset.h @@ -37,6 +37,9 @@ public: inline ArrayBuffer *getBuffer() const { return _buffer; } + inline void setNativeAssetForJS(ArrayBuffer *buffer) { _buffer = buffer; } + inline ArrayBuffer *getNativeAssetForJS() const { return _buffer; } + ccstd::any getNativeAsset() const override; void setNativeAsset(const ccstd::any &obj) override; bool validate() const override { return _buffer != nullptr; } diff --git a/native/tools/tojs/assets.ini b/native/tools/tojs/assets.ini index 4149768d5e..af13e70cde 100644 --- a/native/tools/tojs/assets.ini +++ b/native/tools/tojs/assets.ini @@ -97,12 +97,13 @@ rename_functions = ICreateInfo::[structInfo=struct], IPassInfoFull::[switch_=switch], Material::[getProperty=_getProperty _props=_propsInternal], EffectAsset::[registerAsset=register], + BufferAsset::[getBuffer=buffer], Skeleton::[getBindposes=_getBindposes setBindposes=_setBindposes] getter_setter= Asset::[_uuid/getUuid/setUuid nativeUrl/getNativeUrl _nativeDep/getNativeDep isDefault/isDefault], ImageAsset::[format url/getUrl?/setUrl?], - BufferAsset::[buffer], + BufferAsset::[_nativeAsset/getNativeAssetForJS/setNativeAssetForJS], TextureBase::[isCompressed/isCompressed _width:width/getWidth/setWidth _height:height/getHeight/setHeight], SimpleTexture::[mipmapLevel/mipmapLevel], RenderTexture::[window],