You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Henrique Mendonça (JIRA)" <ji...@apache.org> on 2014/11/14 08:15:34 UTC
[jira] [Updated] (THRIFT-2772) reduce manual maintenance required
for cpp_type & cpp_include
[ https://issues.apache.org/jira/browse/THRIFT-2772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henrique Mendonça updated THRIFT-2772:
--------------------------------------
Priority: Minor (was: Major)
Issue Type: Improvement (was: Bug)
> reduce manual maintenance required for cpp_type & cpp_include
> -------------------------------------------------------------
>
> Key: THRIFT-2772
> URL: https://issues.apache.org/jira/browse/THRIFT-2772
> Project: Thrift
> Issue Type: Improvement
> Components: C++ - Compiler, Compiler (General)
> Reporter: Vitali Lovich
> Priority: Minor
>
> If I want to reference thrift types in a custom unordered_map currently:
> {code}
> // foo.thrift defines Foo
> namespace cpp me::thrift::foo
> // bar.thrift defined Bar
> namespace cpp me::thrift::bar
> // foobar.thrift
> namespace cpp me::thrift
> include "foo.thrift"
> include "bar.thrift"
> cpp_include "<unordered_map>"
> message Foobar {
> map cpp_type "std::unordered_map<foo::Foo, bar::Bar>" <Foo, Bar> mapping;
> }
> {code}
> Downsides:
> * Requires me to have a good rule for generating package names from the get-go.
> * If I change the namespace name, I have to know *all* the spots to update it.
> * If I change the type name, I have to modify it in an extra spot that's not validated by the compiler.
> * I have to duplicate the cpp_include statement across all thrift files & know the mapping.
> A more maintainable mechanism would be a type-mapping file supported by the compiler.
> {code}
> type UnorderedMap<T1, T2> {
> cpp_include = "<unordered_map>"
> cpp_type = "std::unordered_map<$T1, $T2>"
> java_type = "java.util.HashMap"
> }
> {code}
> Then:
> {code}
> include "UnorderedMap.thrift"
> message Foobar {
> UnorderedMap<Foo, Bar> foo;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)