Skip to content

default values for enums are ignored #20

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. create an enum 
2. create a message with a field using that enum
3. compile the protobuf

What is the expected output? What do you see instead?
the default value will be "-1";
it should be the first-declared value in the enum.

What version of the product are you using? On what operating system?


Please provide any additional information below.

the fix is relatively straight-forward.
in as3_enum_field.cc:
in SetEnumVariables(), change this line:
(*variables)["default"] = type + "." + default_value->name();
to this:
(*variables)["default"] = descriptor->enum_type()->name() + "." + 
default_value->name();

and in EnumFieldGenerator::GenerateMembers(), change this line:
"public var $name$:Number = -1; //No default value for now...\n")
to this:
"public var $name$:Number = $default$;\n");

.. i would also recommend changing enums from Number to int,
but that's an independent issue.

Original issue reported on code.google.com by DocOce...@gmail.com on 19 Jan 2010 at 9:02

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions