Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
thrift-gen: Add "namespace go" support.
Currently, if "a.thrift" includes "b.thrift" but "b.thrift" has a "namespace go" declaration, then the Apache Thrift generated code uses the "namespace go" value as the package name. thrift-gen was not respecting the "namespace go" and so the generated code would not compile. This will also help work around the following scenario. If we had: - b/b.thrift which includes: b/shared.thrift - c/c.thrift which includes c/shared.thrift If a.thrift includes "b/b.thrift", everything is OK. As soon as it tries to include "c/c.thrift", everything breaks since the "shared" package is overwritten by the last compiled "shared.thrift". We can work around this by adding a "namespace go" declaration to one of the shared.thrift file to use a unique package for each of the shared.thrift files, without having to rename the file (Which may break a lot of existing code). Fixes #101
- Loading branch information
Showing
6 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
thrift/thrift-gen/test_files/include_test/namespace/a/shared.thrift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace go a_shared | ||
|
||
include "../b/shared.thrift" | ||
|
||
typedef shared.b_string a_string |
3 changes: 3 additions & 0 deletions
3
thrift/thrift-gen/test_files/include_test/namespace/b/shared.thrift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace go b_shared | ||
|
||
typedef string b_string |
5 changes: 5 additions & 0 deletions
5
thrift/thrift-gen/test_files/include_test/namespace/namespace.thrift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include "a/shared.thrift" | ||
|
||
service Foo { | ||
void Foo(1: shared.a_string str) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters