You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by Apache Wiki <wi...@apache.org> on 2009/08/31 21:33:41 UTC
[Thrift Wiki] Update of "ThriftGeneration" by RobSlifka
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change notification.
The following page has been changed by RobSlifka:
http://wiki.apache.org/thrift/ThriftGeneration
The comment on the change is:
Honed variable/datatype non-example. Also added overloading non-example.
------------------------------------------------------------------------------
* Run thrift with the options for your language of choice. e.g. `thrift -php myproject.thrift`
* Your files will be generated in a sub directory called e.g. `gen-php`
+ ==== Caveat: Service Method Parameter Naming ====
+
- Note: Make sure you don't name variables the same as their datatype - you WILL run in to trouble.
+ Make sure you don't name variables the same as their datatype - you WILL run in to trouble.
Consider this example BAD CODE:
{{{
- #!/usr/local/bin/thrift -gen cpp
- #
-
- namespace cpp stuff
-
typedef i32 somevariable
service Example {
-
- // Function that takes somevariable called somevariable and returns datatype somevariable
+ // Function that takes somevariable called somevariable
- somevariable regenerate(1:somevarable somevariable),
+ i32 regenerate(1:somevarable somevariable),
}
}}}
@@ -29, +25 @@
Also note that using terms like "new" as a function name will cause errors in the generated code.
+ ==== Caveat: Service Method Name Overloading ====
+
+ Make sure you don't overload service methods.
+
+ {{{
+ service Example {
+ // Two 'regenerate' functions with different arguments
+ i32 regenerate(1:String foo),
+ i32 regenerate(1:i16 bar),
+ }
+ }}}
+
+ Thrift will compile this, however the generated code will NOT compile.
+