Skip to content

Commit 6cdbeea

Browse files
authored
refactor:由android codegen版本转为harmony新codegen版本 (#11)
1 parent 2193303 commit 6cdbeea

File tree

7 files changed

+84
-103
lines changed

7 files changed

+84
-103
lines changed

packages/default-storage/harmony/async_storage/src/main/cpp/AsyncStoragePackage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
*/
2424

2525
#include "RNOH/Package.h"
26-
#include "RNAsyncStorageTurboModule.h"
26+
#include "RNCAsyncStorage.h"
2727

2828
using namespace rnoh;
2929
using namespace facebook;
3030
class NativeRNAsyncStorageFactoryDelegate : public TurboModuleFactoryDelegate {
3131
public:
3232
SharedTurboModule createTurboModule(Context ctx,const std::string &name) const override {
3333
if (name == "RNCAsyncStorage") {
34-
return std::make_shared<RNAsyncStorageTurboModule>(ctx, name);
34+
return std::make_shared<RNCAsyncStorage>(ctx, name);
3535
}
3636
return nullptr;
3737
};
@@ -45,4 +45,4 @@ class AsyncStoragePackage : public Package {
4545
return std::make_unique<NativeRNAsyncStorageFactoryDelegate>();
4646
}
4747
};
48-
} // namespace rnoh
48+
} // namespace rnoh

packages/default-storage/harmony/async_storage/src/main/cpp/RNAsyncStorageTurboModule.cpp

Lines changed: 0 additions & 63 deletions
This file was deleted.

packages/default-storage/harmony/async_storage/src/main/cpp/RNAsyncStorageTurboModule.h

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
/**
3+
* This code was generated by "react-native codegen-harmony"
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be
6+
* lost once the code is regenerated.
7+
*
8+
* @generatorVersion: 2
9+
*/
10+
#include "RNCAsyncStorage.h"
11+
12+
namespace rnoh {
13+
using namespace facebook;
14+
15+
RNCAsyncStorage::RNCAsyncStorage(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
16+
methodMap_ = {
17+
ARK_METHOD_METADATA(multiGet, 2),
18+
ARK_METHOD_METADATA(multiSet, 2),
19+
ARK_METHOD_METADATA(multiRemove, 2),
20+
ARK_METHOD_METADATA(multiMerge, 2),
21+
ARK_METHOD_METADATA(getAllKeys, 1),
22+
ARK_METHOD_METADATA(clear, 1),
23+
};
24+
}
25+
26+
} // namespace rnoh
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
/**
3+
* This code was generated by "react-native codegen-harmony"
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be
6+
* lost once the code is regenerated.
7+
*
8+
* @generatorVersion: 2
9+
*/
10+
#pragma once
11+
12+
#include "RNOH/ArkTSTurboModule.h"
13+
14+
namespace rnoh {
15+
16+
class JSI_EXPORT RNCAsyncStorage : public ArkTSTurboModule {
17+
public:
18+
RNCAsyncStorage(const ArkTSTurboModule::Context ctx, const std::string name);
19+
};
20+
21+
} // namespace rnoh
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* This code was generated by "react-native codegen-harmony"
3+
*
4+
* Do not edit this file as changes may cause incorrect behavior and will be
5+
* lost once the code is regenerated.
6+
*
7+
* @generatorVersion: 2
8+
*/
9+
10+
export namespace RNCAsyncStorage {
11+
export const NAME = 'RNCAsyncStorage' as const
12+
13+
export interface Spec {
14+
multiGet(keys: string[], callback: (error: unknown[], result: unknown[]) => void): void;
15+
16+
multiSet(kvPairs: unknown[], callback: (error: unknown[]) => void): void;
17+
18+
multiRemove(keys: string[], callback: (error: unknown[]) => void): void;
19+
20+
multiMerge(kvPairs: unknown[], callback: (error: unknown[]) => void): void;
21+
22+
getAllKeys(callback: (error: unknown[], result: unknown[]) => void): void;
23+
24+
clear(callback: (error: unknown[]) => void): void;
25+
26+
}
27+
}

packages/default-storage/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
"registry": "https://npm.pkg.github.com"
1111
},
1212
"harmony": {
13-
"alias": "@react-native-async-storage/async-storage"
13+
"alias": "@react-native-async-storage/async-storage",
14+
"codegenConfig": {
15+
"version": 2,
16+
"specPaths": [
17+
"./src"
18+
]
19+
}
1420
},
1521
"files": [
1622
"harmony/",

0 commit comments

Comments
 (0)