Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 35c7dea

Browse files
786565784@qq.com786565784@qq.com
authored andcommitted
Revert "codegen适配"
This reverts commit 5e5fef7.
1 parent 5e5fef7 commit 35c7dea

30 files changed

+217
-331
lines changed

harmony/sensors.har

898 Bytes
Binary file not shown.

harmony/sensors/BuildProfile.ets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default class BuildProfile {
2+
static readonly HAR_VERSION = '1.0.0';
3+
static readonly BUILD_MODE_NAME = 'debug';
4+
static readonly DEBUG = true;
5+
}

harmony/sensors/Index.ets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from "./ts";
1+
export { MainPage } from './src/main/ets/components/mainpage/MainPage'
2+
export * from './ts'

harmony/sensors/build-profile.json5

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
"targets": [
2424
{
2525
"name": "default"
26-
},
27-
{
28-
"name": "ohosTest"
2926
}
3027
]
3128
}

harmony/sensors/hvigorfile.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export { harTasks } from "@ohos/hvigor-ohos-plugin";
1+
import { harTasks } from '@ohos/hvigor-ohos-plugin';
2+
3+
export default {
4+
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5+
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6+
}

harmony/sensors/oh-package-lock.json5

Lines changed: 4 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

harmony/sensors/oh-package.json5

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
2-
"name": "sensors",
2+
"name": "rnoh-sensors",
33
"version": "1.0.0",
4-
"description": "Please describe the basic information.",
4+
dependencies: {
5+
rnoh: 'file:../rnoh',
6+
},
57
"main": "Index.ets",
68
"author": "",
7-
"license": "Apache-2.0",
8-
"dependencies": {
9-
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
10-
}
9+
"license": "Apache-2.0"
1110
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# the minimum version of CMake
2+
cmake_minimum_required(VERSION 3.13)
3+
set(CMAKE_VERBOSE_MAKEFILE on)
4+
5+
file(GLOB rnoh_sensors_SRC CONFIGURE_DEPENDS *.cpp)
6+
add_library(rnoh_sensors SHARED ${rnoh_sensors_SRC})
7+
target_include_directories(rnoh_sensors PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
8+
target_link_libraries(rnoh_sensors PUBLIC rnoh)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
#ifndef SENSORPACKAGE_H
25+
#define SENSORPACKAGE_H
26+
27+
#include "RNOH/Package.h"
28+
#include "SensorsTurboModule.h"
29+
30+
using namespace rnoh;
31+
using namespace facebook;
32+
class NativeRTNSensorsFactoryDelegate : public TurboModuleFactoryDelegate {
33+
public:
34+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
35+
if (name == "RTNSensors") {
36+
return std::make_shared<RTNSensorsTurboModule>(ctx, name);
37+
}
38+
return nullptr;
39+
}
40+
};
41+
42+
namespace rnoh {
43+
class SensorsPackage : public Package {
44+
public:
45+
SensorsPackage(Package::Context ctx) : Package(ctx) {}
46+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
47+
return std::make_unique<NativeRTNSensorsFactoryDelegate>();
48+
}
49+
};
50+
} // namespace rnoh
51+
#endif
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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

Comments
 (0)