You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Adam Coffman (JIRA)" <ji...@apache.org> on 2009/06/24 02:25:07 UTC
[jira] Issue Comment Edited: (THRIFT-526) Generated Ruby enums have
no good way to get the names back out once you have a number.
[ https://issues.apache.org/jira/browse/THRIFT-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723379#action_12723379 ]
Adam Coffman edited comment on THRIFT-526 at 6/23/09 5:24 PM:
--------------------------------------------------------------
The patch I submitted generates a hash called VALUE_MAP that maps values back to their names (as strings) in ruby enums. It also includes a test for the added functionality.
was (Author: thecoffman):
Generates a hash called VALUE_MAP that maps values back to their names (as strings) in ruby enums.
Also includes a test.
> Generated Ruby enums have no good way to get the names back out once you have a number.
> ---------------------------------------------------------------------------------------
>
> Key: THRIFT-526
> URL: https://issues.apache.org/jira/browse/THRIFT-526
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Ruby)
> Reporter: Adam Coffman
> Priority: Minor
> Attachments: thrift-526.patch
>
>
> Thrift enums are compiled into Ruby modules as Ruby has no native enum type. This works well except that without maintaining a separate map somewhere else or using reflection, it is impossible to get the names of the values back out from the values themselves. Essentially with this setup:
> module MyModule
> DATAPOINT = 1
> OTHERDATA = 2
> end
> If I have 2, it is very difficult to get "OTHERDATA" back out. It would be easier if thrift generated a static map from constant value to constant name. I am going to try and work on a patch for this.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.