1 /* 2 * Copyright (c) 2024 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 #include <string> 17 #include <vector> 18 19 #include "SceneJS.h" 20 #include "scene_adapter/scene_bridge.h" 21 #include "SceneJS.h" 22 23 #include "3d_widget_adapter_log.h" 24 25 namespace OHOS::Render3D { 26 UnwrapSceneFromJs(napi_env env,napi_value value)27std::shared_ptr<ISceneAdapter> SceneBridge::UnwrapSceneFromJs(napi_env env, napi_value value) 28 { 29 SceneJS* sceneNapi = nullptr; 30 napi_status status = napi_unwrap(env, value, reinterpret_cast<void**>(&sceneNapi)); 31 if (status != napi_ok) { 32 WIDGET_LOGE("unwrap scene napi from js failed"); 33 return nullptr; 34 } 35 36 if (sceneNapi == nullptr) { 37 WIDGET_LOGD("get scene napi pointer nullptr"); 38 return nullptr; 39 } 40 41 if (!sceneNapi->scene_) { 42 WIDGET_LOGE("sceneNapi->scene_ is nullptr"); 43 } 44 45 return sceneNapi->scene_; 46 } 47 } // namespace OHOS::Render3D 48