|
| 1 | +/* |
| 2 | + * MIT License |
| 3 | + * |
| 4 | + * Copyright (C) 2023 Huawei Device Co., Ltd.2023-2024.All rights reserved. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + */ |
| 24 | +#include "SensorsTurboModule.h" |
| 25 | +#include "RNOH/ArkTSTurboModule.h" |
| 26 | + |
| 27 | +using namespace rnoh; |
| 28 | +using namespace facebook; |
| 29 | + |
| 30 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_accelerometer(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 31 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "accelerometer", args, count); |
| 32 | +} |
| 33 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_gyroscope(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 34 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "gyroscope", args, count); |
| 35 | +} |
| 36 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_magnetometer(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 37 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "magnetometer", args, count); |
| 38 | +} |
| 39 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_barometer(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 40 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "barometer", args, count); |
| 41 | +} |
| 42 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_orientation(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 43 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "orientation", args, count); |
| 44 | +} |
| 45 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_gravity(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 46 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "gravity", args, count); |
| 47 | +} |
| 48 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_off(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 49 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "off", args, count); |
| 50 | +} |
| 51 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_setUpdateInterval(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 52 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "setUpdateInterval", args, count); |
| 53 | +} |
| 54 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_isAvailable(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 55 | + return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "isAvailable", args, count); |
| 56 | +} |
| 57 | +static jsi::Value __hostFunction_RTNSensorsTurboModule_setLogLevel(jsi::Runtime &rt,react::TurboModule &turboModule, const jsi::Value *args, size_t count) { |
| 58 | + return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "setLogLevel", args, count); |
| 59 | +} |
| 60 | + |
| 61 | +RTNSensorsTurboModule::RTNSensorsTurboModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) { |
| 62 | + methodMap_["accelerometer"] = MethodMetadata{0, __hostFunction_RTNSensorsTurboModule_accelerometer}; |
| 63 | + methodMap_["gyroscope"] = MethodMetadata{0, __hostFunction_RTNSensorsTurboModule_gyroscope}; |
| 64 | + methodMap_["magnetometer"] = MethodMetadata{0, __hostFunction_RTNSensorsTurboModule_magnetometer}; |
| 65 | + methodMap_["barometer"] = MethodMetadata{0, __hostFunction_RTNSensorsTurboModule_barometer}; |
| 66 | + methodMap_["orientation"] = MethodMetadata{0, __hostFunction_RTNSensorsTurboModule_orientation}; |
| 67 | + methodMap_["gravity"] = MethodMetadata{0, __hostFunction_RTNSensorsTurboModule_gravity}; |
| 68 | + methodMap_["off"] = MethodMetadata{1, __hostFunction_RTNSensorsTurboModule_off}; |
| 69 | + methodMap_["setUpdateInterval"] = MethodMetadata{2, __hostFunction_RTNSensorsTurboModule_setUpdateInterval}; |
| 70 | + methodMap_["isAvailable"] = MethodMetadata{1, __hostFunction_RTNSensorsTurboModule_isAvailable}; |
| 71 | + methodMap_["setLogLevel"] = MethodMetadata{1, __hostFunction_RTNSensorsTurboModule_setLogLevel}; |
| 72 | +} |
0 commit comments