We prepend all of our structs with "Thrift" to avoid this problem, in Java
we put the classes into an AutoGenerated package.
-Amit
On Tue, Sep 23, 2008 at 5:27 PM, Wayne Kao <[EMAIL PROTECTED]> wrote:
> In our .thrift file we have a struct like this:
>
> struct Name{
> 1: string first,
> 2: string middle,
> 3: string last
> }
>
>
> That generates Ruby code like this (used the latest Thrift compiler from
> trunk):
>
> require 'thrift/protocol'
>
> class Name
> include Thrift::Struct
> Thrift::Struct.field_accessor self, :first, :middle, :last
> FIELDS = {
> 1 => {:type => Thrift::Types::STRING, :name => 'first'},
> 2 => {:type => Thrift::Types::STRING, :name => 'middle'},
> 3 => {:type => Thrift::Types::STRING, :name => 'last'}
> }
> end
>
>
> Then, in our main (Rails) app, we include it like this at the top of a
> file:
> $:.push("#{RAILS_ROOT}/../blah/gen-rb")
> require 'Blah'
> require 'blah_constants'
>
> Unfortunately, because Ruby allows reopening classes, if we have another
> class called "Name" (like a Rails model), all sorts of subtle badness
> happens. The person who created the original .thrift file probably doesn't
> notice either since they may not even be a Ruby programmer.
>
> Is there a good pattern for namespacing the generated types such that they
> aren't in the global namespace? Or does everyone just come up with fancy
> naming schemes for their Thrift types (e.g. "BlahName" instead of "Name")?
> Is this something we should try tackling in the compiler?
>
> --Wayne
>
>