diff options
author | Jonatan Kronqvist <jonatan@vaadin.com> | 2014-05-11 12:38:08 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-05-12 12:05:18 +0000 |
commit | 82033e827fcbfb396886df627a1f8d7c02359e9d (patch) | |
tree | 77f1d451abbe4c294f3c40db721bc37b3898819a /client-compiler | |
parent | 2b60bbb8576b456c11d324b8f8a92d8ade54ffff (diff) | |
download | vaadin-framework-82033e827fcbfb396886df627a1f8d7c02359e9d.tar.gz vaadin-framework-82033e827fcbfb396886df627a1f8d7c02359e9d.zip |
Support long in state again (#13692)
The fix to #9379 broke the support for long type fields in state classes. This
patch bypasses the unboxing of long values and adds the @UnsafeNativeLong annotation
to the methods which may fetch and return (without modifying) long values.
SerializerTest is extended to test the different data types in States.
Change-Id: I29fd2c6af13cd9a0d29ecb1444ed9eb8a2b013e3
Diffstat (limited to 'client-compiler')
-rw-r--r-- | client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java | 4 | ||||
-rw-r--r-- | client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java index 75225c52dc..cc1841ec05 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -189,6 +189,8 @@ public class ConnectorBundleLoaderFactory extends Generator { if (isNative) { outdent(); println("}-*/;"); + // To support fields of type long (#13692) + println("@com.google.gwt.core.client.UnsafeNativeLong"); println("private native void %s(%s) /*-{", newMethod, args); } else { println("%s();", newMethod); @@ -313,6 +315,8 @@ public class ConnectorBundleLoaderFactory extends Generator { // Separate method for loading native JS stuff (e.g. callbacks) String loadNativeJsMethodName = "loadNativeJs"; + // To support fields of type long (#13692) + w.println("@com.google.gwt.core.client.UnsafeNativeLong"); w.println("private native void %s(%s store) /*-{", loadNativeJsMethodName, TypeDataStore.class.getName()); w.indent(); diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java index a31dafe05c..6c242dfd74 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java @@ -45,17 +45,25 @@ public class FieldProperty extends Property { @Override public void writeSetterBody(TreeLogger logger, SourceWriter w, String beanVariable, String valueVariable) { + // Don't try to unbox Longs in javascript, as it's not supported. + // (#13692) + boolean shouldUnbox = !"long".equals(field.getType() + .getSimpleSourceName()); w.println("%s.@%s::%s = %s;", beanVariable, getBeanType() - .getQualifiedSourceName(), getName(), unboxValue(valueVariable)); + .getQualifiedSourceName(), getName(), + shouldUnbox ? unboxValue(valueVariable) : valueVariable); } @Override public void writeGetterBody(TreeLogger logger, SourceWriter w, String beanVariable) { + // Longs are not unboxed, as it's not supported. (#13692) + boolean shouldBox = !"long".equals(field.getType() + .getSimpleSourceName()); String value = String.format("%s.@%s::%s", beanVariable, getBeanType() .getQualifiedSourceName(), getName()); w.print("return "); - w.print(boxValue(value)); + w.print(shouldBox ? boxValue(value) : value); w.println(";"); } |