Merging in fixes from release-1.3 branch
authorJaroslav Tulach <jtulach@netbeans.org>
Wed, 02 Mar 2016 03:31:49 +0100
changeset 10758583ce1a062b
parent 1067 6e836197b49e
parent 1074 051f9a22ae7c
child 1076 87cf04c7f663
Merging in fixes from release-1.3 branch
.hgtags
boot-agent-test/pom.xml
boot-fx/pom.xml
boot-script/pom.xml
boot/pom.xml
context/pom.xml
equinox-agentclass-hook/pom.xml
geo/pom.xml
html4j-maven-plugin/pom.xml
json-tck/pom.xml
json/pom.xml
ko-felix-test/pom.xml
ko-osgi-test/pom.xml
ko-ws-tyrus/pom.xml
ko4j/pom.xml
pom.xml
sound/pom.xml
xhr4j/pom.xml
     1.1 --- a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java	Mon Feb 29 19:54:28 2016 +0100
     1.2 +++ b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java	Wed Mar 02 03:31:49 2016 +0100
     1.3 @@ -409,7 +409,6 @@
     1.4  
     1.5      @Model(className = "ConstantModel", targetId = "", builder = "assign", properties = {
     1.6          @Property(name = "doubleValue", mutable = false, type = double.class),
     1.7 -        @Property(name = "longValue", mutable = false, type = long.class),
     1.8          @Property(name = "stringValue", mutable = false, type = String.class),
     1.9          @Property(name = "boolValue", mutable = false, type = boolean.class),
    1.10          @Property(name = "intArray", mutable = false, type = int.class, array = true),
    1.11 @@ -462,28 +461,13 @@
    1.12          Utils.exposeHTML(KnockoutTest.class, "");
    1.13      }
    1.14  
    1.15 -    @KOTest public void nonMutableLong() throws Exception {
    1.16 -        Utils.exposeHTML(KnockoutTest.class,
    1.17 -            "Type: <input id='input' data-bind=\"value: typeof longValue\"></input>\n"
    1.18 -        );
    1.19 -
    1.20 -        ConstantModel model = Models.bind(new ConstantModel(), newContext());
    1.21 -        model.assignStringValue("Hello").assignLongValue(Long.MAX_VALUE);
    1.22 -        model.applyBindings();
    1.23 -
    1.24 -        String v = getSetInput("input", null);
    1.25 -        assertEquals(v, "number", "Right type found: " + v);
    1.26 -
    1.27 -        Utils.exposeHTML(KnockoutTest.class, "");
    1.28 -    }
    1.29 -
    1.30      @KOTest public void nonMutableIntArray() throws Exception {
    1.31          Utils.exposeHTML(KnockoutTest.class,
    1.32              "Type: <input id='input' data-bind=\"value: typeof intArray\"></input>\n"
    1.33          );
    1.34  
    1.35          ConstantModel model = Models.bind(new ConstantModel(), newContext());
    1.36 -        model.assignStringValue("Hello").assignLongValue(Long.MAX_VALUE).assignIntArray(1, 2, 3, 4);
    1.37 +        model.assignStringValue("Hello").assignDoubleValue(Long.MAX_VALUE).assignIntArray(1, 2, 3, 4);
    1.38          model.applyBindings();
    1.39  
    1.40          String v = getSetInput("input", null);
     2.1 --- a/ko4j/src/main/java/org/netbeans/html/ko4j/KOTech.java	Mon Feb 29 19:54:28 2016 +0100
     2.2 +++ b/ko4j/src/main/java/org/netbeans/html/ko4j/KOTech.java	Wed Mar 02 03:31:49 2016 +0100
     2.3 @@ -71,13 +71,14 @@
     2.4  
     2.5      final Object createKO(Object model, Object copyFrom, PropertyBinding[] propArr, FunctionBinding[] funcArr, Knockout[] ko) {
     2.6          String[] propNames = new String[propArr.length];
     2.7 -        Boolean[] propReadOnly = new Boolean[propArr.length];
     2.8 -        Boolean[] propConstant = new Boolean[propArr.length];
     2.9 +        Number[] propInfo = new Number[propArr.length];
    2.10          Object[] propValues = new Object[propArr.length];
    2.11          for (int i = 0; i < propNames.length; i++) {
    2.12              propNames[i] = propArr[i].getPropertyName();
    2.13 -            propReadOnly[i] = propArr[i].isReadOnly();
    2.14 -            propConstant[i] = propArr[i].isConstant();
    2.15 +            int info =
    2.16 +                (propArr[i].isReadOnly() ? 1 : 0) +
    2.17 +                (propArr[i].isConstant()? 2 : 0);
    2.18 +            propInfo[i] = info;
    2.19              Object value = propArr[i].getValue();
    2.20              if (value instanceof Enum) {
    2.21                  value = value.toString();
    2.22 @@ -95,8 +96,7 @@
    2.23          }
    2.24          newKO.wrapModel(
    2.25              ret, copyFrom,
    2.26 -            propNames, propReadOnly, propConstant, propValues,
    2.27 -            funcNames
    2.28 +            propNames, propInfo, propValues, funcNames
    2.29          );
    2.30          return ret;
    2.31      }
     3.1 --- a/ko4j/src/main/java/org/netbeans/html/ko4j/Knockout.java	Mon Feb 29 19:54:28 2016 +0100
     3.2 +++ b/ko4j/src/main/java/org/netbeans/html/ko4j/Knockout.java	Wed Mar 02 03:31:49 2016 +0100
     3.3 @@ -168,9 +168,13 @@
     3.4          javacall = true,
     3.5          keepAlive = false,
     3.6          wait4js = false,
     3.7 -        args = { "ret", "copyFrom", "propNames", "propReadOnly", "propConstant", "propValues", "funcNames" },
     3.8 +        args = { "ret", "copyFrom", "propNames", "propInfo", "propValues", "funcNames" },
     3.9          body = 
    3.10            "Object.defineProperty(ret, 'ko4j', { value : this });\n"
    3.11 +        + "function normalValue(r) {\n"
    3.12 +        + "  if (r) try { var br = r.valueOf(); } catch (err) {}\n"
    3.13 +        + "  return br === undefined ? r: br;\n"
    3.14 +        + "}\n"
    3.15          + "function koComputed(index, name, readOnly, value) {\n"
    3.16          + "  var orig = copyFrom ? copyFrom[name] : null;\n"
    3.17          + "  if (!ko['isObservable'](orig)) {\n"
    3.18 @@ -198,8 +202,7 @@
    3.19          + "        var r = activeGetter();\n"
    3.20          + "        activeGetter = realGetter;\n"
    3.21          + "      }\n"
    3.22 -        + "      if (r) try { var br = r.valueOf(); } catch (err) {}\n"
    3.23 -        + "      return br === undefined ? r: br;\n"
    3.24 +        + "      return normalValue(r);;\n"
    3.25          + "    },\n"
    3.26          + "    'owner': ret\n"
    3.27          + "  };\n"
    3.28 @@ -225,10 +228,10 @@
    3.29          + "  ret[name] = cmpt;\n"
    3.30          + "}\n"
    3.31          + "for (var i = 0; i < propNames.length; i++) {\n"
    3.32 -        + "  if (propConstant[i]) {\n"
    3.33 -        + "    ret[propNames[i]] = propValues[i];\n"
    3.34 +        + "  if ((propInfo[i] & 2) !== 0) {\n"
    3.35 +        + "    ret[propNames[i]] = normalValue(propValues[i]);\n"
    3.36          + "  } else {\n"
    3.37 -        + "    koComputed(i, propNames[i], propReadOnly[i], propValues[i]);\n"
    3.38 +        + "    koComputed(i, propNames[i], (propInfo[i] & 1) !== 0, propValues[i]);\n"
    3.39          + "  }\n"
    3.40          + "}\n"
    3.41          + "function koExpose(index, name) {\n"
    3.42 @@ -244,7 +247,7 @@
    3.43          )
    3.44      native void wrapModel(
    3.45          Object ret, Object copyFrom,
    3.46 -        String[] propNames, Boolean[] propReadOnly, Boolean[] propConstant,
    3.47 +        String[] propNames, Number[] propInfo,
    3.48          Object propValues,
    3.49          String[] funcNames
    3.50      );