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