File tree 3 files changed +12
-18
lines changed
crates/cxx-qt-gen/src/writer/cpp 3 files changed +12
-18
lines changed Original file line number Diff line number Diff line change 6
6
use std:: collections:: BTreeSet ;
7
7
8
8
use crate :: generator:: cpp:: { fragment:: CppFragment , GeneratedCppBlocks } ;
9
- use crate :: writer:: cpp:: namespace_pair ;
9
+ use crate :: writer:: cpp:: namespace_start_and_end ;
10
10
use indoc:: formatdoc;
11
11
12
12
/// Extract the header from a given CppFragment
@@ -43,7 +43,7 @@ fn create_block(block: &str, items: &[String]) -> String {
43
43
//
44
44
// Note that this is needed incase ObjectA refers to ObjectB in it's class
45
45
fn forward_declare ( generated : & GeneratedCppBlocks ) -> Vec < String > {
46
- let ( namespace_start, namespace_end) = namespace_pair ( generated) ;
46
+ let ( namespace_start, namespace_end) = namespace_start_and_end ( & generated. namespace ) ;
47
47
48
48
generated
49
49
. qobjects
@@ -66,7 +66,7 @@ fn forward_declare(generated: &GeneratedCppBlocks) -> Vec<String> {
66
66
67
67
/// For a given GeneratedCppBlocks write the classes
68
68
fn qobjects_header ( generated : & GeneratedCppBlocks ) -> Vec < String > {
69
- let ( namespace_start, namespace_end) = namespace_pair ( generated) ;
69
+ let ( namespace_start, namespace_end) = namespace_start_and_end ( & generated. namespace ) ;
70
70
71
71
generated. qobjects . iter ( ) . map ( |qobject| {
72
72
formatdoc ! { r#"
Original file line number Diff line number Diff line change @@ -12,21 +12,15 @@ use header::write_cpp_header;
12
12
use source:: write_cpp_source;
13
13
14
14
/// For a given GeneratedCppBlocks write the namespace pair
15
- pub fn namespace_pair ( generated : & GeneratedCppBlocks ) -> ( String , String ) {
16
- let namespace_start = if generated . namespace . is_empty ( ) {
17
- "" . to_owned ( )
15
+ pub fn namespace_start_and_end ( namespace : & str ) -> ( String , String ) {
16
+ if namespace. is_empty ( ) {
17
+ ( "" . to_owned ( ) , "" . to_owned ( ) )
18
18
} else {
19
- format ! ( "namespace {namespace} {{" , namespace = generated. namespace)
20
- } ;
21
- let namespace_end = if generated. namespace . is_empty ( ) {
22
- "" . to_owned ( )
23
- } else {
24
- format ! (
25
- "}} // namespace {namespace}" ,
26
- namespace = generated. namespace
19
+ (
20
+ format ! ( "namespace {namespace} {{" ) ,
21
+ format ! ( "}} // namespace {namespace}" ) ,
27
22
)
28
- } ;
29
- ( namespace_start, namespace_end)
23
+ }
30
24
}
31
25
32
26
/// For a given GeneratedCppBlocks write this into a C++ header and source pair
Original file line number Diff line number Diff line change 4
4
// SPDX-License-Identifier: MIT OR Apache-2.0
5
5
6
6
use crate :: generator:: cpp:: { fragment:: CppFragment , GeneratedCppBlocks } ;
7
- use crate :: writer:: cpp:: namespace_pair ;
7
+ use crate :: writer:: cpp:: namespace_start_and_end ;
8
8
use indoc:: formatdoc;
9
9
10
10
/// Extract the source from a given CppFragment
@@ -18,7 +18,7 @@ fn pair_as_source(pair: &CppFragment) -> Option<String> {
18
18
19
19
/// For a given GeneratedCppBlocks write the implementations
20
20
fn qobjects_source ( generated : & GeneratedCppBlocks ) -> Vec < String > {
21
- let ( namespace_start, namespace_end) = namespace_pair ( generated) ;
21
+ let ( namespace_start, namespace_end) = namespace_start_and_end ( & generated. namespace ) ;
22
22
23
23
generated. qobjects . iter ( ) . map ( |qobject| {
24
24
formatdoc ! { r#"
You can’t perform that action at this time.
0 commit comments