File tree 10 files changed +113
-19
lines changed
10 files changed +113
-19
lines changed Original file line number Diff line number Diff line change 17
17
'core/core.gypi' ,
18
18
'examples/examples.gypi' ,
19
19
'generator/generator.gypi' ,
20
+ 'test/test.gypi' ,
20
21
],
21
22
22
23
'targets' : [
53
54
'<@(core_cpp_files)' ,
54
55
'<@(examples_cpp_files)' ,
55
56
'<@(examples_idl_output_files)' ,
57
+ '<@(test_cpp_files)' ,
58
+ '<@(test_idl_output_files)' ,
56
59
'<(SHARED_INTERMEDIATE_DIR)/bacardi.cc' ,
57
60
],
58
61
'defines' : [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
104
107
'action_name' : 'idl' ,
105
108
'inputs' : [
106
109
'<@(examples_idl_files)' ,
110
+ '<@(test_idl_files)' ,
107
111
],
108
112
'outputs' : [
109
113
'<@(examples_idl_output_files)' ,
114
+ '<@(test_idl_output_files)' ,
110
115
],
111
116
'conditions' : [
112
117
['OS!="win"' ,
Original file line number Diff line number Diff line change @@ -35,15 +35,15 @@ async function generateBacardi(
35
35
[ file . read ( path . resolve ( TEMPLATE_DIR , 'bacardi_cpp.njk' ) ) ] ) ;
36
36
const cpp_file_path = path . resolve ( output_path , 'bacardi.cc' ) ;
37
37
38
- let idl_interface_names : string [ ] = [ ] ;
38
+ let idl_interfaces : IDLDefinition [ ] = [ ] ;
39
39
definitions . forEach ( async ( definition ) => {
40
40
if ( definition . isIDLInterface ( ) ) {
41
- idl_interface_names . push ( definition . name ) ;
41
+ idl_interfaces . push ( definition ) ;
42
42
}
43
43
} ) ;
44
44
45
45
return file . write (
46
- cpp_file_path , env . renderString ( cpp_tmpl , { names : idl_interface_names } ) ) ;
46
+ cpp_file_path , env . renderString ( cpp_tmpl , { interfaces : idl_interfaces } ) ) ;
47
47
}
48
48
49
49
async function generateInterface (
@@ -58,11 +58,11 @@ async function generateInterface(
58
58
if ( definition . isIDLInterface ( ) ) {
59
59
const header_file_path = path . resolve (
60
60
output_path ,
61
- definition . idlDirName ( ) + '/' + snakeCase ( definition . name ) +
61
+ definition . idl_dir_name + '/' + snakeCase ( definition . name ) +
62
62
'_bridge.h' ) ;
63
63
const cpp_file_path = path . resolve (
64
64
output_path ,
65
- definition . idlDirName ( ) + '/' + snakeCase ( definition . name ) +
65
+ definition . idl_dir_name + '/' + snakeCase ( definition . name ) +
66
66
'_bridge.cc' ) ;
67
67
68
68
await file . write (
Original file line number Diff line number Diff line change 16
16
17
17
export default abstract class IDLDefinition {
18
18
public readonly name : string ;
19
+ public readonly idl_base_name : string ;
20
+ public readonly idl_dir_name : string ;
19
21
protected readonly raw_idl_definition_info : { } ;
20
22
21
23
protected constructor ( name : string , raw_idl_definition_info : { } ) {
22
24
this . name = name ;
25
+ this . idl_base_name = raw_idl_definition_info [ 'idlBaseName' ] ;
26
+ this . idl_dir_name = raw_idl_definition_info [ 'idlDirName' ] ;
23
27
this . raw_idl_definition_info = raw_idl_definition_info ;
24
28
}
25
29
@@ -28,12 +32,4 @@ export default abstract class IDLDefinition {
28
32
public isIDLInterface ( ) : boolean {
29
33
return this . raw_idl_definition_info [ 'type' ] == 'interface' ;
30
34
}
31
-
32
- public idlBaseName ( ) : string {
33
- return this . raw_idl_definition_info [ 'idlBaseName' ] ;
34
- }
35
-
36
- public idlDirName ( ) : string {
37
- return this . raw_idl_definition_info [ 'idlDirName' ] ;
38
- }
39
35
}
Original file line number Diff line number Diff line change 19
19
20
20
#include "core/bacardi.h"
21
21
22
- {% for name in names %}
23
- #include "examples /{{ name | snakecase }} _bridge.h"
22
+ {% for interface in interfaces %}
23
+ #include "{{ interface . idl_dir_name }} /{{ interface . name | snakecase }} _bridge.h"
24
24
{% endfor %}
25
25
26
26
void Init(Napi::Env env, Napi::Object exports, Napi::Object module) {
27
- {% for name in names %}
28
- {{ name }} Bridge::Init(env, exports);
27
+ {% for interface in interfaces %}
28
+ {{ interface . name }} Bridge::Init(env, exports);
29
29
{% endfor %}
30
30
}
31
31
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- #include "examples /{{ name | snakecase }} _bridge.h"
17
+ #include "{{ idl_dir_name }} /{{ name | snakecase }} _bridge.h"
18
18
19
19
#include "core/js_type_traits.h"
20
20
#include "core/native_type_traits.h"
Original file line number Diff line number Diff line change 20
20
#include <memory >
21
21
#include <napi .h >
22
22
23
- #include "examples /{{ name | snakecase }} .h"
23
+ #include "{{ idl_dir_name }} /{{ name | snakecase }} .h"
24
24
25
25
class {{ name }} Bridge : public Napi::ObjectWrap<{{ name }} Bridge> {
26
26
public:
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2017 The Bacardi Authors.
2
+ #
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
+ 'variables' : {
17
+ 'test_cpp_files' : [
18
+ 'test_interface.cc' ,
19
+ 'test_interface.h' ,
20
+ ],
21
+
22
+ 'test_idl_files' : [
23
+ '<(module_root_dir)/test/test_interface.idl' ,
24
+ ],
25
+
26
+ 'test_idl_output_files' : [
27
+ '<(SHARED_INTERMEDIATE_DIR)/test/test_interface_bridge.cc' ,
28
+ '<(SHARED_INTERMEDIATE_DIR)/test/test_interface_bridge.h' ,
29
+ ],
30
+ },
31
+ }
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright (c) 2017 The Bacardi Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include " test/test_interface.h"
18
+
19
+ TestInterface::TestInterface () {}
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Copyright (c) 2017 The Bacardi Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef TEST_TEST_INTERFACE_H_
18
+ #define TEST_TEST_INTERFACE_H_
19
+
20
+ class TestInterface {
21
+ public:
22
+ TestInterface ();
23
+ };
24
+
25
+ #endif // TEST_TEST_INTERFACE_H_
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2017 The Bacardi Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ interface TestInterface {
18
+ };
You can’t perform that action at this time.
0 commit comments