Fixing serialization regression
Change-Id: Ie5cd13d70680c59d321c7bb3715bb8c92f8fd230
diff --git a/src/components/timeline-client.js b/src/components/timeline-client.js
index 3b7e0f6..955d170 100644
--- a/src/components/timeline-client.js
+++ b/src/components/timeline-client.js
@@ -5,6 +5,7 @@
var defineClass = require('../util/define-class');
var ifcx = require('../ifc/conversions');
+var vdlTravel = require('../../ifc');
var destDefs = {
getPlace: function() {
@@ -57,17 +58,17 @@
},
add: function(i) {
- return this.service.add(this.context, ifcx.box(i))
+ return this.service.add(this.context, ifcx.box(i, vdlTravel.Int16))
.then(this.getDestination);
},
get: function(i) {
- return this.service.get(this.context, ifcx.box(i))
+ return this.service.get(this.context, ifcx.box(i, vdlTravel.Int16))
.then(this.getDestinationOrDestinations);
},
remove: function(i) {
- return this.service.remove(this.context, ifcx.box(i))
+ return this.service.remove(this.context, ifcx.box(i, vdlTravel.Int16))
.then(this.getDestination);
},
diff --git a/src/ifc/conversions.js b/src/ifc/conversions.js
index 6a2b8ba..7748f5e 100644
--- a/src/ifc/conversions.js
+++ b/src/ifc/conversions.js
@@ -16,8 +16,8 @@
};
var x = {
- box: function(i) {
- return i === undefined || i === null? i : new vdlTravel.Int16({ value: i });
+ box: function(i, BoxedType) {
+ return i === undefined || i === null? i : new BoxedType({ value: i });
},
unbox: function(ifc) {
@@ -37,8 +37,8 @@
getUrl: function() { return ifc.photoUrl; }
}] : [],
icon: ifc.iconUrl,
- rating: ifc.rating,
- priceLevel: ifc.priceLevel
+ rating: x.unbox(ifc.rating),
+ priceLevel: x.unbox(ifc.priceLevel)
});
},
@@ -56,11 +56,11 @@
formattedAddress: details && details['formatted_address'] ||
placeObj.query,
name: details && details.name,
- photoUrl: details.photos[0]?
+ photoUrl: details.photos && details.photos[0]?
details.photos[0].getUrl(PLACE_PHOTO_OPTS) : '',
iconUrl: details.icon || '',
- rating: details.rating,
- priceLevel: details.priceLevel
+ rating: x.box(details.rating, vdlTravel.Float32),
+ priceLevel: x.box(details.priceLevel, vdlTravel.Byte)
});
},
diff --git a/src/ifc/types.vdl b/src/ifc/types.vdl
index dc5f4ab..46a568b 100644
--- a/src/ifc/types.vdl
+++ b/src/ifc/types.vdl
@@ -14,6 +14,12 @@
}
// required for optional ints
+type Byte struct {
+ Value byte
+}
+type Float32 struct {
+ Value float32
+}
type Int16 struct {
Value int16
}
@@ -42,8 +48,8 @@
Name string
PhotoUrl string
IconUrl string
- Rating float32
- PriceLevel byte
+ Rating ?Float32
+ PriceLevel ?Byte
}
type Event struct {
diff --git a/test/vanadium-wrapper.js b/test/vanadium-wrapper.js
index 6ff997d..da67958 100644
--- a/test/vanadium-wrapper.js
+++ b/test/vanadium-wrapper.js
@@ -32,7 +32,7 @@
return context;
},
function(err) {
- t.fail('init error');
+ t.fail('init error: ' + err);
});
mockVanadium.finishInit(null, mockRuntime);