google-code-export / protostuff

Automatically exported from code.google.com/p/protostuff
Apache License 2.0
1 stars 1 forks source link

Enums generated as int in javascript #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Define some enum message in proto file
2. Try to instantiate it in gwt code

What version of the product are you using? On what operating system?
GWT 2.0, protostuff 1.0.0.M4

What is the expected output? What do you see instead?
Gwt throws exception:
Something other than a Java object was returned from JSNI method 
'@ru.finam.gwt.charts.client.bean.Candle1$Type::create(I)': JS value of type 
int, expected java.lang.Object

In other words proto enum gets int in javascript object and gwt doesn't like 
that

    public static class Type extends JavaScriptObject {

        public static final Type type1 = create(1);
        public static final Type type2 = create(2);
        public static final Type type3 = create(3);

        private static native Type create(int number) /*-{
            return number;   <-- Exception thrown after this!!!
        }-*/;

        protected Type() {}

        public final native int getNumber() /*-{
            return this;
        }-*/;

    }

Original issue reported on code.google.com by nordlig....@gmail.com on 24 Sep 2010 at 2:06

GoogleCodeExporter commented 9 years ago
Enable the compiler option: dev_mode

See http://code.google.com/p/protostuff/wiki/CompilerOptions

When you deploy, turn off that option.

Original comment by david.yu...@gmail.com on 24 Sep 2010 at 3:47

GoogleCodeExporter commented 9 years ago
thank you very much. missed that option. now it works

Original comment by nordlig....@gmail.com on 24 Sep 2010 at 5:32

GoogleCodeExporter commented 9 years ago
Cool

Original comment by david.yu...@gmail.com on 25 Sep 2010 at 12:34