• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TS框架生成工具IntelliJ插件说明
2
3## 简介
4
5ts(type-script)接口生成工具,它可以根据定义在c++头文件中的接口,生成type-script语言的ts接口文件。目前工具支持可执行文件、IntelliJ插件两种入口,本文主要介绍IntelliJ插件使用说明。
6
7## 目录
8
9	├── napi_generator/src/intellij_plugin/h2dts                   # TS框架代码生成工具
10	│   ├── ...                                                    # 其它文件
11	│   ├── ts_IntelliJ_plugin                                     # IntelliJ插件代码
12	│   │   ├── docs                                               # IntelliJ插件说明
13	│   │   ├── resources                                          # IntelliJ插件所需资源文件
14	│   │   ├── src    				                               # IntelliJ插件源码
15	│   │   └── README_zh                                          # IntelliJ插件说明
16
17## 约束
18
19系统:建议Windows 10
20
21依赖版本:JDK 11
22
23开发工具:DevEco stdio、IDEA Community 2021.3.3
24
25## 使用方法
26
27### 使用对象
28
29系统开发者、应用Native开发者
30
31### 使用场景
32
331) 系统框架层新增子系统,需对应用层提供接口。
342) 系统框架层子系统能力增强后,需对应用层提供新接口。
353) 应用层引入C++三方库,需增加OpenHarmony应用层接口。
36
37### 工具使用
38
39插件下载路径如下,点击download下载。
40
41[下载链接](https://plugins.jetbrains.com/plugin/21420-ts-generator/edit/versions)
42
43具体的工具使用步骤,可以左键单击以下链接了解:
44
45[工具使用说明](https://gitee.com/openharmony/napi_generator/tree/master/src/intellij_plugin/h2dts/ts_IntelliJ_plugin/docs/usage/INSTRUCTION_ZH.md)
46
47### 工具输出
48
49根据使用者指定的.h文件,工具会输出对应的ts接口文件。为了方便使用者快速上手工具,可供测试的test.h文件样例如下:
50
51```
52#include < string >
53	#include < vector >
54	using namespace std;
55
56	class TestA {
57    	public:
58    	char16_t string1;
59    	void add(string v, long double v1[]);
60	};
61	double count(double v, double v1[]);
62
63	namespace Space {
64    	class TestBB {
65        	public:
66        	short string4;
67        	bool ifExist(bool v, bool v1[]);
68	};
69    	uint32_t max(uint32_t v, uint32_t v1[]);
70	}
71```
72
73在window环境下的,根据输入文件test.h,生成的输出文件,如下所示:![](../figures/h-2-ts-succ.png)
74
75其中生成的"test.d.ts"文件,定义了应用开发接口,如下所示:
76
77
78```c++
79declare class TestA {
80	string1: string;
81	add(v: string, v1: Array<number>): void;
82}
83declare namespace Space {
84	function max(v: number, v1: Array<number>): number;
85	class TestBB {
86    	string4: number;
87    	ifExist(v: boolean, v1: Array<boolean>): boolean;
88	}
89}
90declare function count(v: number, v1: Array<number>): number;
91
92export default Space;
93```
94
95## 开发说明
96
97### 对象
98
99工具的开发者
100
101### 开发场景
102
103若当前工具的功能已经不能满足开发者的全部需求,则开发者可以基于已有的源码对工具进行二次开发,来增强工具的能力,编译打包生成自定义的可执行文件和插件。
104
105### 开发步骤
106
107开发者可以根据如下的步骤来完成对工具IntelliJ插件的开发:
108
109 [工具开发说明](https://gitee.com/openharmony/napi_generator/tree/master/src/intellij_plugin/h2dts/ts_IntelliJ_plugin/docs/guide/DEVELOP_ZH.md)
110
111## 版本说明
112
113当前版本已支持的特性和待开发的特性,如下所示:
114
115 [已支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2dts/docs/release-notes/ts_Gen-1.0.md)
116
117 [待支持特性](https://gitee.com/openharmony/napi_generator/blob/master/src/cli/h2dts/docs/requirement/ROADMAP_ZH.md)
118
119## FAQ
120
121对于常见问题解决方法指导如下:
122
123  [FAQ](https://gitee.com/openharmony/napi_generator/tree/master/src/cli/h2dts/docs/guide/FAQ.md)
124
125## 相关仓
126
127暂无