1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_SHARE_DATA_JS_SHARE_DATA_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_SHARE_DATA_JS_SHARE_DATA_H 18 19 #include "base/memory/ace_type.h" 20 #include "bridge/codec/standard_codec_buffer_operator.h" 21 #include "bridge/declarative_frontend/engine/bindings.h" 22 #include "bridge/declarative_frontend/engine/js_ref_ptr.h" 23 24 namespace OHOS::Ace::Framework { 25 26 class JSShareData : public Referenced { 27 public: 28 explicit JSShareData(int32_t bufferId); 29 ~JSShareData(); 30 31 static void JSBind(BindingTarget globalObj); 32 33 static void Constructor(const JSCallbackInfo& args); 34 static void Destructor(JSShareData* instance); 35 36 private: 37 void ReadInt32(const JSCallbackInfo& info); 38 void ReadInt64(const JSCallbackInfo& info); 39 void ReadDouble(const JSCallbackInfo& info); 40 void ReadString(const JSCallbackInfo& info); 41 void ReadBoolean(const JSCallbackInfo& info); 42 void ReadObject(const JSCallbackInfo& info); 43 void ReleaseShareBufferById(const JSCallbackInfo& info); 44 45 private: 46 int32_t id_; 47 StandardCodecBufferReader* byteBufferPtr_ = nullptr; 48 }; 49 50 } // namespace OHOS::Ace::Framework 51 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_SHARE_DATA_JS_SHARE_DATA_H