Ah yes, that's more consistent.
Single quoting atoms is a bit ugly anyway :)
Here it is again using uncapitalize.
RJ
Index: compiler/cpp/src/generate/t_erl_generator.cc
===================================================================
--- compiler/cpp/src/generate/t_erl_generator.cc (revision 734105)
+++ compiler/cpp/src/generate/t_erl_generator.cc (working copy)
@@ -356,8 +356,9 @@
out << ", ";
hrl_out << ", ";
}
- out << (*m_iter)->get_name();
- hrl_out << (*m_iter)->get_name();
+ std::string name = uncapitalize((*m_iter)->get_name());
+ out << name;
+ hrl_out << name;
}
out << "})." << endl;
hrl_out << "})." << endl;
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Todd Lipcon
Sent: 14 January 2009 22:01
To: [email protected]
Subject: Re: Erlang compiler fix for upper-case records
Hey RJ,
Good catch. In other places we've dealt with this by just lowercasing the
initial character of the term (eg BlahBlah -> blahBlah).
Another option is to quote them with single quotes to force them as atoms,
but that would be a break from the behavior elsewhere in the generator
(which is maintained from the old original erl bindings)
What do you think about just using the existing
t_erl_generator::uncapitalize function rather than the std::transform?
-Todd
On Wed, Jan 14, 2009 at 8:20 AM, Jones, Richard W <[email protected]> wrote:
> The Thrift compiler is producing invalid syntax for the Erlang equivalent
> of structs: -record()
> The names must start with a lower-case character in Erlang to be valid, and
> convention is to make them all lower-case. The patch below lower cases them.
>
> Eg:
> BEFORE: -record(myStruct, {First, Second}).
> AFTER: -record(myStruct, {first, second}).
>
> This is based off svn:
> URL: http://svn.apache.org/repos/asf/incubator/thrift/trunk
> Repository Root: http://svn.apache.org/repos/asf
> Repository UUID: 13f79535-47bb-0310-9956-ffa450edef68
> Revision: 734105
>
> Regards,
> RJ
>
>
>
> Patch:
>
>
> Index: compiler/cpp/src/generate/t_erl_generator.cc
> ===================================================================
> --- compiler/cpp/src/generate/t_erl_generator.cc (revision 734105)
> +++ compiler/cpp/src/generate/t_erl_generator.cc (working copy)
> @@ -8,6 +8,7 @@
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <sstream>
> +#include <algorithm>
> #include "t_erl_generator.h"
> #include "platform.h"
>
> @@ -356,8 +357,10 @@
> out << ", ";
> hrl_out << ", ";
> }
> - out << (*m_iter)->get_name();
> - hrl_out << (*m_iter)->get_name();
> + std::string name = (*m_iter)->get_name();
> + std::transform(name.begin(), name.end(), name.begin(), ::tolower);
> + out << name;
> + hrl_out << name;
> }
> out << "})." << endl;
> hrl_out << "})." << endl;
>