aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/proto2
diff options
context:
space:
mode:
authorGravatar Rogan Creswick <creswick@galois.com>2012-03-30 17:07:02 -0700
committerGravatar Rogan Creswick <creswick@galois.com>2012-03-30 17:07:02 -0700
commitf6ab6622aab00fe7c2f4c3dc41f786ebbe0f0d73 (patch)
tree870111038542cd27153e1396ebdc063573249689 /contexts/data/lib/closure-library/closure/goog/proto2
initial revision
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/proto2')
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/all-wcprops113
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/entries640
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/lazydeserializer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/package_test.pb.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/proto_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/serializer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/test.pb.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/util.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor.js.svn-base198
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor_test.html.svn-base60
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor.js.svn-base291
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor_test.html.svn-base124
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/lazydeserializer.js.svn-base69
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message.js.svn-base740
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message_test.html.svn-base389
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer.js.svn-base159
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer_test.html.svn-base423
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/package_test.pb.js.svn-base165
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer.js.svn-base150
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer_test.html.svn-base267
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/proto_test.html.svn-base693
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/serializer.js.svn-base148
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/test.pb.js.svn-base2820
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer.js.svn-base965
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer_test.html.svn-base530
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/util.js.svn-base54
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/descriptor.js198
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/descriptor_test.html60
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor.js291
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor_test.html124
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/lazydeserializer.js69
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/message.js740
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/message_test.html389
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/objectserializer.js159
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/objectserializer_test.html423
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/package_test.pb.js165
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer.js150
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer_test.html267
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/proto_test.html693
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/serializer.js148
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/test.pb.js2820
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer.js965
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer_test.html530
-rw-r--r--contexts/data/lib/closure-library/closure/goog/proto2/util.js54
56 files changed, 17333 insertions, 0 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/all-wcprops
new file mode 100644
index 0000000..fd0241b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/all-wcprops
@@ -0,0 +1,113 @@
+K 25
+svn:wc:ra_dav:version-url
+V 44
+/svn/!svn/ver/1417/trunk/closure/goog/proto2
+END
+descriptor_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/svn/!svn/ver/850/trunk/closure/goog/proto2/descriptor_test.html
+END
+pbliteserializer.js
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/svn/!svn/ver/1302/trunk/closure/goog/proto2/pbliteserializer.js
+END
+fielddescriptor_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 69
+/svn/!svn/ver/850/trunk/closure/goog/proto2/fielddescriptor_test.html
+END
+serializer.js
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/svn/!svn/ver/850/trunk/closure/goog/proto2/serializer.js
+END
+message_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 62
+/svn/!svn/ver/1255/trunk/closure/goog/proto2/message_test.html
+END
+util.js
+K 25
+svn:wc:ra_dav:version-url
+V 51
+/svn/!svn/ver/850/trunk/closure/goog/proto2/util.js
+END
+textformatserializer_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/svn/!svn/ver/880/trunk/closure/goog/proto2/textformatserializer_test.html
+END
+descriptor.js
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/svn/!svn/ver/850/trunk/closure/goog/proto2/descriptor.js
+END
+test.pb.js
+K 25
+svn:wc:ra_dav:version-url
+V 55
+/svn/!svn/ver/1417/trunk/closure/goog/proto2/test.pb.js
+END
+fielddescriptor.js
+K 25
+svn:wc:ra_dav:version-url
+V 62
+/svn/!svn/ver/933/trunk/closure/goog/proto2/fielddescriptor.js
+END
+lazydeserializer.js
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/svn/!svn/ver/1302/trunk/closure/goog/proto2/lazydeserializer.js
+END
+message.js
+K 25
+svn:wc:ra_dav:version-url
+V 55
+/svn/!svn/ver/1255/trunk/closure/goog/proto2/message.js
+END
+objectserializer_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 70
+/svn/!svn/ver/850/trunk/closure/goog/proto2/objectserializer_test.html
+END
+textformatserializer.js
+K 25
+svn:wc:ra_dav:version-url
+V 68
+/svn/!svn/ver/1417/trunk/closure/goog/proto2/textformatserializer.js
+END
+proto_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 60
+/svn/!svn/ver/1045/trunk/closure/goog/proto2/proto_test.html
+END
+package_test.pb.js
+K 25
+svn:wc:ra_dav:version-url
+V 62
+/svn/!svn/ver/913/trunk/closure/goog/proto2/package_test.pb.js
+END
+objectserializer.js
+K 25
+svn:wc:ra_dav:version-url
+V 63
+/svn/!svn/ver/850/trunk/closure/goog/proto2/objectserializer.js
+END
+pbliteserializer_test.html
+K 25
+svn:wc:ra_dav:version-url
+V 70
+/svn/!svn/ver/850/trunk/closure/goog/proto2/pbliteserializer_test.html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/entries b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/entries
new file mode 100644
index 0000000..9382bd5
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/entries
@@ -0,0 +1,640 @@
+10
+
+dir
+1494
+http://closure-library.googlecode.com/svn/trunk/closure/goog/proto2
+http://closure-library.googlecode.com/svn
+
+
+
+2011-11-21T19:41:31.000000Z
+1417
+jschorr@google.com
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0b95b8e8-c90f-11de-9d4f-f947ee5921c8
+
+descriptor_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.781346Z
+6d4cb4b7b614182ef3e4a68e5e58b567
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1384
+
+pbliteserializer.js
+file
+
+
+
+
+2011-12-23T22:42:29.783346Z
+c71962db068a88f851b1df62f7eb36c6
+2011-09-27T00:20:47.000000Z
+1302
+bmccann@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4109
+
+fielddescriptor_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.783346Z
+3e8c68e3f94109a3a8e749da7b3eac36
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3123
+
+serializer.js
+file
+
+
+
+
+2011-12-23T22:42:29.782346Z
+a87eae1dc2c0c917394842f56d32603c
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4592
+
+message_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.784346Z
+acf0eaa4cd5576ee98ffc303f71bfab3
+2011-08-26T02:46:09.000000Z
+1255
+nmvc@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14273
+
+util.js
+file
+
+
+
+
+2011-12-23T22:42:29.784346Z
+2caab637d924a2bf078f9d94dd7e9fca
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1652
+
+textformatserializer_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.786346Z
+dd8f96fb4dbfc17c15dc8c0061fab307
+2011-04-21T21:11:05.000000Z
+880
+joonlee@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15917
+
+descriptor.js
+file
+
+
+
+
+2011-12-23T22:42:29.785346Z
+4a8c33d99e2a7c3d6874fd24b5ea0309
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5131
+
+test.pb.js
+file
+
+
+
+
+2011-12-23T22:42:29.787346Z
+47c6bc3f81d2a4b0b48e225bbc499197
+2011-11-21T19:41:31.000000Z
+1417
+jschorr@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+69586
+
+fielddescriptor.js
+file
+
+
+
+
+2011-12-23T22:42:29.789346Z
+03970b07c94518397776d97de3eca95c
+2011-05-16T16:12:22.000000Z
+933
+nicksantos@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7491
+
+lazydeserializer.js
+file
+
+
+
+
+2011-12-23T22:42:29.788346Z
+6ebc50fbf6db66b8e0ccd01c46dfa14f
+2011-09-27T00:20:47.000000Z
+1302
+bmccann@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2240
+
+message.js
+file
+
+
+
+
+2011-12-23T22:42:29.789346Z
+327fb6230dc0ee15cbd612af9e13ccc8
+2011-08-26T02:46:09.000000Z
+1255
+nmvc@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+20902
+
+objectserializer_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.791346Z
+b1559e21a41deb69474545b8d9cdd003
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13550
+
+textformatserializer.js
+file
+
+
+
+
+2011-12-23T22:42:29.790346Z
+e9cd494cae384b947c01b6b69930d4c8
+2011-11-21T19:41:31.000000Z
+1417
+jschorr@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+26597
+
+package_test.pb.js
+file
+
+
+
+
+2011-12-23T22:42:29.792346Z
+be25de5bed93da10867bcb42d0b46c14
+2011-05-10T22:21:58.000000Z
+913
+nnaze@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4296
+
+proto_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.792346Z
+a09f5c844225336486f6e87fda8a9550
+2011-06-15T08:34:48.000000Z
+1045
+pallosp@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+28983
+
+objectserializer.js
+file
+
+
+
+
+2011-12-23T22:42:29.793346Z
+d4aefbeb0a3d971cf723be78b51e3860
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4297
+
+pbliteserializer_test.html
+file
+
+
+
+
+2011-12-23T22:42:29.794346Z
+39b8cc076fd99547a7cbb02aeb2de734
+2011-04-12T20:35:47.000000Z
+850
+diegosalas@google.com
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9376
+
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/descriptor_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/fielddescriptor_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/lazydeserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/lazydeserializer.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/lazydeserializer.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/message_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/objectserializer_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/package_test.pb.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/package_test.pb.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/package_test.pb.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/pbliteserializer_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/proto_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/proto_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/proto_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/serializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/serializer.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/serializer.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/test.pb.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/test.pb.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/test.pb.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer_test.html.svn-base
new file mode 100644
index 0000000..d356868
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/textformatserializer_test.html.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+text/html
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/util.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/util.js.svn-base
new file mode 100644
index 0000000..530636b
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/prop-base/util.js.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 15
+text/javascript
+END
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor.js.svn-base
new file mode 100644
index 0000000..eacec09
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor.js.svn-base
@@ -0,0 +1,198 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer (Message) Descriptor class.
+ */
+
+goog.provide('goog.proto2.Descriptor');
+goog.provide('goog.proto2.Metadata');
+
+goog.require('goog.array');
+goog.require('goog.object');
+goog.require('goog.proto2.Util');
+
+
+/**
+ * @typedef {{name: (string|undefined),
+ * fullName: (string|undefined),
+ * containingType: (goog.proto2.Message|undefined)}}
+ */
+goog.proto2.Metadata;
+
+
+
+/**
+ * A class which describes a Protocol Buffer 2 Message.
+ *
+ * @param {Function} messageType Constructor for the message class that
+ * this descriptor describes.
+ * @param {!goog.proto2.Metadata} metadata The metadata about the message that
+ * will be used to construct this descriptor.
+ * @param {Array.<!goog.proto2.FieldDescriptor>} fields The fields of the
+ * message described by this descriptor.
+ *
+ * @constructor
+ */
+goog.proto2.Descriptor = function(messageType, metadata, fields) {
+
+ /**
+ * @type {Function}
+ * @private
+ */
+ this.messageType_ = messageType;
+
+ /**
+ * @type {?string}
+ * @private
+ */
+ this.name_ = metadata.name || null;
+
+ /**
+ * @type {?string}
+ * @private
+ */
+ this.fullName_ = metadata.fullName || null;
+
+ /**
+ * @type {goog.proto2.Message|undefined}
+ * @private
+ */
+ this.containingType_ = metadata.containingType;
+
+ /**
+ * The fields of the message described by this descriptor.
+ * @type {!Object.<number, !goog.proto2.FieldDescriptor>}
+ * @private
+ */
+ this.fields_ = {};
+
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ this.fields_[field.getTag()] = field;
+ }
+};
+
+
+/**
+ * Returns the name of the message, if any.
+ *
+ * @return {?string} The name.
+ */
+goog.proto2.Descriptor.prototype.getName = function() {
+ return this.name_;
+};
+
+
+/**
+ * Returns the full name of the message, if any.
+ *
+ * @return {?string} The name.
+ */
+goog.proto2.Descriptor.prototype.getFullName = function() {
+ return this.fullName_;
+};
+
+
+/**
+ * Returns the descriptor of the containing message type or null if none.
+ *
+ * @return {goog.proto2.Descriptor} The descriptor.
+ */
+goog.proto2.Descriptor.prototype.getContainingType = function() {
+ if (!this.containingType_) {
+ return null;
+ }
+
+ return this.containingType_.getDescriptor();
+};
+
+
+/**
+ * Returns the fields in the message described by this descriptor ordered by
+ * tag.
+ *
+ * @return {!Array.<!goog.proto2.FieldDescriptor>} The array of field
+ * descriptors.
+ */
+goog.proto2.Descriptor.prototype.getFields = function() {
+ /**
+ * @param {!goog.proto2.FieldDescriptor} fieldA First field.
+ * @param {!goog.proto2.FieldDescriptor} fieldB Second field.
+ * @return {number} Negative if fieldA's tag number is smaller, positive
+ * if greater, zero if the same.
+ */
+ function tagComparator(fieldA, fieldB) {
+ return fieldA.getTag() - fieldB.getTag();
+ };
+
+ var fields = goog.object.getValues(this.fields_);
+ goog.array.sort(fields, tagComparator);
+
+ return fields;
+};
+
+
+/**
+ * Returns the fields in the message as a key/value map, where the key is
+ * the tag number of the field.
+ *
+ * @return {!Object.<number, !goog.proto2.FieldDescriptor>} The field map.
+ */
+goog.proto2.Descriptor.prototype.getFieldsMap = function() {
+ return goog.object.clone(this.fields_);
+};
+
+
+/**
+ * Returns the field matching the given name, if any. Note that
+ * this method searches over the *original* name of the field,
+ * not the camelCase version.
+ *
+ * @param {string} name The field name for which to search.
+ *
+ * @return {goog.proto2.FieldDescriptor} The field found, if any.
+ */
+goog.proto2.Descriptor.prototype.findFieldByName = function(name) {
+ var valueFound = goog.object.findValue(this.fields_,
+ function(field, key, obj) {
+ return field.getName() == name;
+ });
+
+ return /** @type {goog.proto2.FieldDescriptor} */ (valueFound) || null;
+};
+
+
+/**
+ * Returns the field matching the given tag number, if any.
+ *
+ * @param {number|string} tag The field tag number for which to search.
+ *
+ * @return {goog.proto2.FieldDescriptor} The field found, if any.
+ */
+goog.proto2.Descriptor.prototype.findFieldByTag = function(tag) {
+ goog.proto2.Util.assert(goog.string.isNumeric(tag));
+ return this.fields_[parseInt(tag, 10)] || null;
+};
+
+
+/**
+ * Creates an instance of the message type that this descriptor
+ * describes.
+ *
+ * @return {goog.proto2.Message} The instance of the message.
+ */
+goog.proto2.Descriptor.prototype.createMessageInstance = function() {
+ return new this.messageType_;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor_test.html.svn-base
new file mode 100644
index 0000000..a06a9fe
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/descriptor_test.html.svn-base
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - descriptor.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.Descriptor');
+ goog.require('goog.testing.jsunit');
+</script>
+</head>
+<body>
+<script>
+
+function testDescriptorConstruction() {
+ var messageType = {};
+ var descriptor = new goog.proto2.Descriptor(messageType, {
+ name: 'test',
+ fullName: 'this.is.a.test'
+ }, []);
+
+ assertEquals('test', descriptor.getName());
+ assertEquals('this.is.a.test', descriptor.getFullName());
+ assertEquals(null, descriptor.getContainingType());
+}
+
+function testParentDescriptor() {
+ var parentType = {};
+ var messageType = {};
+
+ var parentDescriptor = new goog.proto2.Descriptor(parentType, {
+ name: 'parent',
+ fullName: 'this.is.a.parent'
+ }, []);
+
+ parentType.getDescriptor = function() {
+ return parentDescriptor;
+ };
+
+ var descriptor = new goog.proto2.Descriptor(messageType, {
+ name: 'test',
+ fullName: 'this.is.a.test',
+ containingType: parentType
+ }, []);
+
+ assertEquals(parentDescriptor, descriptor.getContainingType());
+}
+
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor.js.svn-base
new file mode 100644
index 0000000..77114f1
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor.js.svn-base
@@ -0,0 +1,291 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer Field Descriptor class.
+ */
+
+goog.provide('goog.proto2.FieldDescriptor');
+
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * A class which describes a field in a Protocol Buffer 2 Message.
+ *
+ * @param {Function} messageType Constructor for the message
+ * class to which the field described by this class belongs.
+ * @param {number|string} tag The field's tag index.
+ * @param {Object} metadata The metadata about this field that will be used
+ * to construct this descriptor.
+ *
+ * @constructor
+ */
+goog.proto2.FieldDescriptor = function(messageType, tag, metadata) {
+ /**
+ * The message type that contains the field that this
+ * descriptor describes.
+ * @type {Function}
+ * @private
+ */
+ this.parent_ = messageType;
+
+ // Ensure that the tag is numeric.
+ goog.proto2.Util.assert(goog.string.isNumeric(tag));
+
+ /**
+ * The field's tag number.
+ * @type {number}
+ * @private
+ */
+ this.tag_ = /** @type {number} */ (tag);
+
+ /**
+ * The field's name.
+ * @type {string}
+ * @private
+ */
+ this.name_ = metadata.name;
+
+ /** @type {goog.proto2.FieldDescriptor.FieldType} */
+ metadata.fieldType;
+
+ /** @type {*} */
+ metadata.repeated;
+
+ /** @type {*} */
+ metadata.required;
+
+ /**
+ * If true, this field is a repeating field.
+ * @type {boolean}
+ * @private
+ */
+ this.isRepeated_ = !!metadata.repeated;
+
+ /**
+ * If true, this field is required.
+ * @type {boolean}
+ * @private
+ */
+ this.isRequired_ = !!metadata.required;
+
+ /**
+ * The field type of this field.
+ * @type {goog.proto2.FieldDescriptor.FieldType}
+ * @private
+ */
+ this.fieldType_ = metadata.fieldType;
+
+ /**
+ * If this field is a primitive: The native (ECMAScript) type of this field.
+ * If an enumeration: The enumeration object.
+ * If a message or group field: The Message function.
+ * @type {Function}
+ * @private
+ */
+ this.nativeType_ = metadata.type;
+
+ /**
+ * Is it permissible on deserialization to convert between numbers and
+ * well-formed strings? Is true for 64-bit integral field types, false for
+ * all other field types.
+ * @type {boolean}
+ * @private
+ */
+ this.deserializationConversionPermitted_ = false;
+
+ switch (this.fieldType_) {
+ case goog.proto2.FieldDescriptor.FieldType.INT64:
+ case goog.proto2.FieldDescriptor.FieldType.UINT64:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SINT64:
+ this.deserializationConversionPermitted_ = true;
+ break;
+ }
+
+ /**
+ * The default value of this field, if different from the default, default
+ * value.
+ * @type {*}
+ * @private
+ */
+ this.defaultValue_ = metadata.defaultValue;
+};
+
+
+/**
+ * An enumeration defining the possible field types.
+ * Should be a mirror of that defined in descriptor.h.
+ *
+ * @enum {number}
+ */
+goog.proto2.FieldDescriptor.FieldType = {
+ DOUBLE: 1,
+ FLOAT: 2,
+ INT64: 3,
+ UINT64: 4,
+ INT32: 5,
+ FIXED64: 6,
+ FIXED32: 7,
+ BOOL: 8,
+ STRING: 9,
+ GROUP: 10,
+ MESSAGE: 11,
+ BYTES: 12,
+ UINT32: 13,
+ ENUM: 14,
+ SFIXED32: 15,
+ SFIXED64: 16,
+ SINT32: 17,
+ SINT64: 18
+};
+
+
+/**
+ * Returns the tag of the field that this descriptor represents.
+ *
+ * @return {number} The tag number.
+ */
+goog.proto2.FieldDescriptor.prototype.getTag = function() {
+ return this.tag_;
+};
+
+
+/**
+ * Returns the descriptor describing the message that defined this field.
+ * @return {goog.proto2.Descriptor} The descriptor.
+ */
+goog.proto2.FieldDescriptor.prototype.getContainingType = function() {
+ return this.parent_.descriptor_;
+};
+
+
+/**
+ * Returns the name of the field that this descriptor represents.
+ * @return {string} The name.
+ */
+goog.proto2.FieldDescriptor.prototype.getName = function() {
+ return this.name_;
+};
+
+
+/**
+ * Returns the default value of this field.
+ * @return {*} The default value.
+ */
+goog.proto2.FieldDescriptor.prototype.getDefaultValue = function() {
+ if (this.defaultValue_ === undefined) {
+ // Set the default value based on a new instance of the native type.
+ // This will be (0, false, "") for (number, boolean, string) and will
+ // be a new instance of a group/message if the field is a message type.
+ var nativeType = this.nativeType_;
+ if (nativeType === Boolean) {
+ this.defaultValue_ = false;
+ } else if (nativeType === Number) {
+ this.defaultValue_ = 0;
+ } else if (nativeType === String) {
+ this.defaultValue_ = '';
+ } else {
+ this.defaultValue_ = new nativeType;
+ }
+ }
+
+ return this.defaultValue_;
+};
+
+
+/**
+ * Returns the field type of the field described by this descriptor.
+ * @return {goog.proto2.FieldDescriptor.FieldType} The field type.
+ */
+goog.proto2.FieldDescriptor.prototype.getFieldType = function() {
+ return this.fieldType_;
+};
+
+
+/**
+ * Returns the native (i.e. ECMAScript) type of the field described by this
+ * descriptor.
+ *
+ * @return {Object} The native type.
+ */
+goog.proto2.FieldDescriptor.prototype.getNativeType = function() {
+ return this.nativeType_;
+};
+
+
+/**
+ * Returns true if simple conversions between numbers and strings are permitted
+ * during deserialization for this field.
+ *
+ * @return {boolean} Whether conversion is permitted.
+ */
+goog.proto2.FieldDescriptor.prototype.deserializationConversionPermitted =
+ function() {
+ return this.deserializationConversionPermitted_;
+};
+
+
+/**
+ * Returns the descriptor of the message type of this field. Only valid
+ * for fields of type GROUP and MESSAGE.
+ *
+ * @return {goog.proto2.Descriptor} The message descriptor.
+ */
+goog.proto2.FieldDescriptor.prototype.getFieldMessageType = function() {
+ goog.proto2.Util.assert(this.isCompositeType(), 'Expected message or group');
+
+ return this.nativeType_.descriptor_;
+};
+
+
+/**
+ * @return {boolean} True if the field stores composite data or repeated
+ * composite data (message or group).
+ */
+goog.proto2.FieldDescriptor.prototype.isCompositeType = function() {
+ return this.fieldType_ == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ this.fieldType_ == goog.proto2.FieldDescriptor.FieldType.GROUP;
+};
+
+
+/**
+ * Returns whether the field described by this descriptor is repeating.
+ * @return {boolean} Whether the field is repeated.
+ */
+goog.proto2.FieldDescriptor.prototype.isRepeated = function() {
+ return this.isRepeated_;
+};
+
+
+/**
+ * Returns whether the field described by this descriptor is required.
+ * @return {boolean} Whether the field is required.
+ */
+goog.proto2.FieldDescriptor.prototype.isRequired = function() {
+ return this.isRequired_;
+};
+
+
+/**
+ * Returns whether the field described by this descriptor is optional.
+ * @return {boolean} Whether the field is optional.
+ */
+goog.proto2.FieldDescriptor.prototype.isOptional = function() {
+ return !this.isRepeated_ && !this.isRequired_;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor_test.html.svn-base
new file mode 100644
index 0000000..bfbe47f
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/fielddescriptor_test.html.svn-base
@@ -0,0 +1,124 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - fielddescriptor.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.Descriptor');
+ goog.require('goog.proto2.FieldDescriptor');
+ goog.require('goog.testing.jsunit');
+</script>
+</head>
+<body>
+<script>
+
+function testFieldDescriptorConstruction() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ repeated: true,
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(10, fieldDescriptor.getTag());
+ assertEquals('test', fieldDescriptor.getName());
+
+ assertEquals(true, fieldDescriptor.isRepeated());
+
+ assertEquals(7, fieldDescriptor.getFieldType());
+ assertEquals(Number, fieldDescriptor.getNativeType());
+ assertEquals(0, fieldDescriptor.getDefaultValue());
+}
+
+function testFieldDescriptorConstruction2() {
+ var fieldDescriptor = new goog.proto2.FieldDescriptor({}, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: String
+ });
+
+ assertEquals('', fieldDescriptor.getDefaultValue());
+}
+
+function testFieldDescriptorConstruction3() {
+ var fieldDescriptor = new goog.proto2.FieldDescriptor({}, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: Boolean
+ });
+
+ assertEquals(false, fieldDescriptor.getDefaultValue());
+}
+
+function testRepeatedField() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ repeated: true,
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(true, fieldDescriptor.isRepeated());
+ assertEquals(false, fieldDescriptor.isRequired());
+ assertEquals(false, fieldDescriptor.isOptional());
+}
+
+function testRequiredField() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ required: true,
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(false, fieldDescriptor.isRepeated());
+ assertEquals(true, fieldDescriptor.isRequired());
+ assertEquals(false, fieldDescriptor.isOptional());
+}
+
+function testOptionalField() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(false, fieldDescriptor.isRepeated());
+ assertEquals(false, fieldDescriptor.isRequired());
+ assertEquals(true, fieldDescriptor.isOptional());
+}
+
+function testContaingType() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: Number
+ });
+
+ var descriptor = new goog.proto2.Descriptor(messageType, {
+ name: 'test_message',
+ fullName: 'this.is.a.test_message'
+ }, [fieldDescriptor]);
+
+ messageType.descriptor_ = descriptor;
+
+ assertEquals(descriptor, fieldDescriptor.getContainingType());
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/lazydeserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/lazydeserializer.js.svn-base
new file mode 100644
index 0000000..50d7506
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/lazydeserializer.js.svn-base
@@ -0,0 +1,69 @@
+// Copyright 2009 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Base class for all PB2 lazy deserializer. A lazy deserializer
+ * is a serializer whose deserialization occurs on the fly as data is
+ * requested. In order to use a lazy deserializer, the serialized form
+ * of the data must be an object or array that can be indexed by the tag
+ * number.
+ *
+ */
+
+goog.provide('goog.proto2.LazyDeserializer');
+
+goog.require('goog.proto2.Serializer');
+goog.require('goog.proto2.Util');
+
+
+
+/**
+ * Base class for all lazy deserializers.
+ *
+ * @constructor
+ * @extends {goog.proto2.Serializer}
+ */
+goog.proto2.LazyDeserializer = function() {};
+goog.inherits(goog.proto2.LazyDeserializer, goog.proto2.Serializer);
+
+
+/** @override */
+goog.proto2.LazyDeserializer.prototype.deserialize =
+ function(descriptor, data) {
+ var message = descriptor.createMessageInstance();
+ message.initializeForLazyDeserializer(this, data);
+ goog.proto2.Util.assert(message instanceof goog.proto2.Message);
+ return message;
+};
+
+
+/** @override */
+goog.proto2.LazyDeserializer.prototype.deserializeTo = function(message, data) {
+ throw new Error('Unimplemented');
+};
+
+
+/**
+ * Deserializes a message field from the expected format and places the
+ * data in the given message
+ *
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {goog.proto2.FieldDescriptor} field The field for which to set the
+ * message value.
+ * @param {*} data The serialized data for the field.
+ *
+ * @return {*} The deserialized data or null for no value found.
+ */
+goog.proto2.LazyDeserializer.prototype.deserializeField = goog.abstractMethod;
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message.js.svn-base
new file mode 100644
index 0000000..db3ffb1
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message.js.svn-base
@@ -0,0 +1,740 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer Message base class.
+ */
+
+goog.provide('goog.proto2.Message');
+
+goog.require('goog.proto2.Descriptor');
+goog.require('goog.proto2.FieldDescriptor');
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * Abstract base class for all Protocol Buffer 2 messages. It will be
+ * subclassed in the code generated by the Protocol Compiler. Any other
+ * subclasses are prohibited.
+ * @constructor
+ */
+goog.proto2.Message = function() {
+ /**
+ * Stores the field values in this message.
+ * @type {*}
+ * @private
+ */
+ this.values_ = {};
+
+ // The descriptor_ is static to the message function that is being created.
+ // Therefore, we retrieve it via the constructor.
+
+ /**
+ * Stores the information (i.e. metadata) about this message.
+ * @type {!goog.proto2.Descriptor}
+ * @private
+ */
+ this.descriptor_ = this.constructor.descriptor_;
+
+ /**
+ * Stores the field information (i.e. metadata) about this message.
+ * @type {Object.<number, !goog.proto2.FieldDescriptor>}
+ * @private
+ */
+ this.fields_ = this.descriptor_.getFieldsMap();
+
+ /**
+ * The lazy deserializer for this message instance, if any.
+ * @type {goog.proto2.LazyDeserializer}
+ * @private
+ */
+ this.lazyDeserializer_ = null;
+
+ /**
+ * A map of those fields deserialized.
+ * @type {Object}
+ * @private
+ */
+ this.deserializedFields_ = null;
+};
+
+
+/**
+ * An enumeration defining the possible field types.
+ * Should be a mirror of that defined in descriptor.h.
+ *
+ * TODO(user): Remove this alias. The code generator generates code that
+ * references this enum, so it needs to exist until the code generator is
+ * changed. The enum was moved to from Message to FieldDescriptor to avoid a
+ * dependency cycle.
+ *
+ * Use goog.proto2.FieldDescriptor.FieldType instead.
+ *
+ * @enum {number}
+ */
+goog.proto2.Message.FieldType = {
+ DOUBLE: 1,
+ FLOAT: 2,
+ INT64: 3,
+ UINT64: 4,
+ INT32: 5,
+ FIXED64: 6,
+ FIXED32: 7,
+ BOOL: 8,
+ STRING: 9,
+ GROUP: 10,
+ MESSAGE: 11,
+ BYTES: 12,
+ UINT32: 13,
+ ENUM: 14,
+ SFIXED32: 15,
+ SFIXED64: 16,
+ SINT32: 17,
+ SINT64: 18
+};
+
+
+/**
+ * Initializes the message with a lazy deserializer and its associated data.
+ * This method should be called by internal methods ONLY.
+ *
+ * @param {goog.proto2.LazyDeserializer} deserializer The lazy deserializer to
+ * use to decode the data on the fly.
+ *
+ * @param {*} data The data to decode/deserialize.
+ */
+goog.proto2.Message.prototype.initializeForLazyDeserializer = function(
+ deserializer, data) {
+
+ this.lazyDeserializer_ = deserializer;
+ this.values_ = data;
+ this.deserializedFields_ = {};
+};
+
+
+/**
+ * Sets the value of an unknown field, by tag.
+ *
+ * @param {number} tag The tag of an unknown field (must be >= 1).
+ * @param {*} value The value for that unknown field.
+ */
+goog.proto2.Message.prototype.setUnknown = function(tag, value) {
+ goog.proto2.Util.assert(!this.fields_[tag],
+ 'Field is not unknown in this message');
+
+ goog.proto2.Util.assert(tag >= 1, 'Tag is not valid');
+ goog.proto2.Util.assert(value !== null, 'Value cannot be null');
+
+ this.values_[tag] = value;
+};
+
+
+/**
+ * Iterates over all the unknown fields in the message.
+ *
+ * @param {function(number, *)} callback A callback method
+ * which gets invoked for each unknown field.
+ * @param {Object=} opt_scope The scope under which to execute the callback.
+ * If not given, the current message will be used.
+ */
+goog.proto2.Message.prototype.forEachUnknown = function(callback, opt_scope) {
+ var scope = opt_scope || this;
+ for (var key in this.values_) {
+ if (!this.fields_[/** @type {number} */ (key)]) {
+ callback.call(scope, Number(key), this.values_[key]);
+ }
+ }
+};
+
+
+/**
+ * Returns the descriptor which describes the current message.
+ *
+ * @return {goog.proto2.Descriptor} The descriptor.
+ */
+goog.proto2.Message.prototype.getDescriptor = function() {
+ return this.descriptor_;
+};
+
+
+/**
+ * Returns whether there is a value stored at the field specified by the
+ * given field descriptor.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to check
+ * if there is a value.
+ *
+ * @return {boolean} True if a value was found.
+ */
+goog.proto2.Message.prototype.has = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.has$Value(field.getTag());
+};
+
+
+/**
+ * Returns the array of values found for the given repeated field.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to
+ * return the values.
+ *
+ * @return {!Array} The values found.
+ */
+goog.proto2.Message.prototype.arrayOf = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.array$Values(field.getTag());
+};
+
+
+/**
+ * Returns the number of values stored in the given field.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to count
+ * the number of values.
+ *
+ * @return {number} The count of the values in the given field.
+ */
+goog.proto2.Message.prototype.countOf = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.count$Values(field.getTag());
+};
+
+
+/**
+ * Returns the value stored at the field specified by the
+ * given field descriptor.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to get the
+ * value.
+ * @param {number=} opt_index If the field is repeated, the index to use when
+ * looking up the value.
+ *
+ * @return {*} The value found or null if none.
+ */
+goog.proto2.Message.prototype.get = function(field, opt_index) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.get$Value(field.getTag(), opt_index);
+};
+
+
+/**
+ * Returns the value stored at the field specified by the
+ * given field descriptor or the default value if none exists.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to get the
+ * value.
+ * @param {number=} opt_index If the field is repeated, the index to use when
+ * looking up the value.
+ *
+ * @return {*} The value found or the default if none.
+ */
+goog.proto2.Message.prototype.getOrDefault = function(field, opt_index) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.get$ValueOrDefault(field.getTag(), opt_index);
+};
+
+
+/**
+ * Stores the given value to the field specified by the
+ * given field descriptor. Note that the field must not be repeated.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to set
+ * the value.
+ * @param {*} value The new value for the field.
+ */
+goog.proto2.Message.prototype.set = function(field, value) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ this.set$Value(field.getTag(), value);
+};
+
+
+/**
+ * Adds the given value to the field specified by the
+ * given field descriptor. Note that the field must be repeated.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field in which to add the
+ * the value.
+ * @param {*} value The new value to add to the field.
+ */
+goog.proto2.Message.prototype.add = function(field, value) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ this.add$Value(field.getTag(), value);
+};
+
+
+/**
+ * Clears the field specified.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field to clear.
+ */
+goog.proto2.Message.prototype.clear = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ this.clear$Field(field.getTag());
+};
+
+
+/**
+ * Compares this message with another one ignoring the unknown fields.
+ * @param {*} other The other message.
+ * @return {boolean} Whether they are equal. Returns false if the {@code other}
+ * argument is a different type of message or not a message.
+ */
+goog.proto2.Message.prototype.equals = function(other) {
+ if (!other || this.constructor != other.constructor) {
+ return false;
+ }
+
+ var fields = this.getDescriptor().getFields();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ if (this.has(field) != other.has(field)) {
+ return false;
+ }
+
+ if (this.has(field)) {
+ var isComposite = field.isCompositeType();
+
+ function fieldsEqual(value1, value2) {
+ return isComposite ? value1.equals(value2) : value1 == value2;
+ }
+
+ var tag = field.getTag();
+ var thisValue = this.values_[tag];
+ var otherValue = other.values_[tag];
+
+ if (field.isRepeated()) {
+ // In this case thisValue and otherValue are arrays.
+ if (thisValue.length != otherValue.length) {
+ return false;
+ }
+ for (var j = 0; j < thisValue.length; j++) {
+ if (!fieldsEqual(thisValue[j], otherValue[j])) {
+ return false;
+ }
+ }
+ } else if (!fieldsEqual(thisValue, otherValue)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+};
+
+
+/**
+ * Recursively copies the known fields from the given message to this message.
+ * Removes the fields which are not present in the source message.
+ * @param {!goog.proto2.Message} message The source message.
+ */
+goog.proto2.Message.prototype.copyFrom = function(message) {
+ goog.proto2.Util.assert(this.constructor == message.constructor,
+ 'The source message must have the same type.');
+ var fields = this.getDescriptor().getFields();
+
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ delete this.values_[field.getTag()];
+
+ if (message.has(field)) {
+ var isComposite = field.isCompositeType();
+ if (field.isRepeated()) {
+ var values = message.arrayOf(field);
+ for (var j = 0; j < values.length; j++) {
+ this.add(field, isComposite ? values[j].clone() : values[j]);
+ }
+ } else {
+ var value = message.get(field);
+ this.set(field, isComposite ? value.clone() : value);
+ }
+ }
+ }
+};
+
+
+/**
+ * @return {!goog.proto2.Message} Recursive clone of the message only including
+ * the known fields.
+ */
+goog.proto2.Message.prototype.clone = function() {
+ var clone = new this.constructor;
+ clone.copyFrom(this);
+ return clone;
+};
+
+
+/**
+ * Fills in the protocol buffer with default values. Any fields that are
+ * already set will not be overridden.
+ * @param {boolean} simpleFieldsToo If true, all fields will be initialized;
+ * if false, only the nested messages and groups.
+ */
+goog.proto2.Message.prototype.initDefaults = function(simpleFieldsToo) {
+ var fields = this.getDescriptor().getFields();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ var tag = field.getTag();
+ var isComposite = field.isCompositeType();
+
+ // Initialize missing fields.
+ if (!this.has(field) && !field.isRepeated()) {
+ if (isComposite) {
+ this.values_[tag] = new /** @type {Function} */ (field.getNativeType());
+ } else if (simpleFieldsToo) {
+ this.values_[tag] = field.getDefaultValue();
+ }
+ }
+
+ // Fill in the existing composite fields recursively.
+ if (isComposite) {
+ if (field.isRepeated()) {
+ var values = this.array$Values(tag);
+ for (var j = 0; j < values.length; j++) {
+ values[j].initDefaults(simpleFieldsToo);
+ }
+ } else {
+ this.get$Value(tag).initDefaults(simpleFieldsToo);
+ }
+ }
+ }
+};
+
+
+/**
+ * Returns the field in this message by the given tag number. If no
+ * such field exists, throws an exception.
+ *
+ * @param {number} tag The field's tag index.
+ * @return {!goog.proto2.FieldDescriptor} The descriptor for the field.
+ * @private
+ */
+goog.proto2.Message.prototype.getFieldByTag_ = function(tag) {
+ goog.proto2.Util.assert(this.fields_[tag],
+ 'No field found for the given tag');
+
+ return this.fields_[tag];
+};
+
+
+/**
+ * Returns the whether or not the field indicated by the given tag
+ * has a value.
+ *
+ * GENERATED CODE USE ONLY. Basis of the has{Field} methods.
+ *
+ * @param {number} tag The tag.
+ *
+ * @return {boolean} Whether the message has a value for the field.
+ */
+goog.proto2.Message.prototype.has$Value = function(tag) {
+ goog.proto2.Util.assert(this.fields_[tag],
+ 'No field found for the given tag');
+
+ return tag in this.values_ && goog.isDef(this.values_[tag]) &&
+ this.values_[tag] !== null;
+};
+
+
+/**
+ * If a lazy deserializer is instantiated, lazily deserializes the
+ * field if required.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @private
+ */
+goog.proto2.Message.prototype.lazyDeserialize_ = function(field) {
+ // If we have a lazy deserializer, then ensure that the field is
+ // properly deserialized.
+ if (this.lazyDeserializer_) {
+ var tag = field.getTag();
+
+ if (!(tag in this.deserializedFields_)) {
+ this.values_[tag] = this.lazyDeserializer_.deserializeField(
+ this, field, this.values_[tag]);
+
+ this.deserializedFields_[tag] = true;
+ }
+ }
+};
+
+
+/**
+ * Gets the value at the field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the get{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {number=} opt_index If the field is a repeated field, the index
+ * at which to get the value.
+ *
+ * @return {*} The value found or null for none.
+ * @protected
+ */
+goog.proto2.Message.prototype.get$Value = function(tag, opt_index) {
+ var field = this.getFieldByTag_(tag);
+
+ // Ensure that the field is deserialized.
+ this.lazyDeserialize_(field);
+
+ if (field.isRepeated()) {
+ var index = opt_index || 0;
+ goog.proto2.Util.assert(index >= 0 && index < this.count$Values(tag),
+ 'Given index is out of bounds');
+
+ return this.values_[tag][index];
+ } else {
+ goog.proto2.Util.assert(!goog.isArray(this.values_[tag]));
+ return tag in this.values_ ? this.values_[tag] : null;
+ }
+};
+
+
+/**
+ * Gets the value at the field indicated by the given tag or the default value
+ * if none.
+ *
+ * GENERATED CODE USE ONLY. Basis of the get{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {number=} opt_index If the field is a repeated field, the index
+ * at which to get the value.
+ *
+ * @return {*} The value found or the default value if none set.
+ * @protected
+ */
+goog.proto2.Message.prototype.get$ValueOrDefault = function(tag, opt_index) {
+
+ if (!this.has$Value(tag)) {
+ // Return the default value.
+ var field = this.getFieldByTag_(tag);
+ return field.getDefaultValue();
+ }
+
+ return this.get$Value(tag, opt_index);
+};
+
+
+/**
+ * Gets the values at the field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the {field}Array methods.
+ *
+ * @param {number} tag The field's tag index.
+ *
+ * @return {!Array} The values found. If none, returns an empty array.
+ * @protected
+ */
+goog.proto2.Message.prototype.array$Values = function(tag) {
+ goog.proto2.Util.assert(this.getFieldByTag_(tag).isRepeated(),
+ 'Cannot call fieldArray on a non-repeated field');
+
+ var field = this.getFieldByTag_(tag);
+
+ // Ensure that the field is deserialized.
+ this.lazyDeserialize_(field);
+
+ return this.values_[tag] || [];
+};
+
+
+/**
+ * Returns the number of values stored in the field by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the {field}Count methods.
+ *
+ * @param {number} tag The tag.
+ *
+ * @return {number} The number of values.
+ * @protected
+ */
+goog.proto2.Message.prototype.count$Values = function(tag) {
+ var field = this.getFieldByTag_(tag);
+
+ if (field.isRepeated()) {
+ if (this.has$Value(tag)) {
+ goog.proto2.Util.assert(goog.isArray(this.values_[tag]));
+ }
+
+ return this.has$Value(tag) ? this.values_[tag].length : 0;
+ } else {
+ return this.has$Value(tag) ? 1 : 0;
+ }
+};
+
+
+/**
+ * Sets the value of the *non-repeating* field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the set{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {*} value The field's value.
+ * @protected
+ */
+goog.proto2.Message.prototype.set$Value = function(tag, value) {
+ if (goog.proto2.Util.conductChecks()) {
+ var field = this.getFieldByTag_(tag);
+
+ goog.proto2.Util.assert(!field.isRepeated(),
+ 'Cannot call set on a repeated field');
+
+ this.checkFieldType_(field, value);
+ }
+
+ this.values_[tag] = value;
+ if (this.deserializedFields_) {
+ this.deserializedFields_[tag] = true;
+ }
+};
+
+
+/**
+ * Adds the value to the *repeating* field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the add{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {*} value The value to add.
+ * @protected
+ */
+goog.proto2.Message.prototype.add$Value = function(tag, value) {
+ if (goog.proto2.Util.conductChecks()) {
+ var field = this.getFieldByTag_(tag);
+
+ goog.proto2.Util.assert(field.isRepeated(),
+ 'Cannot call add on a non-repeated field');
+
+ this.checkFieldType_(field, value);
+ }
+
+ if (!this.values_[tag]) {
+ this.values_[tag] = [];
+ }
+
+ this.values_[tag].push(value);
+};
+
+
+/**
+ * Ensures that the value being assigned to the given field
+ * is valid.
+ *
+ * @param {!goog.proto2.FieldDescriptor} field The field being assigned.
+ * @param {*} value The value being assigned.
+ * @private
+ */
+goog.proto2.Message.prototype.checkFieldType_ = function(field, value) {
+ goog.proto2.Util.assert(value !== null);
+
+ var nativeType = field.getNativeType();
+ if (nativeType === String) {
+ goog.proto2.Util.assert(typeof value === 'string',
+ 'Expected value of type string');
+ } else if (nativeType === Boolean) {
+ goog.proto2.Util.assert(typeof value === 'boolean',
+ 'Expected value of type boolean');
+ } else if (nativeType === Number) {
+ goog.proto2.Util.assert(typeof value === 'number',
+ 'Expected value of type number');
+ } else if (field.getFieldType() ==
+ goog.proto2.FieldDescriptor.FieldType.ENUM) {
+ goog.proto2.Util.assert(typeof value === 'number',
+ 'Expected an enum value, which is a number');
+ } else {
+ goog.proto2.Util.assert(value instanceof nativeType,
+ 'Expected a matching message type');
+ }
+};
+
+
+/**
+ * Clears the field specified by tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the clear{Field} methods.
+ *
+ * @param {number} tag The tag of the field to clear.
+ * @protected
+ */
+goog.proto2.Message.prototype.clear$Field = function(tag) {
+ goog.proto2.Util.assert(this.getFieldByTag_(tag), 'Unknown field');
+ delete this.values_[tag];
+};
+
+
+/**
+ * Sets the metadata that represents the definition of this message.
+ *
+ * GENERATED CODE USE ONLY. Called when constructing message classes.
+ *
+ * @param {Function} messageType Constructor for the message type to
+ * which this metadata applies.
+ * @param {Object} metadataObj The object containing the metadata.
+ */
+goog.proto2.Message.set$Metadata = function(messageType, metadataObj) {
+ var fields = [];
+ var descriptorInfo;
+
+ for (var key in metadataObj) {
+ if (!metadataObj.hasOwnProperty(key)) {
+ continue;
+ }
+
+ goog.proto2.Util.assert(goog.string.isNumeric(key), 'Keys must be numeric');
+
+ if (key == 0) {
+ descriptorInfo = metadataObj[0];
+ continue;
+ }
+
+ // Create the field descriptor.
+ fields.push(
+ new goog.proto2.FieldDescriptor(messageType, key, metadataObj[key]));
+ }
+
+ goog.proto2.Util.assert(descriptorInfo);
+
+ // Create the descriptor.
+ messageType.descriptor_ =
+ new goog.proto2.Descriptor(messageType, descriptorInfo, fields);
+
+ messageType.getDescriptor = function() {
+ return messageType.descriptor_;
+ };
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message_test.html.svn-base
new file mode 100644
index 0000000..a316d71
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/message_test.html.svn-base
@@ -0,0 +1,389 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2010 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - message.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.Message');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+ goog.require('proto2.TestAllTypes.NestedEnum');
+ goog.require('proto2.TestAllTypes.NestedMessage');
+ goog.require('proto2.TestAllTypes.OptionalGroup');
+ goog.require('proto2.TestAllTypes.RepeatedGroup');
+</script>
+</head>
+<body>
+<script>
+
+function testEqualsWithEmptyMessages() {
+ var message1 = new proto2.TestAllTypes();
+ assertTrue('same message object', message1.equals(message1));
+ assertFalse('comparison with null', message1.equals(null));
+ assertFalse('comparison with undefined', message1.equals(undefined));
+
+ var message2 = new proto2.TestAllTypes();
+ assertTrue('two empty message objects', message1.equals(message2));
+
+ var message3 = new proto2.TestAllTypes.NestedMessage()
+ assertFalse('different message types', message3.equals(message1));
+}
+
+function testEqualsWithSingleInt32Field() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+
+ message1.setOptionalInt32(1);
+ assertFalse('message1 has an extra int32 field', message1.equals(message2));
+
+ message2.setOptionalInt32(1);
+ assertTrue('same int32 field in both messages', message1.equals(message2));
+
+ message2.setOptionalInt32(2);
+ assertFalse('different int32 field', message1.equals(message2));
+
+ message1.clearOptionalInt32();
+ assertFalse('message2 has an extra int32 field', message1.equals(message2));
+}
+
+function testEqualsWithRepeatedInt32Fields() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+
+ message1.addRepeatedInt32(0);
+ message2.addRepeatedInt32(0);
+ assertTrue('equal repeated int32 field', message1.equals(message2));
+
+ message1.addRepeatedInt32(1);
+ assertFalse('message1 has more items', message1.equals(message2));
+
+ message2.addRepeatedInt32(1);
+ message2.addRepeatedInt32(1);
+ assertFalse('message2 has more items', message1.equals(message2));
+
+ message1.addRepeatedInt32(2);
+ assertFalse('different int32 items', message1.equals(message2));
+}
+
+function testEqualsWithDefaultValue() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ message1.setOptionalInt64('1');
+
+ assertEquals('message1.getOptionalInt64OrDefault should return 1',
+ '1', message1.getOptionalInt64OrDefault());
+ assertEquals('message2.getOptionalInt64OrDefault should return 1 too',
+ '1', message2.getOptionalInt64OrDefault());
+ assertTrue('message1.hasOptionalInt64() should be true',
+ message1.hasOptionalInt64());
+ assertFalse('message2.hasOptionalInt64() should be false',
+ message2.hasOptionalInt64());
+ assertFalse('as a result they are not equal', message1.equals(message2));
+}
+
+function testEqualsWithOptionalGroup() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ var group1 = new proto2.TestAllTypes.OptionalGroup();
+ var group2 = new proto2.TestAllTypes.OptionalGroup();
+
+ message1.setOptionalgroup(group1);
+ assertFalse('only message1 has OptionalGroup field',
+ message1.equals(message2));
+
+ message2.setOptionalgroup(group2);
+ assertTrue('both messages have OptionalGroup field',
+ message1.equals(message2));
+
+ group1.setA(0);
+ group2.setA(1);
+ assertFalse('different value in the optional group',
+ message1.equals(message2));
+
+ message1.clearOptionalgroup();
+ assertFalse('only message2 has OptionalGroup field',
+ message1.equals(message2));
+}
+
+function testEqualsWithRepeatedGroup() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ var group1 = new proto2.TestAllTypes.RepeatedGroup();
+ var group2 = new proto2.TestAllTypes.RepeatedGroup();
+
+ message1.addRepeatedgroup(group1);
+ assertFalse('message1 has more RepeatedGroups',
+ message1.equals(message2));
+
+ message2.addRepeatedgroup(group2);
+ assertTrue('both messages have one RepeatedGroup',
+ message1.equals(message2));
+
+ group1.addA(1);
+ assertFalse('message1 has more int32s in RepeatedGroup',
+ message1.equals(message2));
+
+ group2.addA(1);
+ assertTrue('both messages have one int32 in RepeatedGroup',
+ message1.equals(message2));
+
+ group1.addA(1);
+ group2.addA(2);
+ assertFalse('the messages have different int32s in RepeatedGroup',
+ message1.equals(message2));
+}
+
+function testEqualsWithNestedMessage() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ var nested1 = new proto2.TestAllTypes.NestedMessage();
+ var nested2 = new proto2.TestAllTypes.NestedMessage();
+
+ message1.setOptionalNestedMessage(nested1);
+ assertFalse('only message1 has nested message', message1.equals(message2));
+
+ message2.setOptionalNestedMessage(nested2);
+ assertTrue('both messages have nested message', message1.equals(message2));
+
+ nested1.setB(1);
+ assertFalse('different int32 in the nested messages',
+ message1.equals(message2));
+
+ message1.clearOptionalNestedMessage();
+ assertFalse('only message2 has nested message', message1.equals(message2));
+}
+
+function testEqualsWithNestedEnum() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+
+ message1.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ assertFalse('only message1 has nested enum', message1.equals(message2));
+
+ message2.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ assertTrue('both messages have nested enum', message1.equals(message2));
+
+ message2.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.BAR);
+ assertFalse('different enum value', message1.equals(message2));
+
+ message1.clearOptionalNestedEnum();
+ assertFalse('only message2 has nested enum', message1.equals(message2));
+}
+
+function testEqualsWithUnknownFields() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ message1.setUnknown(999, 'foo');
+ message1.setUnknown(999, 'bar');
+ assertTrue('unknown fields are ignored', message1.equals(message2));
+}
+
+function testCloneEmptyMessage() {
+ var message = new proto2.TestAllTypes();
+ var clone = message.clone();
+ assertObjectEquals('cloned empty message', message, clone);
+}
+
+function testCloneMessageWithSeveralFields() {
+ var message = new proto2.TestAllTypes();
+ message.setOptionalInt32(1);
+ message.addRepeatedInt32(2);
+ var optionalGroup = new proto2.TestAllTypes.OptionalGroup();
+ optionalGroup.setA(3);
+ message.setOptionalgroup(optionalGroup);
+ var repeatedGroup = new proto2.TestAllTypes.RepeatedGroup();
+ repeatedGroup.addA(4);
+ message.addRepeatedgroup(repeatedGroup);
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(5);
+ message.setOptionalNestedMessage(nestedMessage);
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ message.setUnknown(999, 'foo');
+
+ var clone = message.clone();
+ assertNotEquals('different OptionalGroup instance',
+ message.getOptionalgroup(), clone.getOptionalgroup());
+ assertNotEquals('different RepeatedGroup array instance',
+ message.repeatedgroupArray(), clone.repeatedgroupArray());
+ assertNotEquals('different RepeatedGroup array item instance',
+ message.getRepeatedgroup(0), clone.getRepeatedgroup(0));
+ assertNotEquals('different NestedMessage instance',
+ message.getOptionalNestedMessage(), clone.getOptionalNestedMessage());
+}
+
+function testCloneWithUnknownFields() {
+ var message = new proto2.TestAllTypes();
+ message.setUnknown(999, 'foo');
+
+ var clone = message.clone();
+ assertTrue('clone.equals(message) returns true', clone.equals(message));
+ clone.forEachUnknown(function(tag, value) {
+ fail('the unknown fields should not have been cloned');
+ });
+
+ clone.setUnknown(999, 'foo');
+ assertObjectEquals('the original and the cloned message are equal except ' +
+ 'for the unknown fields', message, clone);
+}
+
+function testCopyFromFlatMessage() {
+ // Recursive copying is implicitly tested in the testClone... methods.
+
+ var source = new proto2.TestAllTypes();
+ source.setOptionalInt32(32);
+ source.setOptionalInt64('64');
+ source.addRepeatedInt32(32);
+
+ var target = new proto2.TestAllTypes();
+ target.setOptionalInt32(33);
+ target.setOptionalUint32(33);
+ target.addRepeatedInt32(33);
+
+ target.copyFrom(source);
+ assertObjectEquals('source and target are equal after copyFrom', source,
+ target);
+
+ target.copyFrom(source);
+ assertObjectEquals('second copyFrom call has no effect', source, target);
+
+ source.setUnknown(999, 'foo');
+ target.setUnknown(999, 'bar');
+ target.copyFrom(source);
+ assertThrows('unknown fields are not copied',
+ goog.partial(assertObjectEquals, source, target));
+}
+
+function testInitDefaultsWithEmptyMessage() {
+ var message = new proto2.TestAllTypes();
+ message.initDefaults(false);
+
+ assertFalse('int32 field is not set', message.hasOptionalInt32());
+ assertFalse('int64 [default=1] field is not set', message.hasOptionalInt64());
+ assertTrue('optional group field is set', message.hasOptionalgroup());
+ assertFalse('int32 inside the group is not set',
+ message.getOptionalgroup().hasA());
+ assertObjectEquals('value of the optional group',
+ new proto2.TestAllTypes.OptionalGroup(), message.getOptionalgroup());
+ assertTrue('nested message is set', message.hasOptionalNestedMessage());
+ assertObjectEquals('value of the nested message',
+ new proto2.TestAllTypes.NestedMessage(),
+ message.getOptionalNestedMessage());
+ assertFalse('nested enum is not set', message.hasOptionalNestedEnum());
+ assertFalse('repeated int32 is not set', message.hasRepeatedInt32());
+ assertFalse('repeated nested message is not set',
+ message.hasRepeatedNestedMessage());
+
+ message = new proto2.TestAllTypes();
+ message.initDefaults(true);
+
+ assertTrue('int32 field is set', message.hasOptionalInt32());
+ assertEquals('value of the int32 field', 0, message.getOptionalInt32());
+ assertTrue('int64 [default=1] field is set', message.hasOptionalInt64());
+ assertEquals('value of the int64 field', '1', message.getOptionalInt64());
+ assertTrue('int32 inside nested message is set',
+ message.getOptionalNestedMessage().hasB());
+ assertEquals('value of the int32 field inside the nested message', 0,
+ message.getOptionalNestedMessage().getB());
+}
+
+function testInitDefaultsWithNonEmptyMessage() {
+ var message = new proto2.TestAllTypes();
+ message.setOptionalInt32(32);
+ message.setOptionalInt64('64');
+ message.setOptionalgroup(new proto2.TestAllTypes.OptionalGroup());
+ var nested1 = new proto2.TestAllTypes.NestedMessage();
+ nested1.setB(66);
+ message.setOptionalNestedMessage(nested1);
+ var nested2 = new proto2.TestAllTypes.NestedMessage();
+ message.addRepeatedNestedMessage(nested2);
+ var nested3 = new proto2.TestAllTypes.NestedMessage();
+ nested3.setB(66);
+ message.addRepeatedNestedMessage(nested3);
+
+ message.initDefaults(true);
+ assertEquals('int32 field is unchanged', 32, message.getOptionalInt32());
+ assertEquals('int64 [default=1] field is unchanged', '64',
+ message.getOptionalInt64());
+ assertTrue('bool field is initialized', message.hasOptionalBool());
+ assertFalse('value of the bool field', message.getOptionalBool());
+ assertTrue('int32 inside the optional group is initialized',
+ message.getOptionalgroup().hasA());
+ assertEquals('value of the int32 inside the optional group', 0,
+ message.getOptionalgroup().getA());
+ assertEquals('int32 inside nested message is unchanged', 66,
+ message.getOptionalNestedMessage().getB());
+ assertTrue('int32 at index 0 of the repeated nested message is initialized',
+ message.getRepeatedNestedMessage(0).hasB());
+ assertEquals('value of int32 at index 0 of the repeated nested message', 0,
+ message.getRepeatedNestedMessage(0).getB());
+ assertEquals('int32 at index 1 of the repeated nested message is unchanged',
+ 66, message.getRepeatedNestedMessage(1).getB());
+}
+
+function testInitDefaultsTwice() {
+ var message = new proto2.TestAllTypes();
+ message.initDefaults(false);
+ var clone = message.clone();
+ clone.initDefaults(false);
+ assertObjectEquals('second call of initDefaults(false) has no effect',
+ message, clone);
+
+ message = new proto2.TestAllTypes();
+ message.initDefaults(true);
+ clone = message.clone();
+ clone.initDefaults(true);
+ assertObjectEquals('second call of initDefaults(true) has no effect',
+ message, clone);
+}
+
+function testInitDefaultsThenClone() {
+ var message = new proto2.TestAllTypes();
+ message.initDefaults(true);
+ assertObjectEquals('message is cloned properly', message, message.clone());
+}
+
+function testGetAfterSetWithLazyDeserializer() {
+ // Test makes sure that the lazy deserializer for a field is not
+ // erroneously called when get$Value is called after set$Value.
+ var message = new proto2.TestAllTypes();
+
+ var fakeDeserializer = {}; // stub with no methods defined; fails hard
+ message.initializeForLazyDeserializer(fakeDeserializer, {} /* data */);
+ message.setOptionalBool(true);
+ assertEquals(true, message.getOptionalBool());
+}
+
+function testHasOnLazyDeserializer() {
+ // Test that null values for fields are treated as absent by the lazy
+ // deserializer.
+ var message = new proto2.TestAllTypes();
+
+ var fakeDeserializer = {}; // stub with no methods defined; fails hard
+ message.initializeForLazyDeserializer(fakeDeserializer,
+ {13: false} /* data */);
+ assertEquals(true, message.hasOptionalBool());
+}
+
+function testHasOnLazyDeserializerWithNulls() {
+ // Test that null values for fields are treated as absent by the lazy
+ // deserializer.
+ var message = new proto2.TestAllTypes();
+
+ var fakeDeserializer = {}; // stub with no methods defined; fails hard
+ message.initializeForLazyDeserializer(fakeDeserializer,
+ {13: null} /* data */);
+ assertEquals(false, message.hasOptionalBool());
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer.js.svn-base
new file mode 100644
index 0000000..0e84089
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer.js.svn-base
@@ -0,0 +1,159 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer 2 Serializer which serializes messages
+ * into anonymous, simplified JSON objects.
+ *
+ */
+
+goog.provide('goog.proto2.ObjectSerializer');
+
+goog.require('goog.proto2.Serializer');
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * ObjectSerializer, a serializer which turns Messages into simplified
+ * ECMAScript objects.
+ *
+ * @param {goog.proto2.ObjectSerializer.KeyOption=} opt_keyOption If specified,
+ * which key option to use when serializing/deserializing.
+ *
+ * @constructor
+ * @extends {goog.proto2.Serializer}
+ */
+goog.proto2.ObjectSerializer = function(opt_keyOption) {
+ this.keyOption_ = opt_keyOption;
+};
+goog.inherits(goog.proto2.ObjectSerializer, goog.proto2.Serializer);
+
+
+/**
+ * An enumeration of the options for how to emit the keys in
+ * the generated simplified object.
+ *
+ * @enum {number}
+ */
+goog.proto2.ObjectSerializer.KeyOption = {
+ /**
+ * Use the tag of the field as the key (default)
+ */
+ TAG: 0,
+
+ /**
+ * Use the name of the field as the key. Unknown fields
+ * will still use their tags as keys.
+ */
+ NAME: 1
+};
+
+
+/**
+ * Serializes a message to an object.
+ *
+ * @param {goog.proto2.Message} message The message to be serialized.
+ *
+ * @return {Object} The serialized form of the message.
+ */
+goog.proto2.ObjectSerializer.prototype.serialize = function(message) {
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ var objectValue = {};
+
+ // Add the defined fields, recursively.
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+
+ var key =
+ this.keyOption_ == goog.proto2.ObjectSerializer.KeyOption.NAME ?
+ field.getName() : field.getTag();
+
+
+ if (message.has(field)) {
+ if (field.isRepeated()) {
+ var array = [];
+ objectValue[key] = array;
+
+ for (var j = 0; j < message.countOf(field); j++) {
+ array.push(this.getSerializedValue(field, message.get(field, j)));
+ }
+
+ } else {
+ objectValue[key] = this.getSerializedValue(field, message.get(field));
+ }
+ }
+ }
+
+ // Add the unknown fields, if any.
+ message.forEachUnknown(function(tag, value) {
+ objectValue[tag] = value;
+ });
+
+ return objectValue;
+};
+
+
+/**
+ * Deserializes a message from an object and places the
+ * data in the message.
+ *
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {Object} data The data of the message.
+ */
+goog.proto2.ObjectSerializer.prototype.deserializeTo = function(message, data) {
+ var descriptor = message.getDescriptor();
+
+ for (var key in data) {
+ var field;
+ var value = data[key];
+
+ var isNumeric = goog.string.isNumeric(key);
+
+ if (isNumeric) {
+ field = descriptor.findFieldByTag(key);
+ } else {
+ // We must be in Key == NAME mode to lookup by name.
+ goog.proto2.Util.assert(
+ this.keyOption_ == goog.proto2.ObjectSerializer.KeyOption.NAME);
+
+ field = descriptor.findFieldByName(key);
+ }
+
+ if (field) {
+ if (field.isRepeated()) {
+ goog.proto2.Util.assert(goog.isArray(value));
+
+ for (var j = 0; j < value.length; j++) {
+ message.add(field, this.getDeserializedValue(field, value[j]));
+ }
+ } else {
+ goog.proto2.Util.assert(!goog.isArray(value));
+ message.set(field, this.getDeserializedValue(field, value));
+ }
+ } else {
+ if (isNumeric) {
+ // We have an unknown field.
+ message.setUnknown(/** @type {number} */ (key), value);
+ } else {
+ // Named fields must be present.
+ goog.proto2.Util.assert(field);
+ }
+ }
+ }
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer_test.html.svn-base
new file mode 100644
index 0000000..00ada9a
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/objectserializer_test.html.svn-base
@@ -0,0 +1,423 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - objectserializer.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.ObjectSerializer');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testSerialization() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Serialize to a simplified object.
+ var simplified = new goog.proto2.ObjectSerializer().serialize(message);
+
+ // Assert that everything serialized properly.
+ assertEquals(101, simplified[1]);
+ assertEquals('102', simplified[2]);
+ assertEquals(103, simplified[3]);
+ assertEquals('104', simplified[4]);
+ assertEquals(105, simplified[5]);
+ assertEquals('106', simplified[6]);
+ assertEquals(107, simplified[7]);
+ assertEquals('108', simplified[8]);
+ assertEquals(109, simplified[9]);
+ assertEquals('110', simplified[10]);
+ assertEquals(111.5, simplified[11]);
+ assertEquals(112.5, simplified[12]);
+ assertEquals(true, simplified[13]);
+ assertEquals('test', simplified[14]);
+ assertEquals('abcd', simplified[15]);
+
+ assertEquals(111, simplified[16][17]);
+ assertEquals(112, simplified[18][1]);
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO, simplified[21]);
+
+ assertEquals(201, simplified[31][0]);
+ assertEquals(202, simplified[31][1]);
+
+ // Serialize to a simplified object (with key as name).
+ simplified = new goog.proto2.ObjectSerializer(
+ goog.proto2.ObjectSerializer.KeyOption.NAME).serialize(message);
+
+ // Assert that everything serialized properly.
+ assertEquals(101, simplified['optional_int32']);
+ assertEquals('102', simplified['optional_int64']);
+ assertEquals(103, simplified['optional_uint32']);
+ assertEquals('104', simplified['optional_uint64']);
+ assertEquals(105, simplified['optional_sint32']);
+ assertEquals('106', simplified['optional_sint64']);
+ assertEquals(107, simplified['optional_fixed32']);
+ assertEquals('108', simplified['optional_fixed64']);
+ assertEquals(109, simplified['optional_sfixed32']);
+ assertEquals('110', simplified['optional_sfixed64']);
+ assertEquals(111.5, simplified['optional_float']);
+ assertEquals(112.5, simplified['optional_double']);
+ assertEquals(true, simplified['optional_bool']);
+ assertEquals('test', simplified['optional_string']);
+ assertEquals('abcd', simplified['optional_bytes']);
+
+ assertEquals(111, simplified['optionalgroup']['a']);
+ assertEquals(112, simplified['optional_nested_message']['b']);
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ simplified['optional_nested_enum']);
+
+ assertEquals(201, simplified['repeated_int32'][0]);
+ assertEquals(202, simplified['repeated_int32'][1]);
+}
+
+
+function testSerializationOfUnknown() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Known.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Unknown.
+ message.setUnknown(1000, 301);
+ message.setUnknown(1001, 302);
+
+ // Serialize.
+ var simplified = new goog.proto2.ObjectSerializer().serialize(message);
+
+ assertEquals(101, simplified['1']);
+ assertEquals('102', simplified['2']);
+
+ assertEquals(201, simplified['31'][0]);
+ assertEquals(202, simplified['31'][1]);
+
+ assertEquals(301, simplified['1000']);
+ assertEquals(302, simplified['1001']);
+}
+
+function testDeserializationOfUnknown() {
+ var simplified = {
+ 1: 101,
+ 2: '102',
+ 1000: 103,
+ 1001: 104
+ };
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplified);
+
+ assertNotNull(message);
+ assertTrue(message.hasOptionalInt32());
+ assertTrue(message.hasOptionalInt64());
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals('102', message.getOptionalInt64());
+
+ var count = 0;
+
+ message.forEachUnknown(function(tag, value) {
+ if (tag == 1000) {
+ assertEquals(103, value);
+ }
+
+ if (tag == 1001) {
+ assertEquals(104, value);
+ }
+
+ ++count;
+ });
+
+ assertEquals(2, count);
+};
+
+function testDeserializationRepeated() {
+ var simplified = {
+ 31: [101, 102],
+ 41: [201.5, 202.5, 203.5],
+ 42: [],
+ 43: [ true, false ],
+ 44: [ 'he', 'llo' ],
+ 46: [ { 47: [101] } , { 47: [102] } ],
+ 48: [ { 1: 201 }, { 1: 202 } ]
+ }
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplified);
+
+ assertNotNull(message);
+
+ // Ensure the fields are set as expected.
+ assertTrue(message.hasRepeatedInt32());
+ assertTrue(message.hasRepeatedFloat());
+
+ assertFalse(message.hasRepeatedDouble());
+
+ assertTrue(message.hasRepeatedBool());
+ assertTrue(message.hasRepeatedgroup());
+ assertTrue(message.hasRepeatedNestedMessage());
+
+ // Ensure the counts match.
+ assertEquals(2, message.repeatedInt32Count());
+ assertEquals(3, message.repeatedFloatCount());
+
+ assertEquals(0, message.repeatedDoubleCount());
+
+ assertEquals(2, message.repeatedBoolCount());
+ assertEquals(2, message.repeatedStringCount());
+ assertEquals(2, message.repeatedgroupCount());
+ assertEquals(2, message.repeatedNestedMessageCount());
+
+ // Ensure the values match.
+ assertEquals(101, message.getRepeatedInt32(0));
+ assertEquals(102, message.getRepeatedInt32(1));
+
+ assertEquals(201.5, message.getRepeatedFloat(0));
+ assertEquals(202.5, message.getRepeatedFloat(1));
+ assertEquals(203.5, message.getRepeatedFloat(2));
+
+ assertEquals(true, message.getRepeatedBool(0));
+ assertEquals(false, message.getRepeatedBool(1));
+
+ assertEquals('he', message.getRepeatedString(0));
+ assertEquals('llo', message.getRepeatedString(1));
+
+ assertEquals(101, message.getRepeatedgroup(0).getA(0));
+ assertEquals(102, message.getRepeatedgroup(1).getA(0));
+
+ assertEquals(201, message.getRepeatedNestedMessage(0).getB());
+ assertEquals(202, message.getRepeatedNestedMessage(1).getB());
+}
+
+function testDeserialization() {
+ var simplified = {
+ 1: 101,
+ 2: '102',
+ 3: 103,
+ 4: '104',
+ 5: 105,
+ 6: '106',
+ 7: 107,
+ 8: '108',
+ 9: 109,
+ 10: '110',
+ 11: 111.5,
+ 12: 112.5,
+ 13: true,
+ 14: 'test',
+ 15: 'abcd',
+ 16: { 17 : 113 },
+ 18: { 1 : 114 },
+ 21: proto2.TestAllTypes.NestedEnum.FOO
+ };
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplified);
+
+ assertNotNull(message);
+
+ assertTrue(message.hasOptionalInt32());
+ assertTrue(message.hasOptionalInt64());
+ assertTrue(message.hasOptionalUint32());
+ assertTrue(message.hasOptionalUint64());
+ assertTrue(message.hasOptionalSint32());
+ assertTrue(message.hasOptionalSint64());
+ assertTrue(message.hasOptionalFixed32());
+ assertTrue(message.hasOptionalFixed64());
+ assertTrue(message.hasOptionalSfixed32());
+ assertTrue(message.hasOptionalSfixed64());
+ assertTrue(message.hasOptionalFloat());
+ assertTrue(message.hasOptionalDouble());
+ assertTrue(message.hasOptionalBool());
+ assertTrue(message.hasOptionalString());
+ assertTrue(message.hasOptionalBytes());
+ assertTrue(message.hasOptionalgroup());
+ assertTrue(message.hasOptionalNestedMessage());
+ assertTrue(message.hasOptionalNestedEnum());
+
+ assertEquals(1, message.optionalInt32Count());
+ assertEquals(1, message.optionalInt64Count());
+ assertEquals(1, message.optionalUint32Count());
+ assertEquals(1, message.optionalUint64Count());
+ assertEquals(1, message.optionalSint32Count());
+ assertEquals(1, message.optionalSint64Count());
+ assertEquals(1, message.optionalFixed32Count());
+ assertEquals(1, message.optionalFixed64Count());
+ assertEquals(1, message.optionalSfixed32Count());
+ assertEquals(1, message.optionalSfixed64Count());
+ assertEquals(1, message.optionalFloatCount());
+ assertEquals(1, message.optionalDoubleCount());
+ assertEquals(1, message.optionalBoolCount());
+ assertEquals(1, message.optionalStringCount());
+ assertEquals(1, message.optionalBytesCount());
+ assertEquals(1, message.optionalgroupCount());
+ assertEquals(1, message.optionalNestedMessageCount());
+ assertEquals(1, message.optionalNestedEnumCount());
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals('102', message.getOptionalInt64());
+ assertEquals(103, message.getOptionalUint32());
+ assertEquals('104', message.getOptionalUint64());
+ assertEquals(105, message.getOptionalSint32());
+ assertEquals('106', message.getOptionalSint64());
+ assertEquals(107, message.getOptionalFixed32());
+ assertEquals('108', message.getOptionalFixed64());
+ assertEquals(109, message.getOptionalSfixed32());
+ assertEquals('110', message.getOptionalSfixed64());
+ assertEquals(111.5, message.getOptionalFloat());
+ assertEquals(112.5, message.getOptionalDouble());
+ assertEquals(true, message.getOptionalBool());
+ assertEquals('test', message.getOptionalString());
+ assertEquals('abcd', message.getOptionalBytes());
+ assertEquals(113, message.getOptionalgroup().getA());
+ assertEquals(114, message.getOptionalNestedMessage().getB());
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ message.getOptionalNestedEnum());
+}
+
+function testDeserializationNumbersOrStrings() {
+ // 64-bit types may have been serialized as numbers or strings.
+ // Deserialization should be able to handle either.
+
+ var simplifiedWithNumbers = {
+ 50: 5000,
+ 51: 5100,
+ 52: [ 5200, 5201 ],
+ 53: [ 5300, 5301 ]
+ };
+
+ var simplifiedWithStrings = {
+ 50: '5000',
+ 51: '5100',
+ 52: [ '5200', '5201' ],
+ 53: [ '5300', '5301' ]
+ };
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplifiedWithNumbers);
+
+ assertNotNull(message);
+
+ assertEquals(5000, message.getOptionalInt64Number());
+ assertEquals('5100', message.getOptionalInt64String());
+ assertEquals(5200, message.getRepeatedInt64Number(0));
+ assertEquals(5201, message.getRepeatedInt64Number(1));
+ assertEquals('5300', message.getRepeatedInt64String(0));
+ assertEquals('5301', message.getRepeatedInt64String(1));
+
+ assertArrayEquals([5200, 5201], message.repeatedInt64NumberArray());
+ assertArrayEquals(['5300', '5301'], message.repeatedInt64StringArray());
+
+ message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplifiedWithStrings);
+
+ assertNotNull(message);
+
+ assertEquals(5000, message.getOptionalInt64Number());
+ assertEquals('5100', message.getOptionalInt64String());
+ assertEquals(5200, message.getRepeatedInt64Number(0));
+ assertEquals(5201, message.getRepeatedInt64Number(1));
+ assertEquals('5300', message.getRepeatedInt64String(0));
+ assertEquals('5301', message.getRepeatedInt64String(1));
+
+ assertArrayEquals([5200, 5201], message.repeatedInt64NumberArray());
+ assertArrayEquals(['5300', '5301'], message.repeatedInt64StringArray());
+}
+
+function testDeserializationConversionProhibited() {
+ // 64-bit types may have been serialized as numbers or strings.
+ // But 32-bit types must be serialized as numbers.
+ // Test deserialization fails on 32-bit numbers as strings.
+
+ var simplified = {
+ 1: '1000' // optionalInt32
+ };
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ assertThrows('Should have an assertion failure in deserialization',
+ function() {
+ serializer.deserialize(proto2.TestAllTypes.getDescriptor(), simplified);
+ });
+}
+
+function testDefaultValueNumbersOrStrings() {
+ // 64-bit types may have been serialized as numbers or strings.
+ // The default values should have the correct type.
+
+ var serializer = new goog.proto2.ObjectSerializer();
+ var message = serializer.deserialize(proto2.TestAllTypes.getDescriptor(), {});
+
+ assertNotNull(message);
+
+ // Default when using Number is a number, and precision is lost.
+ var value = message.getOptionalInt64NumberOrDefault();
+ assertTrue('Expecting a number', typeof value === 'number');
+ assertEquals(1000000000000000000, value);
+ assertEquals(1000000000000000001, value);
+ assertEquals(1000000000000000002, value);
+ assertEquals('1000000000000000000', String(value)); // Value is rounded!
+
+ // When using a String, the value is preserved.
+ assertEquals('1000000000000000001',
+ message.getOptionalInt64StringOrDefault());
+}
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/package_test.pb.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/package_test.pb.js.svn-base
new file mode 100644
index 0000000..fab330e
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/package_test.pb.js.svn-base
@@ -0,0 +1,165 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// All other code copyright its respective owners(s).
+
+/**
+ * @fileoverview Generated Protocol Buffer code for file
+ * closure/goog/proto2/package_test.proto.
+ */
+
+goog.provide('someprotopackage.TestPackageTypes');
+
+goog.require('goog.proto2.Message');
+goog.require('proto2.TestAllTypes');
+
+goog.setTestOnly('package_test.pb');
+
+
+/**
+ * Message TestPackageTypes.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+someprotopackage.TestPackageTypes = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(someprotopackage.TestPackageTypes, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!someprotopackage.TestPackageTypes} The cloned message.
+ * @override
+ */
+someprotopackage.TestPackageTypes.prototype.clone;
+
+
+/**
+ * Gets the value of the optional_int32 field.
+ * @return {?number} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOptionalInt32 = function() {
+ return /** @type {?number} */ (this.get$Value(1));
+};
+
+
+/**
+ * Gets the value of the optional_int32 field or the default value if not set.
+ * @return {number} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOptionalInt32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(1));
+};
+
+
+/**
+ * Sets the value of the optional_int32 field.
+ * @param {number} value The value.
+ */
+someprotopackage.TestPackageTypes.prototype.setOptionalInt32 = function(value) {
+ this.set$Value(1, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int32 field has a value.
+ */
+someprotopackage.TestPackageTypes.prototype.hasOptionalInt32 = function() {
+ return this.has$Value(1);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int32 field.
+ */
+someprotopackage.TestPackageTypes.prototype.optionalInt32Count = function() {
+ return this.count$Values(1);
+};
+
+
+/**
+ * Clears the values in the optional_int32 field.
+ */
+someprotopackage.TestPackageTypes.prototype.clearOptionalInt32 = function() {
+ this.clear$Field(1);
+};
+
+
+/**
+ * Gets the value of the other_all field.
+ * @return {proto2.TestAllTypes} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOtherAll = function() {
+ return /** @type {proto2.TestAllTypes} */ (this.get$Value(2));
+};
+
+
+/**
+ * Gets the value of the other_all field or the default value if not set.
+ * @return {!proto2.TestAllTypes} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOtherAllOrDefault = function() {
+ return /** @type {!proto2.TestAllTypes} */ (this.get$ValueOrDefault(2));
+};
+
+
+/**
+ * Sets the value of the other_all field.
+ * @param {!proto2.TestAllTypes} value The value.
+ */
+someprotopackage.TestPackageTypes.prototype.setOtherAll = function(value) {
+ this.set$Value(2, value);
+};
+
+
+/**
+ * @return {boolean} Whether the other_all field has a value.
+ */
+someprotopackage.TestPackageTypes.prototype.hasOtherAll = function() {
+ return this.has$Value(2);
+};
+
+
+/**
+ * @return {number} The number of values in the other_all field.
+ */
+someprotopackage.TestPackageTypes.prototype.otherAllCount = function() {
+ return this.count$Values(2);
+};
+
+
+/**
+ * Clears the values in the other_all field.
+ */
+someprotopackage.TestPackageTypes.prototype.clearOtherAll = function() {
+ this.clear$Field(2);
+};
+
+
+goog.proto2.Message.set$Metadata(someprotopackage.TestPackageTypes, {
+ 0: {
+ name: 'TestPackageTypes',
+ fullName: 'someprotopackage.TestPackageTypes'
+ },
+ 1: {
+ name: 'optional_int32',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ },
+ 2: {
+ name: 'other_all',
+ fieldType: goog.proto2.Message.FieldType.MESSAGE,
+ type: proto2.TestAllTypes
+ }
+});
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer.js.svn-base
new file mode 100644
index 0000000..fe179a2
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer.js.svn-base
@@ -0,0 +1,150 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer 2 Serializer which serializes messages
+ * into PB-Lite ("JsPbLite") format.
+ *
+ * PB-Lite format is an array where each index corresponds to the associated tag
+ * number. For example, a message like so:
+ *
+ * message Foo {
+ * optional int bar = 1;
+ * optional int baz = 2;
+ * optional int bop = 4;
+ * }
+ *
+ * would be represented as such:
+ *
+ * [, (bar data), (baz data), (nothing), (bop data)]
+ *
+ * Note that since the array index is used to represent the tag number, sparsely
+ * populated messages with tag numbers that are not continuous (and/or are very
+ * large) will have many (empty) spots and thus, are inefficient.
+ *
+ *
+ */
+
+goog.provide('goog.proto2.PbLiteSerializer');
+
+goog.require('goog.proto2.LazyDeserializer');
+goog.require('goog.proto2.Util');
+
+
+
+/**
+ * PB-Lite serializer.
+ *
+ * @constructor
+ * @extends {goog.proto2.LazyDeserializer}
+ */
+goog.proto2.PbLiteSerializer = function() {};
+goog.inherits(goog.proto2.PbLiteSerializer, goog.proto2.LazyDeserializer);
+
+
+/**
+ * Serializes a message to a PB-Lite object.
+ *
+ * @param {goog.proto2.Message} message The message to be serialized.
+ *
+ * @return {!Array} The serialized form of the message.
+ */
+goog.proto2.PbLiteSerializer.prototype.serialize = function(message) {
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ var serialized = [];
+
+ // Add the known fields.
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+
+ if (!message.has(field)) {
+ continue;
+ }
+
+ var tag = field.getTag();
+
+ if (field.isRepeated()) {
+ serialized[tag] = [];
+
+ for (var j = 0; j < message.countOf(field); j++) {
+ serialized[tag][j] =
+ this.getSerializedValue(field, message.get(field, j));
+ }
+ } else {
+ serialized[tag] = this.getSerializedValue(field, message.get(field));
+ }
+ }
+
+ // Add any unknown fields.
+ message.forEachUnknown(function(tag, value) {
+ serialized[tag] = value;
+ });
+
+ return serialized;
+};
+
+
+/** @override */
+goog.proto2.PbLiteSerializer.prototype.deserializeField =
+ function(message, field, value) {
+
+ if (value == null) {
+ // Since value double-equals null, it may be either null or undefined.
+ // Ensure we return the same one, since they have different meanings.
+ return value;
+ }
+
+ if (field.isRepeated()) {
+ var data = [];
+
+ goog.proto2.Util.assert(goog.isArray(value));
+
+ for (var i = 0; i < value.length; i++) {
+ data[i] = this.getDeserializedValue(field, value[i]);
+ }
+
+ return data;
+ } else {
+ return this.getDeserializedValue(field, value);
+ }
+};
+
+
+/** @override */
+goog.proto2.PbLiteSerializer.prototype.getSerializedValue =
+ function(field, value) {
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.BOOL) {
+ // Booleans are serialized in numeric form.
+ return value ? 1 : 0;
+ }
+
+ return goog.proto2.Serializer.prototype.getSerializedValue.apply(this,
+ arguments);
+};
+
+
+/** @override */
+goog.proto2.PbLiteSerializer.prototype.getDeserializedValue =
+ function(field, value) {
+
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.BOOL) {
+ // Booleans are serialized in numeric form.
+ return value === 1;
+ }
+
+ return goog.proto2.Serializer.prototype.getDeserializedValue.apply(this,
+ arguments);
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer_test.html.svn-base
new file mode 100644
index 0000000..a9b2a31
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/pbliteserializer_test.html.svn-base
@@ -0,0 +1,267 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - pbliteserializer.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.PbLiteSerializer');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testSerializationAndDeserialization() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Skip a few repeated fields so we can test how null array values are
+ // handled.
+ message.addRepeatedString('foo');
+ message.addRepeatedString('bar');
+
+ // Serialize.
+ var serializer = new goog.proto2.PbLiteSerializer();
+ var pblite = serializer.serialize(message);
+
+ assertTrue(goog.isArray(pblite));
+
+ // Assert that everything serialized properly.
+ assertEquals(101, pblite[1]);
+ assertEquals('102', pblite[2]);
+ assertEquals(103, pblite[3]);
+ assertEquals('104', pblite[4]);
+ assertEquals(105, pblite[5]);
+ assertEquals('106', pblite[6]);
+ assertEquals(107, pblite[7]);
+ assertEquals('108', pblite[8]);
+ assertEquals(109, pblite[9]);
+ assertEquals('110', pblite[10]);
+ assertEquals(111.5, pblite[11]);
+ assertEquals(112.5, pblite[12]);
+ assertEquals(1, pblite[13]); // true is serialized as 1
+ assertEquals('test', pblite[14]);
+ assertEquals('abcd', pblite[15]);
+
+ assertEquals(111, pblite[16][17]);
+ assertEquals(112, pblite[18][1]);
+
+ assertTrue(pblite[19] === undefined);
+ assertTrue(pblite[20] === undefined);
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO, pblite[21]);
+
+ assertEquals(201, pblite[31][0]);
+ assertEquals(202, pblite[31][1]);
+ assertEquals('foo', pblite[44][0]);
+ assertEquals('bar', pblite[44][1]);
+
+ var serializer = new goog.proto2.PbLiteSerializer();
+ // Deserialize.
+ var messageCopy =
+ serializer.deserialize(proto2.TestAllTypes.getDescriptor(), pblite);
+
+ assertNotEquals(messageCopy, message);
+
+ assertDeserializationMatches(messageCopy);
+}
+
+function testDeserializationFromExternalSource() {
+ // Test deserialization where the JSON array is initialized from something
+ // outside the Closure proto2 library, such as the JsPbLite library, or
+ // manually as in this test.
+ var pblite = [
+ , // 0
+ 101, // 1
+ '102', // 2
+ 103, // 3
+ '104', // 4
+ 105, // 5
+ '106', // 6
+ 107, // 7
+ '108', // 8
+ 109, // 9
+ '110', // 10
+ 111.5, // 11
+ 112.5, // 12
+ 1, // 13
+ 'test', // 14
+ 'abcd', // 15
+ [,,,,,,,,,,,,,,,,,111], // 16, note the 17 commas so value is index 17
+ , // 17
+ [,112], // 18
+ ,, // 19-20
+ proto2.TestAllTypes.NestedEnum.FOO, // 21
+ ,,,,,,,,, // 22-30
+ [201, 202], // 31
+ ,,,,,,,,,,,, // 32-43
+ ['foo', 'bar'], // 44
+ ,,,, // 45-49
+ ];
+
+ var serializer = new goog.proto2.PbLiteSerializer();
+ // Deserialize.
+ var messageCopy =
+ serializer.deserialize(proto2.TestAllTypes.getDescriptor(), pblite);
+
+ assertDeserializationMatches(messageCopy);
+
+ // http://b/issue?id=2928075
+ assertFalse(messageCopy.hasRepeatedInt64());
+ assertEquals(0, messageCopy.repeatedInt64Count());
+ messageCopy.repeatedInt64Array();
+ assertFalse(messageCopy.hasRepeatedInt64());
+ assertEquals(0, messageCopy.repeatedInt64Count());
+}
+
+function assertDeserializationMatches(messageCopy) {
+ assertNotNull(messageCopy);
+
+ assertTrue(messageCopy.hasOptionalInt32());
+ assertTrue(messageCopy.hasOptionalInt64());
+ assertTrue(messageCopy.hasOptionalUint32());
+ assertTrue(messageCopy.hasOptionalUint64());
+ assertTrue(messageCopy.hasOptionalSint32());
+ assertTrue(messageCopy.hasOptionalSint64());
+ assertTrue(messageCopy.hasOptionalFixed32());
+ assertTrue(messageCopy.hasOptionalFixed64());
+ assertTrue(messageCopy.hasOptionalSfixed32());
+ assertTrue(messageCopy.hasOptionalSfixed64());
+ assertTrue(messageCopy.hasOptionalFloat());
+ assertTrue(messageCopy.hasOptionalDouble());
+ assertTrue(messageCopy.hasOptionalBool());
+ assertTrue(messageCopy.hasOptionalString());
+ assertTrue(messageCopy.hasOptionalBytes());
+ assertTrue(messageCopy.hasOptionalgroup());
+ assertTrue(messageCopy.hasOptionalNestedMessage());
+ assertTrue(messageCopy.hasOptionalNestedEnum());
+
+ assertTrue(messageCopy.hasRepeatedInt32());
+ assertFalse(messageCopy.hasRepeatedInt64());
+ assertFalse(messageCopy.hasRepeatedUint32());
+ assertFalse(messageCopy.hasRepeatedUint64());
+ assertFalse(messageCopy.hasRepeatedSint32());
+ assertFalse(messageCopy.hasRepeatedSint64());
+ assertFalse(messageCopy.hasRepeatedFixed32());
+ assertFalse(messageCopy.hasRepeatedFixed64());
+ assertFalse(messageCopy.hasRepeatedSfixed32());
+ assertFalse(messageCopy.hasRepeatedSfixed64());
+ assertFalse(messageCopy.hasRepeatedFloat());
+ assertFalse(messageCopy.hasRepeatedDouble());
+ assertFalse(messageCopy.hasRepeatedBool());
+ assertTrue(messageCopy.hasRepeatedString());
+ assertFalse(messageCopy.hasRepeatedBytes());
+ assertFalse(messageCopy.hasRepeatedgroup());
+ assertFalse(messageCopy.hasRepeatedNestedMessage());
+ assertFalse(messageCopy.hasRepeatedNestedEnum());
+
+ assertEquals(1, messageCopy.optionalInt32Count());
+ assertEquals(1, messageCopy.optionalInt64Count());
+ assertEquals(1, messageCopy.optionalUint32Count());
+ assertEquals(1, messageCopy.optionalUint64Count());
+ assertEquals(1, messageCopy.optionalSint32Count());
+ assertEquals(1, messageCopy.optionalSint64Count());
+ assertEquals(1, messageCopy.optionalFixed32Count());
+ assertEquals(1, messageCopy.optionalFixed64Count());
+ assertEquals(1, messageCopy.optionalSfixed32Count());
+ assertEquals(1, messageCopy.optionalSfixed64Count());
+ assertEquals(1, messageCopy.optionalFloatCount());
+ assertEquals(1, messageCopy.optionalDoubleCount());
+ assertEquals(1, messageCopy.optionalBoolCount());
+ assertEquals(1, messageCopy.optionalStringCount());
+ assertEquals(1, messageCopy.optionalBytesCount());
+ assertEquals(1, messageCopy.optionalgroupCount());
+ assertEquals(1, messageCopy.optionalNestedMessageCount());
+ assertEquals(1, messageCopy.optionalNestedEnumCount());
+
+ assertEquals(2, messageCopy.repeatedInt32Count());
+ assertEquals(0, messageCopy.repeatedInt64Count());
+ assertEquals(0, messageCopy.repeatedUint32Count());
+ assertEquals(0, messageCopy.repeatedUint64Count());
+ assertEquals(0, messageCopy.repeatedSint32Count());
+ assertEquals(0, messageCopy.repeatedSint64Count());
+ assertEquals(0, messageCopy.repeatedFixed32Count());
+ assertEquals(0, messageCopy.repeatedFixed64Count());
+ assertEquals(0, messageCopy.repeatedSfixed32Count());
+ assertEquals(0, messageCopy.repeatedSfixed64Count());
+ assertEquals(0, messageCopy.repeatedFloatCount());
+ assertEquals(0, messageCopy.repeatedDoubleCount());
+ assertEquals(0, messageCopy.repeatedBoolCount());
+ assertEquals(2, messageCopy.repeatedStringCount());
+ assertEquals(0, messageCopy.repeatedBytesCount());
+ assertEquals(0, messageCopy.repeatedgroupCount());
+ assertEquals(0, messageCopy.repeatedNestedMessageCount());
+ assertEquals(0, messageCopy.repeatedNestedEnumCount());
+
+ assertEquals(101, messageCopy.getOptionalInt32());
+ assertEquals('102', messageCopy.getOptionalInt64());
+ assertEquals(103, messageCopy.getOptionalUint32());
+ assertEquals('104', messageCopy.getOptionalUint64());
+ assertEquals(105, messageCopy.getOptionalSint32());
+ assertEquals('106', messageCopy.getOptionalSint64());
+ assertEquals(107, messageCopy.getOptionalFixed32());
+ assertEquals('108', messageCopy.getOptionalFixed64());
+ assertEquals(109, messageCopy.getOptionalSfixed32());
+ assertEquals('110', messageCopy.getOptionalSfixed64());
+ assertEquals(111.5, messageCopy.getOptionalFloat());
+ assertEquals(112.5, messageCopy.getOptionalDouble());
+ assertEquals(true, messageCopy.getOptionalBool());
+ assertEquals('test', messageCopy.getOptionalString());
+ assertEquals('abcd', messageCopy.getOptionalBytes());
+ assertEquals(111, messageCopy.getOptionalgroup().getA());
+
+ assertEquals(112, messageCopy.getOptionalNestedMessage().getB());
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ messageCopy.getOptionalNestedEnum());
+
+ assertEquals(201, messageCopy.getRepeatedInt32(0));
+ assertEquals(202, messageCopy.getRepeatedInt32(1));
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/proto_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/proto_test.html.svn-base
new file mode 100644
index 0000000..26dc097
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/proto_test.html.svn-base
@@ -0,0 +1,693 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - Message Tests</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('someprotopackage.TestPackageTypes');
+ goog.require('proto2.TestAllTypes');
+ goog.require('goog.testing.jsunit');
+</script>
+</head>
+<body>
+<script>
+
+function testPackage() {
+ var message = new someprotopackage.TestPackageTypes();
+ message.setOptionalInt32(45);
+ message.setOtherAll(new proto2.TestAllTypes());
+}
+
+function testFields() {
+ var message = new proto2.TestAllTypes();
+
+ // Ensure that the fields are not set.
+ assertFalse(message.hasOptionalInt32());
+ assertFalse(message.hasOptionalInt64());
+ assertFalse(message.hasOptionalUint32());
+ assertFalse(message.hasOptionalUint64());
+ assertFalse(message.hasOptionalSint32());
+ assertFalse(message.hasOptionalSint64());
+ assertFalse(message.hasOptionalFixed32());
+ assertFalse(message.hasOptionalFixed64());
+ assertFalse(message.hasOptionalSfixed32());
+ assertFalse(message.hasOptionalSfixed64());
+ assertFalse(message.hasOptionalFloat());
+ assertFalse(message.hasOptionalDouble());
+ assertFalse(message.hasOptionalBool());
+ assertFalse(message.hasOptionalString());
+ assertFalse(message.hasOptionalBytes());
+ assertFalse(message.hasOptionalgroup());
+ assertFalse(message.hasOptionalNestedMessage());
+ assertFalse(message.hasOptionalNestedEnum());
+
+ // Check non-set values.
+ assertNull(message.getOptionalInt32());
+ assertNull(message.getOptionalInt64());
+ assertNull(message.getOptionalFloat());
+ assertNull(message.getOptionalString());
+ assertNull(message.getOptionalBytes());
+ assertNull(message.getOptionalNestedMessage());
+ assertNull(message.getOptionalNestedEnum());
+
+ // Check default values.
+ assertEquals(0, message.getOptionalInt32OrDefault());
+ assertEquals('1', message.getOptionalInt64OrDefault());
+ assertEquals(1.5, message.getOptionalFloatOrDefault());
+ assertEquals('', message.getOptionalStringOrDefault());
+ assertEquals('moo', message.getOptionalBytesOrDefault());
+
+ // Set the fields.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Ensure that the fields are set.
+ assertTrue(message.hasOptionalInt32());
+ assertTrue(message.hasOptionalInt64());
+ assertTrue(message.hasOptionalUint32());
+ assertTrue(message.hasOptionalUint64());
+ assertTrue(message.hasOptionalSint32());
+ assertTrue(message.hasOptionalSint64());
+ assertTrue(message.hasOptionalFixed32());
+ assertTrue(message.hasOptionalFixed64());
+ assertTrue(message.hasOptionalSfixed32());
+ assertTrue(message.hasOptionalSfixed64());
+ assertTrue(message.hasOptionalFloat());
+ assertTrue(message.hasOptionalDouble());
+ assertTrue(message.hasOptionalBool());
+ assertTrue(message.hasOptionalString());
+ assertTrue(message.hasOptionalBytes());
+ assertTrue(message.hasOptionalgroup());
+ assertTrue(message.hasOptionalNestedMessage());
+ assertTrue(message.hasOptionalNestedEnum());
+
+ // Ensure that there is a count of 1 for each of the fields.
+ assertEquals(1, message.optionalInt32Count());
+ assertEquals(1, message.optionalInt64Count());
+ assertEquals(1, message.optionalUint32Count());
+ assertEquals(1, message.optionalUint64Count());
+ assertEquals(1, message.optionalSint32Count());
+ assertEquals(1, message.optionalSint64Count());
+ assertEquals(1, message.optionalFixed32Count());
+ assertEquals(1, message.optionalFixed64Count());
+ assertEquals(1, message.optionalSfixed32Count());
+ assertEquals(1, message.optionalSfixed64Count());
+ assertEquals(1, message.optionalFloatCount());
+ assertEquals(1, message.optionalDoubleCount());
+ assertEquals(1, message.optionalBoolCount());
+ assertEquals(1, message.optionalStringCount());
+ assertEquals(1, message.optionalBytesCount());
+ assertEquals(1, message.optionalgroupCount());
+ assertEquals(1, message.optionalNestedMessageCount());
+ assertEquals(1, message.optionalNestedEnumCount());
+
+ // Ensure that the fields have the values expected.
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals('102', message.getOptionalInt64());
+ assertEquals(103, message.getOptionalUint32());
+ assertEquals('104', message.getOptionalUint64());
+ assertEquals(105, message.getOptionalSint32());
+ assertEquals('106', message.getOptionalSint64());
+ assertEquals(107, message.getOptionalFixed32());
+ assertEquals('108', message.getOptionalFixed64());
+ assertEquals(109, message.getOptionalSfixed32());
+ assertEquals('110', message.getOptionalSfixed64());
+ assertEquals(111.5, message.getOptionalFloat());
+ assertEquals(112.5, message.getOptionalDouble());
+ assertEquals(true, message.getOptionalBool());
+ assertEquals('test', message.getOptionalString());
+ assertEquals('abcd', message.getOptionalBytes());
+ assertEquals(group, message.getOptionalgroup());
+ assertEquals(nestedMessage, message.getOptionalNestedMessage());
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ message.getOptionalNestedEnum());
+}
+
+function testRepeated() {
+ var message = new proto2.TestAllTypes();
+
+ // Ensure that the fields are not set.
+ assertFalse(message.hasRepeatedInt32());
+ assertFalse(message.hasRepeatedInt64());
+ assertFalse(message.hasRepeatedUint32());
+ assertFalse(message.hasRepeatedUint64());
+ assertFalse(message.hasRepeatedSint32());
+ assertFalse(message.hasRepeatedSint64());
+ assertFalse(message.hasRepeatedFixed32());
+ assertFalse(message.hasRepeatedFixed64());
+ assertFalse(message.hasRepeatedSfixed32());
+ assertFalse(message.hasRepeatedSfixed64());
+ assertFalse(message.hasRepeatedFloat());
+ assertFalse(message.hasRepeatedDouble());
+ assertFalse(message.hasRepeatedBool());
+ assertFalse(message.hasRepeatedString());
+ assertFalse(message.hasRepeatedBytes());
+ assertFalse(message.hasRepeatedgroup());
+ assertFalse(message.hasRepeatedNestedMessage());
+ assertFalse(message.hasRepeatedNestedEnum());
+
+ // Expect the arrays to be empty.
+ assertEquals(0, message.repeatedInt32Array().length);
+ assertEquals(0, message.repeatedInt64Array().length);
+ assertEquals(0, message.repeatedUint32Array().length);
+ assertEquals(0, message.repeatedUint64Array().length);
+ assertEquals(0, message.repeatedSint32Array().length);
+ assertEquals(0, message.repeatedSint64Array().length);
+ assertEquals(0, message.repeatedFixed32Array().length);
+ assertEquals(0, message.repeatedFixed64Array().length);
+ assertEquals(0, message.repeatedSfixed32Array().length);
+ assertEquals(0, message.repeatedSfixed64Array().length);
+ assertEquals(0, message.repeatedFloatArray().length);
+ assertEquals(0, message.repeatedDoubleArray().length);
+ assertEquals(0, message.repeatedBoolArray().length);
+ assertEquals(0, message.repeatedStringArray().length);
+ assertEquals(0, message.repeatedBytesArray().length);
+ assertEquals(0, message.repeatedgroupArray().length);
+ assertEquals(0, message.repeatedNestedMessageArray().length);
+ assertEquals(0, message.repeatedNestedEnumArray().length);
+
+ // Set the fields.
+ message.addRepeatedInt32(101);
+ message.addRepeatedInt64('102');
+ message.addRepeatedUint32(103);
+ message.addRepeatedUint64('104');
+ message.addRepeatedSint32(105);
+ message.addRepeatedSint64('106');
+ message.addRepeatedFixed32(107);
+ message.addRepeatedFixed64('108');
+ message.addRepeatedSfixed32(109);
+ message.addRepeatedSfixed64('110');
+ message.addRepeatedFloat(111.5);
+ message.addRepeatedDouble(112.5);
+ message.addRepeatedBool(true);
+ message.addRepeatedString('test');
+ message.addRepeatedBytes('abcd');
+
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt64('202');
+ message.addRepeatedUint32(203);
+ message.addRepeatedUint64('204');
+ message.addRepeatedSint32(205);
+ message.addRepeatedSint64('206');
+ message.addRepeatedFixed32(207);
+ message.addRepeatedFixed64('208');
+ message.addRepeatedSfixed32(209);
+ message.addRepeatedSfixed64('210');
+ message.addRepeatedFloat(211.5);
+ message.addRepeatedDouble(212.5);
+ message.addRepeatedBool(true);
+ message.addRepeatedString('test#2');
+ message.addRepeatedBytes('efgh');
+
+
+ var group1 = new proto2.TestAllTypes.RepeatedGroup();
+ group1.addA(111);
+
+ message.addRepeatedgroup(group1);
+
+ var group2 = new proto2.TestAllTypes.RepeatedGroup();
+ group2.addA(211);
+
+ message.addRepeatedgroup(group2);
+
+ var nestedMessage1 = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage1.setB(112);
+ message.addRepeatedNestedMessage(nestedMessage1);
+
+ var nestedMessage2 = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage2.setB(212);
+ message.addRepeatedNestedMessage(nestedMessage2);
+
+ message.addRepeatedNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ message.addRepeatedNestedEnum(proto2.TestAllTypes.NestedEnum.BAR);
+
+ // Ensure that the fields are set.
+ assertTrue(message.hasRepeatedInt32());
+ assertTrue(message.hasRepeatedInt64());
+ assertTrue(message.hasRepeatedUint32());
+ assertTrue(message.hasRepeatedUint64());
+ assertTrue(message.hasRepeatedSint32());
+ assertTrue(message.hasRepeatedSint64());
+ assertTrue(message.hasRepeatedFixed32());
+ assertTrue(message.hasRepeatedFixed64());
+ assertTrue(message.hasRepeatedSfixed32());
+ assertTrue(message.hasRepeatedSfixed64());
+ assertTrue(message.hasRepeatedFloat());
+ assertTrue(message.hasRepeatedDouble());
+ assertTrue(message.hasRepeatedBool());
+ assertTrue(message.hasRepeatedString());
+ assertTrue(message.hasRepeatedBytes());
+ assertTrue(message.hasRepeatedgroup());
+ assertTrue(message.hasRepeatedNestedMessage());
+ assertTrue(message.hasRepeatedNestedEnum());
+
+ // Ensure that there is a count of 2 for each of the fields.
+ assertEquals(2, message.repeatedInt32Count());
+ assertEquals(2, message.repeatedInt64Count());
+ assertEquals(2, message.repeatedUint32Count());
+ assertEquals(2, message.repeatedUint64Count());
+ assertEquals(2, message.repeatedSint32Count());
+ assertEquals(2, message.repeatedSint64Count());
+ assertEquals(2, message.repeatedFixed32Count());
+ assertEquals(2, message.repeatedFixed64Count());
+ assertEquals(2, message.repeatedSfixed32Count());
+ assertEquals(2, message.repeatedSfixed64Count());
+ assertEquals(2, message.repeatedFloatCount());
+ assertEquals(2, message.repeatedDoubleCount());
+ assertEquals(2, message.repeatedBoolCount());
+ assertEquals(2, message.repeatedStringCount());
+ assertEquals(2, message.repeatedBytesCount());
+ assertEquals(2, message.repeatedgroupCount());
+ assertEquals(2, message.repeatedNestedMessageCount());
+ assertEquals(2, message.repeatedNestedEnumCount());
+
+ // Ensure that the fields have the values expected.
+ assertEquals(101, message.getRepeatedInt32(0));
+ assertEquals('102', message.getRepeatedInt64(0));
+ assertEquals(103, message.getRepeatedUint32(0));
+ assertEquals('104', message.getRepeatedUint64(0));
+ assertEquals(105, message.getRepeatedSint32(0));
+ assertEquals('106', message.getRepeatedSint64(0));
+ assertEquals(107, message.getRepeatedFixed32(0));
+ assertEquals('108', message.getRepeatedFixed64(0));
+ assertEquals(109, message.getRepeatedSfixed32(0));
+ assertEquals('110', message.getRepeatedSfixed64(0));
+ assertEquals(111.5, message.getRepeatedFloat(0));
+ assertEquals(112.5, message.getRepeatedDouble(0));
+ assertEquals(true, message.getRepeatedBool(0));
+ assertEquals('test', message.getRepeatedString(0));
+ assertEquals('abcd', message.getRepeatedBytes(0));
+ assertEquals(group1, message.getRepeatedgroup(0));
+ assertEquals(nestedMessage1, message.getRepeatedNestedMessage(0));
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ message.getRepeatedNestedEnum(0));
+
+ assertEquals(201, message.getRepeatedInt32(1));
+ assertEquals('202', message.getRepeatedInt64(1));
+ assertEquals(203, message.getRepeatedUint32(1));
+ assertEquals('204', message.getRepeatedUint64(1));
+ assertEquals(205, message.getRepeatedSint32(1));
+ assertEquals('206', message.getRepeatedSint64(1));
+ assertEquals(207, message.getRepeatedFixed32(1));
+ assertEquals('208', message.getRepeatedFixed64(1));
+ assertEquals(209, message.getRepeatedSfixed32(1));
+ assertEquals('210', message.getRepeatedSfixed64(1));
+ assertEquals(211.5, message.getRepeatedFloat(1));
+ assertEquals(212.5, message.getRepeatedDouble(1));
+ assertEquals(true, message.getRepeatedBool(1));
+ assertEquals('test#2', message.getRepeatedString(1));
+ assertEquals('efgh', message.getRepeatedBytes(1));
+ assertEquals(group2, message.getRepeatedgroup(1));
+ assertEquals(nestedMessage2, message.getRepeatedNestedMessage(1));
+ assertEquals(proto2.TestAllTypes.NestedEnum.BAR,
+ message.getRepeatedNestedEnum(1));
+
+ // Check the array lengths.
+ assertEquals(2, message.repeatedInt32Array().length);
+ assertEquals(2, message.repeatedInt64Array().length);
+ assertEquals(2, message.repeatedUint32Array().length);
+ assertEquals(2, message.repeatedUint64Array().length);
+ assertEquals(2, message.repeatedSint32Array().length);
+ assertEquals(2, message.repeatedSint64Array().length);
+ assertEquals(2, message.repeatedFixed32Array().length);
+ assertEquals(2, message.repeatedFixed64Array().length);
+ assertEquals(2, message.repeatedSfixed32Array().length);
+ assertEquals(2, message.repeatedSfixed64Array().length);
+ assertEquals(2, message.repeatedFloatArray().length);
+ assertEquals(2, message.repeatedDoubleArray().length);
+ assertEquals(2, message.repeatedBoolArray().length);
+ assertEquals(2, message.repeatedStringArray().length);
+ assertEquals(2, message.repeatedBytesArray().length);
+ assertEquals(2, message.repeatedgroupArray().length);
+ assertEquals(2, message.repeatedNestedMessageArray().length);
+ assertEquals(2, message.repeatedNestedEnumArray().length);
+
+ // Check the array values.
+ assertEquals(message.getRepeatedInt32(0), message.repeatedInt32Array()[0]);
+ assertEquals(message.getRepeatedInt64(0), message.repeatedInt64Array()[0]);
+ assertEquals(message.getRepeatedUint32(0), message.repeatedUint32Array()[0]);
+ assertEquals(message.getRepeatedUint64(0), message.repeatedUint64Array()[0]);
+ assertEquals(message.getRepeatedSint32(0), message.repeatedSint32Array()[0]);
+ assertEquals(message.getRepeatedSint64(0), message.repeatedSint64Array()[0]);
+ assertEquals(message.getRepeatedFixed32(0),
+ message.repeatedFixed32Array()[0]);
+ assertEquals(message.getRepeatedFixed64(0),
+ message.repeatedFixed64Array()[0]);
+ assertEquals(message.getRepeatedSfixed32(0),
+ message.repeatedSfixed32Array()[0]);
+ assertEquals(message.getRepeatedSfixed64(0),
+ message.repeatedSfixed64Array()[0]);
+ assertEquals(message.getRepeatedFloat(0), message.repeatedFloatArray()[0]);
+ assertEquals(message.getRepeatedDouble(0), message.repeatedDoubleArray()[0]);
+ assertEquals(message.getRepeatedBool(0), message.repeatedBoolArray()[0]);
+ assertEquals(message.getRepeatedString(0), message.repeatedStringArray()[0]);
+ assertEquals(message.getRepeatedBytes(0), message.repeatedBytesArray()[0]);
+ assertEquals(message.getRepeatedgroup(0), message.repeatedgroupArray()[0]);
+ assertEquals(message.getRepeatedNestedMessage(0),
+ message.repeatedNestedMessageArray()[0]);
+ assertEquals(message.getRepeatedNestedEnum(0),
+ message.repeatedNestedEnumArray()[0]);
+
+ assertEquals(message.getRepeatedInt32(1), message.repeatedInt32Array()[1]);
+ assertEquals(message.getRepeatedInt64(1), message.repeatedInt64Array()[1]);
+ assertEquals(message.getRepeatedUint32(1), message.repeatedUint32Array()[1]);
+ assertEquals(message.getRepeatedUint64(1), message.repeatedUint64Array()[1]);
+ assertEquals(message.getRepeatedSint32(1), message.repeatedSint32Array()[1]);
+ assertEquals(message.getRepeatedSint64(1), message.repeatedSint64Array()[1]);
+ assertEquals(message.getRepeatedFixed32(1),
+ message.repeatedFixed32Array()[1]);
+ assertEquals(message.getRepeatedFixed64(1),
+ message.repeatedFixed64Array()[1]);
+ assertEquals(message.getRepeatedSfixed32(1),
+ message.repeatedSfixed32Array()[1]);
+ assertEquals(message.getRepeatedSfixed64(1),
+ message.repeatedSfixed64Array()[1]);
+ assertEquals(message.getRepeatedFloat(1), message.repeatedFloatArray()[1]);
+ assertEquals(message.getRepeatedDouble(1), message.repeatedDoubleArray()[1]);
+ assertEquals(message.getRepeatedBool(1), message.repeatedBoolArray()[1]);
+ assertEquals(message.getRepeatedString(1), message.repeatedStringArray()[1]);
+ assertEquals(message.getRepeatedBytes(1), message.repeatedBytesArray()[1]);
+ assertEquals(message.getRepeatedgroup(1), message.repeatedgroupArray()[1]);
+ assertEquals(message.getRepeatedNestedMessage(1),
+ message.repeatedNestedMessageArray()[1]);
+ assertEquals(message.getRepeatedNestedEnum(1),
+ message.repeatedNestedEnumArray()[1]);
+}
+
+function testDescriptor() {
+ var message = new proto2.TestAllTypes();
+ var descriptor = message.getDescriptor();
+
+ assertEquals('TestAllTypes', descriptor.getName());
+ assertEquals('TestAllTypes', descriptor.getFullName());
+ assertEquals(null, descriptor.getContainingType());
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ var nestedDescriptor = nestedMessage.getDescriptor();
+
+ assertEquals('NestedMessage', nestedDescriptor.getName());
+ assertEquals('TestAllTypes.NestedMessage',
+ nestedDescriptor.getFullName());
+ assertEquals(descriptor, nestedDescriptor.getContainingType());
+}
+
+function testFieldDescriptor() {
+ var message = new proto2.TestAllTypes();
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ assertEquals(40, fields.length);
+
+ // Check the containing types.
+ for (var i = 0; i < fields.length; ++i) {
+ assertEquals(descriptor, fields[i].getContainingType());
+ }
+
+ // Check the field names.
+ assertEquals('optional_int32', fields[0].getName());
+ assertEquals('optional_int64', fields[1].getName());
+ assertEquals('optional_uint32', fields[2].getName());
+ assertEquals('optional_uint64', fields[3].getName());
+ assertEquals('optional_sint32', fields[4].getName());
+ assertEquals('optional_sint64', fields[5].getName());
+ assertEquals('optional_fixed32', fields[6].getName());
+ assertEquals('optional_fixed64', fields[7].getName());
+ assertEquals('optional_sfixed32', fields[8].getName());
+ assertEquals('optional_sfixed64', fields[9].getName());
+ assertEquals('optional_float', fields[10].getName());
+ assertEquals('optional_double', fields[11].getName());
+ assertEquals('optional_bool', fields[12].getName());
+ assertEquals('optional_string', fields[13].getName());
+ assertEquals('optional_bytes', fields[14].getName());
+ assertEquals('optionalgroup', fields[15].getName());
+ assertEquals('optional_nested_message', fields[16].getName());
+ assertEquals('optional_nested_enum', fields[17].getName());
+
+ assertEquals('repeated_int32', fields[18].getName());
+ assertEquals('repeated_int64', fields[19].getName());
+ assertEquals('repeated_uint32', fields[20].getName());
+ assertEquals('repeated_uint64', fields[21].getName());
+ assertEquals('repeated_sint32', fields[22].getName());
+ assertEquals('repeated_sint64', fields[23].getName());
+ assertEquals('repeated_fixed32', fields[24].getName());
+ assertEquals('repeated_fixed64', fields[25].getName());
+ assertEquals('repeated_sfixed32', fields[26].getName());
+ assertEquals('repeated_sfixed64', fields[27].getName());
+ assertEquals('repeated_float', fields[28].getName());
+ assertEquals('repeated_double', fields[29].getName());
+ assertEquals('repeated_bool', fields[30].getName());
+ assertEquals('repeated_string', fields[31].getName());
+ assertEquals('repeated_bytes', fields[32].getName());
+ assertEquals('repeatedgroup', fields[33].getName());
+ assertEquals('repeated_nested_message', fields[34].getName());
+ assertEquals('repeated_nested_enum', fields[35].getName());
+
+ assertEquals('optional_int64_number', fields[36].getName());
+ assertEquals('optional_int64_string', fields[37].getName());
+ assertEquals('repeated_int64_number', fields[38].getName());
+ assertEquals('repeated_int64_string', fields[39].getName());
+
+ // Check the field types.
+ var FieldType = goog.proto2.FieldDescriptor.FieldType;
+ assertEquals(FieldType.INT32, fields[0].getFieldType());
+ assertEquals(FieldType.INT64, fields[1].getFieldType());
+ assertEquals(FieldType.UINT32, fields[2].getFieldType());
+ assertEquals(FieldType.UINT64, fields[3].getFieldType());
+ assertEquals(FieldType.SINT32, fields[4].getFieldType());
+ assertEquals(FieldType.SINT64, fields[5].getFieldType());
+ assertEquals(FieldType.FIXED32, fields[6].getFieldType());
+ assertEquals(FieldType.FIXED64, fields[7].getFieldType());
+ assertEquals(FieldType.SFIXED32, fields[8].getFieldType());
+ assertEquals(FieldType.SFIXED64, fields[9].getFieldType());
+ assertEquals(FieldType.FLOAT, fields[10].getFieldType());
+ assertEquals(FieldType.DOUBLE, fields[11].getFieldType());
+ assertEquals(FieldType.BOOL, fields[12].getFieldType());
+ assertEquals(FieldType.STRING, fields[13].getFieldType());
+ assertEquals(FieldType.BYTES, fields[14].getFieldType());
+ assertEquals(FieldType.GROUP, fields[15].getFieldType());
+ assertEquals(FieldType.MESSAGE, fields[16].getFieldType());
+ assertEquals(FieldType.ENUM, fields[17].getFieldType());
+
+ assertEquals(FieldType.INT32, fields[18].getFieldType());
+ assertEquals(FieldType.INT64, fields[19].getFieldType());
+ assertEquals(FieldType.UINT32, fields[20].getFieldType());
+ assertEquals(FieldType.UINT64, fields[21].getFieldType());
+ assertEquals(FieldType.SINT32, fields[22].getFieldType());
+ assertEquals(FieldType.SINT64, fields[23].getFieldType());
+ assertEquals(FieldType.FIXED32, fields[24].getFieldType());
+ assertEquals(FieldType.FIXED64, fields[25].getFieldType());
+ assertEquals(FieldType.SFIXED32, fields[26].getFieldType());
+ assertEquals(FieldType.SFIXED64, fields[27].getFieldType());
+ assertEquals(FieldType.FLOAT, fields[28].getFieldType());
+ assertEquals(FieldType.DOUBLE, fields[29].getFieldType());
+ assertEquals(FieldType.BOOL, fields[30].getFieldType());
+ assertEquals(FieldType.STRING, fields[31].getFieldType());
+ assertEquals(FieldType.BYTES, fields[32].getFieldType());
+ assertEquals(FieldType.GROUP, fields[33].getFieldType());
+ assertEquals(FieldType.MESSAGE, fields[34].getFieldType());
+ assertEquals(FieldType.ENUM, fields[35].getFieldType());
+
+ assertEquals(FieldType.INT64, fields[36].getFieldType());
+ assertEquals(FieldType.INT64, fields[37].getFieldType());
+ assertEquals(FieldType.INT64, fields[38].getFieldType());
+ assertEquals(FieldType.INT64, fields[39].getFieldType());
+
+ // Check the field native types.
+ // Singular.
+ assertEquals(Number, fields[0].getNativeType());
+ assertEquals(String, fields[1].getNativeType()); // 64 bit values are strings.
+ assertEquals(Number, fields[2].getNativeType());
+ assertEquals(String, fields[3].getNativeType());
+ assertEquals(Number, fields[4].getNativeType());
+ assertEquals(String, fields[5].getNativeType());
+ assertEquals(Number, fields[6].getNativeType());
+ assertEquals(String, fields[7].getNativeType());
+ assertEquals(Number, fields[8].getNativeType());
+ assertEquals(String, fields[9].getNativeType());
+ assertEquals(Number, fields[10].getNativeType());
+ assertEquals(Number, fields[11].getNativeType());
+
+ assertEquals(Boolean, fields[12].getNativeType());
+
+ assertEquals(String, fields[13].getNativeType());
+ assertEquals(String, fields[14].getNativeType());
+
+ assertEquals(proto2.TestAllTypes.OptionalGroup, fields[15].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedMessage, fields[16].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedEnum, fields[17].getNativeType());
+
+ assertEquals(Number, fields[36].getNativeType()); // [jstype="number"]
+ assertEquals(String, fields[37].getNativeType());
+
+ // Repeated.
+ assertEquals(Number, fields[18].getNativeType());
+ assertEquals(String, fields[19].getNativeType());
+ assertEquals(Number, fields[20].getNativeType());
+ assertEquals(String, fields[21].getNativeType());
+ assertEquals(Number, fields[22].getNativeType());
+ assertEquals(String, fields[23].getNativeType());
+ assertEquals(Number, fields[24].getNativeType());
+ assertEquals(String, fields[25].getNativeType());
+ assertEquals(Number, fields[26].getNativeType());
+ assertEquals(String, fields[27].getNativeType());
+ assertEquals(Number, fields[28].getNativeType());
+ assertEquals(Number, fields[29].getNativeType());
+
+ assertEquals(Boolean, fields[30].getNativeType());
+
+ assertEquals(String, fields[31].getNativeType());
+ assertEquals(String, fields[32].getNativeType());
+
+ assertEquals(proto2.TestAllTypes.RepeatedGroup, fields[33].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedMessage, fields[34].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedEnum, fields[35].getNativeType());
+
+ assertEquals(Number, fields[38].getNativeType()); // [jstype="number"]
+ assertEquals(String, fields[39].getNativeType());
+}
+
+function testUnknown() {
+ var message = new proto2.TestAllTypes();
+
+ // Set some unknown fields.
+ message.setUnknown(1000, 101);
+ message.setUnknown(1001, -102);
+ message.setUnknown(1002, true);
+ message.setUnknown(1003, 'abcd');
+ message.setUnknown(1004, [ 'he', 'llo']);
+
+ // Ensure we find them all.
+ var count = 0;
+
+ message.forEachUnknown(function(tag, value) {
+ if (tag == 1000) {
+ assertEquals(101, value);
+ }
+
+ if (tag == 1001) {
+ assertEquals(-102, value);
+ }
+
+ if (tag == 1002) {
+ assertEquals(true, value);
+ }
+
+ if (tag == 1003) {
+ assertEquals('abcd', value);
+ }
+
+ if (tag == 1004) {
+ assertEquals('he', value[0]);
+ assertEquals('llo', value[1]);
+ }
+
+ count++;
+ });
+
+ assertEquals(5, count);
+}
+
+function testReflection() {
+ var message = new proto2.TestAllTypes();
+ var descriptor = message.getDescriptor();
+ var optionalInt = descriptor.findFieldByName('optional_int32');
+ var optionalString = descriptor.findFieldByName('optional_string');
+ var repeatedInt64 = descriptor.findFieldByName('repeated_int64');
+ var optionalWrong = descriptor.findFieldByName('foo_bar');
+
+ assertFalse(optionalInt == null);
+ assertFalse(optionalString == null);
+ assertFalse(repeatedInt64 == null);
+ assertTrue(optionalWrong == null);
+
+ // Check to ensure the fields are empty.
+ assertFalse(message.has(optionalInt));
+ assertFalse(message.has(optionalString));
+ assertFalse(message.has(repeatedInt64));
+
+ assertEquals(0, message.arrayOf(repeatedInt64).length);
+
+ // Check default values.
+ assertEquals(0, message.getOrDefault(optionalInt));
+ assertEquals('', message.getOrDefault(optionalString));
+
+ // Set some of the fields.
+ message.set(optionalString, 'hello!');
+
+ message.add(repeatedInt64, '101');
+ message.add(repeatedInt64, '102');
+
+ // Check the fields.
+ assertFalse(message.has(optionalInt));
+
+ assertTrue(message.has(optionalString));
+ assertTrue(message.hasOptionalString());
+
+ assertTrue(message.has(repeatedInt64));
+ assertTrue(message.hasRepeatedInt64());
+
+ // Check the values.
+ assertEquals('hello!', message.get(optionalString));
+ assertEquals('hello!', message.getOptionalString());
+
+ assertEquals('101', message.get(repeatedInt64, 0));
+ assertEquals('102', message.get(repeatedInt64, 1));
+
+ assertEquals('101', message.getRepeatedInt64(0));
+ assertEquals('102', message.getRepeatedInt64(1));
+
+ // Check the count.
+ assertEquals(0, message.countOf(optionalInt));
+
+ assertEquals(1, message.countOf(optionalString));
+ assertEquals(1, message.optionalStringCount());
+
+ assertEquals(2, message.countOf(repeatedInt64));
+ assertEquals(2, message.repeatedInt64Count());
+
+ // Check the array.
+ assertEquals(2, message.arrayOf(repeatedInt64).length);
+
+ assertEquals(message.get(repeatedInt64, 0),
+ message.arrayOf(repeatedInt64)[0]);
+
+ assertEquals(message.get(repeatedInt64, 1),
+ message.arrayOf(repeatedInt64)[1]);
+}
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/serializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/serializer.js.svn-base
new file mode 100644
index 0000000..2038339
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/serializer.js.svn-base
@@ -0,0 +1,148 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Base class for all Protocol Buffer 2 serializers.
+ */
+
+goog.provide('goog.proto2.Serializer');
+
+goog.require('goog.proto2.Descriptor');
+goog.require('goog.proto2.FieldDescriptor');
+goog.require('goog.proto2.Message');
+goog.require('goog.proto2.Util');
+
+
+
+/**
+ * Abstract base class for PB2 serializers. A serializer is a class which
+ * implements the serialization and deserialization of a Protocol Buffer Message
+ * to/from a specific format.
+ *
+ * @constructor
+ */
+goog.proto2.Serializer = function() {};
+
+
+/**
+ * Serializes a message to the expected format.
+ *
+ * @param {goog.proto2.Message} message The message to be serialized.
+ *
+ * @return {Object} The serialized form of the message.
+ */
+goog.proto2.Serializer.prototype.serialize = goog.abstractMethod;
+
+
+/**
+ * Returns the serialized form of the given value for the given field
+ * if the field is a Message or Group and returns the value unchanged
+ * otherwise.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field from which this
+ * value came.
+ *
+ * @param {*} value The value of the field.
+ *
+ * @return {*} The value.
+ * @protected
+ */
+goog.proto2.Serializer.prototype.getSerializedValue = function(field, value) {
+ if (field.isCompositeType()) {
+ return this.serialize(/** @type {goog.proto2.Message} */ (value));
+ } else {
+ return value;
+ }
+};
+
+
+/**
+ * Deserializes a message from the expected format.
+ *
+ * @param {goog.proto2.Descriptor} descriptor The descriptor of the message
+ * to be created.
+ * @param {*} data The data of the message.
+ *
+ * @return {goog.proto2.Message} The message created.
+ */
+goog.proto2.Serializer.prototype.deserialize = function(descriptor, data) {
+ var message = descriptor.createMessageInstance();
+ this.deserializeTo(message, data);
+ goog.proto2.Util.assert(message instanceof goog.proto2.Message);
+ return message;
+};
+
+
+/**
+ * Deserializes a message from the expected format and places the
+ * data in the message.
+ *
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {*} data The data of the message.
+ */
+goog.proto2.Serializer.prototype.deserializeTo = goog.abstractMethod;
+
+
+/**
+ * Returns the deserialized form of the given value for the given field if the
+ * field is a Message or Group and returns the value, converted or unchanged,
+ * for primitive field types otherwise.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field from which this
+ * value came.
+ *
+ * @param {*} value The value of the field.
+ *
+ * @return {*} The value.
+ * @protected
+ */
+goog.proto2.Serializer.prototype.getDeserializedValue = function(field, value) {
+ // Composite types are deserialized recursively.
+ if (field.isCompositeType()) {
+ return this.deserialize(field.getFieldMessageType(), value);
+ }
+
+ // Return the raw value if the field does not allow the JSON input to be
+ // converted.
+ if (!field.deserializationConversionPermitted()) {
+ return value;
+ }
+
+ // Convert to native type of field. Return the converted value or fall
+ // through to return the raw value. The JSON encoding of int64 value 123
+ // might be either the number 123 or the string "123". The field native type
+ // could be either Number or String (depending on field options in the .proto
+ // file). All four combinations should work correctly.
+ var nativeType = field.getNativeType();
+
+ if (nativeType === String) {
+ // JSON numbers can be converted to strings.
+ if (typeof value === 'number') {
+ return String(value);
+ }
+ } else if (nativeType === Number) {
+ // JSON strings are sometimes used for large integer numeric values.
+ if (typeof value === 'string') {
+ // Validate the string. If the string is not an integral number, we would
+ // rather have an assertion or error in the caller than a mysterious NaN
+ // value.
+ if (/^-?[0-9]+$/.test(value)) {
+ return Number(value);
+ }
+ }
+ }
+
+ return value;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/test.pb.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/test.pb.js.svn-base
new file mode 100644
index 0000000..2681214
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/test.pb.js.svn-base
@@ -0,0 +1,2820 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// All other code copyright its respective owners(s).
+
+/**
+ * @fileoverview Generated Protocol Buffer code for file
+ * closure/goog/proto2/test.proto.
+ */
+
+goog.provide('proto2.TestAllTypes');
+goog.provide('proto2.TestAllTypes.NestedMessage');
+goog.provide('proto2.TestAllTypes.OptionalGroup');
+goog.provide('proto2.TestAllTypes.RepeatedGroup');
+goog.provide('proto2.TestAllTypes.NestedEnum');
+
+goog.require('goog.proto2.Message');
+
+
+
+/**
+ * Message TestAllTypes.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.prototype.clone;
+
+
+/**
+ * Gets the value of the optional_int32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt32 = function() {
+ return /** @type {?number} */ (this.get$Value(1));
+};
+
+
+/**
+ * Gets the value of the optional_int32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(1));
+};
+
+
+/**
+ * Sets the value of the optional_int32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt32 = function(value) {
+ this.set$Value(1, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt32 = function() {
+ return this.has$Value(1);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int32 field.
+ */
+proto2.TestAllTypes.prototype.optionalInt32Count = function() {
+ return this.count$Values(1);
+};
+
+
+/**
+ * Clears the values in the optional_int32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt32 = function() {
+ this.clear$Field(1);
+};
+
+
+/**
+ * Gets the value of the optional_int64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64 = function() {
+ return /** @type {?string} */ (this.get$Value(2));
+};
+
+
+/**
+ * Gets the value of the optional_int64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(2));
+};
+
+
+/**
+ * Sets the value of the optional_int64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt64 = function(value) {
+ this.set$Value(2, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt64 = function() {
+ return this.has$Value(2);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int64 field.
+ */
+proto2.TestAllTypes.prototype.optionalInt64Count = function() {
+ return this.count$Values(2);
+};
+
+
+/**
+ * Clears the values in the optional_int64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt64 = function() {
+ this.clear$Field(2);
+};
+
+
+/**
+ * Gets the value of the optional_uint32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint32 = function() {
+ return /** @type {?number} */ (this.get$Value(3));
+};
+
+
+/**
+ * Gets the value of the optional_uint32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(3));
+};
+
+
+/**
+ * Sets the value of the optional_uint32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalUint32 = function(value) {
+ this.set$Value(3, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_uint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalUint32 = function() {
+ return this.has$Value(3);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_uint32 field.
+ */
+proto2.TestAllTypes.prototype.optionalUint32Count = function() {
+ return this.count$Values(3);
+};
+
+
+/**
+ * Clears the values in the optional_uint32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalUint32 = function() {
+ this.clear$Field(3);
+};
+
+
+/**
+ * Gets the value of the optional_uint64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint64 = function() {
+ return /** @type {?string} */ (this.get$Value(4));
+};
+
+
+/**
+ * Gets the value of the optional_uint64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(4));
+};
+
+
+/**
+ * Sets the value of the optional_uint64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalUint64 = function(value) {
+ this.set$Value(4, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_uint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalUint64 = function() {
+ return this.has$Value(4);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_uint64 field.
+ */
+proto2.TestAllTypes.prototype.optionalUint64Count = function() {
+ return this.count$Values(4);
+};
+
+
+/**
+ * Clears the values in the optional_uint64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalUint64 = function() {
+ this.clear$Field(4);
+};
+
+
+/**
+ * Gets the value of the optional_sint32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint32 = function() {
+ return /** @type {?number} */ (this.get$Value(5));
+};
+
+
+/**
+ * Gets the value of the optional_sint32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(5));
+};
+
+
+/**
+ * Sets the value of the optional_sint32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSint32 = function(value) {
+ this.set$Value(5, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSint32 = function() {
+ return this.has$Value(5);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sint32 field.
+ */
+proto2.TestAllTypes.prototype.optionalSint32Count = function() {
+ return this.count$Values(5);
+};
+
+
+/**
+ * Clears the values in the optional_sint32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSint32 = function() {
+ this.clear$Field(5);
+};
+
+
+/**
+ * Gets the value of the optional_sint64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint64 = function() {
+ return /** @type {?string} */ (this.get$Value(6));
+};
+
+
+/**
+ * Gets the value of the optional_sint64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(6));
+};
+
+
+/**
+ * Sets the value of the optional_sint64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSint64 = function(value) {
+ this.set$Value(6, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSint64 = function() {
+ return this.has$Value(6);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sint64 field.
+ */
+proto2.TestAllTypes.prototype.optionalSint64Count = function() {
+ return this.count$Values(6);
+};
+
+
+/**
+ * Clears the values in the optional_sint64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSint64 = function() {
+ this.clear$Field(6);
+};
+
+
+/**
+ * Gets the value of the optional_fixed32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed32 = function() {
+ return /** @type {?number} */ (this.get$Value(7));
+};
+
+
+/**
+ * Gets the value of the optional_fixed32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(7));
+};
+
+
+/**
+ * Sets the value of the optional_fixed32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalFixed32 = function(value) {
+ this.set$Value(7, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_fixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalFixed32 = function() {
+ return this.has$Value(7);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.optionalFixed32Count = function() {
+ return this.count$Values(7);
+};
+
+
+/**
+ * Clears the values in the optional_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalFixed32 = function() {
+ this.clear$Field(7);
+};
+
+
+/**
+ * Gets the value of the optional_fixed64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed64 = function() {
+ return /** @type {?string} */ (this.get$Value(8));
+};
+
+
+/**
+ * Gets the value of the optional_fixed64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(8));
+};
+
+
+/**
+ * Sets the value of the optional_fixed64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalFixed64 = function(value) {
+ this.set$Value(8, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_fixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalFixed64 = function() {
+ return this.has$Value(8);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.optionalFixed64Count = function() {
+ return this.count$Values(8);
+};
+
+
+/**
+ * Clears the values in the optional_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalFixed64 = function() {
+ this.clear$Field(8);
+};
+
+
+/**
+ * Gets the value of the optional_sfixed32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed32 = function() {
+ return /** @type {?number} */ (this.get$Value(9));
+};
+
+
+/**
+ * Gets the value of the optional_sfixed32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(9));
+};
+
+
+/**
+ * Sets the value of the optional_sfixed32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSfixed32 = function(value) {
+ this.set$Value(9, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sfixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSfixed32 = function() {
+ return this.has$Value(9);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.optionalSfixed32Count = function() {
+ return this.count$Values(9);
+};
+
+
+/**
+ * Clears the values in the optional_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSfixed32 = function() {
+ this.clear$Field(9);
+};
+
+
+/**
+ * Gets the value of the optional_sfixed64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed64 = function() {
+ return /** @type {?string} */ (this.get$Value(10));
+};
+
+
+/**
+ * Gets the value of the optional_sfixed64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(10));
+};
+
+
+/**
+ * Sets the value of the optional_sfixed64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSfixed64 = function(value) {
+ this.set$Value(10, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sfixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSfixed64 = function() {
+ return this.has$Value(10);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.optionalSfixed64Count = function() {
+ return this.count$Values(10);
+};
+
+
+/**
+ * Clears the values in the optional_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSfixed64 = function() {
+ this.clear$Field(10);
+};
+
+
+/**
+ * Gets the value of the optional_float field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFloat = function() {
+ return /** @type {?number} */ (this.get$Value(11));
+};
+
+
+/**
+ * Gets the value of the optional_float field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFloatOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(11));
+};
+
+
+/**
+ * Sets the value of the optional_float field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalFloat = function(value) {
+ this.set$Value(11, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_float field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalFloat = function() {
+ return this.has$Value(11);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_float field.
+ */
+proto2.TestAllTypes.prototype.optionalFloatCount = function() {
+ return this.count$Values(11);
+};
+
+
+/**
+ * Clears the values in the optional_float field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalFloat = function() {
+ this.clear$Field(11);
+};
+
+
+/**
+ * Gets the value of the optional_double field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalDouble = function() {
+ return /** @type {?number} */ (this.get$Value(12));
+};
+
+
+/**
+ * Gets the value of the optional_double field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalDoubleOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(12));
+};
+
+
+/**
+ * Sets the value of the optional_double field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalDouble = function(value) {
+ this.set$Value(12, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_double field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalDouble = function() {
+ return this.has$Value(12);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_double field.
+ */
+proto2.TestAllTypes.prototype.optionalDoubleCount = function() {
+ return this.count$Values(12);
+};
+
+
+/**
+ * Clears the values in the optional_double field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalDouble = function() {
+ this.clear$Field(12);
+};
+
+
+/**
+ * Gets the value of the optional_bool field.
+ * @return {?boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBool = function() {
+ return /** @type {?boolean} */ (this.get$Value(13));
+};
+
+
+/**
+ * Gets the value of the optional_bool field or the default value if not set.
+ * @return {boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBoolOrDefault = function() {
+ return /** @type {boolean} */ (this.get$ValueOrDefault(13));
+};
+
+
+/**
+ * Sets the value of the optional_bool field.
+ * @param {boolean} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalBool = function(value) {
+ this.set$Value(13, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_bool field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalBool = function() {
+ return this.has$Value(13);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_bool field.
+ */
+proto2.TestAllTypes.prototype.optionalBoolCount = function() {
+ return this.count$Values(13);
+};
+
+
+/**
+ * Clears the values in the optional_bool field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalBool = function() {
+ this.clear$Field(13);
+};
+
+
+/**
+ * Gets the value of the optional_string field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalString = function() {
+ return /** @type {?string} */ (this.get$Value(14));
+};
+
+
+/**
+ * Gets the value of the optional_string field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalStringOrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(14));
+};
+
+
+/**
+ * Sets the value of the optional_string field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalString = function(value) {
+ this.set$Value(14, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalString = function() {
+ return this.has$Value(14);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_string field.
+ */
+proto2.TestAllTypes.prototype.optionalStringCount = function() {
+ return this.count$Values(14);
+};
+
+
+/**
+ * Clears the values in the optional_string field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalString = function() {
+ this.clear$Field(14);
+};
+
+
+/**
+ * Gets the value of the optional_bytes field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBytes = function() {
+ return /** @type {?string} */ (this.get$Value(15));
+};
+
+
+/**
+ * Gets the value of the optional_bytes field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBytesOrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(15));
+};
+
+
+/**
+ * Sets the value of the optional_bytes field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalBytes = function(value) {
+ this.set$Value(15, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_bytes field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalBytes = function() {
+ return this.has$Value(15);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_bytes field.
+ */
+proto2.TestAllTypes.prototype.optionalBytesCount = function() {
+ return this.count$Values(15);
+};
+
+
+/**
+ * Clears the values in the optional_bytes field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalBytes = function() {
+ this.clear$Field(15);
+};
+
+
+/**
+ * Gets the value of the optionalgroup field.
+ * @return {proto2.TestAllTypes.OptionalGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalgroup = function() {
+ return /** @type {proto2.TestAllTypes.OptionalGroup} */ (this.get$Value(16));
+};
+
+
+/**
+ * Gets the value of the optionalgroup field or the default value if not set.
+ * @return {!proto2.TestAllTypes.OptionalGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalgroupOrDefault = function() {
+ return /** @type {!proto2.TestAllTypes.OptionalGroup} */ (this.get$ValueOrDefault(16));
+};
+
+
+/**
+ * Sets the value of the optionalgroup field.
+ * @param {!proto2.TestAllTypes.OptionalGroup} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalgroup = function(value) {
+ this.set$Value(16, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optionalgroup field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalgroup = function() {
+ return this.has$Value(16);
+};
+
+
+/**
+ * @return {number} The number of values in the optionalgroup field.
+ */
+proto2.TestAllTypes.prototype.optionalgroupCount = function() {
+ return this.count$Values(16);
+};
+
+
+/**
+ * Clears the values in the optionalgroup field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalgroup = function() {
+ this.clear$Field(16);
+};
+
+
+/**
+ * Gets the value of the optional_nested_message field.
+ * @return {proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedMessage = function() {
+ return /** @type {proto2.TestAllTypes.NestedMessage} */ (this.get$Value(18));
+};
+
+
+/**
+ * Gets the value of the optional_nested_message field or the default value if not set.
+ * @return {!proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedMessageOrDefault = function() {
+ return /** @type {!proto2.TestAllTypes.NestedMessage} */ (this.get$ValueOrDefault(18));
+};
+
+
+/**
+ * Sets the value of the optional_nested_message field.
+ * @param {!proto2.TestAllTypes.NestedMessage} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalNestedMessage = function(value) {
+ this.set$Value(18, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_nested_message field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalNestedMessage = function() {
+ return this.has$Value(18);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_nested_message field.
+ */
+proto2.TestAllTypes.prototype.optionalNestedMessageCount = function() {
+ return this.count$Values(18);
+};
+
+
+/**
+ * Clears the values in the optional_nested_message field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalNestedMessage = function() {
+ this.clear$Field(18);
+};
+
+
+/**
+ * Gets the value of the optional_nested_enum field.
+ * @return {?proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedEnum = function() {
+ return /** @type {?proto2.TestAllTypes.NestedEnum} */ (this.get$Value(21));
+};
+
+
+/**
+ * Gets the value of the optional_nested_enum field or the default value if not set.
+ * @return {proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedEnumOrDefault = function() {
+ return /** @type {proto2.TestAllTypes.NestedEnum} */ (this.get$ValueOrDefault(21));
+};
+
+
+/**
+ * Sets the value of the optional_nested_enum field.
+ * @param {proto2.TestAllTypes.NestedEnum} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalNestedEnum = function(value) {
+ this.set$Value(21, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_nested_enum field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalNestedEnum = function() {
+ return this.has$Value(21);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.optionalNestedEnumCount = function() {
+ return this.count$Values(21);
+};
+
+
+/**
+ * Clears the values in the optional_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalNestedEnum = function() {
+ this.clear$Field(21);
+};
+
+
+/**
+ * Gets the value of the optional_int64_number field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64Number = function() {
+ return /** @type {?number} */ (this.get$Value(50));
+};
+
+
+/**
+ * Gets the value of the optional_int64_number field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64NumberOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(50));
+};
+
+
+/**
+ * Sets the value of the optional_int64_number field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt64Number = function(value) {
+ this.set$Value(50, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int64_number field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt64Number = function() {
+ return this.has$Value(50);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int64_number field.
+ */
+proto2.TestAllTypes.prototype.optionalInt64NumberCount = function() {
+ return this.count$Values(50);
+};
+
+
+/**
+ * Clears the values in the optional_int64_number field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt64Number = function() {
+ this.clear$Field(50);
+};
+
+
+/**
+ * Gets the value of the optional_int64_string field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64String = function() {
+ return /** @type {?string} */ (this.get$Value(51));
+};
+
+
+/**
+ * Gets the value of the optional_int64_string field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64StringOrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(51));
+};
+
+
+/**
+ * Sets the value of the optional_int64_string field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt64String = function(value) {
+ this.set$Value(51, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int64_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt64String = function() {
+ return this.has$Value(51);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int64_string field.
+ */
+proto2.TestAllTypes.prototype.optionalInt64StringCount = function() {
+ return this.count$Values(51);
+};
+
+
+/**
+ * Clears the values in the optional_int64_string field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt64String = function() {
+ this.clear$Field(51);
+};
+
+
+/**
+ * Gets the value of the repeated_int32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(31, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(31, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt32 = function(value) {
+ this.add$Value(31, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(31));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt32 = function() {
+ return this.has$Value(31);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt32Count = function() {
+ return this.count$Values(31);
+};
+
+
+/**
+ * Clears the values in the repeated_int32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt32 = function() {
+ this.clear$Field(31);
+};
+
+
+/**
+ * Gets the value of the repeated_int64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(32, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(32, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt64 = function(value) {
+ this.add$Value(32, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(32));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt64 = function() {
+ return this.has$Value(32);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64Count = function() {
+ return this.count$Values(32);
+};
+
+
+/**
+ * Clears the values in the repeated_int64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt64 = function() {
+ this.clear$Field(32);
+};
+
+
+/**
+ * Gets the value of the repeated_uint32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(33, index));
+};
+
+
+/**
+ * Gets the value of the repeated_uint32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(33, index));
+};
+
+
+/**
+ * Adds a value to the repeated_uint32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedUint32 = function(value) {
+ this.add$Value(33, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_uint32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(33));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_uint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedUint32 = function() {
+ return this.has$Value(33);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_uint32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint32Count = function() {
+ return this.count$Values(33);
+};
+
+
+/**
+ * Clears the values in the repeated_uint32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedUint32 = function() {
+ this.clear$Field(33);
+};
+
+
+/**
+ * Gets the value of the repeated_uint64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(34, index));
+};
+
+
+/**
+ * Gets the value of the repeated_uint64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(34, index));
+};
+
+
+/**
+ * Adds a value to the repeated_uint64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedUint64 = function(value) {
+ this.add$Value(34, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_uint64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(34));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_uint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedUint64 = function() {
+ return this.has$Value(34);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_uint64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint64Count = function() {
+ return this.count$Values(34);
+};
+
+
+/**
+ * Clears the values in the repeated_uint64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedUint64 = function() {
+ this.clear$Field(34);
+};
+
+
+/**
+ * Gets the value of the repeated_sint32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(35, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sint32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(35, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sint32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSint32 = function(value) {
+ this.add$Value(35, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sint32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(35));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSint32 = function() {
+ return this.has$Value(35);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sint32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint32Count = function() {
+ return this.count$Values(35);
+};
+
+
+/**
+ * Clears the values in the repeated_sint32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSint32 = function() {
+ this.clear$Field(35);
+};
+
+
+/**
+ * Gets the value of the repeated_sint64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(36, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sint64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(36, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sint64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSint64 = function(value) {
+ this.add$Value(36, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sint64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(36));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSint64 = function() {
+ return this.has$Value(36);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sint64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint64Count = function() {
+ return this.count$Values(36);
+};
+
+
+/**
+ * Clears the values in the repeated_sint64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSint64 = function() {
+ this.clear$Field(36);
+};
+
+
+/**
+ * Gets the value of the repeated_fixed32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(37, index));
+};
+
+
+/**
+ * Gets the value of the repeated_fixed32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(37, index));
+};
+
+
+/**
+ * Adds a value to the repeated_fixed32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedFixed32 = function(value) {
+ this.add$Value(37, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_fixed32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(37));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_fixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedFixed32 = function() {
+ return this.has$Value(37);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed32Count = function() {
+ return this.count$Values(37);
+};
+
+
+/**
+ * Clears the values in the repeated_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedFixed32 = function() {
+ this.clear$Field(37);
+};
+
+
+/**
+ * Gets the value of the repeated_fixed64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(38, index));
+};
+
+
+/**
+ * Gets the value of the repeated_fixed64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(38, index));
+};
+
+
+/**
+ * Adds a value to the repeated_fixed64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedFixed64 = function(value) {
+ this.add$Value(38, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_fixed64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(38));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_fixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedFixed64 = function() {
+ return this.has$Value(38);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed64Count = function() {
+ return this.count$Values(38);
+};
+
+
+/**
+ * Clears the values in the repeated_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedFixed64 = function() {
+ this.clear$Field(38);
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(39, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(39, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sfixed32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSfixed32 = function(value) {
+ this.add$Value(39, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sfixed32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(39));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sfixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSfixed32 = function() {
+ return this.has$Value(39);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed32Count = function() {
+ return this.count$Values(39);
+};
+
+
+/**
+ * Clears the values in the repeated_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSfixed32 = function() {
+ this.clear$Field(39);
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(40, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(40, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sfixed64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSfixed64 = function(value) {
+ this.add$Value(40, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sfixed64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(40));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sfixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSfixed64 = function() {
+ return this.has$Value(40);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed64Count = function() {
+ return this.count$Values(40);
+};
+
+
+/**
+ * Clears the values in the repeated_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSfixed64 = function() {
+ this.clear$Field(40);
+};
+
+
+/**
+ * Gets the value of the repeated_float field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFloat = function(index) {
+ return /** @type {?number} */ (this.get$Value(41, index));
+};
+
+
+/**
+ * Gets the value of the repeated_float field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFloatOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(41, index));
+};
+
+
+/**
+ * Adds a value to the repeated_float field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedFloat = function(value) {
+ this.add$Value(41, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_float field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedFloatArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(41));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_float field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedFloat = function() {
+ return this.has$Value(41);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_float field.
+ */
+proto2.TestAllTypes.prototype.repeatedFloatCount = function() {
+ return this.count$Values(41);
+};
+
+
+/**
+ * Clears the values in the repeated_float field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedFloat = function() {
+ this.clear$Field(41);
+};
+
+
+/**
+ * Gets the value of the repeated_double field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedDouble = function(index) {
+ return /** @type {?number} */ (this.get$Value(42, index));
+};
+
+
+/**
+ * Gets the value of the repeated_double field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedDoubleOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(42, index));
+};
+
+
+/**
+ * Adds a value to the repeated_double field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedDouble = function(value) {
+ this.add$Value(42, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_double field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedDoubleArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(42));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_double field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedDouble = function() {
+ return this.has$Value(42);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_double field.
+ */
+proto2.TestAllTypes.prototype.repeatedDoubleCount = function() {
+ return this.count$Values(42);
+};
+
+
+/**
+ * Clears the values in the repeated_double field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedDouble = function() {
+ this.clear$Field(42);
+};
+
+
+/**
+ * Gets the value of the repeated_bool field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBool = function(index) {
+ return /** @type {?boolean} */ (this.get$Value(43, index));
+};
+
+
+/**
+ * Gets the value of the repeated_bool field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBoolOrDefault = function(index) {
+ return /** @type {boolean} */ (this.get$ValueOrDefault(43, index));
+};
+
+
+/**
+ * Adds a value to the repeated_bool field.
+ * @param {boolean} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedBool = function(value) {
+ this.add$Value(43, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_bool field.
+ * @return {!Array.<boolean>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedBoolArray = function() {
+ return /** @type {!Array.<boolean>} */ (this.array$Values(43));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_bool field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedBool = function() {
+ return this.has$Value(43);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_bool field.
+ */
+proto2.TestAllTypes.prototype.repeatedBoolCount = function() {
+ return this.count$Values(43);
+};
+
+
+/**
+ * Clears the values in the repeated_bool field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedBool = function() {
+ this.clear$Field(43);
+};
+
+
+/**
+ * Gets the value of the repeated_string field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedString = function(index) {
+ return /** @type {?string} */ (this.get$Value(44, index));
+};
+
+
+/**
+ * Gets the value of the repeated_string field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedStringOrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(44, index));
+};
+
+
+/**
+ * Adds a value to the repeated_string field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedString = function(value) {
+ this.add$Value(44, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_string field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedStringArray = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(44));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedString = function() {
+ return this.has$Value(44);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_string field.
+ */
+proto2.TestAllTypes.prototype.repeatedStringCount = function() {
+ return this.count$Values(44);
+};
+
+
+/**
+ * Clears the values in the repeated_string field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedString = function() {
+ this.clear$Field(44);
+};
+
+
+/**
+ * Gets the value of the repeated_bytes field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBytes = function(index) {
+ return /** @type {?string} */ (this.get$Value(45, index));
+};
+
+
+/**
+ * Gets the value of the repeated_bytes field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBytesOrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(45, index));
+};
+
+
+/**
+ * Adds a value to the repeated_bytes field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedBytes = function(value) {
+ this.add$Value(45, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_bytes field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedBytesArray = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(45));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_bytes field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedBytes = function() {
+ return this.has$Value(45);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_bytes field.
+ */
+proto2.TestAllTypes.prototype.repeatedBytesCount = function() {
+ return this.count$Values(45);
+};
+
+
+/**
+ * Clears the values in the repeated_bytes field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedBytes = function() {
+ this.clear$Field(45);
+};
+
+
+/**
+ * Gets the value of the repeatedgroup field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {proto2.TestAllTypes.RepeatedGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedgroup = function(index) {
+ return /** @type {proto2.TestAllTypes.RepeatedGroup} */ (this.get$Value(46, index));
+};
+
+
+/**
+ * Gets the value of the repeatedgroup field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {!proto2.TestAllTypes.RepeatedGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedgroupOrDefault = function(index) {
+ return /** @type {!proto2.TestAllTypes.RepeatedGroup} */ (this.get$ValueOrDefault(46, index));
+};
+
+
+/**
+ * Adds a value to the repeatedgroup field.
+ * @param {!proto2.TestAllTypes.RepeatedGroup} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedgroup = function(value) {
+ this.add$Value(46, value);
+};
+
+
+/**
+ * Returns the array of values in the repeatedgroup field.
+ * @return {!Array.<!proto2.TestAllTypes.RepeatedGroup>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedgroupArray = function() {
+ return /** @type {!Array.<!proto2.TestAllTypes.RepeatedGroup>} */ (this.array$Values(46));
+};
+
+
+/**
+ * @return {boolean} Whether the repeatedgroup field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedgroup = function() {
+ return this.has$Value(46);
+};
+
+
+/**
+ * @return {number} The number of values in the repeatedgroup field.
+ */
+proto2.TestAllTypes.prototype.repeatedgroupCount = function() {
+ return this.count$Values(46);
+};
+
+
+/**
+ * Clears the values in the repeatedgroup field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedgroup = function() {
+ this.clear$Field(46);
+};
+
+
+/**
+ * Gets the value of the repeated_nested_message field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedMessage = function(index) {
+ return /** @type {proto2.TestAllTypes.NestedMessage} */ (this.get$Value(48, index));
+};
+
+
+/**
+ * Gets the value of the repeated_nested_message field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {!proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedMessageOrDefault = function(index) {
+ return /** @type {!proto2.TestAllTypes.NestedMessage} */ (this.get$ValueOrDefault(48, index));
+};
+
+
+/**
+ * Adds a value to the repeated_nested_message field.
+ * @param {!proto2.TestAllTypes.NestedMessage} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedNestedMessage = function(value) {
+ this.add$Value(48, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_nested_message field.
+ * @return {!Array.<!proto2.TestAllTypes.NestedMessage>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedMessageArray = function() {
+ return /** @type {!Array.<!proto2.TestAllTypes.NestedMessage>} */ (this.array$Values(48));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_nested_message field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedNestedMessage = function() {
+ return this.has$Value(48);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_nested_message field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedMessageCount = function() {
+ return this.count$Values(48);
+};
+
+
+/**
+ * Clears the values in the repeated_nested_message field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedNestedMessage = function() {
+ this.clear$Field(48);
+};
+
+
+/**
+ * Gets the value of the repeated_nested_enum field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedEnum = function(index) {
+ return /** @type {?proto2.TestAllTypes.NestedEnum} */ (this.get$Value(49, index));
+};
+
+
+/**
+ * Gets the value of the repeated_nested_enum field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedEnumOrDefault = function(index) {
+ return /** @type {proto2.TestAllTypes.NestedEnum} */ (this.get$ValueOrDefault(49, index));
+};
+
+
+/**
+ * Adds a value to the repeated_nested_enum field.
+ * @param {proto2.TestAllTypes.NestedEnum} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedNestedEnum = function(value) {
+ this.add$Value(49, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_nested_enum field.
+ * @return {!Array.<proto2.TestAllTypes.NestedEnum>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedEnumArray = function() {
+ return /** @type {!Array.<proto2.TestAllTypes.NestedEnum>} */ (this.array$Values(49));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_nested_enum field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedNestedEnum = function() {
+ return this.has$Value(49);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedEnumCount = function() {
+ return this.count$Values(49);
+};
+
+
+/**
+ * Clears the values in the repeated_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedNestedEnum = function() {
+ this.clear$Field(49);
+};
+
+
+/**
+ * Gets the value of the repeated_int64_number field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64Number = function(index) {
+ return /** @type {?number} */ (this.get$Value(52, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int64_number field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64NumberOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(52, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int64_number field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt64Number = function(value) {
+ this.add$Value(52, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int64_number field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64NumberArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(52));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int64_number field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt64Number = function() {
+ return this.has$Value(52);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int64_number field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64NumberCount = function() {
+ return this.count$Values(52);
+};
+
+
+/**
+ * Clears the values in the repeated_int64_number field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt64Number = function() {
+ this.clear$Field(52);
+};
+
+
+/**
+ * Gets the value of the repeated_int64_string field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64String = function(index) {
+ return /** @type {?string} */ (this.get$Value(53, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int64_string field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64StringOrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(53, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int64_string field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt64String = function(value) {
+ this.add$Value(53, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int64_string field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64StringArray = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(53));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int64_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt64String = function() {
+ return this.has$Value(53);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int64_string field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64StringCount = function() {
+ return this.count$Values(53);
+};
+
+
+/**
+ * Clears the values in the repeated_int64_string field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt64String = function() {
+ this.clear$Field(53);
+};
+
+
+/**
+ * Enumeration NestedEnum.
+ * @enum {number}
+ */
+proto2.TestAllTypes.NestedEnum = {
+ FOO: 0,
+ BAR: 2,
+ BAZ: 3
+};
+
+
+
+/**
+ * Message NestedMessage.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes.NestedMessage = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes.NestedMessage, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes.NestedMessage} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.NestedMessage.prototype.clone;
+
+
+/**
+ * Gets the value of the b field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.getB = function() {
+ return /** @type {?number} */ (this.get$Value(1));
+};
+
+
+/**
+ * Gets the value of the b field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.getBOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(1));
+};
+
+
+/**
+ * Sets the value of the b field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.setB = function(value) {
+ this.set$Value(1, value);
+};
+
+
+/**
+ * @return {boolean} Whether the b field has a value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.hasB = function() {
+ return this.has$Value(1);
+};
+
+
+/**
+ * @return {number} The number of values in the b field.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.bCount = function() {
+ return this.count$Values(1);
+};
+
+
+/**
+ * Clears the values in the b field.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.clearB = function() {
+ this.clear$Field(1);
+};
+
+
+
+/**
+ * Message OptionalGroup.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes.OptionalGroup = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes.OptionalGroup, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes.OptionalGroup} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.clone;
+
+
+/**
+ * Gets the value of the a field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.getA = function() {
+ return /** @type {?number} */ (this.get$Value(17));
+};
+
+
+/**
+ * Gets the value of the a field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.getAOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(17));
+};
+
+
+/**
+ * Sets the value of the a field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.setA = function(value) {
+ this.set$Value(17, value);
+};
+
+
+/**
+ * @return {boolean} Whether the a field has a value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.hasA = function() {
+ return this.has$Value(17);
+};
+
+
+/**
+ * @return {number} The number of values in the a field.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.aCount = function() {
+ return this.count$Values(17);
+};
+
+
+/**
+ * Clears the values in the a field.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.clearA = function() {
+ this.clear$Field(17);
+};
+
+
+
+/**
+ * Message RepeatedGroup.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes.RepeatedGroup = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes.RepeatedGroup, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes.RepeatedGroup} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.clone;
+
+
+/**
+ * Gets the value of the a field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.getA = function(index) {
+ return /** @type {?number} */ (this.get$Value(47, index));
+};
+
+
+/**
+ * Gets the value of the a field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.getAOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(47, index));
+};
+
+
+/**
+ * Adds a value to the a field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.addA = function(value) {
+ this.add$Value(47, value);
+};
+
+
+/**
+ * Returns the array of values in the a field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.aArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(47));
+};
+
+
+/**
+ * @return {boolean} Whether the a field has a value.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.hasA = function() {
+ return this.has$Value(47);
+};
+
+
+/**
+ * @return {number} The number of values in the a field.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.aCount = function() {
+ return this.count$Values(47);
+};
+
+
+/**
+ * Clears the values in the a field.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.clearA = function() {
+ this.clear$Field(47);
+};
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes, {
+ 0: {
+ name: 'TestAllTypes',
+ fullName: 'TestAllTypes'
+ },
+ 1: {
+ name: 'optional_int32',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ },
+ 2: {
+ name: 'optional_int64',
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ defaultValue: '1',
+ type: String
+ },
+ 3: {
+ name: 'optional_uint32',
+ fieldType: goog.proto2.Message.FieldType.UINT32,
+ type: Number
+ },
+ 4: {
+ name: 'optional_uint64',
+ fieldType: goog.proto2.Message.FieldType.UINT64,
+ type: String
+ },
+ 5: {
+ name: 'optional_sint32',
+ fieldType: goog.proto2.Message.FieldType.SINT32,
+ type: Number
+ },
+ 6: {
+ name: 'optional_sint64',
+ fieldType: goog.proto2.Message.FieldType.SINT64,
+ type: String
+ },
+ 7: {
+ name: 'optional_fixed32',
+ fieldType: goog.proto2.Message.FieldType.FIXED32,
+ type: Number
+ },
+ 8: {
+ name: 'optional_fixed64',
+ fieldType: goog.proto2.Message.FieldType.FIXED64,
+ type: String
+ },
+ 9: {
+ name: 'optional_sfixed32',
+ fieldType: goog.proto2.Message.FieldType.SFIXED32,
+ type: Number
+ },
+ 10: {
+ name: 'optional_sfixed64',
+ fieldType: goog.proto2.Message.FieldType.SFIXED64,
+ type: String
+ },
+ 11: {
+ name: 'optional_float',
+ fieldType: goog.proto2.Message.FieldType.FLOAT,
+ defaultValue: 1.5,
+ type: Number
+ },
+ 12: {
+ name: 'optional_double',
+ fieldType: goog.proto2.Message.FieldType.DOUBLE,
+ type: Number
+ },
+ 13: {
+ name: 'optional_bool',
+ fieldType: goog.proto2.Message.FieldType.BOOL,
+ type: Boolean
+ },
+ 14: {
+ name: 'optional_string',
+ fieldType: goog.proto2.Message.FieldType.STRING,
+ type: String
+ },
+ 15: {
+ name: 'optional_bytes',
+ fieldType: goog.proto2.Message.FieldType.BYTES,
+ defaultValue: 'moo',
+ type: String
+ },
+ 16: {
+ name: 'optionalgroup',
+ fieldType: goog.proto2.Message.FieldType.GROUP,
+ type: proto2.TestAllTypes.OptionalGroup
+ },
+ 18: {
+ name: 'optional_nested_message',
+ fieldType: goog.proto2.Message.FieldType.MESSAGE,
+ type: proto2.TestAllTypes.NestedMessage
+ },
+ 21: {
+ name: 'optional_nested_enum',
+ fieldType: goog.proto2.Message.FieldType.ENUM,
+ defaultValue: proto2.TestAllTypes.NestedEnum.FOO,
+ type: proto2.TestAllTypes.NestedEnum
+ },
+ 50: {
+ name: 'optional_int64_number',
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ defaultValue: 1000000000000000001,
+ type: Number
+ },
+ 51: {
+ name: 'optional_int64_string',
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ defaultValue: '1000000000000000001',
+ type: String
+ },
+ 31: {
+ name: 'repeated_int32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ },
+ 32: {
+ name: 'repeated_int64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ type: String
+ },
+ 33: {
+ name: 'repeated_uint32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.UINT32,
+ type: Number
+ },
+ 34: {
+ name: 'repeated_uint64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.UINT64,
+ type: String
+ },
+ 35: {
+ name: 'repeated_sint32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SINT32,
+ type: Number
+ },
+ 36: {
+ name: 'repeated_sint64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SINT64,
+ type: String
+ },
+ 37: {
+ name: 'repeated_fixed32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.FIXED32,
+ type: Number
+ },
+ 38: {
+ name: 'repeated_fixed64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.FIXED64,
+ type: String
+ },
+ 39: {
+ name: 'repeated_sfixed32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SFIXED32,
+ type: Number
+ },
+ 40: {
+ name: 'repeated_sfixed64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SFIXED64,
+ type: String
+ },
+ 41: {
+ name: 'repeated_float',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.FLOAT,
+ type: Number
+ },
+ 42: {
+ name: 'repeated_double',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.DOUBLE,
+ type: Number
+ },
+ 43: {
+ name: 'repeated_bool',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.BOOL,
+ type: Boolean
+ },
+ 44: {
+ name: 'repeated_string',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.STRING,
+ type: String
+ },
+ 45: {
+ name: 'repeated_bytes',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.BYTES,
+ type: String
+ },
+ 46: {
+ name: 'repeatedgroup',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.GROUP,
+ type: proto2.TestAllTypes.RepeatedGroup
+ },
+ 48: {
+ name: 'repeated_nested_message',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.MESSAGE,
+ type: proto2.TestAllTypes.NestedMessage
+ },
+ 49: {
+ name: 'repeated_nested_enum',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.ENUM,
+ defaultValue: proto2.TestAllTypes.NestedEnum.FOO,
+ type: proto2.TestAllTypes.NestedEnum
+ },
+ 52: {
+ name: 'repeated_int64_number',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ type: Number
+ },
+ 53: {
+ name: 'repeated_int64_string',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ type: String
+ }
+});
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes.NestedMessage, {
+ 0: {
+ name: 'NestedMessage',
+ containingType: proto2.TestAllTypes,
+ fullName: 'TestAllTypes.NestedMessage'
+ },
+ 1: {
+ name: 'b',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ }
+});
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes.OptionalGroup, {
+ 0: {
+ name: 'OptionalGroup',
+ containingType: proto2.TestAllTypes,
+ fullName: 'TestAllTypes.OptionalGroup'
+ },
+ 17: {
+ name: 'a',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ }
+});
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes.RepeatedGroup, {
+ 0: {
+ name: 'RepeatedGroup',
+ containingType: proto2.TestAllTypes,
+ fullName: 'TestAllTypes.RepeatedGroup'
+ },
+ 47: {
+ name: 'a',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ }
+});
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer.js.svn-base
new file mode 100644
index 0000000..aa147a1
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer.js.svn-base
@@ -0,0 +1,965 @@
+// Copyright 2011 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer 2 Serializer which serializes messages
+ * into a user-friendly text format. Note that this code can run a bit
+ * slowly (especially for parsing) and should therefore not be used for
+ * time or space-critical applications.
+ *
+ * @see http://goo.gl/QDmDr
+ */
+
+goog.provide('goog.proto2.TextFormatSerializer');
+goog.provide('goog.proto2.TextFormatSerializer.Parser');
+
+goog.require('goog.json');
+goog.require('goog.proto2.Serializer');
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * TextFormatSerializer, a serializer which turns Messages into the human
+ * readable text format.
+ * @param {boolean=} opt_ignoreMissingFields If true, then fields that cannot be
+ * found on the proto when parsing the text format will be ignored.
+ * @constructor
+ * @extends {goog.proto2.Serializer}
+ */
+goog.proto2.TextFormatSerializer = function(opt_ignoreMissingFields) {
+ /**
+ * Whether to ignore fields not defined on the proto when parsing the text
+ * format.
+ * @type {boolean}
+ * @private
+ */
+ this.ignoreMissingFields_ = !!opt_ignoreMissingFields;
+};
+goog.inherits(goog.proto2.TextFormatSerializer, goog.proto2.Serializer);
+
+
+/**
+ * Deserializes a message from text format and places the data in the message.
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {string} data The text format data.
+ * @return {?string} The parse error or null on success.
+ */
+goog.proto2.TextFormatSerializer.prototype.deserializeTo =
+ function(message, data) {
+ var descriptor = message.getDescriptor();
+ var textData = data.toString();
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ if (!parser.parse(message, textData, this.ignoreMissingFields_)) {
+ return parser.getError();
+ }
+
+ return null;
+};
+
+
+/**
+ * Serializes a message to a string.
+ * @param {goog.proto2.Message} message The message to be serialized.
+ * @return {string} The serialized form of the message.
+ */
+goog.proto2.TextFormatSerializer.prototype.serialize = function(message) {
+ var printer = new goog.proto2.TextFormatSerializer.Printer_();
+ this.serializeMessage_(message, printer);
+ return printer.toString();
+};
+
+
+/**
+ * Serializes the message and prints the text form into the given printer.
+ * @param {goog.proto2.Message} message The message to serialize.
+ * @param {goog.proto2.TextFormatSerializer.Printer_} printer The printer to
+ * which the text format will be printed.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.prototype.serializeMessage_ =
+ function(message, printer) {
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ // Add the defined fields, recursively.
+ goog.array.forEach(fields, function(field) {
+ this.printField_(message, field, printer);
+ }, this);
+
+ // Add the unknown fields, if any.
+ message.forEachUnknown(function(tag, value) {
+ if (!value) { return; }
+
+ printer.append(tag);
+ if (goog.typeOf(value) == 'object') {
+ printer.append(' {');
+ printer.appendLine();
+ printer.indent();
+ } else {
+ printer.append(': ');
+ }
+
+ switch (goog.typeOf(value)) {
+ case 'string':
+ value = goog.string.quote(value);
+ printer.append(value);
+ break;
+
+ case 'object':
+ this.serializeMessage_(value, printer);
+ break;
+
+ default:
+ printer.append(value.toString());
+ break;
+ }
+
+ if (goog.typeOf(value) == 'object') {
+ printer.dedent();
+ printer.append('}');
+ } else {
+ printer.appendLine();
+ }
+ }, this);
+};
+
+
+/**
+ * Prints the serialized value for the given field to the printer.
+ * @param {*} value The field's value.
+ * @param {goog.proto2.FieldDescriptor} field The field whose value is being
+ * printed.
+ * @param {goog.proto2.TextFormatSerializer.Printer_} printer The printer to
+ * which the value will be printed.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.prototype.printFieldValue_ =
+ function(value, field, printer) {
+ switch (field.getFieldType()) {
+ case goog.proto2.FieldDescriptor.FieldType.DOUBLE:
+ case goog.proto2.FieldDescriptor.FieldType.FLOAT:
+ case goog.proto2.FieldDescriptor.FieldType.INT64:
+ case goog.proto2.FieldDescriptor.FieldType.UINT64:
+ case goog.proto2.FieldDescriptor.FieldType.INT32:
+ case goog.proto2.FieldDescriptor.FieldType.UINT32:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.BOOL:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SINT32:
+ case goog.proto2.FieldDescriptor.FieldType.SINT64:
+ printer.append(value);
+ break;
+
+ case goog.proto2.FieldDescriptor.FieldType.BYTES:
+ case goog.proto2.FieldDescriptor.FieldType.STRING:
+ value = goog.string.quote(value.toString());
+ printer.append(value);
+ break;
+
+ case goog.proto2.FieldDescriptor.FieldType.ENUM:
+ // Search the enum type for a matching key.
+ var found = false;
+ goog.object.forEach(field.getNativeType(), function(eValue, key) {
+ if (eValue == value) {
+ printer.append(key);
+ found = true;
+ }
+ });
+
+ if (!found) {
+ // Otherwise, just print the numeric value.
+ printer.append(value.toString());
+ }
+ break;
+
+ case goog.proto2.FieldDescriptor.FieldType.GROUP:
+ case goog.proto2.FieldDescriptor.FieldType.MESSAGE:
+ this.serializeMessage_(
+ (/** @type {goog.proto2.Message} */value), printer);
+ break;
+ }
+};
+
+
+/**
+ * Prints the serialized field to the printer.
+ * @param {goog.proto2.Message} message The parent message.
+ * @param {goog.proto2.FieldDescriptor} field The field to print.
+ * @param {goog.proto2.TextFormatSerializer.Printer_} printer The printer to
+ * which the field will be printed.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.prototype.printField_ =
+ function(message, field, printer) {
+ // Skip fields not present.
+ if (!message.has(field)) {
+ return;
+ }
+
+ var count = message.countOf(field);
+ for (var i = 0; i < count; ++i) {
+ // Field name.
+ printer.append(field.getName());
+
+ // Field delimiter.
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.GROUP) {
+ printer.append(' {');
+ printer.appendLine();
+ printer.indent();
+ } else {
+ printer.append(': ');
+ }
+
+ // Write the field value.
+ this.printFieldValue_(message.get(field, i), field, printer);
+
+ // Close the field.
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.GROUP) {
+ printer.dedent();
+ printer.append('}');
+ printer.appendLine();
+ } else {
+ printer.appendLine();
+ }
+ }
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
+/**
+ * Helper class used by the text format serializer for pretty-printing text.
+ * @constructor
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Printer_ = function() {
+ /**
+ * The current indentation count.
+ * @type {number}
+ * @private
+ */
+ this.indentation_ = 0;
+
+ /**
+ * The buffer of string pieces.
+ * @type {Array.<string>}
+ * @private
+ */
+ this.buffer_ = [];
+
+ /**
+ * Whether indentation is required before the next append of characters.
+ * @type {boolean}
+ * @private
+ */
+ this.requiresIndentation_ = true;
+};
+
+
+/**
+ * @return {string} The contents of the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.toString = function() {
+ return this.buffer_.join('');
+};
+
+
+/**
+ * Increases the indentation in the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.indent = function() {
+ this.indentation_ += 2;
+};
+
+
+/**
+ * Decreases the indentation in the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.dedent = function() {
+ this.indentation_ -= 2;
+ goog.asserts.assert(this.indentation_ >= 0);
+};
+
+
+/**
+ * Appends the given value to the printer.
+ * @param {*} value The value to append.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.append = function(value) {
+ if (this.requiresIndentation_) {
+ for (var i = 0; i < this.indentation_; ++i) {
+ this.buffer_.push(' ');
+ }
+ this.requiresIndentation_ = false;
+ }
+
+ this.buffer_.push(value.toString());
+};
+
+
+/**
+ * Appends a newline to the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.appendLine = function() {
+ this.buffer_.push('\n');
+ this.requiresIndentation_ = true;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
+/**
+ * Helper class for tokenizing the text format.
+ * @param {string} data The string data to tokenize.
+ * @param {boolean=} opt_ignoreWhitespace If true, whitespace tokens will not
+ * be reported by the tokenizer.
+ * @constructor
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_ =
+ function(data, opt_ignoreWhitespace) {
+
+ /**
+ * Whether to skip whitespace tokens on output.
+ * @type {boolean}
+ * @private
+ */
+ this.ignoreWhitespace_ = !!opt_ignoreWhitespace;
+
+ /**
+ * The data being tokenized.
+ * @type {string}
+ * @private
+ */
+ this.data_ = data;
+
+ /**
+ * The current index in the data.
+ * @type {number}
+ * @private
+ */
+ this.index_ = 0;
+
+ /**
+ * The data string starting at the current index.
+ * @type {string}
+ * @private
+ */
+ this.currentData_ = data;
+
+ /**
+ * The current token type.
+ * @type {goog.proto2.TextFormatSerializer.Tokenizer_.Token}
+ * @private
+ */
+ this.current_ = {
+ type: goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes.END,
+ value: null
+ };
+};
+
+
+/**
+ * @typedef {{type: goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes,
+ * value: ?string}}
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.Token;
+
+
+/**
+ * @return {goog.proto2.TextFormatSerializer.Tokenizer_.Token} The current
+ * token.
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.prototype.getCurrent = function() {
+ return this.current_;
+};
+
+
+/**
+ * An enumeration of all the token types.
+ * @enum {*}
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes = {
+ END: /---end---/,
+ IDENTIFIER: /^[a-zA-Z][a-zA-Z0-9_]*/,
+ NUMBER: /^(0x[0-9a-f]+)|(([-])?[0-9][0-9]*(\.?[0-9]+)?([f])?)/,
+ COMMENT: /^#.*/,
+ OPEN_BRACE: /^{/,
+ CLOSE_BRACE: /^}/,
+ OPEN_TAG: /^</,
+ CLOSE_TAG: /^>/,
+ OPEN_LIST: /^\[/,
+ CLOSE_LIST: /^\]/,
+ STRING: new RegExp('^"([^"\\\\]|\\\\.)*"'),
+ COLON: /^:/,
+ COMMA: /^,/,
+ SEMI: /^;/,
+ WHITESPACE: /^\s/
+};
+
+
+/**
+ * Advances to the next token.
+ * @return {boolean} True if a valid token was found, false if the end was
+ * reached or no valid token was found.
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.prototype.next = function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+
+ // Skip any whitespace if requested.
+ while (this.nextInternal_()) {
+ if (this.getCurrent().type != types.WHITESPACE || !this.ignoreWhitespace_) {
+ return true;
+ }
+ }
+
+ // If we reach this point, set the current token to END.
+ this.current_ = {
+ type: goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes.END,
+ value: null
+ };
+
+ return false;
+};
+
+
+/**
+ * Internal method for determining the next token.
+ * @return {boolean} True if a next token was found, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.prototype.nextInternal_ =
+ function() {
+ if (this.index_ >= this.data_.length) {
+ return false;
+ }
+
+ var data = this.currentData_;
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ var next = null;
+
+ // Loop through each token type and try to match the beginning of the string
+ // with the token's regular expression.
+ goog.object.forEach(types, function(type, id) {
+ if (next || type == types.END) {
+ return;
+ }
+
+ // Note: This regular expression check is at, minimum, O(n).
+ var info = type.exec(data);
+ if (info && info.index == 0) {
+ next = {
+ type: type,
+ value: info[0]
+ };
+ }
+ });
+
+ // Advance the index by the length of the token.
+ if (next) {
+ this.current_ =
+ (/** @type {goog.proto2.TextFormatSerializer.Tokenizer_.Token} */next);
+ this.index_ += next.value.length;
+ this.currentData_ = this.currentData_.substring(next.value.length);
+ }
+
+ return !!next;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
+/**
+ * Helper class for parsing the text format.
+ * @constructor
+ */
+goog.proto2.TextFormatSerializer.Parser = function() {
+ /**
+ * The error during parsing, if any.
+ * @type {?string}
+ * @private
+ */
+ this.error_ = null;
+
+ /**
+ * The current tokenizer.
+ * @type {goog.proto2.TextFormatSerializer.Tokenizer_}
+ * @private
+ */
+ this.tokenizer_ = null;
+
+ /**
+ * Whether to ignore missing fields in the proto when parsing.
+ * @type {boolean}
+ * @private
+ */
+ this.ignoreMissingFields_ = false;
+};
+
+
+/**
+ * Parses the given data, filling the message as it goes.
+ * @param {goog.proto2.Message} message The message to fill.
+ * @param {string} data The text format data.
+ * @param {boolean=} opt_ignoreMissingFields If true, fields missing in the
+ * proto will be ignored.
+ * @return {boolean} True on success, false on failure. On failure, the
+ * getError method can be called to get the reason for failure.
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.parse =
+ function(message, data, opt_ignoreMissingFields) {
+ this.error_ = null;
+ this.ignoreMissingFields_ = !!opt_ignoreMissingFields;
+ this.tokenizer_ = new goog.proto2.TextFormatSerializer.Tokenizer_(data, true);
+ this.tokenizer_.next();
+ return this.consumeMessage_(message, '');
+};
+
+
+/**
+ * @return {?string} The parse error, if any.
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.getError = function() {
+ return this.error_;
+};
+
+
+/**
+ * Reports a parse error.
+ * @param {string} msg The error message.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.reportError_ =
+ function(msg) {
+ this.error_ = msg;
+};
+
+
+/**
+ * Attempts to consume the given message.
+ * @param {goog.proto2.Message} message The message to consume and fill. If
+ * null, then the message contents will be consumed without ever being set
+ * to anything.
+ * @param {string} delimiter The delimiter expected at the end of the message.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeMessage_ =
+ function(message, delimiter) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ while (!this.lookingAt_('>') && !this.lookingAt_('}') &&
+ !this.lookingAtType_(types.END)) {
+ if (!this.consumeField_(message)) { return false; }
+ }
+
+ if (delimiter) {
+ if (!this.consume_(delimiter)) { return false; }
+ } else {
+ if (!this.lookingAtType_(types.END)) {
+ this.reportError_('Expected END token');
+ }
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to consume the value of the given field.
+ * @param {goog.proto2.Message} message The parent message.
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeFieldValue_ =
+ function(message, field) {
+ var value = this.getFieldValue_(field);
+ if (goog.isNull(value)) { return false; }
+
+ if (field.isRepeated()) {
+ message.add(field, value);
+ } else {
+ message.set(field, value);
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to convert a string to a number.
+ * @param {string} num in hexadecimal or float format.
+ * @return {?number} The converted number or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.getNumberFromString_ =
+ function(num) {
+ var numberString = num;
+ var numberBase = 10;
+ if (num.substr(0, 2) == '0x') {
+ // ASCII output can be printed in unsigned hexadecimal format
+ // occasionally. e.g. 0xaed9b43
+ numberString = num.substr(2);
+ numberBase = 16;
+ } else if (goog.string.endsWith(num, 'f')) {
+ numberString = num.substring(0, num.length - 1);
+ }
+
+ var actualNumber = numberBase == 10 ?
+ parseFloat(numberString) : parseInt(numberString, numberBase);
+ if (actualNumber.toString(numberBase) != numberString) {
+ this.reportError_('Unknown number: ' + num);
+ return null;
+ }
+ return actualNumber;
+};
+
+
+/**
+ * Attempts to parse the given field's value from the stream.
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @return {*} The field's value or null if none.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.getFieldValue_ =
+ function(field) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ switch (field.getFieldType()) {
+ case goog.proto2.FieldDescriptor.FieldType.DOUBLE:
+ case goog.proto2.FieldDescriptor.FieldType.FLOAT:
+ case goog.proto2.FieldDescriptor.FieldType.INT32:
+ case goog.proto2.FieldDescriptor.FieldType.UINT32:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.SINT32:
+ var num = this.consumeNumber_();
+ if (!num) { return null; }
+
+ return this.getNumberFromString_(num);
+
+ case goog.proto2.FieldDescriptor.FieldType.INT64:
+ case goog.proto2.FieldDescriptor.FieldType.UINT64:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SINT64:
+ var num = this.consumeNumber_();
+ if (!num) { return null; }
+
+ if (field.getNativeType() == Number) {
+ // 64-bit number stored as a number.
+ return this.getNumberFromString_(num);
+ }
+
+ return num; // 64-bit numbers are by default stored as strings.
+
+ case goog.proto2.FieldDescriptor.FieldType.BOOL:
+ var ident = this.consumeIdentifier_();
+ if (!ident) { return null; }
+
+ switch (ident) {
+ case 'true': return true;
+ case 'false': return false;
+ default:
+ this.reportError_('Unknown type for bool: ' + ident);
+ return null;
+ }
+
+ case goog.proto2.FieldDescriptor.FieldType.ENUM:
+ if (this.lookingAtType_(types.NUMBER)) {
+ return this.consumeNumber_();
+ } else {
+ // Search the enum type for a matching key.
+ var name = this.consumeIdentifier_();
+ if (!name) {
+ return null;
+ }
+
+ var enumValue = field.getNativeType()[name];
+ if (enumValue == null) {
+ this.reportError_('Unknown enum value: ' + name);
+ return null;
+ }
+
+ return enumValue;
+ }
+
+ case goog.proto2.FieldDescriptor.FieldType.BYTES:
+ case goog.proto2.FieldDescriptor.FieldType.STRING:
+ return this.consumeString_();
+ }
+};
+
+
+/**
+ * Attempts to consume a nested message.
+ * @param {goog.proto2.Message} message The parent message.
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeNestedMessage_ =
+ function(message, field) {
+ var delimiter = '';
+
+ // Messages support both < > and { } as delimiters for legacy reasons.
+ if (this.tryConsume_('<')) {
+ delimiter = '>';
+ } else {
+ if (!this.consume_('{')) { return false; }
+ delimiter = '}';
+ }
+
+ var msg = field.getFieldMessageType().createMessageInstance();
+ var result = this.consumeMessage_(msg, delimiter);
+ if (!result) { return false; }
+
+ // Add the message to the parent message.
+ if (field.isRepeated()) {
+ message.add(field, msg);
+ } else {
+ message.set(field, msg);
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to consume the value of an unknown field. This method uses
+ * heuristics to try to consume just the right tokens.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeUnknownFieldValue_ =
+ function() {
+ // : is optional.
+ this.tryConsume_(':');
+
+ // Handle form: [.. , ... , ..]
+ if (this.tryConsume_('[')) {
+ while (true) {
+ this.tokenizer_.next();
+ if (this.tryConsume_(']')) {
+ break;
+ }
+ if (!this.consume_(',')) { return false; }
+ }
+
+ return true;
+ }
+
+ // Handle nested messages/groups.
+ if (this.tryConsume_('<')) {
+ return this.consumeMessage_(null /* unknown */, '>');
+ } else if (this.tryConsume_('{')) {
+ return this.consumeMessage_(null /* unknown */, '}');
+ } else {
+ // Otherwise, consume a single token for the field value.
+ this.tokenizer_.next();
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to consume a field under a message.
+ * @param {goog.proto2.Message} message The parent message. If null, then the
+ * field value will be consumed without being assigned to anything.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeField_ =
+ function(message) {
+ var fieldName = this.consumeIdentifier_();
+ if (!fieldName) {
+ this.reportError_('Missing field name');
+ return false;
+ }
+
+ var field = null;
+ if (message) {
+ field = message.getDescriptor().findFieldByName(fieldName.toString());
+ }
+
+ if (field == null) {
+ if (this.ignoreMissingFields_) {
+ return this.consumeUnknownFieldValue_();
+ } else {
+ this.reportError_('Unknown field: ' + fieldName);
+ return false;
+ }
+ }
+
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.GROUP) {
+ // : is optional here.
+ this.tryConsume_(':');
+ if (!this.consumeNestedMessage_(message, field)) { return false; }
+ } else {
+ // Long Format: "someField: 123"
+ // Short Format: "someField: [123, 456, 789]"
+ if (!this.consume_(':')) { return false; }
+
+ if (field.isRepeated() && this.tryConsume_('[')) {
+ // Short repeated format, e.g. "foo: [1, 2, 3]"
+ while (true) {
+ if (!this.consumeFieldValue_(message, field)) { return false; }
+ if (this.tryConsume_(']')) {
+ break;
+ }
+ if (!this.consume_(',')) { return false; }
+ }
+ } else {
+ // Normal field format.
+ if (!this.consumeFieldValue_(message, field)) { return false; }
+ }
+ }
+
+ // For historical reasons, fields may optionally be separated by commas or
+ // semicolons.
+ this.tryConsume_(',') || this.tryConsume_(';');
+ return true;
+};
+
+
+/**
+ * Attempts to consume a token with the given string value.
+ * @param {string} value The string value for the token.
+ * @return {boolean} True if the token matches and was consumed, false
+ * otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.tryConsume_ =
+ function(value) {
+ if (this.lookingAt_(value)) {
+ this.tokenizer_.next();
+ return true;
+ }
+ return false;
+};
+
+
+/**
+ * Consumes a token of the given type.
+ * @param {goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes} type The type
+ * of the token to consume.
+ * @return {?string} The string value of the token or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeToken_ =
+ function(type) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ if (!this.lookingAtType_(type)) {
+ this.reportError_('Expected token type: ' + type);
+ return null;
+ }
+
+ var value = this.tokenizer_.getCurrent().value;
+ this.tokenizer_.next();
+ return value;
+};
+
+
+/**
+ * Consumes an IDENTIFIER token.
+ * @return {?string} The string value or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeIdentifier_ =
+ function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ return this.consumeToken_(types.IDENTIFIER);
+};
+
+
+/**
+ * Consumes a NUMBER token.
+ * @return {?string} The string value or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeNumber_ =
+ function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ return this.consumeToken_(types.NUMBER);
+};
+
+
+/**
+ * Consumes a STRING token.
+ * @return {?string} The *deescaped* string value or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeString_ =
+ function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ var value = this.consumeToken_(types.STRING);
+ if (!value) {
+ return null;
+ }
+
+ return goog.json.parse(value).toString();
+};
+
+
+/**
+ * Consumes a token with the given value. If not found, reports an error.
+ * @param {string} value The string value expected for the token.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consume_ = function(value) {
+ if (!this.tryConsume_(value)) {
+ this.reportError_('Expected token "' + value + '"');
+ return false;
+ }
+
+ return true;
+};
+
+
+/**
+ * @param {string} value The value to check against.
+ * @return {boolean} True if the current token has the given string value.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.lookingAt_ =
+ function(value) {
+ return this.tokenizer_.getCurrent().value == value;
+};
+
+
+/**
+ * @param {goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes} type The
+ * token type.
+ * @return {boolean} True if the current token has the given type.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.lookingAtType_ =
+ function(type) {
+ return this.tokenizer_.getCurrent().type == type;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer_test.html.svn-base
new file mode 100644
index 0000000..0879654
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/textformatserializer_test.html.svn-base
@@ -0,0 +1,530 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2011 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - textformatserializer.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.TextFormatSerializer');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testSerialization() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalUint32(103);
+ message.setOptionalSint32(105);
+ message.setOptionalFixed32(107);
+ message.setOptionalSfixed32(109);
+ message.setOptionalInt64('102');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Serialize to a simplified text format.
+ var simplified = new goog.proto2.TextFormatSerializer().serialize(message);
+ var expected = 'optional_int32: 101\n' +
+ 'optional_int64: 102\n' +
+ 'optional_uint32: 103\n' +
+ 'optional_sint32: 105\n' +
+ 'optional_fixed32: 107\n' +
+ 'optional_sfixed32: 109\n' +
+ 'optional_float: 111.5\n' +
+ 'optional_double: 112.5\n' +
+ 'optional_bool: true\n' +
+ 'optional_string: "test"\n' +
+ 'optional_bytes: "abcd"\n' +
+ 'optionalgroup {\n' +
+ ' a: 111\n' +
+ '}\n' +
+ 'optional_nested_message {\n' +
+ ' b: 112\n' +
+ '}\n' +
+ 'optional_nested_enum: FOO\n' +
+ 'repeated_int32: 201\n' +
+ 'repeated_int32: 202\n';
+
+ assertEquals(expected, simplified);
+}
+
+function testSerializationOfUnknown() {
+ var nestedUnknown = new proto2.TestAllTypes();
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Known.
+ message.setOptionalInt32(101);
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ nestedUnknown.addRepeatedInt32(301);
+ nestedUnknown.addRepeatedInt32(302);
+
+ // Unknown.
+ message.setUnknown(1000, 301);
+ message.setUnknown(1001, 302);
+ message.setUnknown(1002, 'hello world');
+ message.setUnknown(1002, nestedUnknown);
+
+ nestedUnknown.setUnknown(2000, 401);
+
+ // Serialize.
+ var simplified = new goog.proto2.TextFormatSerializer().serialize(message);
+ var expected = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'repeated_int32: 202\n' +
+ '1000: 301\n' +
+ '1001: 302\n' +
+ '1002 {\n' +
+ ' repeated_int32: 301\n' +
+ ' repeated_int32: 302\n' +
+ ' 2000: 401\n' +
+ '}';
+
+ assertEquals(expected, simplified);
+}
+
+/**
+ * Asserts that the given string value parses into the given set of tokens.
+ * @param {string} value The string value to parse.
+ * @param {Array.<Token> | Token} tokens The tokens to check against. If not
+ * an array, a single token is expected.
+ * @param {boolean=} opt_ignoreWhitespace Whether whitespace tokens should be
+ * skipped by the tokenizer.
+ */
+function assertTokens(value, tokens, opt_ignoreWhitespace) {
+ var tokenizer = new goog.proto2.TextFormatSerializer.Tokenizer_(
+ value, opt_ignoreWhitespace);
+ var tokensFound = [];
+
+ while (tokenizer.next()) {
+ tokensFound.push(tokenizer.getCurrent());
+ }
+
+ if (goog.typeOf(tokens) != 'array') {
+ tokens = [tokens];
+ }
+
+ assertEquals(tokens.length, tokensFound.length);
+ for (var i = 0; i < tokens.length; ++i) {
+ assertToken(tokens[i], tokensFound[i]);
+ }
+}
+
+function assertToken(expected, found) {
+ assertEquals(expected.type, found.type);
+ if (expected.value) {
+ assertEquals(expected.value, found.value);
+ }
+}
+
+function testTokenizer() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens('{ 123 }', [
+ { type: types.OPEN_BRACE },
+ { type: types.WHITESPACE, value: ' ' },
+ { type: types.NUMBER, value: '123' },
+ { type: types.WHITESPACE, value: ' '},
+ { type: types.CLOSE_BRACE }
+ ]);
+}
+
+function testTokenizerNoWhitespace() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens('{ "hello world" }', [
+ { type: types.OPEN_BRACE },
+ { type: types.STRING, value: '"hello world"' },
+ { type: types.CLOSE_BRACE }
+ ], true);
+}
+
+
+function assertIdentifier(identifier) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(identifier, { type: types.IDENTIFIER, value: identifier });
+}
+
+function assertComment(comment) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(comment, { type: types.COMMENT, value: comment });
+}
+
+function assertString(str) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(str, { type: types.STRING, value: str });
+}
+
+function assertNumber(num) {
+ num = num.toString();
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(num, { type: types.NUMBER, value: num });
+}
+
+function testTokenizerSingleTokens() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens('{', { type: types.OPEN_BRACE });
+ assertTokens('}', { type: types.CLOSE_BRACE });
+ assertTokens('<', { type: types.OPEN_TAG });
+ assertTokens('>', { type: types.CLOSE_TAG });
+ assertTokens(':', { type: types.COLON });
+ assertTokens(',', { type: types.COMMA });
+ assertTokens(';', { type: types.SEMI });
+
+ assertIdentifier('abcd');
+ assertIdentifier('Abcd');
+ assertIdentifier('ABcd');
+ assertIdentifier('ABcD');
+ assertIdentifier('a123nc');
+ assertIdentifier('a45_bC');
+ assertIdentifier('A45_bC');
+
+ assertIdentifier('inf');
+ assertIdentifier('infinity');
+ assertIdentifier('nan');
+
+ assertNumber(0);
+ assertNumber(10);
+ assertNumber(123);
+ assertNumber(1234);
+ assertNumber(123.56);
+ assertNumber(-124);
+ assertNumber(-1234);
+ assertNumber(-123.56);
+ assertNumber('123f');
+ assertNumber('123.6f');
+ assertNumber('-123f');
+ assertNumber('-123.8f');
+ assertNumber('0x1234');
+ assertNumber('0x12ac34');
+ assertNumber('0x49e281db686fb');
+
+ assertString('""');
+ assertString('"hello world"');
+ assertString('"hello # world"');
+ assertString('"hello #\\" world"');
+ assertString('"|"');
+ assertString('"\\"\\""');
+ assertString('"\\"foo\\""');
+ assertString('"\\"foo\\" and \\"bar\\""');
+ assertString('"foo \\"and\\" bar"');
+
+ assertComment('# foo bar baz');
+ assertComment('# foo ## bar baz');
+ assertComment('# foo "bar" baz');
+}
+
+function testSerializationOfStringWithQuotes() {
+ var nestedUnknown = new proto2.TestAllTypes();
+ var message = new proto2.TestAllTypes();
+ message.setOptionalString('hello "world"');
+
+ // Serialize.
+ var simplified = new goog.proto2.TextFormatSerializer().serialize(message);
+ var expected = 'optional_string: "hello \\"world\\""\n';
+ assertEquals(expected, simplified);
+}
+
+function testDeserialization() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationOfList() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: [201, 202]\n' +
+ 'optional_float: 123.4';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationOfIntegerAsHexadecimalString() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 0x1\n' +
+ 'optional_sint32: 0xf\n' +
+ 'optional_uint32: 0xffffffff\n' +
+ 'repeated_int32: [0x0, 0xff]\n';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(1, message.getOptionalInt32());
+ assertEquals(15, message.getOptionalSint32());
+ assertEquals(4294967295, message.getOptionalUint32());
+ assertEquals(0, message.getRepeatedInt32(0));
+ assertEquals(255, message.getRepeatedInt32(1));
+}
+
+function testDeserializationOfInt64AsHexadecimalString() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int64: 0xf';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals('0xf', message.getOptionalInt64());
+}
+
+function testDeserializationOfZeroFalseAndEmptyString() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 0\n' +
+ 'optional_bool: false\n' +
+ 'optional_string: ""';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(0, message.getOptionalInt32());
+ assertEquals(false, message.getOptionalBool());
+ assertEquals('', message.getOptionalString());
+}
+
+function testDeserializationSkipUnknown() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: true\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertTrue(parser.parse(message, value, true));
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationSkipUnknownList() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: [true, 1, 201, "hello"]\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertTrue(parser.parse(message, value, true));
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationSkipUnknownNested() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: <\n' +
+ ' a: 1\n' +
+ ' b: 2\n' +
+ '>\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertTrue(parser.parse(message, value, true));
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationSkipUnknownNestedInvalid() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: <\n' +
+ ' a: \n' + // Missing value.
+ ' b: 2\n' +
+ '>\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertFalse(parser.parse(message, value, true));
+}
+
+function testDeserializationSkipUnknownNestedInvalid2() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: <\n' +
+ ' a: 2\n' +
+ ' b: 2\n' +
+ '}\n' + // Delimiter mismatch
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertFalse(parser.parse(message, value, true));
+}
+
+
+function testDeserializationLegacyFormat() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101,\n' +
+ 'repeated_int32: 201,\n' +
+ 'repeated_int32: 202;\n' +
+ 'optional_float: 123.4';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationError() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int33: 101\n';
+ var result =
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+ assertEquals(result, 'Unknown field: optional_int33');
+}
+
+function testNestedDeserialization() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'optional_nested_message: {\n' +
+ ' b: 301\n' +
+ '}';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(301, message.getOptionalNestedMessage().getB());
+}
+
+function testNestedDeserializationLegacyFormat() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'optional_nested_message: <\n' +
+ ' b: 301\n' +
+ '>';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(301, message.getOptionalNestedMessage().getB());
+}
+
+function testBidirectional() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+ message.addRepeatedString('hello "world"');
+
+ // Serialize the message to text form.
+ var serializer = new goog.proto2.TextFormatSerializer();
+ var textform = serializer.serialize(message);
+
+ // Create a copy and deserialize into the copy.
+ var copy = new proto2.TestAllTypes();
+ serializer.deserializeTo(copy, textform);
+
+ // Assert that the messages are structurally equivalent.
+ assertTrue(copy.equals(message));
+}
+
+
+function testBidirectional64BitNumber() {
+ var message = new proto2.TestAllTypes();
+ message.setOptionalInt64Number(10000000);
+ message.setOptionalInt64String('200000000000000000');
+
+ // Serialize the message to text form.
+ var serializer = new goog.proto2.TextFormatSerializer();
+ var textform = serializer.serialize(message);
+
+ // Create a copy and deserialize into the copy.
+ var copy = new proto2.TestAllTypes();
+ serializer.deserializeTo(copy, textform);
+
+ // Assert that the messages are structurally equivalent.
+ assertTrue(copy.equals(message));
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/util.js.svn-base b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/util.js.svn-base
new file mode 100644
index 0000000..cb60f9e
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/.svn/text-base/util.js.svn-base
@@ -0,0 +1,54 @@
+// Copyright 2009 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Utility methods for Protocol Buffer 2 implementation.
+ */
+
+goog.provide('goog.proto2.Util');
+
+goog.require('goog.asserts');
+
+
+/**
+ * @define {boolean} Defines a PBCHECK constant that can be turned off by
+ * clients of PB2. This for is clients that do not want assertion/checking
+ * running even in non-COMPILED builds.
+ */
+goog.proto2.Util.PBCHECK = !COMPILED;
+
+
+/**
+ * Asserts that the given condition is true, if and only if the PBCHECK
+ * flag is on.
+ *
+ * @param {*} condition The condition to check.
+ * @param {string=} opt_message Error message in case of failure.
+ * @throws {Error} Assertion failed, the condition evaluates to false.
+ */
+goog.proto2.Util.assert = function(condition, opt_message) {
+ if (goog.proto2.Util.PBCHECK) {
+ goog.asserts.assert(condition, opt_message);
+ }
+};
+
+
+/**
+ * Returns true if debug assertions (checks) are on.
+ *
+ * @return {boolean} The value of the PBCHECK constant.
+ */
+goog.proto2.Util.conductChecks = function() {
+ return goog.proto2.Util.PBCHECK;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/descriptor.js b/contexts/data/lib/closure-library/closure/goog/proto2/descriptor.js
new file mode 100644
index 0000000..eacec09
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/descriptor.js
@@ -0,0 +1,198 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer (Message) Descriptor class.
+ */
+
+goog.provide('goog.proto2.Descriptor');
+goog.provide('goog.proto2.Metadata');
+
+goog.require('goog.array');
+goog.require('goog.object');
+goog.require('goog.proto2.Util');
+
+
+/**
+ * @typedef {{name: (string|undefined),
+ * fullName: (string|undefined),
+ * containingType: (goog.proto2.Message|undefined)}}
+ */
+goog.proto2.Metadata;
+
+
+
+/**
+ * A class which describes a Protocol Buffer 2 Message.
+ *
+ * @param {Function} messageType Constructor for the message class that
+ * this descriptor describes.
+ * @param {!goog.proto2.Metadata} metadata The metadata about the message that
+ * will be used to construct this descriptor.
+ * @param {Array.<!goog.proto2.FieldDescriptor>} fields The fields of the
+ * message described by this descriptor.
+ *
+ * @constructor
+ */
+goog.proto2.Descriptor = function(messageType, metadata, fields) {
+
+ /**
+ * @type {Function}
+ * @private
+ */
+ this.messageType_ = messageType;
+
+ /**
+ * @type {?string}
+ * @private
+ */
+ this.name_ = metadata.name || null;
+
+ /**
+ * @type {?string}
+ * @private
+ */
+ this.fullName_ = metadata.fullName || null;
+
+ /**
+ * @type {goog.proto2.Message|undefined}
+ * @private
+ */
+ this.containingType_ = metadata.containingType;
+
+ /**
+ * The fields of the message described by this descriptor.
+ * @type {!Object.<number, !goog.proto2.FieldDescriptor>}
+ * @private
+ */
+ this.fields_ = {};
+
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ this.fields_[field.getTag()] = field;
+ }
+};
+
+
+/**
+ * Returns the name of the message, if any.
+ *
+ * @return {?string} The name.
+ */
+goog.proto2.Descriptor.prototype.getName = function() {
+ return this.name_;
+};
+
+
+/**
+ * Returns the full name of the message, if any.
+ *
+ * @return {?string} The name.
+ */
+goog.proto2.Descriptor.prototype.getFullName = function() {
+ return this.fullName_;
+};
+
+
+/**
+ * Returns the descriptor of the containing message type or null if none.
+ *
+ * @return {goog.proto2.Descriptor} The descriptor.
+ */
+goog.proto2.Descriptor.prototype.getContainingType = function() {
+ if (!this.containingType_) {
+ return null;
+ }
+
+ return this.containingType_.getDescriptor();
+};
+
+
+/**
+ * Returns the fields in the message described by this descriptor ordered by
+ * tag.
+ *
+ * @return {!Array.<!goog.proto2.FieldDescriptor>} The array of field
+ * descriptors.
+ */
+goog.proto2.Descriptor.prototype.getFields = function() {
+ /**
+ * @param {!goog.proto2.FieldDescriptor} fieldA First field.
+ * @param {!goog.proto2.FieldDescriptor} fieldB Second field.
+ * @return {number} Negative if fieldA's tag number is smaller, positive
+ * if greater, zero if the same.
+ */
+ function tagComparator(fieldA, fieldB) {
+ return fieldA.getTag() - fieldB.getTag();
+ };
+
+ var fields = goog.object.getValues(this.fields_);
+ goog.array.sort(fields, tagComparator);
+
+ return fields;
+};
+
+
+/**
+ * Returns the fields in the message as a key/value map, where the key is
+ * the tag number of the field.
+ *
+ * @return {!Object.<number, !goog.proto2.FieldDescriptor>} The field map.
+ */
+goog.proto2.Descriptor.prototype.getFieldsMap = function() {
+ return goog.object.clone(this.fields_);
+};
+
+
+/**
+ * Returns the field matching the given name, if any. Note that
+ * this method searches over the *original* name of the field,
+ * not the camelCase version.
+ *
+ * @param {string} name The field name for which to search.
+ *
+ * @return {goog.proto2.FieldDescriptor} The field found, if any.
+ */
+goog.proto2.Descriptor.prototype.findFieldByName = function(name) {
+ var valueFound = goog.object.findValue(this.fields_,
+ function(field, key, obj) {
+ return field.getName() == name;
+ });
+
+ return /** @type {goog.proto2.FieldDescriptor} */ (valueFound) || null;
+};
+
+
+/**
+ * Returns the field matching the given tag number, if any.
+ *
+ * @param {number|string} tag The field tag number for which to search.
+ *
+ * @return {goog.proto2.FieldDescriptor} The field found, if any.
+ */
+goog.proto2.Descriptor.prototype.findFieldByTag = function(tag) {
+ goog.proto2.Util.assert(goog.string.isNumeric(tag));
+ return this.fields_[parseInt(tag, 10)] || null;
+};
+
+
+/**
+ * Creates an instance of the message type that this descriptor
+ * describes.
+ *
+ * @return {goog.proto2.Message} The instance of the message.
+ */
+goog.proto2.Descriptor.prototype.createMessageInstance = function() {
+ return new this.messageType_;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/descriptor_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/descriptor_test.html
new file mode 100644
index 0000000..a06a9fe
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/descriptor_test.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - descriptor.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.Descriptor');
+ goog.require('goog.testing.jsunit');
+</script>
+</head>
+<body>
+<script>
+
+function testDescriptorConstruction() {
+ var messageType = {};
+ var descriptor = new goog.proto2.Descriptor(messageType, {
+ name: 'test',
+ fullName: 'this.is.a.test'
+ }, []);
+
+ assertEquals('test', descriptor.getName());
+ assertEquals('this.is.a.test', descriptor.getFullName());
+ assertEquals(null, descriptor.getContainingType());
+}
+
+function testParentDescriptor() {
+ var parentType = {};
+ var messageType = {};
+
+ var parentDescriptor = new goog.proto2.Descriptor(parentType, {
+ name: 'parent',
+ fullName: 'this.is.a.parent'
+ }, []);
+
+ parentType.getDescriptor = function() {
+ return parentDescriptor;
+ };
+
+ var descriptor = new goog.proto2.Descriptor(messageType, {
+ name: 'test',
+ fullName: 'this.is.a.test',
+ containingType: parentType
+ }, []);
+
+ assertEquals(parentDescriptor, descriptor.getContainingType());
+}
+
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor.js b/contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor.js
new file mode 100644
index 0000000..77114f1
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor.js
@@ -0,0 +1,291 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer Field Descriptor class.
+ */
+
+goog.provide('goog.proto2.FieldDescriptor');
+
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * A class which describes a field in a Protocol Buffer 2 Message.
+ *
+ * @param {Function} messageType Constructor for the message
+ * class to which the field described by this class belongs.
+ * @param {number|string} tag The field's tag index.
+ * @param {Object} metadata The metadata about this field that will be used
+ * to construct this descriptor.
+ *
+ * @constructor
+ */
+goog.proto2.FieldDescriptor = function(messageType, tag, metadata) {
+ /**
+ * The message type that contains the field that this
+ * descriptor describes.
+ * @type {Function}
+ * @private
+ */
+ this.parent_ = messageType;
+
+ // Ensure that the tag is numeric.
+ goog.proto2.Util.assert(goog.string.isNumeric(tag));
+
+ /**
+ * The field's tag number.
+ * @type {number}
+ * @private
+ */
+ this.tag_ = /** @type {number} */ (tag);
+
+ /**
+ * The field's name.
+ * @type {string}
+ * @private
+ */
+ this.name_ = metadata.name;
+
+ /** @type {goog.proto2.FieldDescriptor.FieldType} */
+ metadata.fieldType;
+
+ /** @type {*} */
+ metadata.repeated;
+
+ /** @type {*} */
+ metadata.required;
+
+ /**
+ * If true, this field is a repeating field.
+ * @type {boolean}
+ * @private
+ */
+ this.isRepeated_ = !!metadata.repeated;
+
+ /**
+ * If true, this field is required.
+ * @type {boolean}
+ * @private
+ */
+ this.isRequired_ = !!metadata.required;
+
+ /**
+ * The field type of this field.
+ * @type {goog.proto2.FieldDescriptor.FieldType}
+ * @private
+ */
+ this.fieldType_ = metadata.fieldType;
+
+ /**
+ * If this field is a primitive: The native (ECMAScript) type of this field.
+ * If an enumeration: The enumeration object.
+ * If a message or group field: The Message function.
+ * @type {Function}
+ * @private
+ */
+ this.nativeType_ = metadata.type;
+
+ /**
+ * Is it permissible on deserialization to convert between numbers and
+ * well-formed strings? Is true for 64-bit integral field types, false for
+ * all other field types.
+ * @type {boolean}
+ * @private
+ */
+ this.deserializationConversionPermitted_ = false;
+
+ switch (this.fieldType_) {
+ case goog.proto2.FieldDescriptor.FieldType.INT64:
+ case goog.proto2.FieldDescriptor.FieldType.UINT64:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SINT64:
+ this.deserializationConversionPermitted_ = true;
+ break;
+ }
+
+ /**
+ * The default value of this field, if different from the default, default
+ * value.
+ * @type {*}
+ * @private
+ */
+ this.defaultValue_ = metadata.defaultValue;
+};
+
+
+/**
+ * An enumeration defining the possible field types.
+ * Should be a mirror of that defined in descriptor.h.
+ *
+ * @enum {number}
+ */
+goog.proto2.FieldDescriptor.FieldType = {
+ DOUBLE: 1,
+ FLOAT: 2,
+ INT64: 3,
+ UINT64: 4,
+ INT32: 5,
+ FIXED64: 6,
+ FIXED32: 7,
+ BOOL: 8,
+ STRING: 9,
+ GROUP: 10,
+ MESSAGE: 11,
+ BYTES: 12,
+ UINT32: 13,
+ ENUM: 14,
+ SFIXED32: 15,
+ SFIXED64: 16,
+ SINT32: 17,
+ SINT64: 18
+};
+
+
+/**
+ * Returns the tag of the field that this descriptor represents.
+ *
+ * @return {number} The tag number.
+ */
+goog.proto2.FieldDescriptor.prototype.getTag = function() {
+ return this.tag_;
+};
+
+
+/**
+ * Returns the descriptor describing the message that defined this field.
+ * @return {goog.proto2.Descriptor} The descriptor.
+ */
+goog.proto2.FieldDescriptor.prototype.getContainingType = function() {
+ return this.parent_.descriptor_;
+};
+
+
+/**
+ * Returns the name of the field that this descriptor represents.
+ * @return {string} The name.
+ */
+goog.proto2.FieldDescriptor.prototype.getName = function() {
+ return this.name_;
+};
+
+
+/**
+ * Returns the default value of this field.
+ * @return {*} The default value.
+ */
+goog.proto2.FieldDescriptor.prototype.getDefaultValue = function() {
+ if (this.defaultValue_ === undefined) {
+ // Set the default value based on a new instance of the native type.
+ // This will be (0, false, "") for (number, boolean, string) and will
+ // be a new instance of a group/message if the field is a message type.
+ var nativeType = this.nativeType_;
+ if (nativeType === Boolean) {
+ this.defaultValue_ = false;
+ } else if (nativeType === Number) {
+ this.defaultValue_ = 0;
+ } else if (nativeType === String) {
+ this.defaultValue_ = '';
+ } else {
+ this.defaultValue_ = new nativeType;
+ }
+ }
+
+ return this.defaultValue_;
+};
+
+
+/**
+ * Returns the field type of the field described by this descriptor.
+ * @return {goog.proto2.FieldDescriptor.FieldType} The field type.
+ */
+goog.proto2.FieldDescriptor.prototype.getFieldType = function() {
+ return this.fieldType_;
+};
+
+
+/**
+ * Returns the native (i.e. ECMAScript) type of the field described by this
+ * descriptor.
+ *
+ * @return {Object} The native type.
+ */
+goog.proto2.FieldDescriptor.prototype.getNativeType = function() {
+ return this.nativeType_;
+};
+
+
+/**
+ * Returns true if simple conversions between numbers and strings are permitted
+ * during deserialization for this field.
+ *
+ * @return {boolean} Whether conversion is permitted.
+ */
+goog.proto2.FieldDescriptor.prototype.deserializationConversionPermitted =
+ function() {
+ return this.deserializationConversionPermitted_;
+};
+
+
+/**
+ * Returns the descriptor of the message type of this field. Only valid
+ * for fields of type GROUP and MESSAGE.
+ *
+ * @return {goog.proto2.Descriptor} The message descriptor.
+ */
+goog.proto2.FieldDescriptor.prototype.getFieldMessageType = function() {
+ goog.proto2.Util.assert(this.isCompositeType(), 'Expected message or group');
+
+ return this.nativeType_.descriptor_;
+};
+
+
+/**
+ * @return {boolean} True if the field stores composite data or repeated
+ * composite data (message or group).
+ */
+goog.proto2.FieldDescriptor.prototype.isCompositeType = function() {
+ return this.fieldType_ == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ this.fieldType_ == goog.proto2.FieldDescriptor.FieldType.GROUP;
+};
+
+
+/**
+ * Returns whether the field described by this descriptor is repeating.
+ * @return {boolean} Whether the field is repeated.
+ */
+goog.proto2.FieldDescriptor.prototype.isRepeated = function() {
+ return this.isRepeated_;
+};
+
+
+/**
+ * Returns whether the field described by this descriptor is required.
+ * @return {boolean} Whether the field is required.
+ */
+goog.proto2.FieldDescriptor.prototype.isRequired = function() {
+ return this.isRequired_;
+};
+
+
+/**
+ * Returns whether the field described by this descriptor is optional.
+ * @return {boolean} Whether the field is optional.
+ */
+goog.proto2.FieldDescriptor.prototype.isOptional = function() {
+ return !this.isRepeated_ && !this.isRequired_;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor_test.html
new file mode 100644
index 0000000..bfbe47f
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/fielddescriptor_test.html
@@ -0,0 +1,124 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - fielddescriptor.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.Descriptor');
+ goog.require('goog.proto2.FieldDescriptor');
+ goog.require('goog.testing.jsunit');
+</script>
+</head>
+<body>
+<script>
+
+function testFieldDescriptorConstruction() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ repeated: true,
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(10, fieldDescriptor.getTag());
+ assertEquals('test', fieldDescriptor.getName());
+
+ assertEquals(true, fieldDescriptor.isRepeated());
+
+ assertEquals(7, fieldDescriptor.getFieldType());
+ assertEquals(Number, fieldDescriptor.getNativeType());
+ assertEquals(0, fieldDescriptor.getDefaultValue());
+}
+
+function testFieldDescriptorConstruction2() {
+ var fieldDescriptor = new goog.proto2.FieldDescriptor({}, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: String
+ });
+
+ assertEquals('', fieldDescriptor.getDefaultValue());
+}
+
+function testFieldDescriptorConstruction3() {
+ var fieldDescriptor = new goog.proto2.FieldDescriptor({}, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: Boolean
+ });
+
+ assertEquals(false, fieldDescriptor.getDefaultValue());
+}
+
+function testRepeatedField() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ repeated: true,
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(true, fieldDescriptor.isRepeated());
+ assertEquals(false, fieldDescriptor.isRequired());
+ assertEquals(false, fieldDescriptor.isOptional());
+}
+
+function testRequiredField() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ required: true,
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(false, fieldDescriptor.isRepeated());
+ assertEquals(true, fieldDescriptor.isRequired());
+ assertEquals(false, fieldDescriptor.isOptional());
+}
+
+function testOptionalField() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: Number
+ });
+
+ assertEquals(false, fieldDescriptor.isRepeated());
+ assertEquals(false, fieldDescriptor.isRequired());
+ assertEquals(true, fieldDescriptor.isOptional());
+}
+
+function testContaingType() {
+ var messageType = {};
+ var fieldDescriptor = new goog.proto2.FieldDescriptor(messageType, 10, {
+ name: 'test',
+ fieldType: 7,
+ type: Number
+ });
+
+ var descriptor = new goog.proto2.Descriptor(messageType, {
+ name: 'test_message',
+ fullName: 'this.is.a.test_message'
+ }, [fieldDescriptor]);
+
+ messageType.descriptor_ = descriptor;
+
+ assertEquals(descriptor, fieldDescriptor.getContainingType());
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/lazydeserializer.js b/contexts/data/lib/closure-library/closure/goog/proto2/lazydeserializer.js
new file mode 100644
index 0000000..50d7506
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/lazydeserializer.js
@@ -0,0 +1,69 @@
+// Copyright 2009 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Base class for all PB2 lazy deserializer. A lazy deserializer
+ * is a serializer whose deserialization occurs on the fly as data is
+ * requested. In order to use a lazy deserializer, the serialized form
+ * of the data must be an object or array that can be indexed by the tag
+ * number.
+ *
+ */
+
+goog.provide('goog.proto2.LazyDeserializer');
+
+goog.require('goog.proto2.Serializer');
+goog.require('goog.proto2.Util');
+
+
+
+/**
+ * Base class for all lazy deserializers.
+ *
+ * @constructor
+ * @extends {goog.proto2.Serializer}
+ */
+goog.proto2.LazyDeserializer = function() {};
+goog.inherits(goog.proto2.LazyDeserializer, goog.proto2.Serializer);
+
+
+/** @override */
+goog.proto2.LazyDeserializer.prototype.deserialize =
+ function(descriptor, data) {
+ var message = descriptor.createMessageInstance();
+ message.initializeForLazyDeserializer(this, data);
+ goog.proto2.Util.assert(message instanceof goog.proto2.Message);
+ return message;
+};
+
+
+/** @override */
+goog.proto2.LazyDeserializer.prototype.deserializeTo = function(message, data) {
+ throw new Error('Unimplemented');
+};
+
+
+/**
+ * Deserializes a message field from the expected format and places the
+ * data in the given message
+ *
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {goog.proto2.FieldDescriptor} field The field for which to set the
+ * message value.
+ * @param {*} data The serialized data for the field.
+ *
+ * @return {*} The deserialized data or null for no value found.
+ */
+goog.proto2.LazyDeserializer.prototype.deserializeField = goog.abstractMethod;
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/message.js b/contexts/data/lib/closure-library/closure/goog/proto2/message.js
new file mode 100644
index 0000000..db3ffb1
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/message.js
@@ -0,0 +1,740 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer Message base class.
+ */
+
+goog.provide('goog.proto2.Message');
+
+goog.require('goog.proto2.Descriptor');
+goog.require('goog.proto2.FieldDescriptor');
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * Abstract base class for all Protocol Buffer 2 messages. It will be
+ * subclassed in the code generated by the Protocol Compiler. Any other
+ * subclasses are prohibited.
+ * @constructor
+ */
+goog.proto2.Message = function() {
+ /**
+ * Stores the field values in this message.
+ * @type {*}
+ * @private
+ */
+ this.values_ = {};
+
+ // The descriptor_ is static to the message function that is being created.
+ // Therefore, we retrieve it via the constructor.
+
+ /**
+ * Stores the information (i.e. metadata) about this message.
+ * @type {!goog.proto2.Descriptor}
+ * @private
+ */
+ this.descriptor_ = this.constructor.descriptor_;
+
+ /**
+ * Stores the field information (i.e. metadata) about this message.
+ * @type {Object.<number, !goog.proto2.FieldDescriptor>}
+ * @private
+ */
+ this.fields_ = this.descriptor_.getFieldsMap();
+
+ /**
+ * The lazy deserializer for this message instance, if any.
+ * @type {goog.proto2.LazyDeserializer}
+ * @private
+ */
+ this.lazyDeserializer_ = null;
+
+ /**
+ * A map of those fields deserialized.
+ * @type {Object}
+ * @private
+ */
+ this.deserializedFields_ = null;
+};
+
+
+/**
+ * An enumeration defining the possible field types.
+ * Should be a mirror of that defined in descriptor.h.
+ *
+ * TODO(user): Remove this alias. The code generator generates code that
+ * references this enum, so it needs to exist until the code generator is
+ * changed. The enum was moved to from Message to FieldDescriptor to avoid a
+ * dependency cycle.
+ *
+ * Use goog.proto2.FieldDescriptor.FieldType instead.
+ *
+ * @enum {number}
+ */
+goog.proto2.Message.FieldType = {
+ DOUBLE: 1,
+ FLOAT: 2,
+ INT64: 3,
+ UINT64: 4,
+ INT32: 5,
+ FIXED64: 6,
+ FIXED32: 7,
+ BOOL: 8,
+ STRING: 9,
+ GROUP: 10,
+ MESSAGE: 11,
+ BYTES: 12,
+ UINT32: 13,
+ ENUM: 14,
+ SFIXED32: 15,
+ SFIXED64: 16,
+ SINT32: 17,
+ SINT64: 18
+};
+
+
+/**
+ * Initializes the message with a lazy deserializer and its associated data.
+ * This method should be called by internal methods ONLY.
+ *
+ * @param {goog.proto2.LazyDeserializer} deserializer The lazy deserializer to
+ * use to decode the data on the fly.
+ *
+ * @param {*} data The data to decode/deserialize.
+ */
+goog.proto2.Message.prototype.initializeForLazyDeserializer = function(
+ deserializer, data) {
+
+ this.lazyDeserializer_ = deserializer;
+ this.values_ = data;
+ this.deserializedFields_ = {};
+};
+
+
+/**
+ * Sets the value of an unknown field, by tag.
+ *
+ * @param {number} tag The tag of an unknown field (must be >= 1).
+ * @param {*} value The value for that unknown field.
+ */
+goog.proto2.Message.prototype.setUnknown = function(tag, value) {
+ goog.proto2.Util.assert(!this.fields_[tag],
+ 'Field is not unknown in this message');
+
+ goog.proto2.Util.assert(tag >= 1, 'Tag is not valid');
+ goog.proto2.Util.assert(value !== null, 'Value cannot be null');
+
+ this.values_[tag] = value;
+};
+
+
+/**
+ * Iterates over all the unknown fields in the message.
+ *
+ * @param {function(number, *)} callback A callback method
+ * which gets invoked for each unknown field.
+ * @param {Object=} opt_scope The scope under which to execute the callback.
+ * If not given, the current message will be used.
+ */
+goog.proto2.Message.prototype.forEachUnknown = function(callback, opt_scope) {
+ var scope = opt_scope || this;
+ for (var key in this.values_) {
+ if (!this.fields_[/** @type {number} */ (key)]) {
+ callback.call(scope, Number(key), this.values_[key]);
+ }
+ }
+};
+
+
+/**
+ * Returns the descriptor which describes the current message.
+ *
+ * @return {goog.proto2.Descriptor} The descriptor.
+ */
+goog.proto2.Message.prototype.getDescriptor = function() {
+ return this.descriptor_;
+};
+
+
+/**
+ * Returns whether there is a value stored at the field specified by the
+ * given field descriptor.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to check
+ * if there is a value.
+ *
+ * @return {boolean} True if a value was found.
+ */
+goog.proto2.Message.prototype.has = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.has$Value(field.getTag());
+};
+
+
+/**
+ * Returns the array of values found for the given repeated field.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to
+ * return the values.
+ *
+ * @return {!Array} The values found.
+ */
+goog.proto2.Message.prototype.arrayOf = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.array$Values(field.getTag());
+};
+
+
+/**
+ * Returns the number of values stored in the given field.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to count
+ * the number of values.
+ *
+ * @return {number} The count of the values in the given field.
+ */
+goog.proto2.Message.prototype.countOf = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.count$Values(field.getTag());
+};
+
+
+/**
+ * Returns the value stored at the field specified by the
+ * given field descriptor.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to get the
+ * value.
+ * @param {number=} opt_index If the field is repeated, the index to use when
+ * looking up the value.
+ *
+ * @return {*} The value found or null if none.
+ */
+goog.proto2.Message.prototype.get = function(field, opt_index) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.get$Value(field.getTag(), opt_index);
+};
+
+
+/**
+ * Returns the value stored at the field specified by the
+ * given field descriptor or the default value if none exists.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to get the
+ * value.
+ * @param {number=} opt_index If the field is repeated, the index to use when
+ * looking up the value.
+ *
+ * @return {*} The value found or the default if none.
+ */
+goog.proto2.Message.prototype.getOrDefault = function(field, opt_index) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ return this.get$ValueOrDefault(field.getTag(), opt_index);
+};
+
+
+/**
+ * Stores the given value to the field specified by the
+ * given field descriptor. Note that the field must not be repeated.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field for which to set
+ * the value.
+ * @param {*} value The new value for the field.
+ */
+goog.proto2.Message.prototype.set = function(field, value) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ this.set$Value(field.getTag(), value);
+};
+
+
+/**
+ * Adds the given value to the field specified by the
+ * given field descriptor. Note that the field must be repeated.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field in which to add the
+ * the value.
+ * @param {*} value The new value to add to the field.
+ */
+goog.proto2.Message.prototype.add = function(field, value) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ this.add$Value(field.getTag(), value);
+};
+
+
+/**
+ * Clears the field specified.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field to clear.
+ */
+goog.proto2.Message.prototype.clear = function(field) {
+ goog.proto2.Util.assert(
+ field.getContainingType() == this.descriptor_,
+ 'The current message does not contain the given field');
+
+ this.clear$Field(field.getTag());
+};
+
+
+/**
+ * Compares this message with another one ignoring the unknown fields.
+ * @param {*} other The other message.
+ * @return {boolean} Whether they are equal. Returns false if the {@code other}
+ * argument is a different type of message or not a message.
+ */
+goog.proto2.Message.prototype.equals = function(other) {
+ if (!other || this.constructor != other.constructor) {
+ return false;
+ }
+
+ var fields = this.getDescriptor().getFields();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ if (this.has(field) != other.has(field)) {
+ return false;
+ }
+
+ if (this.has(field)) {
+ var isComposite = field.isCompositeType();
+
+ function fieldsEqual(value1, value2) {
+ return isComposite ? value1.equals(value2) : value1 == value2;
+ }
+
+ var tag = field.getTag();
+ var thisValue = this.values_[tag];
+ var otherValue = other.values_[tag];
+
+ if (field.isRepeated()) {
+ // In this case thisValue and otherValue are arrays.
+ if (thisValue.length != otherValue.length) {
+ return false;
+ }
+ for (var j = 0; j < thisValue.length; j++) {
+ if (!fieldsEqual(thisValue[j], otherValue[j])) {
+ return false;
+ }
+ }
+ } else if (!fieldsEqual(thisValue, otherValue)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+};
+
+
+/**
+ * Recursively copies the known fields from the given message to this message.
+ * Removes the fields which are not present in the source message.
+ * @param {!goog.proto2.Message} message The source message.
+ */
+goog.proto2.Message.prototype.copyFrom = function(message) {
+ goog.proto2.Util.assert(this.constructor == message.constructor,
+ 'The source message must have the same type.');
+ var fields = this.getDescriptor().getFields();
+
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ delete this.values_[field.getTag()];
+
+ if (message.has(field)) {
+ var isComposite = field.isCompositeType();
+ if (field.isRepeated()) {
+ var values = message.arrayOf(field);
+ for (var j = 0; j < values.length; j++) {
+ this.add(field, isComposite ? values[j].clone() : values[j]);
+ }
+ } else {
+ var value = message.get(field);
+ this.set(field, isComposite ? value.clone() : value);
+ }
+ }
+ }
+};
+
+
+/**
+ * @return {!goog.proto2.Message} Recursive clone of the message only including
+ * the known fields.
+ */
+goog.proto2.Message.prototype.clone = function() {
+ var clone = new this.constructor;
+ clone.copyFrom(this);
+ return clone;
+};
+
+
+/**
+ * Fills in the protocol buffer with default values. Any fields that are
+ * already set will not be overridden.
+ * @param {boolean} simpleFieldsToo If true, all fields will be initialized;
+ * if false, only the nested messages and groups.
+ */
+goog.proto2.Message.prototype.initDefaults = function(simpleFieldsToo) {
+ var fields = this.getDescriptor().getFields();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ var tag = field.getTag();
+ var isComposite = field.isCompositeType();
+
+ // Initialize missing fields.
+ if (!this.has(field) && !field.isRepeated()) {
+ if (isComposite) {
+ this.values_[tag] = new /** @type {Function} */ (field.getNativeType());
+ } else if (simpleFieldsToo) {
+ this.values_[tag] = field.getDefaultValue();
+ }
+ }
+
+ // Fill in the existing composite fields recursively.
+ if (isComposite) {
+ if (field.isRepeated()) {
+ var values = this.array$Values(tag);
+ for (var j = 0; j < values.length; j++) {
+ values[j].initDefaults(simpleFieldsToo);
+ }
+ } else {
+ this.get$Value(tag).initDefaults(simpleFieldsToo);
+ }
+ }
+ }
+};
+
+
+/**
+ * Returns the field in this message by the given tag number. If no
+ * such field exists, throws an exception.
+ *
+ * @param {number} tag The field's tag index.
+ * @return {!goog.proto2.FieldDescriptor} The descriptor for the field.
+ * @private
+ */
+goog.proto2.Message.prototype.getFieldByTag_ = function(tag) {
+ goog.proto2.Util.assert(this.fields_[tag],
+ 'No field found for the given tag');
+
+ return this.fields_[tag];
+};
+
+
+/**
+ * Returns the whether or not the field indicated by the given tag
+ * has a value.
+ *
+ * GENERATED CODE USE ONLY. Basis of the has{Field} methods.
+ *
+ * @param {number} tag The tag.
+ *
+ * @return {boolean} Whether the message has a value for the field.
+ */
+goog.proto2.Message.prototype.has$Value = function(tag) {
+ goog.proto2.Util.assert(this.fields_[tag],
+ 'No field found for the given tag');
+
+ return tag in this.values_ && goog.isDef(this.values_[tag]) &&
+ this.values_[tag] !== null;
+};
+
+
+/**
+ * If a lazy deserializer is instantiated, lazily deserializes the
+ * field if required.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @private
+ */
+goog.proto2.Message.prototype.lazyDeserialize_ = function(field) {
+ // If we have a lazy deserializer, then ensure that the field is
+ // properly deserialized.
+ if (this.lazyDeserializer_) {
+ var tag = field.getTag();
+
+ if (!(tag in this.deserializedFields_)) {
+ this.values_[tag] = this.lazyDeserializer_.deserializeField(
+ this, field, this.values_[tag]);
+
+ this.deserializedFields_[tag] = true;
+ }
+ }
+};
+
+
+/**
+ * Gets the value at the field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the get{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {number=} opt_index If the field is a repeated field, the index
+ * at which to get the value.
+ *
+ * @return {*} The value found or null for none.
+ * @protected
+ */
+goog.proto2.Message.prototype.get$Value = function(tag, opt_index) {
+ var field = this.getFieldByTag_(tag);
+
+ // Ensure that the field is deserialized.
+ this.lazyDeserialize_(field);
+
+ if (field.isRepeated()) {
+ var index = opt_index || 0;
+ goog.proto2.Util.assert(index >= 0 && index < this.count$Values(tag),
+ 'Given index is out of bounds');
+
+ return this.values_[tag][index];
+ } else {
+ goog.proto2.Util.assert(!goog.isArray(this.values_[tag]));
+ return tag in this.values_ ? this.values_[tag] : null;
+ }
+};
+
+
+/**
+ * Gets the value at the field indicated by the given tag or the default value
+ * if none.
+ *
+ * GENERATED CODE USE ONLY. Basis of the get{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {number=} opt_index If the field is a repeated field, the index
+ * at which to get the value.
+ *
+ * @return {*} The value found or the default value if none set.
+ * @protected
+ */
+goog.proto2.Message.prototype.get$ValueOrDefault = function(tag, opt_index) {
+
+ if (!this.has$Value(tag)) {
+ // Return the default value.
+ var field = this.getFieldByTag_(tag);
+ return field.getDefaultValue();
+ }
+
+ return this.get$Value(tag, opt_index);
+};
+
+
+/**
+ * Gets the values at the field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the {field}Array methods.
+ *
+ * @param {number} tag The field's tag index.
+ *
+ * @return {!Array} The values found. If none, returns an empty array.
+ * @protected
+ */
+goog.proto2.Message.prototype.array$Values = function(tag) {
+ goog.proto2.Util.assert(this.getFieldByTag_(tag).isRepeated(),
+ 'Cannot call fieldArray on a non-repeated field');
+
+ var field = this.getFieldByTag_(tag);
+
+ // Ensure that the field is deserialized.
+ this.lazyDeserialize_(field);
+
+ return this.values_[tag] || [];
+};
+
+
+/**
+ * Returns the number of values stored in the field by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the {field}Count methods.
+ *
+ * @param {number} tag The tag.
+ *
+ * @return {number} The number of values.
+ * @protected
+ */
+goog.proto2.Message.prototype.count$Values = function(tag) {
+ var field = this.getFieldByTag_(tag);
+
+ if (field.isRepeated()) {
+ if (this.has$Value(tag)) {
+ goog.proto2.Util.assert(goog.isArray(this.values_[tag]));
+ }
+
+ return this.has$Value(tag) ? this.values_[tag].length : 0;
+ } else {
+ return this.has$Value(tag) ? 1 : 0;
+ }
+};
+
+
+/**
+ * Sets the value of the *non-repeating* field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the set{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {*} value The field's value.
+ * @protected
+ */
+goog.proto2.Message.prototype.set$Value = function(tag, value) {
+ if (goog.proto2.Util.conductChecks()) {
+ var field = this.getFieldByTag_(tag);
+
+ goog.proto2.Util.assert(!field.isRepeated(),
+ 'Cannot call set on a repeated field');
+
+ this.checkFieldType_(field, value);
+ }
+
+ this.values_[tag] = value;
+ if (this.deserializedFields_) {
+ this.deserializedFields_[tag] = true;
+ }
+};
+
+
+/**
+ * Adds the value to the *repeating* field indicated by the given tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the add{Field} methods.
+ *
+ * @param {number} tag The field's tag index.
+ * @param {*} value The value to add.
+ * @protected
+ */
+goog.proto2.Message.prototype.add$Value = function(tag, value) {
+ if (goog.proto2.Util.conductChecks()) {
+ var field = this.getFieldByTag_(tag);
+
+ goog.proto2.Util.assert(field.isRepeated(),
+ 'Cannot call add on a non-repeated field');
+
+ this.checkFieldType_(field, value);
+ }
+
+ if (!this.values_[tag]) {
+ this.values_[tag] = [];
+ }
+
+ this.values_[tag].push(value);
+};
+
+
+/**
+ * Ensures that the value being assigned to the given field
+ * is valid.
+ *
+ * @param {!goog.proto2.FieldDescriptor} field The field being assigned.
+ * @param {*} value The value being assigned.
+ * @private
+ */
+goog.proto2.Message.prototype.checkFieldType_ = function(field, value) {
+ goog.proto2.Util.assert(value !== null);
+
+ var nativeType = field.getNativeType();
+ if (nativeType === String) {
+ goog.proto2.Util.assert(typeof value === 'string',
+ 'Expected value of type string');
+ } else if (nativeType === Boolean) {
+ goog.proto2.Util.assert(typeof value === 'boolean',
+ 'Expected value of type boolean');
+ } else if (nativeType === Number) {
+ goog.proto2.Util.assert(typeof value === 'number',
+ 'Expected value of type number');
+ } else if (field.getFieldType() ==
+ goog.proto2.FieldDescriptor.FieldType.ENUM) {
+ goog.proto2.Util.assert(typeof value === 'number',
+ 'Expected an enum value, which is a number');
+ } else {
+ goog.proto2.Util.assert(value instanceof nativeType,
+ 'Expected a matching message type');
+ }
+};
+
+
+/**
+ * Clears the field specified by tag.
+ *
+ * GENERATED CODE USE ONLY. Basis of the clear{Field} methods.
+ *
+ * @param {number} tag The tag of the field to clear.
+ * @protected
+ */
+goog.proto2.Message.prototype.clear$Field = function(tag) {
+ goog.proto2.Util.assert(this.getFieldByTag_(tag), 'Unknown field');
+ delete this.values_[tag];
+};
+
+
+/**
+ * Sets the metadata that represents the definition of this message.
+ *
+ * GENERATED CODE USE ONLY. Called when constructing message classes.
+ *
+ * @param {Function} messageType Constructor for the message type to
+ * which this metadata applies.
+ * @param {Object} metadataObj The object containing the metadata.
+ */
+goog.proto2.Message.set$Metadata = function(messageType, metadataObj) {
+ var fields = [];
+ var descriptorInfo;
+
+ for (var key in metadataObj) {
+ if (!metadataObj.hasOwnProperty(key)) {
+ continue;
+ }
+
+ goog.proto2.Util.assert(goog.string.isNumeric(key), 'Keys must be numeric');
+
+ if (key == 0) {
+ descriptorInfo = metadataObj[0];
+ continue;
+ }
+
+ // Create the field descriptor.
+ fields.push(
+ new goog.proto2.FieldDescriptor(messageType, key, metadataObj[key]));
+ }
+
+ goog.proto2.Util.assert(descriptorInfo);
+
+ // Create the descriptor.
+ messageType.descriptor_ =
+ new goog.proto2.Descriptor(messageType, descriptorInfo, fields);
+
+ messageType.getDescriptor = function() {
+ return messageType.descriptor_;
+ };
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/message_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/message_test.html
new file mode 100644
index 0000000..a316d71
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/message_test.html
@@ -0,0 +1,389 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2010 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - message.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.Message');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+ goog.require('proto2.TestAllTypes.NestedEnum');
+ goog.require('proto2.TestAllTypes.NestedMessage');
+ goog.require('proto2.TestAllTypes.OptionalGroup');
+ goog.require('proto2.TestAllTypes.RepeatedGroup');
+</script>
+</head>
+<body>
+<script>
+
+function testEqualsWithEmptyMessages() {
+ var message1 = new proto2.TestAllTypes();
+ assertTrue('same message object', message1.equals(message1));
+ assertFalse('comparison with null', message1.equals(null));
+ assertFalse('comparison with undefined', message1.equals(undefined));
+
+ var message2 = new proto2.TestAllTypes();
+ assertTrue('two empty message objects', message1.equals(message2));
+
+ var message3 = new proto2.TestAllTypes.NestedMessage()
+ assertFalse('different message types', message3.equals(message1));
+}
+
+function testEqualsWithSingleInt32Field() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+
+ message1.setOptionalInt32(1);
+ assertFalse('message1 has an extra int32 field', message1.equals(message2));
+
+ message2.setOptionalInt32(1);
+ assertTrue('same int32 field in both messages', message1.equals(message2));
+
+ message2.setOptionalInt32(2);
+ assertFalse('different int32 field', message1.equals(message2));
+
+ message1.clearOptionalInt32();
+ assertFalse('message2 has an extra int32 field', message1.equals(message2));
+}
+
+function testEqualsWithRepeatedInt32Fields() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+
+ message1.addRepeatedInt32(0);
+ message2.addRepeatedInt32(0);
+ assertTrue('equal repeated int32 field', message1.equals(message2));
+
+ message1.addRepeatedInt32(1);
+ assertFalse('message1 has more items', message1.equals(message2));
+
+ message2.addRepeatedInt32(1);
+ message2.addRepeatedInt32(1);
+ assertFalse('message2 has more items', message1.equals(message2));
+
+ message1.addRepeatedInt32(2);
+ assertFalse('different int32 items', message1.equals(message2));
+}
+
+function testEqualsWithDefaultValue() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ message1.setOptionalInt64('1');
+
+ assertEquals('message1.getOptionalInt64OrDefault should return 1',
+ '1', message1.getOptionalInt64OrDefault());
+ assertEquals('message2.getOptionalInt64OrDefault should return 1 too',
+ '1', message2.getOptionalInt64OrDefault());
+ assertTrue('message1.hasOptionalInt64() should be true',
+ message1.hasOptionalInt64());
+ assertFalse('message2.hasOptionalInt64() should be false',
+ message2.hasOptionalInt64());
+ assertFalse('as a result they are not equal', message1.equals(message2));
+}
+
+function testEqualsWithOptionalGroup() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ var group1 = new proto2.TestAllTypes.OptionalGroup();
+ var group2 = new proto2.TestAllTypes.OptionalGroup();
+
+ message1.setOptionalgroup(group1);
+ assertFalse('only message1 has OptionalGroup field',
+ message1.equals(message2));
+
+ message2.setOptionalgroup(group2);
+ assertTrue('both messages have OptionalGroup field',
+ message1.equals(message2));
+
+ group1.setA(0);
+ group2.setA(1);
+ assertFalse('different value in the optional group',
+ message1.equals(message2));
+
+ message1.clearOptionalgroup();
+ assertFalse('only message2 has OptionalGroup field',
+ message1.equals(message2));
+}
+
+function testEqualsWithRepeatedGroup() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ var group1 = new proto2.TestAllTypes.RepeatedGroup();
+ var group2 = new proto2.TestAllTypes.RepeatedGroup();
+
+ message1.addRepeatedgroup(group1);
+ assertFalse('message1 has more RepeatedGroups',
+ message1.equals(message2));
+
+ message2.addRepeatedgroup(group2);
+ assertTrue('both messages have one RepeatedGroup',
+ message1.equals(message2));
+
+ group1.addA(1);
+ assertFalse('message1 has more int32s in RepeatedGroup',
+ message1.equals(message2));
+
+ group2.addA(1);
+ assertTrue('both messages have one int32 in RepeatedGroup',
+ message1.equals(message2));
+
+ group1.addA(1);
+ group2.addA(2);
+ assertFalse('the messages have different int32s in RepeatedGroup',
+ message1.equals(message2));
+}
+
+function testEqualsWithNestedMessage() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ var nested1 = new proto2.TestAllTypes.NestedMessage();
+ var nested2 = new proto2.TestAllTypes.NestedMessage();
+
+ message1.setOptionalNestedMessage(nested1);
+ assertFalse('only message1 has nested message', message1.equals(message2));
+
+ message2.setOptionalNestedMessage(nested2);
+ assertTrue('both messages have nested message', message1.equals(message2));
+
+ nested1.setB(1);
+ assertFalse('different int32 in the nested messages',
+ message1.equals(message2));
+
+ message1.clearOptionalNestedMessage();
+ assertFalse('only message2 has nested message', message1.equals(message2));
+}
+
+function testEqualsWithNestedEnum() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+
+ message1.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ assertFalse('only message1 has nested enum', message1.equals(message2));
+
+ message2.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ assertTrue('both messages have nested enum', message1.equals(message2));
+
+ message2.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.BAR);
+ assertFalse('different enum value', message1.equals(message2));
+
+ message1.clearOptionalNestedEnum();
+ assertFalse('only message2 has nested enum', message1.equals(message2));
+}
+
+function testEqualsWithUnknownFields() {
+ var message1 = new proto2.TestAllTypes();
+ var message2 = new proto2.TestAllTypes();
+ message1.setUnknown(999, 'foo');
+ message1.setUnknown(999, 'bar');
+ assertTrue('unknown fields are ignored', message1.equals(message2));
+}
+
+function testCloneEmptyMessage() {
+ var message = new proto2.TestAllTypes();
+ var clone = message.clone();
+ assertObjectEquals('cloned empty message', message, clone);
+}
+
+function testCloneMessageWithSeveralFields() {
+ var message = new proto2.TestAllTypes();
+ message.setOptionalInt32(1);
+ message.addRepeatedInt32(2);
+ var optionalGroup = new proto2.TestAllTypes.OptionalGroup();
+ optionalGroup.setA(3);
+ message.setOptionalgroup(optionalGroup);
+ var repeatedGroup = new proto2.TestAllTypes.RepeatedGroup();
+ repeatedGroup.addA(4);
+ message.addRepeatedgroup(repeatedGroup);
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(5);
+ message.setOptionalNestedMessage(nestedMessage);
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ message.setUnknown(999, 'foo');
+
+ var clone = message.clone();
+ assertNotEquals('different OptionalGroup instance',
+ message.getOptionalgroup(), clone.getOptionalgroup());
+ assertNotEquals('different RepeatedGroup array instance',
+ message.repeatedgroupArray(), clone.repeatedgroupArray());
+ assertNotEquals('different RepeatedGroup array item instance',
+ message.getRepeatedgroup(0), clone.getRepeatedgroup(0));
+ assertNotEquals('different NestedMessage instance',
+ message.getOptionalNestedMessage(), clone.getOptionalNestedMessage());
+}
+
+function testCloneWithUnknownFields() {
+ var message = new proto2.TestAllTypes();
+ message.setUnknown(999, 'foo');
+
+ var clone = message.clone();
+ assertTrue('clone.equals(message) returns true', clone.equals(message));
+ clone.forEachUnknown(function(tag, value) {
+ fail('the unknown fields should not have been cloned');
+ });
+
+ clone.setUnknown(999, 'foo');
+ assertObjectEquals('the original and the cloned message are equal except ' +
+ 'for the unknown fields', message, clone);
+}
+
+function testCopyFromFlatMessage() {
+ // Recursive copying is implicitly tested in the testClone... methods.
+
+ var source = new proto2.TestAllTypes();
+ source.setOptionalInt32(32);
+ source.setOptionalInt64('64');
+ source.addRepeatedInt32(32);
+
+ var target = new proto2.TestAllTypes();
+ target.setOptionalInt32(33);
+ target.setOptionalUint32(33);
+ target.addRepeatedInt32(33);
+
+ target.copyFrom(source);
+ assertObjectEquals('source and target are equal after copyFrom', source,
+ target);
+
+ target.copyFrom(source);
+ assertObjectEquals('second copyFrom call has no effect', source, target);
+
+ source.setUnknown(999, 'foo');
+ target.setUnknown(999, 'bar');
+ target.copyFrom(source);
+ assertThrows('unknown fields are not copied',
+ goog.partial(assertObjectEquals, source, target));
+}
+
+function testInitDefaultsWithEmptyMessage() {
+ var message = new proto2.TestAllTypes();
+ message.initDefaults(false);
+
+ assertFalse('int32 field is not set', message.hasOptionalInt32());
+ assertFalse('int64 [default=1] field is not set', message.hasOptionalInt64());
+ assertTrue('optional group field is set', message.hasOptionalgroup());
+ assertFalse('int32 inside the group is not set',
+ message.getOptionalgroup().hasA());
+ assertObjectEquals('value of the optional group',
+ new proto2.TestAllTypes.OptionalGroup(), message.getOptionalgroup());
+ assertTrue('nested message is set', message.hasOptionalNestedMessage());
+ assertObjectEquals('value of the nested message',
+ new proto2.TestAllTypes.NestedMessage(),
+ message.getOptionalNestedMessage());
+ assertFalse('nested enum is not set', message.hasOptionalNestedEnum());
+ assertFalse('repeated int32 is not set', message.hasRepeatedInt32());
+ assertFalse('repeated nested message is not set',
+ message.hasRepeatedNestedMessage());
+
+ message = new proto2.TestAllTypes();
+ message.initDefaults(true);
+
+ assertTrue('int32 field is set', message.hasOptionalInt32());
+ assertEquals('value of the int32 field', 0, message.getOptionalInt32());
+ assertTrue('int64 [default=1] field is set', message.hasOptionalInt64());
+ assertEquals('value of the int64 field', '1', message.getOptionalInt64());
+ assertTrue('int32 inside nested message is set',
+ message.getOptionalNestedMessage().hasB());
+ assertEquals('value of the int32 field inside the nested message', 0,
+ message.getOptionalNestedMessage().getB());
+}
+
+function testInitDefaultsWithNonEmptyMessage() {
+ var message = new proto2.TestAllTypes();
+ message.setOptionalInt32(32);
+ message.setOptionalInt64('64');
+ message.setOptionalgroup(new proto2.TestAllTypes.OptionalGroup());
+ var nested1 = new proto2.TestAllTypes.NestedMessage();
+ nested1.setB(66);
+ message.setOptionalNestedMessage(nested1);
+ var nested2 = new proto2.TestAllTypes.NestedMessage();
+ message.addRepeatedNestedMessage(nested2);
+ var nested3 = new proto2.TestAllTypes.NestedMessage();
+ nested3.setB(66);
+ message.addRepeatedNestedMessage(nested3);
+
+ message.initDefaults(true);
+ assertEquals('int32 field is unchanged', 32, message.getOptionalInt32());
+ assertEquals('int64 [default=1] field is unchanged', '64',
+ message.getOptionalInt64());
+ assertTrue('bool field is initialized', message.hasOptionalBool());
+ assertFalse('value of the bool field', message.getOptionalBool());
+ assertTrue('int32 inside the optional group is initialized',
+ message.getOptionalgroup().hasA());
+ assertEquals('value of the int32 inside the optional group', 0,
+ message.getOptionalgroup().getA());
+ assertEquals('int32 inside nested message is unchanged', 66,
+ message.getOptionalNestedMessage().getB());
+ assertTrue('int32 at index 0 of the repeated nested message is initialized',
+ message.getRepeatedNestedMessage(0).hasB());
+ assertEquals('value of int32 at index 0 of the repeated nested message', 0,
+ message.getRepeatedNestedMessage(0).getB());
+ assertEquals('int32 at index 1 of the repeated nested message is unchanged',
+ 66, message.getRepeatedNestedMessage(1).getB());
+}
+
+function testInitDefaultsTwice() {
+ var message = new proto2.TestAllTypes();
+ message.initDefaults(false);
+ var clone = message.clone();
+ clone.initDefaults(false);
+ assertObjectEquals('second call of initDefaults(false) has no effect',
+ message, clone);
+
+ message = new proto2.TestAllTypes();
+ message.initDefaults(true);
+ clone = message.clone();
+ clone.initDefaults(true);
+ assertObjectEquals('second call of initDefaults(true) has no effect',
+ message, clone);
+}
+
+function testInitDefaultsThenClone() {
+ var message = new proto2.TestAllTypes();
+ message.initDefaults(true);
+ assertObjectEquals('message is cloned properly', message, message.clone());
+}
+
+function testGetAfterSetWithLazyDeserializer() {
+ // Test makes sure that the lazy deserializer for a field is not
+ // erroneously called when get$Value is called after set$Value.
+ var message = new proto2.TestAllTypes();
+
+ var fakeDeserializer = {}; // stub with no methods defined; fails hard
+ message.initializeForLazyDeserializer(fakeDeserializer, {} /* data */);
+ message.setOptionalBool(true);
+ assertEquals(true, message.getOptionalBool());
+}
+
+function testHasOnLazyDeserializer() {
+ // Test that null values for fields are treated as absent by the lazy
+ // deserializer.
+ var message = new proto2.TestAllTypes();
+
+ var fakeDeserializer = {}; // stub with no methods defined; fails hard
+ message.initializeForLazyDeserializer(fakeDeserializer,
+ {13: false} /* data */);
+ assertEquals(true, message.hasOptionalBool());
+}
+
+function testHasOnLazyDeserializerWithNulls() {
+ // Test that null values for fields are treated as absent by the lazy
+ // deserializer.
+ var message = new proto2.TestAllTypes();
+
+ var fakeDeserializer = {}; // stub with no methods defined; fails hard
+ message.initializeForLazyDeserializer(fakeDeserializer,
+ {13: null} /* data */);
+ assertEquals(false, message.hasOptionalBool());
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/objectserializer.js b/contexts/data/lib/closure-library/closure/goog/proto2/objectserializer.js
new file mode 100644
index 0000000..0e84089
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/objectserializer.js
@@ -0,0 +1,159 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer 2 Serializer which serializes messages
+ * into anonymous, simplified JSON objects.
+ *
+ */
+
+goog.provide('goog.proto2.ObjectSerializer');
+
+goog.require('goog.proto2.Serializer');
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * ObjectSerializer, a serializer which turns Messages into simplified
+ * ECMAScript objects.
+ *
+ * @param {goog.proto2.ObjectSerializer.KeyOption=} opt_keyOption If specified,
+ * which key option to use when serializing/deserializing.
+ *
+ * @constructor
+ * @extends {goog.proto2.Serializer}
+ */
+goog.proto2.ObjectSerializer = function(opt_keyOption) {
+ this.keyOption_ = opt_keyOption;
+};
+goog.inherits(goog.proto2.ObjectSerializer, goog.proto2.Serializer);
+
+
+/**
+ * An enumeration of the options for how to emit the keys in
+ * the generated simplified object.
+ *
+ * @enum {number}
+ */
+goog.proto2.ObjectSerializer.KeyOption = {
+ /**
+ * Use the tag of the field as the key (default)
+ */
+ TAG: 0,
+
+ /**
+ * Use the name of the field as the key. Unknown fields
+ * will still use their tags as keys.
+ */
+ NAME: 1
+};
+
+
+/**
+ * Serializes a message to an object.
+ *
+ * @param {goog.proto2.Message} message The message to be serialized.
+ *
+ * @return {Object} The serialized form of the message.
+ */
+goog.proto2.ObjectSerializer.prototype.serialize = function(message) {
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ var objectValue = {};
+
+ // Add the defined fields, recursively.
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+
+ var key =
+ this.keyOption_ == goog.proto2.ObjectSerializer.KeyOption.NAME ?
+ field.getName() : field.getTag();
+
+
+ if (message.has(field)) {
+ if (field.isRepeated()) {
+ var array = [];
+ objectValue[key] = array;
+
+ for (var j = 0; j < message.countOf(field); j++) {
+ array.push(this.getSerializedValue(field, message.get(field, j)));
+ }
+
+ } else {
+ objectValue[key] = this.getSerializedValue(field, message.get(field));
+ }
+ }
+ }
+
+ // Add the unknown fields, if any.
+ message.forEachUnknown(function(tag, value) {
+ objectValue[tag] = value;
+ });
+
+ return objectValue;
+};
+
+
+/**
+ * Deserializes a message from an object and places the
+ * data in the message.
+ *
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {Object} data The data of the message.
+ */
+goog.proto2.ObjectSerializer.prototype.deserializeTo = function(message, data) {
+ var descriptor = message.getDescriptor();
+
+ for (var key in data) {
+ var field;
+ var value = data[key];
+
+ var isNumeric = goog.string.isNumeric(key);
+
+ if (isNumeric) {
+ field = descriptor.findFieldByTag(key);
+ } else {
+ // We must be in Key == NAME mode to lookup by name.
+ goog.proto2.Util.assert(
+ this.keyOption_ == goog.proto2.ObjectSerializer.KeyOption.NAME);
+
+ field = descriptor.findFieldByName(key);
+ }
+
+ if (field) {
+ if (field.isRepeated()) {
+ goog.proto2.Util.assert(goog.isArray(value));
+
+ for (var j = 0; j < value.length; j++) {
+ message.add(field, this.getDeserializedValue(field, value[j]));
+ }
+ } else {
+ goog.proto2.Util.assert(!goog.isArray(value));
+ message.set(field, this.getDeserializedValue(field, value));
+ }
+ } else {
+ if (isNumeric) {
+ // We have an unknown field.
+ message.setUnknown(/** @type {number} */ (key), value);
+ } else {
+ // Named fields must be present.
+ goog.proto2.Util.assert(field);
+ }
+ }
+ }
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/objectserializer_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/objectserializer_test.html
new file mode 100644
index 0000000..00ada9a
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/objectserializer_test.html
@@ -0,0 +1,423 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - objectserializer.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.ObjectSerializer');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testSerialization() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Serialize to a simplified object.
+ var simplified = new goog.proto2.ObjectSerializer().serialize(message);
+
+ // Assert that everything serialized properly.
+ assertEquals(101, simplified[1]);
+ assertEquals('102', simplified[2]);
+ assertEquals(103, simplified[3]);
+ assertEquals('104', simplified[4]);
+ assertEquals(105, simplified[5]);
+ assertEquals('106', simplified[6]);
+ assertEquals(107, simplified[7]);
+ assertEquals('108', simplified[8]);
+ assertEquals(109, simplified[9]);
+ assertEquals('110', simplified[10]);
+ assertEquals(111.5, simplified[11]);
+ assertEquals(112.5, simplified[12]);
+ assertEquals(true, simplified[13]);
+ assertEquals('test', simplified[14]);
+ assertEquals('abcd', simplified[15]);
+
+ assertEquals(111, simplified[16][17]);
+ assertEquals(112, simplified[18][1]);
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO, simplified[21]);
+
+ assertEquals(201, simplified[31][0]);
+ assertEquals(202, simplified[31][1]);
+
+ // Serialize to a simplified object (with key as name).
+ simplified = new goog.proto2.ObjectSerializer(
+ goog.proto2.ObjectSerializer.KeyOption.NAME).serialize(message);
+
+ // Assert that everything serialized properly.
+ assertEquals(101, simplified['optional_int32']);
+ assertEquals('102', simplified['optional_int64']);
+ assertEquals(103, simplified['optional_uint32']);
+ assertEquals('104', simplified['optional_uint64']);
+ assertEquals(105, simplified['optional_sint32']);
+ assertEquals('106', simplified['optional_sint64']);
+ assertEquals(107, simplified['optional_fixed32']);
+ assertEquals('108', simplified['optional_fixed64']);
+ assertEquals(109, simplified['optional_sfixed32']);
+ assertEquals('110', simplified['optional_sfixed64']);
+ assertEquals(111.5, simplified['optional_float']);
+ assertEquals(112.5, simplified['optional_double']);
+ assertEquals(true, simplified['optional_bool']);
+ assertEquals('test', simplified['optional_string']);
+ assertEquals('abcd', simplified['optional_bytes']);
+
+ assertEquals(111, simplified['optionalgroup']['a']);
+ assertEquals(112, simplified['optional_nested_message']['b']);
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ simplified['optional_nested_enum']);
+
+ assertEquals(201, simplified['repeated_int32'][0]);
+ assertEquals(202, simplified['repeated_int32'][1]);
+}
+
+
+function testSerializationOfUnknown() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Known.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Unknown.
+ message.setUnknown(1000, 301);
+ message.setUnknown(1001, 302);
+
+ // Serialize.
+ var simplified = new goog.proto2.ObjectSerializer().serialize(message);
+
+ assertEquals(101, simplified['1']);
+ assertEquals('102', simplified['2']);
+
+ assertEquals(201, simplified['31'][0]);
+ assertEquals(202, simplified['31'][1]);
+
+ assertEquals(301, simplified['1000']);
+ assertEquals(302, simplified['1001']);
+}
+
+function testDeserializationOfUnknown() {
+ var simplified = {
+ 1: 101,
+ 2: '102',
+ 1000: 103,
+ 1001: 104
+ };
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplified);
+
+ assertNotNull(message);
+ assertTrue(message.hasOptionalInt32());
+ assertTrue(message.hasOptionalInt64());
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals('102', message.getOptionalInt64());
+
+ var count = 0;
+
+ message.forEachUnknown(function(tag, value) {
+ if (tag == 1000) {
+ assertEquals(103, value);
+ }
+
+ if (tag == 1001) {
+ assertEquals(104, value);
+ }
+
+ ++count;
+ });
+
+ assertEquals(2, count);
+};
+
+function testDeserializationRepeated() {
+ var simplified = {
+ 31: [101, 102],
+ 41: [201.5, 202.5, 203.5],
+ 42: [],
+ 43: [ true, false ],
+ 44: [ 'he', 'llo' ],
+ 46: [ { 47: [101] } , { 47: [102] } ],
+ 48: [ { 1: 201 }, { 1: 202 } ]
+ }
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplified);
+
+ assertNotNull(message);
+
+ // Ensure the fields are set as expected.
+ assertTrue(message.hasRepeatedInt32());
+ assertTrue(message.hasRepeatedFloat());
+
+ assertFalse(message.hasRepeatedDouble());
+
+ assertTrue(message.hasRepeatedBool());
+ assertTrue(message.hasRepeatedgroup());
+ assertTrue(message.hasRepeatedNestedMessage());
+
+ // Ensure the counts match.
+ assertEquals(2, message.repeatedInt32Count());
+ assertEquals(3, message.repeatedFloatCount());
+
+ assertEquals(0, message.repeatedDoubleCount());
+
+ assertEquals(2, message.repeatedBoolCount());
+ assertEquals(2, message.repeatedStringCount());
+ assertEquals(2, message.repeatedgroupCount());
+ assertEquals(2, message.repeatedNestedMessageCount());
+
+ // Ensure the values match.
+ assertEquals(101, message.getRepeatedInt32(0));
+ assertEquals(102, message.getRepeatedInt32(1));
+
+ assertEquals(201.5, message.getRepeatedFloat(0));
+ assertEquals(202.5, message.getRepeatedFloat(1));
+ assertEquals(203.5, message.getRepeatedFloat(2));
+
+ assertEquals(true, message.getRepeatedBool(0));
+ assertEquals(false, message.getRepeatedBool(1));
+
+ assertEquals('he', message.getRepeatedString(0));
+ assertEquals('llo', message.getRepeatedString(1));
+
+ assertEquals(101, message.getRepeatedgroup(0).getA(0));
+ assertEquals(102, message.getRepeatedgroup(1).getA(0));
+
+ assertEquals(201, message.getRepeatedNestedMessage(0).getB());
+ assertEquals(202, message.getRepeatedNestedMessage(1).getB());
+}
+
+function testDeserialization() {
+ var simplified = {
+ 1: 101,
+ 2: '102',
+ 3: 103,
+ 4: '104',
+ 5: 105,
+ 6: '106',
+ 7: 107,
+ 8: '108',
+ 9: 109,
+ 10: '110',
+ 11: 111.5,
+ 12: 112.5,
+ 13: true,
+ 14: 'test',
+ 15: 'abcd',
+ 16: { 17 : 113 },
+ 18: { 1 : 114 },
+ 21: proto2.TestAllTypes.NestedEnum.FOO
+ };
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplified);
+
+ assertNotNull(message);
+
+ assertTrue(message.hasOptionalInt32());
+ assertTrue(message.hasOptionalInt64());
+ assertTrue(message.hasOptionalUint32());
+ assertTrue(message.hasOptionalUint64());
+ assertTrue(message.hasOptionalSint32());
+ assertTrue(message.hasOptionalSint64());
+ assertTrue(message.hasOptionalFixed32());
+ assertTrue(message.hasOptionalFixed64());
+ assertTrue(message.hasOptionalSfixed32());
+ assertTrue(message.hasOptionalSfixed64());
+ assertTrue(message.hasOptionalFloat());
+ assertTrue(message.hasOptionalDouble());
+ assertTrue(message.hasOptionalBool());
+ assertTrue(message.hasOptionalString());
+ assertTrue(message.hasOptionalBytes());
+ assertTrue(message.hasOptionalgroup());
+ assertTrue(message.hasOptionalNestedMessage());
+ assertTrue(message.hasOptionalNestedEnum());
+
+ assertEquals(1, message.optionalInt32Count());
+ assertEquals(1, message.optionalInt64Count());
+ assertEquals(1, message.optionalUint32Count());
+ assertEquals(1, message.optionalUint64Count());
+ assertEquals(1, message.optionalSint32Count());
+ assertEquals(1, message.optionalSint64Count());
+ assertEquals(1, message.optionalFixed32Count());
+ assertEquals(1, message.optionalFixed64Count());
+ assertEquals(1, message.optionalSfixed32Count());
+ assertEquals(1, message.optionalSfixed64Count());
+ assertEquals(1, message.optionalFloatCount());
+ assertEquals(1, message.optionalDoubleCount());
+ assertEquals(1, message.optionalBoolCount());
+ assertEquals(1, message.optionalStringCount());
+ assertEquals(1, message.optionalBytesCount());
+ assertEquals(1, message.optionalgroupCount());
+ assertEquals(1, message.optionalNestedMessageCount());
+ assertEquals(1, message.optionalNestedEnumCount());
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals('102', message.getOptionalInt64());
+ assertEquals(103, message.getOptionalUint32());
+ assertEquals('104', message.getOptionalUint64());
+ assertEquals(105, message.getOptionalSint32());
+ assertEquals('106', message.getOptionalSint64());
+ assertEquals(107, message.getOptionalFixed32());
+ assertEquals('108', message.getOptionalFixed64());
+ assertEquals(109, message.getOptionalSfixed32());
+ assertEquals('110', message.getOptionalSfixed64());
+ assertEquals(111.5, message.getOptionalFloat());
+ assertEquals(112.5, message.getOptionalDouble());
+ assertEquals(true, message.getOptionalBool());
+ assertEquals('test', message.getOptionalString());
+ assertEquals('abcd', message.getOptionalBytes());
+ assertEquals(113, message.getOptionalgroup().getA());
+ assertEquals(114, message.getOptionalNestedMessage().getB());
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ message.getOptionalNestedEnum());
+}
+
+function testDeserializationNumbersOrStrings() {
+ // 64-bit types may have been serialized as numbers or strings.
+ // Deserialization should be able to handle either.
+
+ var simplifiedWithNumbers = {
+ 50: 5000,
+ 51: 5100,
+ 52: [ 5200, 5201 ],
+ 53: [ 5300, 5301 ]
+ };
+
+ var simplifiedWithStrings = {
+ 50: '5000',
+ 51: '5100',
+ 52: [ '5200', '5201' ],
+ 53: [ '5300', '5301' ]
+ };
+
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ var message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplifiedWithNumbers);
+
+ assertNotNull(message);
+
+ assertEquals(5000, message.getOptionalInt64Number());
+ assertEquals('5100', message.getOptionalInt64String());
+ assertEquals(5200, message.getRepeatedInt64Number(0));
+ assertEquals(5201, message.getRepeatedInt64Number(1));
+ assertEquals('5300', message.getRepeatedInt64String(0));
+ assertEquals('5301', message.getRepeatedInt64String(1));
+
+ assertArrayEquals([5200, 5201], message.repeatedInt64NumberArray());
+ assertArrayEquals(['5300', '5301'], message.repeatedInt64StringArray());
+
+ message = serializer.deserialize(
+ proto2.TestAllTypes.getDescriptor(), simplifiedWithStrings);
+
+ assertNotNull(message);
+
+ assertEquals(5000, message.getOptionalInt64Number());
+ assertEquals('5100', message.getOptionalInt64String());
+ assertEquals(5200, message.getRepeatedInt64Number(0));
+ assertEquals(5201, message.getRepeatedInt64Number(1));
+ assertEquals('5300', message.getRepeatedInt64String(0));
+ assertEquals('5301', message.getRepeatedInt64String(1));
+
+ assertArrayEquals([5200, 5201], message.repeatedInt64NumberArray());
+ assertArrayEquals(['5300', '5301'], message.repeatedInt64StringArray());
+}
+
+function testDeserializationConversionProhibited() {
+ // 64-bit types may have been serialized as numbers or strings.
+ // But 32-bit types must be serialized as numbers.
+ // Test deserialization fails on 32-bit numbers as strings.
+
+ var simplified = {
+ 1: '1000' // optionalInt32
+ };
+ var serializer = new goog.proto2.ObjectSerializer();
+
+ assertThrows('Should have an assertion failure in deserialization',
+ function() {
+ serializer.deserialize(proto2.TestAllTypes.getDescriptor(), simplified);
+ });
+}
+
+function testDefaultValueNumbersOrStrings() {
+ // 64-bit types may have been serialized as numbers or strings.
+ // The default values should have the correct type.
+
+ var serializer = new goog.proto2.ObjectSerializer();
+ var message = serializer.deserialize(proto2.TestAllTypes.getDescriptor(), {});
+
+ assertNotNull(message);
+
+ // Default when using Number is a number, and precision is lost.
+ var value = message.getOptionalInt64NumberOrDefault();
+ assertTrue('Expecting a number', typeof value === 'number');
+ assertEquals(1000000000000000000, value);
+ assertEquals(1000000000000000001, value);
+ assertEquals(1000000000000000002, value);
+ assertEquals('1000000000000000000', String(value)); // Value is rounded!
+
+ // When using a String, the value is preserved.
+ assertEquals('1000000000000000001',
+ message.getOptionalInt64StringOrDefault());
+}
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/package_test.pb.js b/contexts/data/lib/closure-library/closure/goog/proto2/package_test.pb.js
new file mode 100644
index 0000000..fab330e
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/package_test.pb.js
@@ -0,0 +1,165 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// All other code copyright its respective owners(s).
+
+/**
+ * @fileoverview Generated Protocol Buffer code for file
+ * closure/goog/proto2/package_test.proto.
+ */
+
+goog.provide('someprotopackage.TestPackageTypes');
+
+goog.require('goog.proto2.Message');
+goog.require('proto2.TestAllTypes');
+
+goog.setTestOnly('package_test.pb');
+
+
+/**
+ * Message TestPackageTypes.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+someprotopackage.TestPackageTypes = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(someprotopackage.TestPackageTypes, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!someprotopackage.TestPackageTypes} The cloned message.
+ * @override
+ */
+someprotopackage.TestPackageTypes.prototype.clone;
+
+
+/**
+ * Gets the value of the optional_int32 field.
+ * @return {?number} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOptionalInt32 = function() {
+ return /** @type {?number} */ (this.get$Value(1));
+};
+
+
+/**
+ * Gets the value of the optional_int32 field or the default value if not set.
+ * @return {number} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOptionalInt32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(1));
+};
+
+
+/**
+ * Sets the value of the optional_int32 field.
+ * @param {number} value The value.
+ */
+someprotopackage.TestPackageTypes.prototype.setOptionalInt32 = function(value) {
+ this.set$Value(1, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int32 field has a value.
+ */
+someprotopackage.TestPackageTypes.prototype.hasOptionalInt32 = function() {
+ return this.has$Value(1);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int32 field.
+ */
+someprotopackage.TestPackageTypes.prototype.optionalInt32Count = function() {
+ return this.count$Values(1);
+};
+
+
+/**
+ * Clears the values in the optional_int32 field.
+ */
+someprotopackage.TestPackageTypes.prototype.clearOptionalInt32 = function() {
+ this.clear$Field(1);
+};
+
+
+/**
+ * Gets the value of the other_all field.
+ * @return {proto2.TestAllTypes} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOtherAll = function() {
+ return /** @type {proto2.TestAllTypes} */ (this.get$Value(2));
+};
+
+
+/**
+ * Gets the value of the other_all field or the default value if not set.
+ * @return {!proto2.TestAllTypes} The value.
+ */
+someprotopackage.TestPackageTypes.prototype.getOtherAllOrDefault = function() {
+ return /** @type {!proto2.TestAllTypes} */ (this.get$ValueOrDefault(2));
+};
+
+
+/**
+ * Sets the value of the other_all field.
+ * @param {!proto2.TestAllTypes} value The value.
+ */
+someprotopackage.TestPackageTypes.prototype.setOtherAll = function(value) {
+ this.set$Value(2, value);
+};
+
+
+/**
+ * @return {boolean} Whether the other_all field has a value.
+ */
+someprotopackage.TestPackageTypes.prototype.hasOtherAll = function() {
+ return this.has$Value(2);
+};
+
+
+/**
+ * @return {number} The number of values in the other_all field.
+ */
+someprotopackage.TestPackageTypes.prototype.otherAllCount = function() {
+ return this.count$Values(2);
+};
+
+
+/**
+ * Clears the values in the other_all field.
+ */
+someprotopackage.TestPackageTypes.prototype.clearOtherAll = function() {
+ this.clear$Field(2);
+};
+
+
+goog.proto2.Message.set$Metadata(someprotopackage.TestPackageTypes, {
+ 0: {
+ name: 'TestPackageTypes',
+ fullName: 'someprotopackage.TestPackageTypes'
+ },
+ 1: {
+ name: 'optional_int32',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ },
+ 2: {
+ name: 'other_all',
+ fieldType: goog.proto2.Message.FieldType.MESSAGE,
+ type: proto2.TestAllTypes
+ }
+});
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer.js b/contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer.js
new file mode 100644
index 0000000..fe179a2
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer.js
@@ -0,0 +1,150 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer 2 Serializer which serializes messages
+ * into PB-Lite ("JsPbLite") format.
+ *
+ * PB-Lite format is an array where each index corresponds to the associated tag
+ * number. For example, a message like so:
+ *
+ * message Foo {
+ * optional int bar = 1;
+ * optional int baz = 2;
+ * optional int bop = 4;
+ * }
+ *
+ * would be represented as such:
+ *
+ * [, (bar data), (baz data), (nothing), (bop data)]
+ *
+ * Note that since the array index is used to represent the tag number, sparsely
+ * populated messages with tag numbers that are not continuous (and/or are very
+ * large) will have many (empty) spots and thus, are inefficient.
+ *
+ *
+ */
+
+goog.provide('goog.proto2.PbLiteSerializer');
+
+goog.require('goog.proto2.LazyDeserializer');
+goog.require('goog.proto2.Util');
+
+
+
+/**
+ * PB-Lite serializer.
+ *
+ * @constructor
+ * @extends {goog.proto2.LazyDeserializer}
+ */
+goog.proto2.PbLiteSerializer = function() {};
+goog.inherits(goog.proto2.PbLiteSerializer, goog.proto2.LazyDeserializer);
+
+
+/**
+ * Serializes a message to a PB-Lite object.
+ *
+ * @param {goog.proto2.Message} message The message to be serialized.
+ *
+ * @return {!Array} The serialized form of the message.
+ */
+goog.proto2.PbLiteSerializer.prototype.serialize = function(message) {
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ var serialized = [];
+
+ // Add the known fields.
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+
+ if (!message.has(field)) {
+ continue;
+ }
+
+ var tag = field.getTag();
+
+ if (field.isRepeated()) {
+ serialized[tag] = [];
+
+ for (var j = 0; j < message.countOf(field); j++) {
+ serialized[tag][j] =
+ this.getSerializedValue(field, message.get(field, j));
+ }
+ } else {
+ serialized[tag] = this.getSerializedValue(field, message.get(field));
+ }
+ }
+
+ // Add any unknown fields.
+ message.forEachUnknown(function(tag, value) {
+ serialized[tag] = value;
+ });
+
+ return serialized;
+};
+
+
+/** @override */
+goog.proto2.PbLiteSerializer.prototype.deserializeField =
+ function(message, field, value) {
+
+ if (value == null) {
+ // Since value double-equals null, it may be either null or undefined.
+ // Ensure we return the same one, since they have different meanings.
+ return value;
+ }
+
+ if (field.isRepeated()) {
+ var data = [];
+
+ goog.proto2.Util.assert(goog.isArray(value));
+
+ for (var i = 0; i < value.length; i++) {
+ data[i] = this.getDeserializedValue(field, value[i]);
+ }
+
+ return data;
+ } else {
+ return this.getDeserializedValue(field, value);
+ }
+};
+
+
+/** @override */
+goog.proto2.PbLiteSerializer.prototype.getSerializedValue =
+ function(field, value) {
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.BOOL) {
+ // Booleans are serialized in numeric form.
+ return value ? 1 : 0;
+ }
+
+ return goog.proto2.Serializer.prototype.getSerializedValue.apply(this,
+ arguments);
+};
+
+
+/** @override */
+goog.proto2.PbLiteSerializer.prototype.getDeserializedValue =
+ function(field, value) {
+
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.BOOL) {
+ // Booleans are serialized in numeric form.
+ return value === 1;
+ }
+
+ return goog.proto2.Serializer.prototype.getDeserializedValue.apply(this,
+ arguments);
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer_test.html
new file mode 100644
index 0000000..a9b2a31
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/pbliteserializer_test.html
@@ -0,0 +1,267 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - pbliteserializer.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.PbLiteSerializer');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testSerializationAndDeserialization() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Skip a few repeated fields so we can test how null array values are
+ // handled.
+ message.addRepeatedString('foo');
+ message.addRepeatedString('bar');
+
+ // Serialize.
+ var serializer = new goog.proto2.PbLiteSerializer();
+ var pblite = serializer.serialize(message);
+
+ assertTrue(goog.isArray(pblite));
+
+ // Assert that everything serialized properly.
+ assertEquals(101, pblite[1]);
+ assertEquals('102', pblite[2]);
+ assertEquals(103, pblite[3]);
+ assertEquals('104', pblite[4]);
+ assertEquals(105, pblite[5]);
+ assertEquals('106', pblite[6]);
+ assertEquals(107, pblite[7]);
+ assertEquals('108', pblite[8]);
+ assertEquals(109, pblite[9]);
+ assertEquals('110', pblite[10]);
+ assertEquals(111.5, pblite[11]);
+ assertEquals(112.5, pblite[12]);
+ assertEquals(1, pblite[13]); // true is serialized as 1
+ assertEquals('test', pblite[14]);
+ assertEquals('abcd', pblite[15]);
+
+ assertEquals(111, pblite[16][17]);
+ assertEquals(112, pblite[18][1]);
+
+ assertTrue(pblite[19] === undefined);
+ assertTrue(pblite[20] === undefined);
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO, pblite[21]);
+
+ assertEquals(201, pblite[31][0]);
+ assertEquals(202, pblite[31][1]);
+ assertEquals('foo', pblite[44][0]);
+ assertEquals('bar', pblite[44][1]);
+
+ var serializer = new goog.proto2.PbLiteSerializer();
+ // Deserialize.
+ var messageCopy =
+ serializer.deserialize(proto2.TestAllTypes.getDescriptor(), pblite);
+
+ assertNotEquals(messageCopy, message);
+
+ assertDeserializationMatches(messageCopy);
+}
+
+function testDeserializationFromExternalSource() {
+ // Test deserialization where the JSON array is initialized from something
+ // outside the Closure proto2 library, such as the JsPbLite library, or
+ // manually as in this test.
+ var pblite = [
+ , // 0
+ 101, // 1
+ '102', // 2
+ 103, // 3
+ '104', // 4
+ 105, // 5
+ '106', // 6
+ 107, // 7
+ '108', // 8
+ 109, // 9
+ '110', // 10
+ 111.5, // 11
+ 112.5, // 12
+ 1, // 13
+ 'test', // 14
+ 'abcd', // 15
+ [,,,,,,,,,,,,,,,,,111], // 16, note the 17 commas so value is index 17
+ , // 17
+ [,112], // 18
+ ,, // 19-20
+ proto2.TestAllTypes.NestedEnum.FOO, // 21
+ ,,,,,,,,, // 22-30
+ [201, 202], // 31
+ ,,,,,,,,,,,, // 32-43
+ ['foo', 'bar'], // 44
+ ,,,, // 45-49
+ ];
+
+ var serializer = new goog.proto2.PbLiteSerializer();
+ // Deserialize.
+ var messageCopy =
+ serializer.deserialize(proto2.TestAllTypes.getDescriptor(), pblite);
+
+ assertDeserializationMatches(messageCopy);
+
+ // http://b/issue?id=2928075
+ assertFalse(messageCopy.hasRepeatedInt64());
+ assertEquals(0, messageCopy.repeatedInt64Count());
+ messageCopy.repeatedInt64Array();
+ assertFalse(messageCopy.hasRepeatedInt64());
+ assertEquals(0, messageCopy.repeatedInt64Count());
+}
+
+function assertDeserializationMatches(messageCopy) {
+ assertNotNull(messageCopy);
+
+ assertTrue(messageCopy.hasOptionalInt32());
+ assertTrue(messageCopy.hasOptionalInt64());
+ assertTrue(messageCopy.hasOptionalUint32());
+ assertTrue(messageCopy.hasOptionalUint64());
+ assertTrue(messageCopy.hasOptionalSint32());
+ assertTrue(messageCopy.hasOptionalSint64());
+ assertTrue(messageCopy.hasOptionalFixed32());
+ assertTrue(messageCopy.hasOptionalFixed64());
+ assertTrue(messageCopy.hasOptionalSfixed32());
+ assertTrue(messageCopy.hasOptionalSfixed64());
+ assertTrue(messageCopy.hasOptionalFloat());
+ assertTrue(messageCopy.hasOptionalDouble());
+ assertTrue(messageCopy.hasOptionalBool());
+ assertTrue(messageCopy.hasOptionalString());
+ assertTrue(messageCopy.hasOptionalBytes());
+ assertTrue(messageCopy.hasOptionalgroup());
+ assertTrue(messageCopy.hasOptionalNestedMessage());
+ assertTrue(messageCopy.hasOptionalNestedEnum());
+
+ assertTrue(messageCopy.hasRepeatedInt32());
+ assertFalse(messageCopy.hasRepeatedInt64());
+ assertFalse(messageCopy.hasRepeatedUint32());
+ assertFalse(messageCopy.hasRepeatedUint64());
+ assertFalse(messageCopy.hasRepeatedSint32());
+ assertFalse(messageCopy.hasRepeatedSint64());
+ assertFalse(messageCopy.hasRepeatedFixed32());
+ assertFalse(messageCopy.hasRepeatedFixed64());
+ assertFalse(messageCopy.hasRepeatedSfixed32());
+ assertFalse(messageCopy.hasRepeatedSfixed64());
+ assertFalse(messageCopy.hasRepeatedFloat());
+ assertFalse(messageCopy.hasRepeatedDouble());
+ assertFalse(messageCopy.hasRepeatedBool());
+ assertTrue(messageCopy.hasRepeatedString());
+ assertFalse(messageCopy.hasRepeatedBytes());
+ assertFalse(messageCopy.hasRepeatedgroup());
+ assertFalse(messageCopy.hasRepeatedNestedMessage());
+ assertFalse(messageCopy.hasRepeatedNestedEnum());
+
+ assertEquals(1, messageCopy.optionalInt32Count());
+ assertEquals(1, messageCopy.optionalInt64Count());
+ assertEquals(1, messageCopy.optionalUint32Count());
+ assertEquals(1, messageCopy.optionalUint64Count());
+ assertEquals(1, messageCopy.optionalSint32Count());
+ assertEquals(1, messageCopy.optionalSint64Count());
+ assertEquals(1, messageCopy.optionalFixed32Count());
+ assertEquals(1, messageCopy.optionalFixed64Count());
+ assertEquals(1, messageCopy.optionalSfixed32Count());
+ assertEquals(1, messageCopy.optionalSfixed64Count());
+ assertEquals(1, messageCopy.optionalFloatCount());
+ assertEquals(1, messageCopy.optionalDoubleCount());
+ assertEquals(1, messageCopy.optionalBoolCount());
+ assertEquals(1, messageCopy.optionalStringCount());
+ assertEquals(1, messageCopy.optionalBytesCount());
+ assertEquals(1, messageCopy.optionalgroupCount());
+ assertEquals(1, messageCopy.optionalNestedMessageCount());
+ assertEquals(1, messageCopy.optionalNestedEnumCount());
+
+ assertEquals(2, messageCopy.repeatedInt32Count());
+ assertEquals(0, messageCopy.repeatedInt64Count());
+ assertEquals(0, messageCopy.repeatedUint32Count());
+ assertEquals(0, messageCopy.repeatedUint64Count());
+ assertEquals(0, messageCopy.repeatedSint32Count());
+ assertEquals(0, messageCopy.repeatedSint64Count());
+ assertEquals(0, messageCopy.repeatedFixed32Count());
+ assertEquals(0, messageCopy.repeatedFixed64Count());
+ assertEquals(0, messageCopy.repeatedSfixed32Count());
+ assertEquals(0, messageCopy.repeatedSfixed64Count());
+ assertEquals(0, messageCopy.repeatedFloatCount());
+ assertEquals(0, messageCopy.repeatedDoubleCount());
+ assertEquals(0, messageCopy.repeatedBoolCount());
+ assertEquals(2, messageCopy.repeatedStringCount());
+ assertEquals(0, messageCopy.repeatedBytesCount());
+ assertEquals(0, messageCopy.repeatedgroupCount());
+ assertEquals(0, messageCopy.repeatedNestedMessageCount());
+ assertEquals(0, messageCopy.repeatedNestedEnumCount());
+
+ assertEquals(101, messageCopy.getOptionalInt32());
+ assertEquals('102', messageCopy.getOptionalInt64());
+ assertEquals(103, messageCopy.getOptionalUint32());
+ assertEquals('104', messageCopy.getOptionalUint64());
+ assertEquals(105, messageCopy.getOptionalSint32());
+ assertEquals('106', messageCopy.getOptionalSint64());
+ assertEquals(107, messageCopy.getOptionalFixed32());
+ assertEquals('108', messageCopy.getOptionalFixed64());
+ assertEquals(109, messageCopy.getOptionalSfixed32());
+ assertEquals('110', messageCopy.getOptionalSfixed64());
+ assertEquals(111.5, messageCopy.getOptionalFloat());
+ assertEquals(112.5, messageCopy.getOptionalDouble());
+ assertEquals(true, messageCopy.getOptionalBool());
+ assertEquals('test', messageCopy.getOptionalString());
+ assertEquals('abcd', messageCopy.getOptionalBytes());
+ assertEquals(111, messageCopy.getOptionalgroup().getA());
+
+ assertEquals(112, messageCopy.getOptionalNestedMessage().getB());
+
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ messageCopy.getOptionalNestedEnum());
+
+ assertEquals(201, messageCopy.getRepeatedInt32(0));
+ assertEquals(202, messageCopy.getRepeatedInt32(1));
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/proto_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/proto_test.html
new file mode 100644
index 0000000..26dc097
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/proto_test.html
@@ -0,0 +1,693 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2008 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - Message Tests</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('someprotopackage.TestPackageTypes');
+ goog.require('proto2.TestAllTypes');
+ goog.require('goog.testing.jsunit');
+</script>
+</head>
+<body>
+<script>
+
+function testPackage() {
+ var message = new someprotopackage.TestPackageTypes();
+ message.setOptionalInt32(45);
+ message.setOtherAll(new proto2.TestAllTypes());
+}
+
+function testFields() {
+ var message = new proto2.TestAllTypes();
+
+ // Ensure that the fields are not set.
+ assertFalse(message.hasOptionalInt32());
+ assertFalse(message.hasOptionalInt64());
+ assertFalse(message.hasOptionalUint32());
+ assertFalse(message.hasOptionalUint64());
+ assertFalse(message.hasOptionalSint32());
+ assertFalse(message.hasOptionalSint64());
+ assertFalse(message.hasOptionalFixed32());
+ assertFalse(message.hasOptionalFixed64());
+ assertFalse(message.hasOptionalSfixed32());
+ assertFalse(message.hasOptionalSfixed64());
+ assertFalse(message.hasOptionalFloat());
+ assertFalse(message.hasOptionalDouble());
+ assertFalse(message.hasOptionalBool());
+ assertFalse(message.hasOptionalString());
+ assertFalse(message.hasOptionalBytes());
+ assertFalse(message.hasOptionalgroup());
+ assertFalse(message.hasOptionalNestedMessage());
+ assertFalse(message.hasOptionalNestedEnum());
+
+ // Check non-set values.
+ assertNull(message.getOptionalInt32());
+ assertNull(message.getOptionalInt64());
+ assertNull(message.getOptionalFloat());
+ assertNull(message.getOptionalString());
+ assertNull(message.getOptionalBytes());
+ assertNull(message.getOptionalNestedMessage());
+ assertNull(message.getOptionalNestedEnum());
+
+ // Check default values.
+ assertEquals(0, message.getOptionalInt32OrDefault());
+ assertEquals('1', message.getOptionalInt64OrDefault());
+ assertEquals(1.5, message.getOptionalFloatOrDefault());
+ assertEquals('', message.getOptionalStringOrDefault());
+ assertEquals('moo', message.getOptionalBytesOrDefault());
+
+ // Set the fields.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Ensure that the fields are set.
+ assertTrue(message.hasOptionalInt32());
+ assertTrue(message.hasOptionalInt64());
+ assertTrue(message.hasOptionalUint32());
+ assertTrue(message.hasOptionalUint64());
+ assertTrue(message.hasOptionalSint32());
+ assertTrue(message.hasOptionalSint64());
+ assertTrue(message.hasOptionalFixed32());
+ assertTrue(message.hasOptionalFixed64());
+ assertTrue(message.hasOptionalSfixed32());
+ assertTrue(message.hasOptionalSfixed64());
+ assertTrue(message.hasOptionalFloat());
+ assertTrue(message.hasOptionalDouble());
+ assertTrue(message.hasOptionalBool());
+ assertTrue(message.hasOptionalString());
+ assertTrue(message.hasOptionalBytes());
+ assertTrue(message.hasOptionalgroup());
+ assertTrue(message.hasOptionalNestedMessage());
+ assertTrue(message.hasOptionalNestedEnum());
+
+ // Ensure that there is a count of 1 for each of the fields.
+ assertEquals(1, message.optionalInt32Count());
+ assertEquals(1, message.optionalInt64Count());
+ assertEquals(1, message.optionalUint32Count());
+ assertEquals(1, message.optionalUint64Count());
+ assertEquals(1, message.optionalSint32Count());
+ assertEquals(1, message.optionalSint64Count());
+ assertEquals(1, message.optionalFixed32Count());
+ assertEquals(1, message.optionalFixed64Count());
+ assertEquals(1, message.optionalSfixed32Count());
+ assertEquals(1, message.optionalSfixed64Count());
+ assertEquals(1, message.optionalFloatCount());
+ assertEquals(1, message.optionalDoubleCount());
+ assertEquals(1, message.optionalBoolCount());
+ assertEquals(1, message.optionalStringCount());
+ assertEquals(1, message.optionalBytesCount());
+ assertEquals(1, message.optionalgroupCount());
+ assertEquals(1, message.optionalNestedMessageCount());
+ assertEquals(1, message.optionalNestedEnumCount());
+
+ // Ensure that the fields have the values expected.
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals('102', message.getOptionalInt64());
+ assertEquals(103, message.getOptionalUint32());
+ assertEquals('104', message.getOptionalUint64());
+ assertEquals(105, message.getOptionalSint32());
+ assertEquals('106', message.getOptionalSint64());
+ assertEquals(107, message.getOptionalFixed32());
+ assertEquals('108', message.getOptionalFixed64());
+ assertEquals(109, message.getOptionalSfixed32());
+ assertEquals('110', message.getOptionalSfixed64());
+ assertEquals(111.5, message.getOptionalFloat());
+ assertEquals(112.5, message.getOptionalDouble());
+ assertEquals(true, message.getOptionalBool());
+ assertEquals('test', message.getOptionalString());
+ assertEquals('abcd', message.getOptionalBytes());
+ assertEquals(group, message.getOptionalgroup());
+ assertEquals(nestedMessage, message.getOptionalNestedMessage());
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ message.getOptionalNestedEnum());
+}
+
+function testRepeated() {
+ var message = new proto2.TestAllTypes();
+
+ // Ensure that the fields are not set.
+ assertFalse(message.hasRepeatedInt32());
+ assertFalse(message.hasRepeatedInt64());
+ assertFalse(message.hasRepeatedUint32());
+ assertFalse(message.hasRepeatedUint64());
+ assertFalse(message.hasRepeatedSint32());
+ assertFalse(message.hasRepeatedSint64());
+ assertFalse(message.hasRepeatedFixed32());
+ assertFalse(message.hasRepeatedFixed64());
+ assertFalse(message.hasRepeatedSfixed32());
+ assertFalse(message.hasRepeatedSfixed64());
+ assertFalse(message.hasRepeatedFloat());
+ assertFalse(message.hasRepeatedDouble());
+ assertFalse(message.hasRepeatedBool());
+ assertFalse(message.hasRepeatedString());
+ assertFalse(message.hasRepeatedBytes());
+ assertFalse(message.hasRepeatedgroup());
+ assertFalse(message.hasRepeatedNestedMessage());
+ assertFalse(message.hasRepeatedNestedEnum());
+
+ // Expect the arrays to be empty.
+ assertEquals(0, message.repeatedInt32Array().length);
+ assertEquals(0, message.repeatedInt64Array().length);
+ assertEquals(0, message.repeatedUint32Array().length);
+ assertEquals(0, message.repeatedUint64Array().length);
+ assertEquals(0, message.repeatedSint32Array().length);
+ assertEquals(0, message.repeatedSint64Array().length);
+ assertEquals(0, message.repeatedFixed32Array().length);
+ assertEquals(0, message.repeatedFixed64Array().length);
+ assertEquals(0, message.repeatedSfixed32Array().length);
+ assertEquals(0, message.repeatedSfixed64Array().length);
+ assertEquals(0, message.repeatedFloatArray().length);
+ assertEquals(0, message.repeatedDoubleArray().length);
+ assertEquals(0, message.repeatedBoolArray().length);
+ assertEquals(0, message.repeatedStringArray().length);
+ assertEquals(0, message.repeatedBytesArray().length);
+ assertEquals(0, message.repeatedgroupArray().length);
+ assertEquals(0, message.repeatedNestedMessageArray().length);
+ assertEquals(0, message.repeatedNestedEnumArray().length);
+
+ // Set the fields.
+ message.addRepeatedInt32(101);
+ message.addRepeatedInt64('102');
+ message.addRepeatedUint32(103);
+ message.addRepeatedUint64('104');
+ message.addRepeatedSint32(105);
+ message.addRepeatedSint64('106');
+ message.addRepeatedFixed32(107);
+ message.addRepeatedFixed64('108');
+ message.addRepeatedSfixed32(109);
+ message.addRepeatedSfixed64('110');
+ message.addRepeatedFloat(111.5);
+ message.addRepeatedDouble(112.5);
+ message.addRepeatedBool(true);
+ message.addRepeatedString('test');
+ message.addRepeatedBytes('abcd');
+
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt64('202');
+ message.addRepeatedUint32(203);
+ message.addRepeatedUint64('204');
+ message.addRepeatedSint32(205);
+ message.addRepeatedSint64('206');
+ message.addRepeatedFixed32(207);
+ message.addRepeatedFixed64('208');
+ message.addRepeatedSfixed32(209);
+ message.addRepeatedSfixed64('210');
+ message.addRepeatedFloat(211.5);
+ message.addRepeatedDouble(212.5);
+ message.addRepeatedBool(true);
+ message.addRepeatedString('test#2');
+ message.addRepeatedBytes('efgh');
+
+
+ var group1 = new proto2.TestAllTypes.RepeatedGroup();
+ group1.addA(111);
+
+ message.addRepeatedgroup(group1);
+
+ var group2 = new proto2.TestAllTypes.RepeatedGroup();
+ group2.addA(211);
+
+ message.addRepeatedgroup(group2);
+
+ var nestedMessage1 = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage1.setB(112);
+ message.addRepeatedNestedMessage(nestedMessage1);
+
+ var nestedMessage2 = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage2.setB(212);
+ message.addRepeatedNestedMessage(nestedMessage2);
+
+ message.addRepeatedNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+ message.addRepeatedNestedEnum(proto2.TestAllTypes.NestedEnum.BAR);
+
+ // Ensure that the fields are set.
+ assertTrue(message.hasRepeatedInt32());
+ assertTrue(message.hasRepeatedInt64());
+ assertTrue(message.hasRepeatedUint32());
+ assertTrue(message.hasRepeatedUint64());
+ assertTrue(message.hasRepeatedSint32());
+ assertTrue(message.hasRepeatedSint64());
+ assertTrue(message.hasRepeatedFixed32());
+ assertTrue(message.hasRepeatedFixed64());
+ assertTrue(message.hasRepeatedSfixed32());
+ assertTrue(message.hasRepeatedSfixed64());
+ assertTrue(message.hasRepeatedFloat());
+ assertTrue(message.hasRepeatedDouble());
+ assertTrue(message.hasRepeatedBool());
+ assertTrue(message.hasRepeatedString());
+ assertTrue(message.hasRepeatedBytes());
+ assertTrue(message.hasRepeatedgroup());
+ assertTrue(message.hasRepeatedNestedMessage());
+ assertTrue(message.hasRepeatedNestedEnum());
+
+ // Ensure that there is a count of 2 for each of the fields.
+ assertEquals(2, message.repeatedInt32Count());
+ assertEquals(2, message.repeatedInt64Count());
+ assertEquals(2, message.repeatedUint32Count());
+ assertEquals(2, message.repeatedUint64Count());
+ assertEquals(2, message.repeatedSint32Count());
+ assertEquals(2, message.repeatedSint64Count());
+ assertEquals(2, message.repeatedFixed32Count());
+ assertEquals(2, message.repeatedFixed64Count());
+ assertEquals(2, message.repeatedSfixed32Count());
+ assertEquals(2, message.repeatedSfixed64Count());
+ assertEquals(2, message.repeatedFloatCount());
+ assertEquals(2, message.repeatedDoubleCount());
+ assertEquals(2, message.repeatedBoolCount());
+ assertEquals(2, message.repeatedStringCount());
+ assertEquals(2, message.repeatedBytesCount());
+ assertEquals(2, message.repeatedgroupCount());
+ assertEquals(2, message.repeatedNestedMessageCount());
+ assertEquals(2, message.repeatedNestedEnumCount());
+
+ // Ensure that the fields have the values expected.
+ assertEquals(101, message.getRepeatedInt32(0));
+ assertEquals('102', message.getRepeatedInt64(0));
+ assertEquals(103, message.getRepeatedUint32(0));
+ assertEquals('104', message.getRepeatedUint64(0));
+ assertEquals(105, message.getRepeatedSint32(0));
+ assertEquals('106', message.getRepeatedSint64(0));
+ assertEquals(107, message.getRepeatedFixed32(0));
+ assertEquals('108', message.getRepeatedFixed64(0));
+ assertEquals(109, message.getRepeatedSfixed32(0));
+ assertEquals('110', message.getRepeatedSfixed64(0));
+ assertEquals(111.5, message.getRepeatedFloat(0));
+ assertEquals(112.5, message.getRepeatedDouble(0));
+ assertEquals(true, message.getRepeatedBool(0));
+ assertEquals('test', message.getRepeatedString(0));
+ assertEquals('abcd', message.getRepeatedBytes(0));
+ assertEquals(group1, message.getRepeatedgroup(0));
+ assertEquals(nestedMessage1, message.getRepeatedNestedMessage(0));
+ assertEquals(proto2.TestAllTypes.NestedEnum.FOO,
+ message.getRepeatedNestedEnum(0));
+
+ assertEquals(201, message.getRepeatedInt32(1));
+ assertEquals('202', message.getRepeatedInt64(1));
+ assertEquals(203, message.getRepeatedUint32(1));
+ assertEquals('204', message.getRepeatedUint64(1));
+ assertEquals(205, message.getRepeatedSint32(1));
+ assertEquals('206', message.getRepeatedSint64(1));
+ assertEquals(207, message.getRepeatedFixed32(1));
+ assertEquals('208', message.getRepeatedFixed64(1));
+ assertEquals(209, message.getRepeatedSfixed32(1));
+ assertEquals('210', message.getRepeatedSfixed64(1));
+ assertEquals(211.5, message.getRepeatedFloat(1));
+ assertEquals(212.5, message.getRepeatedDouble(1));
+ assertEquals(true, message.getRepeatedBool(1));
+ assertEquals('test#2', message.getRepeatedString(1));
+ assertEquals('efgh', message.getRepeatedBytes(1));
+ assertEquals(group2, message.getRepeatedgroup(1));
+ assertEquals(nestedMessage2, message.getRepeatedNestedMessage(1));
+ assertEquals(proto2.TestAllTypes.NestedEnum.BAR,
+ message.getRepeatedNestedEnum(1));
+
+ // Check the array lengths.
+ assertEquals(2, message.repeatedInt32Array().length);
+ assertEquals(2, message.repeatedInt64Array().length);
+ assertEquals(2, message.repeatedUint32Array().length);
+ assertEquals(2, message.repeatedUint64Array().length);
+ assertEquals(2, message.repeatedSint32Array().length);
+ assertEquals(2, message.repeatedSint64Array().length);
+ assertEquals(2, message.repeatedFixed32Array().length);
+ assertEquals(2, message.repeatedFixed64Array().length);
+ assertEquals(2, message.repeatedSfixed32Array().length);
+ assertEquals(2, message.repeatedSfixed64Array().length);
+ assertEquals(2, message.repeatedFloatArray().length);
+ assertEquals(2, message.repeatedDoubleArray().length);
+ assertEquals(2, message.repeatedBoolArray().length);
+ assertEquals(2, message.repeatedStringArray().length);
+ assertEquals(2, message.repeatedBytesArray().length);
+ assertEquals(2, message.repeatedgroupArray().length);
+ assertEquals(2, message.repeatedNestedMessageArray().length);
+ assertEquals(2, message.repeatedNestedEnumArray().length);
+
+ // Check the array values.
+ assertEquals(message.getRepeatedInt32(0), message.repeatedInt32Array()[0]);
+ assertEquals(message.getRepeatedInt64(0), message.repeatedInt64Array()[0]);
+ assertEquals(message.getRepeatedUint32(0), message.repeatedUint32Array()[0]);
+ assertEquals(message.getRepeatedUint64(0), message.repeatedUint64Array()[0]);
+ assertEquals(message.getRepeatedSint32(0), message.repeatedSint32Array()[0]);
+ assertEquals(message.getRepeatedSint64(0), message.repeatedSint64Array()[0]);
+ assertEquals(message.getRepeatedFixed32(0),
+ message.repeatedFixed32Array()[0]);
+ assertEquals(message.getRepeatedFixed64(0),
+ message.repeatedFixed64Array()[0]);
+ assertEquals(message.getRepeatedSfixed32(0),
+ message.repeatedSfixed32Array()[0]);
+ assertEquals(message.getRepeatedSfixed64(0),
+ message.repeatedSfixed64Array()[0]);
+ assertEquals(message.getRepeatedFloat(0), message.repeatedFloatArray()[0]);
+ assertEquals(message.getRepeatedDouble(0), message.repeatedDoubleArray()[0]);
+ assertEquals(message.getRepeatedBool(0), message.repeatedBoolArray()[0]);
+ assertEquals(message.getRepeatedString(0), message.repeatedStringArray()[0]);
+ assertEquals(message.getRepeatedBytes(0), message.repeatedBytesArray()[0]);
+ assertEquals(message.getRepeatedgroup(0), message.repeatedgroupArray()[0]);
+ assertEquals(message.getRepeatedNestedMessage(0),
+ message.repeatedNestedMessageArray()[0]);
+ assertEquals(message.getRepeatedNestedEnum(0),
+ message.repeatedNestedEnumArray()[0]);
+
+ assertEquals(message.getRepeatedInt32(1), message.repeatedInt32Array()[1]);
+ assertEquals(message.getRepeatedInt64(1), message.repeatedInt64Array()[1]);
+ assertEquals(message.getRepeatedUint32(1), message.repeatedUint32Array()[1]);
+ assertEquals(message.getRepeatedUint64(1), message.repeatedUint64Array()[1]);
+ assertEquals(message.getRepeatedSint32(1), message.repeatedSint32Array()[1]);
+ assertEquals(message.getRepeatedSint64(1), message.repeatedSint64Array()[1]);
+ assertEquals(message.getRepeatedFixed32(1),
+ message.repeatedFixed32Array()[1]);
+ assertEquals(message.getRepeatedFixed64(1),
+ message.repeatedFixed64Array()[1]);
+ assertEquals(message.getRepeatedSfixed32(1),
+ message.repeatedSfixed32Array()[1]);
+ assertEquals(message.getRepeatedSfixed64(1),
+ message.repeatedSfixed64Array()[1]);
+ assertEquals(message.getRepeatedFloat(1), message.repeatedFloatArray()[1]);
+ assertEquals(message.getRepeatedDouble(1), message.repeatedDoubleArray()[1]);
+ assertEquals(message.getRepeatedBool(1), message.repeatedBoolArray()[1]);
+ assertEquals(message.getRepeatedString(1), message.repeatedStringArray()[1]);
+ assertEquals(message.getRepeatedBytes(1), message.repeatedBytesArray()[1]);
+ assertEquals(message.getRepeatedgroup(1), message.repeatedgroupArray()[1]);
+ assertEquals(message.getRepeatedNestedMessage(1),
+ message.repeatedNestedMessageArray()[1]);
+ assertEquals(message.getRepeatedNestedEnum(1),
+ message.repeatedNestedEnumArray()[1]);
+}
+
+function testDescriptor() {
+ var message = new proto2.TestAllTypes();
+ var descriptor = message.getDescriptor();
+
+ assertEquals('TestAllTypes', descriptor.getName());
+ assertEquals('TestAllTypes', descriptor.getFullName());
+ assertEquals(null, descriptor.getContainingType());
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ var nestedDescriptor = nestedMessage.getDescriptor();
+
+ assertEquals('NestedMessage', nestedDescriptor.getName());
+ assertEquals('TestAllTypes.NestedMessage',
+ nestedDescriptor.getFullName());
+ assertEquals(descriptor, nestedDescriptor.getContainingType());
+}
+
+function testFieldDescriptor() {
+ var message = new proto2.TestAllTypes();
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ assertEquals(40, fields.length);
+
+ // Check the containing types.
+ for (var i = 0; i < fields.length; ++i) {
+ assertEquals(descriptor, fields[i].getContainingType());
+ }
+
+ // Check the field names.
+ assertEquals('optional_int32', fields[0].getName());
+ assertEquals('optional_int64', fields[1].getName());
+ assertEquals('optional_uint32', fields[2].getName());
+ assertEquals('optional_uint64', fields[3].getName());
+ assertEquals('optional_sint32', fields[4].getName());
+ assertEquals('optional_sint64', fields[5].getName());
+ assertEquals('optional_fixed32', fields[6].getName());
+ assertEquals('optional_fixed64', fields[7].getName());
+ assertEquals('optional_sfixed32', fields[8].getName());
+ assertEquals('optional_sfixed64', fields[9].getName());
+ assertEquals('optional_float', fields[10].getName());
+ assertEquals('optional_double', fields[11].getName());
+ assertEquals('optional_bool', fields[12].getName());
+ assertEquals('optional_string', fields[13].getName());
+ assertEquals('optional_bytes', fields[14].getName());
+ assertEquals('optionalgroup', fields[15].getName());
+ assertEquals('optional_nested_message', fields[16].getName());
+ assertEquals('optional_nested_enum', fields[17].getName());
+
+ assertEquals('repeated_int32', fields[18].getName());
+ assertEquals('repeated_int64', fields[19].getName());
+ assertEquals('repeated_uint32', fields[20].getName());
+ assertEquals('repeated_uint64', fields[21].getName());
+ assertEquals('repeated_sint32', fields[22].getName());
+ assertEquals('repeated_sint64', fields[23].getName());
+ assertEquals('repeated_fixed32', fields[24].getName());
+ assertEquals('repeated_fixed64', fields[25].getName());
+ assertEquals('repeated_sfixed32', fields[26].getName());
+ assertEquals('repeated_sfixed64', fields[27].getName());
+ assertEquals('repeated_float', fields[28].getName());
+ assertEquals('repeated_double', fields[29].getName());
+ assertEquals('repeated_bool', fields[30].getName());
+ assertEquals('repeated_string', fields[31].getName());
+ assertEquals('repeated_bytes', fields[32].getName());
+ assertEquals('repeatedgroup', fields[33].getName());
+ assertEquals('repeated_nested_message', fields[34].getName());
+ assertEquals('repeated_nested_enum', fields[35].getName());
+
+ assertEquals('optional_int64_number', fields[36].getName());
+ assertEquals('optional_int64_string', fields[37].getName());
+ assertEquals('repeated_int64_number', fields[38].getName());
+ assertEquals('repeated_int64_string', fields[39].getName());
+
+ // Check the field types.
+ var FieldType = goog.proto2.FieldDescriptor.FieldType;
+ assertEquals(FieldType.INT32, fields[0].getFieldType());
+ assertEquals(FieldType.INT64, fields[1].getFieldType());
+ assertEquals(FieldType.UINT32, fields[2].getFieldType());
+ assertEquals(FieldType.UINT64, fields[3].getFieldType());
+ assertEquals(FieldType.SINT32, fields[4].getFieldType());
+ assertEquals(FieldType.SINT64, fields[5].getFieldType());
+ assertEquals(FieldType.FIXED32, fields[6].getFieldType());
+ assertEquals(FieldType.FIXED64, fields[7].getFieldType());
+ assertEquals(FieldType.SFIXED32, fields[8].getFieldType());
+ assertEquals(FieldType.SFIXED64, fields[9].getFieldType());
+ assertEquals(FieldType.FLOAT, fields[10].getFieldType());
+ assertEquals(FieldType.DOUBLE, fields[11].getFieldType());
+ assertEquals(FieldType.BOOL, fields[12].getFieldType());
+ assertEquals(FieldType.STRING, fields[13].getFieldType());
+ assertEquals(FieldType.BYTES, fields[14].getFieldType());
+ assertEquals(FieldType.GROUP, fields[15].getFieldType());
+ assertEquals(FieldType.MESSAGE, fields[16].getFieldType());
+ assertEquals(FieldType.ENUM, fields[17].getFieldType());
+
+ assertEquals(FieldType.INT32, fields[18].getFieldType());
+ assertEquals(FieldType.INT64, fields[19].getFieldType());
+ assertEquals(FieldType.UINT32, fields[20].getFieldType());
+ assertEquals(FieldType.UINT64, fields[21].getFieldType());
+ assertEquals(FieldType.SINT32, fields[22].getFieldType());
+ assertEquals(FieldType.SINT64, fields[23].getFieldType());
+ assertEquals(FieldType.FIXED32, fields[24].getFieldType());
+ assertEquals(FieldType.FIXED64, fields[25].getFieldType());
+ assertEquals(FieldType.SFIXED32, fields[26].getFieldType());
+ assertEquals(FieldType.SFIXED64, fields[27].getFieldType());
+ assertEquals(FieldType.FLOAT, fields[28].getFieldType());
+ assertEquals(FieldType.DOUBLE, fields[29].getFieldType());
+ assertEquals(FieldType.BOOL, fields[30].getFieldType());
+ assertEquals(FieldType.STRING, fields[31].getFieldType());
+ assertEquals(FieldType.BYTES, fields[32].getFieldType());
+ assertEquals(FieldType.GROUP, fields[33].getFieldType());
+ assertEquals(FieldType.MESSAGE, fields[34].getFieldType());
+ assertEquals(FieldType.ENUM, fields[35].getFieldType());
+
+ assertEquals(FieldType.INT64, fields[36].getFieldType());
+ assertEquals(FieldType.INT64, fields[37].getFieldType());
+ assertEquals(FieldType.INT64, fields[38].getFieldType());
+ assertEquals(FieldType.INT64, fields[39].getFieldType());
+
+ // Check the field native types.
+ // Singular.
+ assertEquals(Number, fields[0].getNativeType());
+ assertEquals(String, fields[1].getNativeType()); // 64 bit values are strings.
+ assertEquals(Number, fields[2].getNativeType());
+ assertEquals(String, fields[3].getNativeType());
+ assertEquals(Number, fields[4].getNativeType());
+ assertEquals(String, fields[5].getNativeType());
+ assertEquals(Number, fields[6].getNativeType());
+ assertEquals(String, fields[7].getNativeType());
+ assertEquals(Number, fields[8].getNativeType());
+ assertEquals(String, fields[9].getNativeType());
+ assertEquals(Number, fields[10].getNativeType());
+ assertEquals(Number, fields[11].getNativeType());
+
+ assertEquals(Boolean, fields[12].getNativeType());
+
+ assertEquals(String, fields[13].getNativeType());
+ assertEquals(String, fields[14].getNativeType());
+
+ assertEquals(proto2.TestAllTypes.OptionalGroup, fields[15].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedMessage, fields[16].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedEnum, fields[17].getNativeType());
+
+ assertEquals(Number, fields[36].getNativeType()); // [jstype="number"]
+ assertEquals(String, fields[37].getNativeType());
+
+ // Repeated.
+ assertEquals(Number, fields[18].getNativeType());
+ assertEquals(String, fields[19].getNativeType());
+ assertEquals(Number, fields[20].getNativeType());
+ assertEquals(String, fields[21].getNativeType());
+ assertEquals(Number, fields[22].getNativeType());
+ assertEquals(String, fields[23].getNativeType());
+ assertEquals(Number, fields[24].getNativeType());
+ assertEquals(String, fields[25].getNativeType());
+ assertEquals(Number, fields[26].getNativeType());
+ assertEquals(String, fields[27].getNativeType());
+ assertEquals(Number, fields[28].getNativeType());
+ assertEquals(Number, fields[29].getNativeType());
+
+ assertEquals(Boolean, fields[30].getNativeType());
+
+ assertEquals(String, fields[31].getNativeType());
+ assertEquals(String, fields[32].getNativeType());
+
+ assertEquals(proto2.TestAllTypes.RepeatedGroup, fields[33].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedMessage, fields[34].getNativeType());
+ assertEquals(proto2.TestAllTypes.NestedEnum, fields[35].getNativeType());
+
+ assertEquals(Number, fields[38].getNativeType()); // [jstype="number"]
+ assertEquals(String, fields[39].getNativeType());
+}
+
+function testUnknown() {
+ var message = new proto2.TestAllTypes();
+
+ // Set some unknown fields.
+ message.setUnknown(1000, 101);
+ message.setUnknown(1001, -102);
+ message.setUnknown(1002, true);
+ message.setUnknown(1003, 'abcd');
+ message.setUnknown(1004, [ 'he', 'llo']);
+
+ // Ensure we find them all.
+ var count = 0;
+
+ message.forEachUnknown(function(tag, value) {
+ if (tag == 1000) {
+ assertEquals(101, value);
+ }
+
+ if (tag == 1001) {
+ assertEquals(-102, value);
+ }
+
+ if (tag == 1002) {
+ assertEquals(true, value);
+ }
+
+ if (tag == 1003) {
+ assertEquals('abcd', value);
+ }
+
+ if (tag == 1004) {
+ assertEquals('he', value[0]);
+ assertEquals('llo', value[1]);
+ }
+
+ count++;
+ });
+
+ assertEquals(5, count);
+}
+
+function testReflection() {
+ var message = new proto2.TestAllTypes();
+ var descriptor = message.getDescriptor();
+ var optionalInt = descriptor.findFieldByName('optional_int32');
+ var optionalString = descriptor.findFieldByName('optional_string');
+ var repeatedInt64 = descriptor.findFieldByName('repeated_int64');
+ var optionalWrong = descriptor.findFieldByName('foo_bar');
+
+ assertFalse(optionalInt == null);
+ assertFalse(optionalString == null);
+ assertFalse(repeatedInt64 == null);
+ assertTrue(optionalWrong == null);
+
+ // Check to ensure the fields are empty.
+ assertFalse(message.has(optionalInt));
+ assertFalse(message.has(optionalString));
+ assertFalse(message.has(repeatedInt64));
+
+ assertEquals(0, message.arrayOf(repeatedInt64).length);
+
+ // Check default values.
+ assertEquals(0, message.getOrDefault(optionalInt));
+ assertEquals('', message.getOrDefault(optionalString));
+
+ // Set some of the fields.
+ message.set(optionalString, 'hello!');
+
+ message.add(repeatedInt64, '101');
+ message.add(repeatedInt64, '102');
+
+ // Check the fields.
+ assertFalse(message.has(optionalInt));
+
+ assertTrue(message.has(optionalString));
+ assertTrue(message.hasOptionalString());
+
+ assertTrue(message.has(repeatedInt64));
+ assertTrue(message.hasRepeatedInt64());
+
+ // Check the values.
+ assertEquals('hello!', message.get(optionalString));
+ assertEquals('hello!', message.getOptionalString());
+
+ assertEquals('101', message.get(repeatedInt64, 0));
+ assertEquals('102', message.get(repeatedInt64, 1));
+
+ assertEquals('101', message.getRepeatedInt64(0));
+ assertEquals('102', message.getRepeatedInt64(1));
+
+ // Check the count.
+ assertEquals(0, message.countOf(optionalInt));
+
+ assertEquals(1, message.countOf(optionalString));
+ assertEquals(1, message.optionalStringCount());
+
+ assertEquals(2, message.countOf(repeatedInt64));
+ assertEquals(2, message.repeatedInt64Count());
+
+ // Check the array.
+ assertEquals(2, message.arrayOf(repeatedInt64).length);
+
+ assertEquals(message.get(repeatedInt64, 0),
+ message.arrayOf(repeatedInt64)[0]);
+
+ assertEquals(message.get(repeatedInt64, 1),
+ message.arrayOf(repeatedInt64)[1]);
+}
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/serializer.js b/contexts/data/lib/closure-library/closure/goog/proto2/serializer.js
new file mode 100644
index 0000000..2038339
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/serializer.js
@@ -0,0 +1,148 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Base class for all Protocol Buffer 2 serializers.
+ */
+
+goog.provide('goog.proto2.Serializer');
+
+goog.require('goog.proto2.Descriptor');
+goog.require('goog.proto2.FieldDescriptor');
+goog.require('goog.proto2.Message');
+goog.require('goog.proto2.Util');
+
+
+
+/**
+ * Abstract base class for PB2 serializers. A serializer is a class which
+ * implements the serialization and deserialization of a Protocol Buffer Message
+ * to/from a specific format.
+ *
+ * @constructor
+ */
+goog.proto2.Serializer = function() {};
+
+
+/**
+ * Serializes a message to the expected format.
+ *
+ * @param {goog.proto2.Message} message The message to be serialized.
+ *
+ * @return {Object} The serialized form of the message.
+ */
+goog.proto2.Serializer.prototype.serialize = goog.abstractMethod;
+
+
+/**
+ * Returns the serialized form of the given value for the given field
+ * if the field is a Message or Group and returns the value unchanged
+ * otherwise.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field from which this
+ * value came.
+ *
+ * @param {*} value The value of the field.
+ *
+ * @return {*} The value.
+ * @protected
+ */
+goog.proto2.Serializer.prototype.getSerializedValue = function(field, value) {
+ if (field.isCompositeType()) {
+ return this.serialize(/** @type {goog.proto2.Message} */ (value));
+ } else {
+ return value;
+ }
+};
+
+
+/**
+ * Deserializes a message from the expected format.
+ *
+ * @param {goog.proto2.Descriptor} descriptor The descriptor of the message
+ * to be created.
+ * @param {*} data The data of the message.
+ *
+ * @return {goog.proto2.Message} The message created.
+ */
+goog.proto2.Serializer.prototype.deserialize = function(descriptor, data) {
+ var message = descriptor.createMessageInstance();
+ this.deserializeTo(message, data);
+ goog.proto2.Util.assert(message instanceof goog.proto2.Message);
+ return message;
+};
+
+
+/**
+ * Deserializes a message from the expected format and places the
+ * data in the message.
+ *
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {*} data The data of the message.
+ */
+goog.proto2.Serializer.prototype.deserializeTo = goog.abstractMethod;
+
+
+/**
+ * Returns the deserialized form of the given value for the given field if the
+ * field is a Message or Group and returns the value, converted or unchanged,
+ * for primitive field types otherwise.
+ *
+ * @param {goog.proto2.FieldDescriptor} field The field from which this
+ * value came.
+ *
+ * @param {*} value The value of the field.
+ *
+ * @return {*} The value.
+ * @protected
+ */
+goog.proto2.Serializer.prototype.getDeserializedValue = function(field, value) {
+ // Composite types are deserialized recursively.
+ if (field.isCompositeType()) {
+ return this.deserialize(field.getFieldMessageType(), value);
+ }
+
+ // Return the raw value if the field does not allow the JSON input to be
+ // converted.
+ if (!field.deserializationConversionPermitted()) {
+ return value;
+ }
+
+ // Convert to native type of field. Return the converted value or fall
+ // through to return the raw value. The JSON encoding of int64 value 123
+ // might be either the number 123 or the string "123". The field native type
+ // could be either Number or String (depending on field options in the .proto
+ // file). All four combinations should work correctly.
+ var nativeType = field.getNativeType();
+
+ if (nativeType === String) {
+ // JSON numbers can be converted to strings.
+ if (typeof value === 'number') {
+ return String(value);
+ }
+ } else if (nativeType === Number) {
+ // JSON strings are sometimes used for large integer numeric values.
+ if (typeof value === 'string') {
+ // Validate the string. If the string is not an integral number, we would
+ // rather have an assertion or error in the caller than a mysterious NaN
+ // value.
+ if (/^-?[0-9]+$/.test(value)) {
+ return Number(value);
+ }
+ }
+ }
+
+ return value;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/test.pb.js b/contexts/data/lib/closure-library/closure/goog/proto2/test.pb.js
new file mode 100644
index 0000000..2681214
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/test.pb.js
@@ -0,0 +1,2820 @@
+// Copyright 2008 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// All other code copyright its respective owners(s).
+
+/**
+ * @fileoverview Generated Protocol Buffer code for file
+ * closure/goog/proto2/test.proto.
+ */
+
+goog.provide('proto2.TestAllTypes');
+goog.provide('proto2.TestAllTypes.NestedMessage');
+goog.provide('proto2.TestAllTypes.OptionalGroup');
+goog.provide('proto2.TestAllTypes.RepeatedGroup');
+goog.provide('proto2.TestAllTypes.NestedEnum');
+
+goog.require('goog.proto2.Message');
+
+
+
+/**
+ * Message TestAllTypes.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.prototype.clone;
+
+
+/**
+ * Gets the value of the optional_int32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt32 = function() {
+ return /** @type {?number} */ (this.get$Value(1));
+};
+
+
+/**
+ * Gets the value of the optional_int32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(1));
+};
+
+
+/**
+ * Sets the value of the optional_int32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt32 = function(value) {
+ this.set$Value(1, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt32 = function() {
+ return this.has$Value(1);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int32 field.
+ */
+proto2.TestAllTypes.prototype.optionalInt32Count = function() {
+ return this.count$Values(1);
+};
+
+
+/**
+ * Clears the values in the optional_int32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt32 = function() {
+ this.clear$Field(1);
+};
+
+
+/**
+ * Gets the value of the optional_int64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64 = function() {
+ return /** @type {?string} */ (this.get$Value(2));
+};
+
+
+/**
+ * Gets the value of the optional_int64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(2));
+};
+
+
+/**
+ * Sets the value of the optional_int64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt64 = function(value) {
+ this.set$Value(2, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt64 = function() {
+ return this.has$Value(2);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int64 field.
+ */
+proto2.TestAllTypes.prototype.optionalInt64Count = function() {
+ return this.count$Values(2);
+};
+
+
+/**
+ * Clears the values in the optional_int64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt64 = function() {
+ this.clear$Field(2);
+};
+
+
+/**
+ * Gets the value of the optional_uint32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint32 = function() {
+ return /** @type {?number} */ (this.get$Value(3));
+};
+
+
+/**
+ * Gets the value of the optional_uint32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(3));
+};
+
+
+/**
+ * Sets the value of the optional_uint32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalUint32 = function(value) {
+ this.set$Value(3, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_uint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalUint32 = function() {
+ return this.has$Value(3);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_uint32 field.
+ */
+proto2.TestAllTypes.prototype.optionalUint32Count = function() {
+ return this.count$Values(3);
+};
+
+
+/**
+ * Clears the values in the optional_uint32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalUint32 = function() {
+ this.clear$Field(3);
+};
+
+
+/**
+ * Gets the value of the optional_uint64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint64 = function() {
+ return /** @type {?string} */ (this.get$Value(4));
+};
+
+
+/**
+ * Gets the value of the optional_uint64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalUint64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(4));
+};
+
+
+/**
+ * Sets the value of the optional_uint64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalUint64 = function(value) {
+ this.set$Value(4, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_uint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalUint64 = function() {
+ return this.has$Value(4);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_uint64 field.
+ */
+proto2.TestAllTypes.prototype.optionalUint64Count = function() {
+ return this.count$Values(4);
+};
+
+
+/**
+ * Clears the values in the optional_uint64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalUint64 = function() {
+ this.clear$Field(4);
+};
+
+
+/**
+ * Gets the value of the optional_sint32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint32 = function() {
+ return /** @type {?number} */ (this.get$Value(5));
+};
+
+
+/**
+ * Gets the value of the optional_sint32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(5));
+};
+
+
+/**
+ * Sets the value of the optional_sint32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSint32 = function(value) {
+ this.set$Value(5, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSint32 = function() {
+ return this.has$Value(5);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sint32 field.
+ */
+proto2.TestAllTypes.prototype.optionalSint32Count = function() {
+ return this.count$Values(5);
+};
+
+
+/**
+ * Clears the values in the optional_sint32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSint32 = function() {
+ this.clear$Field(5);
+};
+
+
+/**
+ * Gets the value of the optional_sint64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint64 = function() {
+ return /** @type {?string} */ (this.get$Value(6));
+};
+
+
+/**
+ * Gets the value of the optional_sint64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSint64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(6));
+};
+
+
+/**
+ * Sets the value of the optional_sint64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSint64 = function(value) {
+ this.set$Value(6, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSint64 = function() {
+ return this.has$Value(6);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sint64 field.
+ */
+proto2.TestAllTypes.prototype.optionalSint64Count = function() {
+ return this.count$Values(6);
+};
+
+
+/**
+ * Clears the values in the optional_sint64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSint64 = function() {
+ this.clear$Field(6);
+};
+
+
+/**
+ * Gets the value of the optional_fixed32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed32 = function() {
+ return /** @type {?number} */ (this.get$Value(7));
+};
+
+
+/**
+ * Gets the value of the optional_fixed32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(7));
+};
+
+
+/**
+ * Sets the value of the optional_fixed32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalFixed32 = function(value) {
+ this.set$Value(7, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_fixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalFixed32 = function() {
+ return this.has$Value(7);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.optionalFixed32Count = function() {
+ return this.count$Values(7);
+};
+
+
+/**
+ * Clears the values in the optional_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalFixed32 = function() {
+ this.clear$Field(7);
+};
+
+
+/**
+ * Gets the value of the optional_fixed64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed64 = function() {
+ return /** @type {?string} */ (this.get$Value(8));
+};
+
+
+/**
+ * Gets the value of the optional_fixed64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFixed64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(8));
+};
+
+
+/**
+ * Sets the value of the optional_fixed64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalFixed64 = function(value) {
+ this.set$Value(8, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_fixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalFixed64 = function() {
+ return this.has$Value(8);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.optionalFixed64Count = function() {
+ return this.count$Values(8);
+};
+
+
+/**
+ * Clears the values in the optional_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalFixed64 = function() {
+ this.clear$Field(8);
+};
+
+
+/**
+ * Gets the value of the optional_sfixed32 field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed32 = function() {
+ return /** @type {?number} */ (this.get$Value(9));
+};
+
+
+/**
+ * Gets the value of the optional_sfixed32 field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed32OrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(9));
+};
+
+
+/**
+ * Sets the value of the optional_sfixed32 field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSfixed32 = function(value) {
+ this.set$Value(9, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sfixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSfixed32 = function() {
+ return this.has$Value(9);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.optionalSfixed32Count = function() {
+ return this.count$Values(9);
+};
+
+
+/**
+ * Clears the values in the optional_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSfixed32 = function() {
+ this.clear$Field(9);
+};
+
+
+/**
+ * Gets the value of the optional_sfixed64 field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed64 = function() {
+ return /** @type {?string} */ (this.get$Value(10));
+};
+
+
+/**
+ * Gets the value of the optional_sfixed64 field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalSfixed64OrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(10));
+};
+
+
+/**
+ * Sets the value of the optional_sfixed64 field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalSfixed64 = function(value) {
+ this.set$Value(10, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_sfixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalSfixed64 = function() {
+ return this.has$Value(10);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.optionalSfixed64Count = function() {
+ return this.count$Values(10);
+};
+
+
+/**
+ * Clears the values in the optional_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalSfixed64 = function() {
+ this.clear$Field(10);
+};
+
+
+/**
+ * Gets the value of the optional_float field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFloat = function() {
+ return /** @type {?number} */ (this.get$Value(11));
+};
+
+
+/**
+ * Gets the value of the optional_float field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalFloatOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(11));
+};
+
+
+/**
+ * Sets the value of the optional_float field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalFloat = function(value) {
+ this.set$Value(11, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_float field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalFloat = function() {
+ return this.has$Value(11);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_float field.
+ */
+proto2.TestAllTypes.prototype.optionalFloatCount = function() {
+ return this.count$Values(11);
+};
+
+
+/**
+ * Clears the values in the optional_float field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalFloat = function() {
+ this.clear$Field(11);
+};
+
+
+/**
+ * Gets the value of the optional_double field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalDouble = function() {
+ return /** @type {?number} */ (this.get$Value(12));
+};
+
+
+/**
+ * Gets the value of the optional_double field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalDoubleOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(12));
+};
+
+
+/**
+ * Sets the value of the optional_double field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalDouble = function(value) {
+ this.set$Value(12, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_double field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalDouble = function() {
+ return this.has$Value(12);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_double field.
+ */
+proto2.TestAllTypes.prototype.optionalDoubleCount = function() {
+ return this.count$Values(12);
+};
+
+
+/**
+ * Clears the values in the optional_double field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalDouble = function() {
+ this.clear$Field(12);
+};
+
+
+/**
+ * Gets the value of the optional_bool field.
+ * @return {?boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBool = function() {
+ return /** @type {?boolean} */ (this.get$Value(13));
+};
+
+
+/**
+ * Gets the value of the optional_bool field or the default value if not set.
+ * @return {boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBoolOrDefault = function() {
+ return /** @type {boolean} */ (this.get$ValueOrDefault(13));
+};
+
+
+/**
+ * Sets the value of the optional_bool field.
+ * @param {boolean} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalBool = function(value) {
+ this.set$Value(13, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_bool field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalBool = function() {
+ return this.has$Value(13);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_bool field.
+ */
+proto2.TestAllTypes.prototype.optionalBoolCount = function() {
+ return this.count$Values(13);
+};
+
+
+/**
+ * Clears the values in the optional_bool field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalBool = function() {
+ this.clear$Field(13);
+};
+
+
+/**
+ * Gets the value of the optional_string field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalString = function() {
+ return /** @type {?string} */ (this.get$Value(14));
+};
+
+
+/**
+ * Gets the value of the optional_string field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalStringOrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(14));
+};
+
+
+/**
+ * Sets the value of the optional_string field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalString = function(value) {
+ this.set$Value(14, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalString = function() {
+ return this.has$Value(14);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_string field.
+ */
+proto2.TestAllTypes.prototype.optionalStringCount = function() {
+ return this.count$Values(14);
+};
+
+
+/**
+ * Clears the values in the optional_string field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalString = function() {
+ this.clear$Field(14);
+};
+
+
+/**
+ * Gets the value of the optional_bytes field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBytes = function() {
+ return /** @type {?string} */ (this.get$Value(15));
+};
+
+
+/**
+ * Gets the value of the optional_bytes field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalBytesOrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(15));
+};
+
+
+/**
+ * Sets the value of the optional_bytes field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalBytes = function(value) {
+ this.set$Value(15, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_bytes field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalBytes = function() {
+ return this.has$Value(15);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_bytes field.
+ */
+proto2.TestAllTypes.prototype.optionalBytesCount = function() {
+ return this.count$Values(15);
+};
+
+
+/**
+ * Clears the values in the optional_bytes field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalBytes = function() {
+ this.clear$Field(15);
+};
+
+
+/**
+ * Gets the value of the optionalgroup field.
+ * @return {proto2.TestAllTypes.OptionalGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalgroup = function() {
+ return /** @type {proto2.TestAllTypes.OptionalGroup} */ (this.get$Value(16));
+};
+
+
+/**
+ * Gets the value of the optionalgroup field or the default value if not set.
+ * @return {!proto2.TestAllTypes.OptionalGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalgroupOrDefault = function() {
+ return /** @type {!proto2.TestAllTypes.OptionalGroup} */ (this.get$ValueOrDefault(16));
+};
+
+
+/**
+ * Sets the value of the optionalgroup field.
+ * @param {!proto2.TestAllTypes.OptionalGroup} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalgroup = function(value) {
+ this.set$Value(16, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optionalgroup field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalgroup = function() {
+ return this.has$Value(16);
+};
+
+
+/**
+ * @return {number} The number of values in the optionalgroup field.
+ */
+proto2.TestAllTypes.prototype.optionalgroupCount = function() {
+ return this.count$Values(16);
+};
+
+
+/**
+ * Clears the values in the optionalgroup field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalgroup = function() {
+ this.clear$Field(16);
+};
+
+
+/**
+ * Gets the value of the optional_nested_message field.
+ * @return {proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedMessage = function() {
+ return /** @type {proto2.TestAllTypes.NestedMessage} */ (this.get$Value(18));
+};
+
+
+/**
+ * Gets the value of the optional_nested_message field or the default value if not set.
+ * @return {!proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedMessageOrDefault = function() {
+ return /** @type {!proto2.TestAllTypes.NestedMessage} */ (this.get$ValueOrDefault(18));
+};
+
+
+/**
+ * Sets the value of the optional_nested_message field.
+ * @param {!proto2.TestAllTypes.NestedMessage} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalNestedMessage = function(value) {
+ this.set$Value(18, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_nested_message field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalNestedMessage = function() {
+ return this.has$Value(18);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_nested_message field.
+ */
+proto2.TestAllTypes.prototype.optionalNestedMessageCount = function() {
+ return this.count$Values(18);
+};
+
+
+/**
+ * Clears the values in the optional_nested_message field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalNestedMessage = function() {
+ this.clear$Field(18);
+};
+
+
+/**
+ * Gets the value of the optional_nested_enum field.
+ * @return {?proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedEnum = function() {
+ return /** @type {?proto2.TestAllTypes.NestedEnum} */ (this.get$Value(21));
+};
+
+
+/**
+ * Gets the value of the optional_nested_enum field or the default value if not set.
+ * @return {proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalNestedEnumOrDefault = function() {
+ return /** @type {proto2.TestAllTypes.NestedEnum} */ (this.get$ValueOrDefault(21));
+};
+
+
+/**
+ * Sets the value of the optional_nested_enum field.
+ * @param {proto2.TestAllTypes.NestedEnum} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalNestedEnum = function(value) {
+ this.set$Value(21, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_nested_enum field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalNestedEnum = function() {
+ return this.has$Value(21);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.optionalNestedEnumCount = function() {
+ return this.count$Values(21);
+};
+
+
+/**
+ * Clears the values in the optional_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalNestedEnum = function() {
+ this.clear$Field(21);
+};
+
+
+/**
+ * Gets the value of the optional_int64_number field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64Number = function() {
+ return /** @type {?number} */ (this.get$Value(50));
+};
+
+
+/**
+ * Gets the value of the optional_int64_number field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64NumberOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(50));
+};
+
+
+/**
+ * Sets the value of the optional_int64_number field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt64Number = function(value) {
+ this.set$Value(50, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int64_number field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt64Number = function() {
+ return this.has$Value(50);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int64_number field.
+ */
+proto2.TestAllTypes.prototype.optionalInt64NumberCount = function() {
+ return this.count$Values(50);
+};
+
+
+/**
+ * Clears the values in the optional_int64_number field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt64Number = function() {
+ this.clear$Field(50);
+};
+
+
+/**
+ * Gets the value of the optional_int64_string field.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64String = function() {
+ return /** @type {?string} */ (this.get$Value(51));
+};
+
+
+/**
+ * Gets the value of the optional_int64_string field or the default value if not set.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getOptionalInt64StringOrDefault = function() {
+ return /** @type {string} */ (this.get$ValueOrDefault(51));
+};
+
+
+/**
+ * Sets the value of the optional_int64_string field.
+ * @param {string} value The value.
+ */
+proto2.TestAllTypes.prototype.setOptionalInt64String = function(value) {
+ this.set$Value(51, value);
+};
+
+
+/**
+ * @return {boolean} Whether the optional_int64_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasOptionalInt64String = function() {
+ return this.has$Value(51);
+};
+
+
+/**
+ * @return {number} The number of values in the optional_int64_string field.
+ */
+proto2.TestAllTypes.prototype.optionalInt64StringCount = function() {
+ return this.count$Values(51);
+};
+
+
+/**
+ * Clears the values in the optional_int64_string field.
+ */
+proto2.TestAllTypes.prototype.clearOptionalInt64String = function() {
+ this.clear$Field(51);
+};
+
+
+/**
+ * Gets the value of the repeated_int32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(31, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(31, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt32 = function(value) {
+ this.add$Value(31, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(31));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt32 = function() {
+ return this.has$Value(31);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt32Count = function() {
+ return this.count$Values(31);
+};
+
+
+/**
+ * Clears the values in the repeated_int32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt32 = function() {
+ this.clear$Field(31);
+};
+
+
+/**
+ * Gets the value of the repeated_int64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(32, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(32, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt64 = function(value) {
+ this.add$Value(32, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(32));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt64 = function() {
+ return this.has$Value(32);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64Count = function() {
+ return this.count$Values(32);
+};
+
+
+/**
+ * Clears the values in the repeated_int64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt64 = function() {
+ this.clear$Field(32);
+};
+
+
+/**
+ * Gets the value of the repeated_uint32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(33, index));
+};
+
+
+/**
+ * Gets the value of the repeated_uint32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(33, index));
+};
+
+
+/**
+ * Adds a value to the repeated_uint32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedUint32 = function(value) {
+ this.add$Value(33, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_uint32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(33));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_uint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedUint32 = function() {
+ return this.has$Value(33);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_uint32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint32Count = function() {
+ return this.count$Values(33);
+};
+
+
+/**
+ * Clears the values in the repeated_uint32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedUint32 = function() {
+ this.clear$Field(33);
+};
+
+
+/**
+ * Gets the value of the repeated_uint64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(34, index));
+};
+
+
+/**
+ * Gets the value of the repeated_uint64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedUint64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(34, index));
+};
+
+
+/**
+ * Adds a value to the repeated_uint64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedUint64 = function(value) {
+ this.add$Value(34, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_uint64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(34));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_uint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedUint64 = function() {
+ return this.has$Value(34);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_uint64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedUint64Count = function() {
+ return this.count$Values(34);
+};
+
+
+/**
+ * Clears the values in the repeated_uint64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedUint64 = function() {
+ this.clear$Field(34);
+};
+
+
+/**
+ * Gets the value of the repeated_sint32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(35, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sint32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(35, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sint32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSint32 = function(value) {
+ this.add$Value(35, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sint32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(35));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sint32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSint32 = function() {
+ return this.has$Value(35);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sint32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint32Count = function() {
+ return this.count$Values(35);
+};
+
+
+/**
+ * Clears the values in the repeated_sint32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSint32 = function() {
+ this.clear$Field(35);
+};
+
+
+/**
+ * Gets the value of the repeated_sint64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(36, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sint64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSint64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(36, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sint64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSint64 = function(value) {
+ this.add$Value(36, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sint64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(36));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sint64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSint64 = function() {
+ return this.has$Value(36);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sint64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSint64Count = function() {
+ return this.count$Values(36);
+};
+
+
+/**
+ * Clears the values in the repeated_sint64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSint64 = function() {
+ this.clear$Field(36);
+};
+
+
+/**
+ * Gets the value of the repeated_fixed32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(37, index));
+};
+
+
+/**
+ * Gets the value of the repeated_fixed32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(37, index));
+};
+
+
+/**
+ * Adds a value to the repeated_fixed32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedFixed32 = function(value) {
+ this.add$Value(37, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_fixed32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(37));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_fixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedFixed32 = function() {
+ return this.has$Value(37);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed32Count = function() {
+ return this.count$Values(37);
+};
+
+
+/**
+ * Clears the values in the repeated_fixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedFixed32 = function() {
+ this.clear$Field(37);
+};
+
+
+/**
+ * Gets the value of the repeated_fixed64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(38, index));
+};
+
+
+/**
+ * Gets the value of the repeated_fixed64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFixed64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(38, index));
+};
+
+
+/**
+ * Adds a value to the repeated_fixed64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedFixed64 = function(value) {
+ this.add$Value(38, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_fixed64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(38));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_fixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedFixed64 = function() {
+ return this.has$Value(38);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedFixed64Count = function() {
+ return this.count$Values(38);
+};
+
+
+/**
+ * Clears the values in the repeated_fixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedFixed64 = function() {
+ this.clear$Field(38);
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed32 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed32 = function(index) {
+ return /** @type {?number} */ (this.get$Value(39, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed32 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed32OrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(39, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sfixed32 field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSfixed32 = function(value) {
+ this.add$Value(39, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sfixed32 field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed32Array = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(39));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sfixed32 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSfixed32 = function() {
+ return this.has$Value(39);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed32Count = function() {
+ return this.count$Values(39);
+};
+
+
+/**
+ * Clears the values in the repeated_sfixed32 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSfixed32 = function() {
+ this.clear$Field(39);
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed64 field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed64 = function(index) {
+ return /** @type {?string} */ (this.get$Value(40, index));
+};
+
+
+/**
+ * Gets the value of the repeated_sfixed64 field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedSfixed64OrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(40, index));
+};
+
+
+/**
+ * Adds a value to the repeated_sfixed64 field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedSfixed64 = function(value) {
+ this.add$Value(40, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_sfixed64 field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed64Array = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(40));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_sfixed64 field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedSfixed64 = function() {
+ return this.has$Value(40);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.repeatedSfixed64Count = function() {
+ return this.count$Values(40);
+};
+
+
+/**
+ * Clears the values in the repeated_sfixed64 field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedSfixed64 = function() {
+ this.clear$Field(40);
+};
+
+
+/**
+ * Gets the value of the repeated_float field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFloat = function(index) {
+ return /** @type {?number} */ (this.get$Value(41, index));
+};
+
+
+/**
+ * Gets the value of the repeated_float field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedFloatOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(41, index));
+};
+
+
+/**
+ * Adds a value to the repeated_float field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedFloat = function(value) {
+ this.add$Value(41, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_float field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedFloatArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(41));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_float field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedFloat = function() {
+ return this.has$Value(41);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_float field.
+ */
+proto2.TestAllTypes.prototype.repeatedFloatCount = function() {
+ return this.count$Values(41);
+};
+
+
+/**
+ * Clears the values in the repeated_float field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedFloat = function() {
+ this.clear$Field(41);
+};
+
+
+/**
+ * Gets the value of the repeated_double field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedDouble = function(index) {
+ return /** @type {?number} */ (this.get$Value(42, index));
+};
+
+
+/**
+ * Gets the value of the repeated_double field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedDoubleOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(42, index));
+};
+
+
+/**
+ * Adds a value to the repeated_double field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedDouble = function(value) {
+ this.add$Value(42, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_double field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedDoubleArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(42));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_double field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedDouble = function() {
+ return this.has$Value(42);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_double field.
+ */
+proto2.TestAllTypes.prototype.repeatedDoubleCount = function() {
+ return this.count$Values(42);
+};
+
+
+/**
+ * Clears the values in the repeated_double field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedDouble = function() {
+ this.clear$Field(42);
+};
+
+
+/**
+ * Gets the value of the repeated_bool field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBool = function(index) {
+ return /** @type {?boolean} */ (this.get$Value(43, index));
+};
+
+
+/**
+ * Gets the value of the repeated_bool field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {boolean} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBoolOrDefault = function(index) {
+ return /** @type {boolean} */ (this.get$ValueOrDefault(43, index));
+};
+
+
+/**
+ * Adds a value to the repeated_bool field.
+ * @param {boolean} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedBool = function(value) {
+ this.add$Value(43, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_bool field.
+ * @return {!Array.<boolean>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedBoolArray = function() {
+ return /** @type {!Array.<boolean>} */ (this.array$Values(43));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_bool field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedBool = function() {
+ return this.has$Value(43);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_bool field.
+ */
+proto2.TestAllTypes.prototype.repeatedBoolCount = function() {
+ return this.count$Values(43);
+};
+
+
+/**
+ * Clears the values in the repeated_bool field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedBool = function() {
+ this.clear$Field(43);
+};
+
+
+/**
+ * Gets the value of the repeated_string field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedString = function(index) {
+ return /** @type {?string} */ (this.get$Value(44, index));
+};
+
+
+/**
+ * Gets the value of the repeated_string field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedStringOrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(44, index));
+};
+
+
+/**
+ * Adds a value to the repeated_string field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedString = function(value) {
+ this.add$Value(44, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_string field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedStringArray = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(44));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedString = function() {
+ return this.has$Value(44);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_string field.
+ */
+proto2.TestAllTypes.prototype.repeatedStringCount = function() {
+ return this.count$Values(44);
+};
+
+
+/**
+ * Clears the values in the repeated_string field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedString = function() {
+ this.clear$Field(44);
+};
+
+
+/**
+ * Gets the value of the repeated_bytes field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBytes = function(index) {
+ return /** @type {?string} */ (this.get$Value(45, index));
+};
+
+
+/**
+ * Gets the value of the repeated_bytes field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedBytesOrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(45, index));
+};
+
+
+/**
+ * Adds a value to the repeated_bytes field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedBytes = function(value) {
+ this.add$Value(45, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_bytes field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedBytesArray = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(45));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_bytes field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedBytes = function() {
+ return this.has$Value(45);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_bytes field.
+ */
+proto2.TestAllTypes.prototype.repeatedBytesCount = function() {
+ return this.count$Values(45);
+};
+
+
+/**
+ * Clears the values in the repeated_bytes field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedBytes = function() {
+ this.clear$Field(45);
+};
+
+
+/**
+ * Gets the value of the repeatedgroup field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {proto2.TestAllTypes.RepeatedGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedgroup = function(index) {
+ return /** @type {proto2.TestAllTypes.RepeatedGroup} */ (this.get$Value(46, index));
+};
+
+
+/**
+ * Gets the value of the repeatedgroup field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {!proto2.TestAllTypes.RepeatedGroup} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedgroupOrDefault = function(index) {
+ return /** @type {!proto2.TestAllTypes.RepeatedGroup} */ (this.get$ValueOrDefault(46, index));
+};
+
+
+/**
+ * Adds a value to the repeatedgroup field.
+ * @param {!proto2.TestAllTypes.RepeatedGroup} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedgroup = function(value) {
+ this.add$Value(46, value);
+};
+
+
+/**
+ * Returns the array of values in the repeatedgroup field.
+ * @return {!Array.<!proto2.TestAllTypes.RepeatedGroup>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedgroupArray = function() {
+ return /** @type {!Array.<!proto2.TestAllTypes.RepeatedGroup>} */ (this.array$Values(46));
+};
+
+
+/**
+ * @return {boolean} Whether the repeatedgroup field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedgroup = function() {
+ return this.has$Value(46);
+};
+
+
+/**
+ * @return {number} The number of values in the repeatedgroup field.
+ */
+proto2.TestAllTypes.prototype.repeatedgroupCount = function() {
+ return this.count$Values(46);
+};
+
+
+/**
+ * Clears the values in the repeatedgroup field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedgroup = function() {
+ this.clear$Field(46);
+};
+
+
+/**
+ * Gets the value of the repeated_nested_message field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedMessage = function(index) {
+ return /** @type {proto2.TestAllTypes.NestedMessage} */ (this.get$Value(48, index));
+};
+
+
+/**
+ * Gets the value of the repeated_nested_message field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {!proto2.TestAllTypes.NestedMessage} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedMessageOrDefault = function(index) {
+ return /** @type {!proto2.TestAllTypes.NestedMessage} */ (this.get$ValueOrDefault(48, index));
+};
+
+
+/**
+ * Adds a value to the repeated_nested_message field.
+ * @param {!proto2.TestAllTypes.NestedMessage} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedNestedMessage = function(value) {
+ this.add$Value(48, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_nested_message field.
+ * @return {!Array.<!proto2.TestAllTypes.NestedMessage>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedMessageArray = function() {
+ return /** @type {!Array.<!proto2.TestAllTypes.NestedMessage>} */ (this.array$Values(48));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_nested_message field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedNestedMessage = function() {
+ return this.has$Value(48);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_nested_message field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedMessageCount = function() {
+ return this.count$Values(48);
+};
+
+
+/**
+ * Clears the values in the repeated_nested_message field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedNestedMessage = function() {
+ this.clear$Field(48);
+};
+
+
+/**
+ * Gets the value of the repeated_nested_enum field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedEnum = function(index) {
+ return /** @type {?proto2.TestAllTypes.NestedEnum} */ (this.get$Value(49, index));
+};
+
+
+/**
+ * Gets the value of the repeated_nested_enum field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {proto2.TestAllTypes.NestedEnum} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedNestedEnumOrDefault = function(index) {
+ return /** @type {proto2.TestAllTypes.NestedEnum} */ (this.get$ValueOrDefault(49, index));
+};
+
+
+/**
+ * Adds a value to the repeated_nested_enum field.
+ * @param {proto2.TestAllTypes.NestedEnum} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedNestedEnum = function(value) {
+ this.add$Value(49, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_nested_enum field.
+ * @return {!Array.<proto2.TestAllTypes.NestedEnum>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedEnumArray = function() {
+ return /** @type {!Array.<proto2.TestAllTypes.NestedEnum>} */ (this.array$Values(49));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_nested_enum field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedNestedEnum = function() {
+ return this.has$Value(49);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.repeatedNestedEnumCount = function() {
+ return this.count$Values(49);
+};
+
+
+/**
+ * Clears the values in the repeated_nested_enum field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedNestedEnum = function() {
+ this.clear$Field(49);
+};
+
+
+/**
+ * Gets the value of the repeated_int64_number field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64Number = function(index) {
+ return /** @type {?number} */ (this.get$Value(52, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int64_number field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64NumberOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(52, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int64_number field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt64Number = function(value) {
+ this.add$Value(52, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int64_number field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64NumberArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(52));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int64_number field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt64Number = function() {
+ return this.has$Value(52);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int64_number field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64NumberCount = function() {
+ return this.count$Values(52);
+};
+
+
+/**
+ * Clears the values in the repeated_int64_number field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt64Number = function() {
+ this.clear$Field(52);
+};
+
+
+/**
+ * Gets the value of the repeated_int64_string field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64String = function(index) {
+ return /** @type {?string} */ (this.get$Value(53, index));
+};
+
+
+/**
+ * Gets the value of the repeated_int64_string field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {string} The value.
+ */
+proto2.TestAllTypes.prototype.getRepeatedInt64StringOrDefault = function(index) {
+ return /** @type {string} */ (this.get$ValueOrDefault(53, index));
+};
+
+
+/**
+ * Adds a value to the repeated_int64_string field.
+ * @param {string} value The value to add.
+ */
+proto2.TestAllTypes.prototype.addRepeatedInt64String = function(value) {
+ this.add$Value(53, value);
+};
+
+
+/**
+ * Returns the array of values in the repeated_int64_string field.
+ * @return {!Array.<string>} The values in the field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64StringArray = function() {
+ return /** @type {!Array.<string>} */ (this.array$Values(53));
+};
+
+
+/**
+ * @return {boolean} Whether the repeated_int64_string field has a value.
+ */
+proto2.TestAllTypes.prototype.hasRepeatedInt64String = function() {
+ return this.has$Value(53);
+};
+
+
+/**
+ * @return {number} The number of values in the repeated_int64_string field.
+ */
+proto2.TestAllTypes.prototype.repeatedInt64StringCount = function() {
+ return this.count$Values(53);
+};
+
+
+/**
+ * Clears the values in the repeated_int64_string field.
+ */
+proto2.TestAllTypes.prototype.clearRepeatedInt64String = function() {
+ this.clear$Field(53);
+};
+
+
+/**
+ * Enumeration NestedEnum.
+ * @enum {number}
+ */
+proto2.TestAllTypes.NestedEnum = {
+ FOO: 0,
+ BAR: 2,
+ BAZ: 3
+};
+
+
+
+/**
+ * Message NestedMessage.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes.NestedMessage = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes.NestedMessage, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes.NestedMessage} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.NestedMessage.prototype.clone;
+
+
+/**
+ * Gets the value of the b field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.getB = function() {
+ return /** @type {?number} */ (this.get$Value(1));
+};
+
+
+/**
+ * Gets the value of the b field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.getBOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(1));
+};
+
+
+/**
+ * Sets the value of the b field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.setB = function(value) {
+ this.set$Value(1, value);
+};
+
+
+/**
+ * @return {boolean} Whether the b field has a value.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.hasB = function() {
+ return this.has$Value(1);
+};
+
+
+/**
+ * @return {number} The number of values in the b field.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.bCount = function() {
+ return this.count$Values(1);
+};
+
+
+/**
+ * Clears the values in the b field.
+ */
+proto2.TestAllTypes.NestedMessage.prototype.clearB = function() {
+ this.clear$Field(1);
+};
+
+
+
+/**
+ * Message OptionalGroup.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes.OptionalGroup = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes.OptionalGroup, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes.OptionalGroup} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.clone;
+
+
+/**
+ * Gets the value of the a field.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.getA = function() {
+ return /** @type {?number} */ (this.get$Value(17));
+};
+
+
+/**
+ * Gets the value of the a field or the default value if not set.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.getAOrDefault = function() {
+ return /** @type {number} */ (this.get$ValueOrDefault(17));
+};
+
+
+/**
+ * Sets the value of the a field.
+ * @param {number} value The value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.setA = function(value) {
+ this.set$Value(17, value);
+};
+
+
+/**
+ * @return {boolean} Whether the a field has a value.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.hasA = function() {
+ return this.has$Value(17);
+};
+
+
+/**
+ * @return {number} The number of values in the a field.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.aCount = function() {
+ return this.count$Values(17);
+};
+
+
+/**
+ * Clears the values in the a field.
+ */
+proto2.TestAllTypes.OptionalGroup.prototype.clearA = function() {
+ this.clear$Field(17);
+};
+
+
+
+/**
+ * Message RepeatedGroup.
+ * @constructor
+ * @extends {goog.proto2.Message}
+ */
+proto2.TestAllTypes.RepeatedGroup = function() {
+ goog.proto2.Message.apply(this);
+};
+goog.inherits(proto2.TestAllTypes.RepeatedGroup, goog.proto2.Message);
+
+
+/**
+ * Overrides {@link goog.proto2.Message#clone} to specify its exact return type.
+ * @return {!proto2.TestAllTypes.RepeatedGroup} The cloned message.
+ * @override
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.clone;
+
+
+/**
+ * Gets the value of the a field at the index given.
+ * @param {number} index The index to lookup.
+ * @return {?number} The value.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.getA = function(index) {
+ return /** @type {?number} */ (this.get$Value(47, index));
+};
+
+
+/**
+ * Gets the value of the a field at the index given or the default value if not set.
+ * @param {number} index The index to lookup.
+ * @return {number} The value.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.getAOrDefault = function(index) {
+ return /** @type {number} */ (this.get$ValueOrDefault(47, index));
+};
+
+
+/**
+ * Adds a value to the a field.
+ * @param {number} value The value to add.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.addA = function(value) {
+ this.add$Value(47, value);
+};
+
+
+/**
+ * Returns the array of values in the a field.
+ * @return {!Array.<number>} The values in the field.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.aArray = function() {
+ return /** @type {!Array.<number>} */ (this.array$Values(47));
+};
+
+
+/**
+ * @return {boolean} Whether the a field has a value.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.hasA = function() {
+ return this.has$Value(47);
+};
+
+
+/**
+ * @return {number} The number of values in the a field.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.aCount = function() {
+ return this.count$Values(47);
+};
+
+
+/**
+ * Clears the values in the a field.
+ */
+proto2.TestAllTypes.RepeatedGroup.prototype.clearA = function() {
+ this.clear$Field(47);
+};
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes, {
+ 0: {
+ name: 'TestAllTypes',
+ fullName: 'TestAllTypes'
+ },
+ 1: {
+ name: 'optional_int32',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ },
+ 2: {
+ name: 'optional_int64',
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ defaultValue: '1',
+ type: String
+ },
+ 3: {
+ name: 'optional_uint32',
+ fieldType: goog.proto2.Message.FieldType.UINT32,
+ type: Number
+ },
+ 4: {
+ name: 'optional_uint64',
+ fieldType: goog.proto2.Message.FieldType.UINT64,
+ type: String
+ },
+ 5: {
+ name: 'optional_sint32',
+ fieldType: goog.proto2.Message.FieldType.SINT32,
+ type: Number
+ },
+ 6: {
+ name: 'optional_sint64',
+ fieldType: goog.proto2.Message.FieldType.SINT64,
+ type: String
+ },
+ 7: {
+ name: 'optional_fixed32',
+ fieldType: goog.proto2.Message.FieldType.FIXED32,
+ type: Number
+ },
+ 8: {
+ name: 'optional_fixed64',
+ fieldType: goog.proto2.Message.FieldType.FIXED64,
+ type: String
+ },
+ 9: {
+ name: 'optional_sfixed32',
+ fieldType: goog.proto2.Message.FieldType.SFIXED32,
+ type: Number
+ },
+ 10: {
+ name: 'optional_sfixed64',
+ fieldType: goog.proto2.Message.FieldType.SFIXED64,
+ type: String
+ },
+ 11: {
+ name: 'optional_float',
+ fieldType: goog.proto2.Message.FieldType.FLOAT,
+ defaultValue: 1.5,
+ type: Number
+ },
+ 12: {
+ name: 'optional_double',
+ fieldType: goog.proto2.Message.FieldType.DOUBLE,
+ type: Number
+ },
+ 13: {
+ name: 'optional_bool',
+ fieldType: goog.proto2.Message.FieldType.BOOL,
+ type: Boolean
+ },
+ 14: {
+ name: 'optional_string',
+ fieldType: goog.proto2.Message.FieldType.STRING,
+ type: String
+ },
+ 15: {
+ name: 'optional_bytes',
+ fieldType: goog.proto2.Message.FieldType.BYTES,
+ defaultValue: 'moo',
+ type: String
+ },
+ 16: {
+ name: 'optionalgroup',
+ fieldType: goog.proto2.Message.FieldType.GROUP,
+ type: proto2.TestAllTypes.OptionalGroup
+ },
+ 18: {
+ name: 'optional_nested_message',
+ fieldType: goog.proto2.Message.FieldType.MESSAGE,
+ type: proto2.TestAllTypes.NestedMessage
+ },
+ 21: {
+ name: 'optional_nested_enum',
+ fieldType: goog.proto2.Message.FieldType.ENUM,
+ defaultValue: proto2.TestAllTypes.NestedEnum.FOO,
+ type: proto2.TestAllTypes.NestedEnum
+ },
+ 50: {
+ name: 'optional_int64_number',
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ defaultValue: 1000000000000000001,
+ type: Number
+ },
+ 51: {
+ name: 'optional_int64_string',
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ defaultValue: '1000000000000000001',
+ type: String
+ },
+ 31: {
+ name: 'repeated_int32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ },
+ 32: {
+ name: 'repeated_int64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ type: String
+ },
+ 33: {
+ name: 'repeated_uint32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.UINT32,
+ type: Number
+ },
+ 34: {
+ name: 'repeated_uint64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.UINT64,
+ type: String
+ },
+ 35: {
+ name: 'repeated_sint32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SINT32,
+ type: Number
+ },
+ 36: {
+ name: 'repeated_sint64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SINT64,
+ type: String
+ },
+ 37: {
+ name: 'repeated_fixed32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.FIXED32,
+ type: Number
+ },
+ 38: {
+ name: 'repeated_fixed64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.FIXED64,
+ type: String
+ },
+ 39: {
+ name: 'repeated_sfixed32',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SFIXED32,
+ type: Number
+ },
+ 40: {
+ name: 'repeated_sfixed64',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.SFIXED64,
+ type: String
+ },
+ 41: {
+ name: 'repeated_float',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.FLOAT,
+ type: Number
+ },
+ 42: {
+ name: 'repeated_double',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.DOUBLE,
+ type: Number
+ },
+ 43: {
+ name: 'repeated_bool',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.BOOL,
+ type: Boolean
+ },
+ 44: {
+ name: 'repeated_string',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.STRING,
+ type: String
+ },
+ 45: {
+ name: 'repeated_bytes',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.BYTES,
+ type: String
+ },
+ 46: {
+ name: 'repeatedgroup',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.GROUP,
+ type: proto2.TestAllTypes.RepeatedGroup
+ },
+ 48: {
+ name: 'repeated_nested_message',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.MESSAGE,
+ type: proto2.TestAllTypes.NestedMessage
+ },
+ 49: {
+ name: 'repeated_nested_enum',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.ENUM,
+ defaultValue: proto2.TestAllTypes.NestedEnum.FOO,
+ type: proto2.TestAllTypes.NestedEnum
+ },
+ 52: {
+ name: 'repeated_int64_number',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ type: Number
+ },
+ 53: {
+ name: 'repeated_int64_string',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT64,
+ type: String
+ }
+});
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes.NestedMessage, {
+ 0: {
+ name: 'NestedMessage',
+ containingType: proto2.TestAllTypes,
+ fullName: 'TestAllTypes.NestedMessage'
+ },
+ 1: {
+ name: 'b',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ }
+});
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes.OptionalGroup, {
+ 0: {
+ name: 'OptionalGroup',
+ containingType: proto2.TestAllTypes,
+ fullName: 'TestAllTypes.OptionalGroup'
+ },
+ 17: {
+ name: 'a',
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ }
+});
+
+
+goog.proto2.Message.set$Metadata(proto2.TestAllTypes.RepeatedGroup, {
+ 0: {
+ name: 'RepeatedGroup',
+ containingType: proto2.TestAllTypes,
+ fullName: 'TestAllTypes.RepeatedGroup'
+ },
+ 47: {
+ name: 'a',
+ repeated: true,
+ fieldType: goog.proto2.Message.FieldType.INT32,
+ type: Number
+ }
+});
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer.js b/contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer.js
new file mode 100644
index 0000000..aa147a1
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer.js
@@ -0,0 +1,965 @@
+// Copyright 2011 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Protocol Buffer 2 Serializer which serializes messages
+ * into a user-friendly text format. Note that this code can run a bit
+ * slowly (especially for parsing) and should therefore not be used for
+ * time or space-critical applications.
+ *
+ * @see http://goo.gl/QDmDr
+ */
+
+goog.provide('goog.proto2.TextFormatSerializer');
+goog.provide('goog.proto2.TextFormatSerializer.Parser');
+
+goog.require('goog.json');
+goog.require('goog.proto2.Serializer');
+goog.require('goog.proto2.Util');
+goog.require('goog.string');
+
+
+
+/**
+ * TextFormatSerializer, a serializer which turns Messages into the human
+ * readable text format.
+ * @param {boolean=} opt_ignoreMissingFields If true, then fields that cannot be
+ * found on the proto when parsing the text format will be ignored.
+ * @constructor
+ * @extends {goog.proto2.Serializer}
+ */
+goog.proto2.TextFormatSerializer = function(opt_ignoreMissingFields) {
+ /**
+ * Whether to ignore fields not defined on the proto when parsing the text
+ * format.
+ * @type {boolean}
+ * @private
+ */
+ this.ignoreMissingFields_ = !!opt_ignoreMissingFields;
+};
+goog.inherits(goog.proto2.TextFormatSerializer, goog.proto2.Serializer);
+
+
+/**
+ * Deserializes a message from text format and places the data in the message.
+ * @param {goog.proto2.Message} message The message in which to
+ * place the information.
+ * @param {string} data The text format data.
+ * @return {?string} The parse error or null on success.
+ */
+goog.proto2.TextFormatSerializer.prototype.deserializeTo =
+ function(message, data) {
+ var descriptor = message.getDescriptor();
+ var textData = data.toString();
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ if (!parser.parse(message, textData, this.ignoreMissingFields_)) {
+ return parser.getError();
+ }
+
+ return null;
+};
+
+
+/**
+ * Serializes a message to a string.
+ * @param {goog.proto2.Message} message The message to be serialized.
+ * @return {string} The serialized form of the message.
+ */
+goog.proto2.TextFormatSerializer.prototype.serialize = function(message) {
+ var printer = new goog.proto2.TextFormatSerializer.Printer_();
+ this.serializeMessage_(message, printer);
+ return printer.toString();
+};
+
+
+/**
+ * Serializes the message and prints the text form into the given printer.
+ * @param {goog.proto2.Message} message The message to serialize.
+ * @param {goog.proto2.TextFormatSerializer.Printer_} printer The printer to
+ * which the text format will be printed.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.prototype.serializeMessage_ =
+ function(message, printer) {
+ var descriptor = message.getDescriptor();
+ var fields = descriptor.getFields();
+
+ // Add the defined fields, recursively.
+ goog.array.forEach(fields, function(field) {
+ this.printField_(message, field, printer);
+ }, this);
+
+ // Add the unknown fields, if any.
+ message.forEachUnknown(function(tag, value) {
+ if (!value) { return; }
+
+ printer.append(tag);
+ if (goog.typeOf(value) == 'object') {
+ printer.append(' {');
+ printer.appendLine();
+ printer.indent();
+ } else {
+ printer.append(': ');
+ }
+
+ switch (goog.typeOf(value)) {
+ case 'string':
+ value = goog.string.quote(value);
+ printer.append(value);
+ break;
+
+ case 'object':
+ this.serializeMessage_(value, printer);
+ break;
+
+ default:
+ printer.append(value.toString());
+ break;
+ }
+
+ if (goog.typeOf(value) == 'object') {
+ printer.dedent();
+ printer.append('}');
+ } else {
+ printer.appendLine();
+ }
+ }, this);
+};
+
+
+/**
+ * Prints the serialized value for the given field to the printer.
+ * @param {*} value The field's value.
+ * @param {goog.proto2.FieldDescriptor} field The field whose value is being
+ * printed.
+ * @param {goog.proto2.TextFormatSerializer.Printer_} printer The printer to
+ * which the value will be printed.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.prototype.printFieldValue_ =
+ function(value, field, printer) {
+ switch (field.getFieldType()) {
+ case goog.proto2.FieldDescriptor.FieldType.DOUBLE:
+ case goog.proto2.FieldDescriptor.FieldType.FLOAT:
+ case goog.proto2.FieldDescriptor.FieldType.INT64:
+ case goog.proto2.FieldDescriptor.FieldType.UINT64:
+ case goog.proto2.FieldDescriptor.FieldType.INT32:
+ case goog.proto2.FieldDescriptor.FieldType.UINT32:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.BOOL:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SINT32:
+ case goog.proto2.FieldDescriptor.FieldType.SINT64:
+ printer.append(value);
+ break;
+
+ case goog.proto2.FieldDescriptor.FieldType.BYTES:
+ case goog.proto2.FieldDescriptor.FieldType.STRING:
+ value = goog.string.quote(value.toString());
+ printer.append(value);
+ break;
+
+ case goog.proto2.FieldDescriptor.FieldType.ENUM:
+ // Search the enum type for a matching key.
+ var found = false;
+ goog.object.forEach(field.getNativeType(), function(eValue, key) {
+ if (eValue == value) {
+ printer.append(key);
+ found = true;
+ }
+ });
+
+ if (!found) {
+ // Otherwise, just print the numeric value.
+ printer.append(value.toString());
+ }
+ break;
+
+ case goog.proto2.FieldDescriptor.FieldType.GROUP:
+ case goog.proto2.FieldDescriptor.FieldType.MESSAGE:
+ this.serializeMessage_(
+ (/** @type {goog.proto2.Message} */value), printer);
+ break;
+ }
+};
+
+
+/**
+ * Prints the serialized field to the printer.
+ * @param {goog.proto2.Message} message The parent message.
+ * @param {goog.proto2.FieldDescriptor} field The field to print.
+ * @param {goog.proto2.TextFormatSerializer.Printer_} printer The printer to
+ * which the field will be printed.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.prototype.printField_ =
+ function(message, field, printer) {
+ // Skip fields not present.
+ if (!message.has(field)) {
+ return;
+ }
+
+ var count = message.countOf(field);
+ for (var i = 0; i < count; ++i) {
+ // Field name.
+ printer.append(field.getName());
+
+ // Field delimiter.
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.GROUP) {
+ printer.append(' {');
+ printer.appendLine();
+ printer.indent();
+ } else {
+ printer.append(': ');
+ }
+
+ // Write the field value.
+ this.printFieldValue_(message.get(field, i), field, printer);
+
+ // Close the field.
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.GROUP) {
+ printer.dedent();
+ printer.append('}');
+ printer.appendLine();
+ } else {
+ printer.appendLine();
+ }
+ }
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
+/**
+ * Helper class used by the text format serializer for pretty-printing text.
+ * @constructor
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Printer_ = function() {
+ /**
+ * The current indentation count.
+ * @type {number}
+ * @private
+ */
+ this.indentation_ = 0;
+
+ /**
+ * The buffer of string pieces.
+ * @type {Array.<string>}
+ * @private
+ */
+ this.buffer_ = [];
+
+ /**
+ * Whether indentation is required before the next append of characters.
+ * @type {boolean}
+ * @private
+ */
+ this.requiresIndentation_ = true;
+};
+
+
+/**
+ * @return {string} The contents of the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.toString = function() {
+ return this.buffer_.join('');
+};
+
+
+/**
+ * Increases the indentation in the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.indent = function() {
+ this.indentation_ += 2;
+};
+
+
+/**
+ * Decreases the indentation in the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.dedent = function() {
+ this.indentation_ -= 2;
+ goog.asserts.assert(this.indentation_ >= 0);
+};
+
+
+/**
+ * Appends the given value to the printer.
+ * @param {*} value The value to append.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.append = function(value) {
+ if (this.requiresIndentation_) {
+ for (var i = 0; i < this.indentation_; ++i) {
+ this.buffer_.push(' ');
+ }
+ this.requiresIndentation_ = false;
+ }
+
+ this.buffer_.push(value.toString());
+};
+
+
+/**
+ * Appends a newline to the printer.
+ */
+goog.proto2.TextFormatSerializer.Printer_.prototype.appendLine = function() {
+ this.buffer_.push('\n');
+ this.requiresIndentation_ = true;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
+/**
+ * Helper class for tokenizing the text format.
+ * @param {string} data The string data to tokenize.
+ * @param {boolean=} opt_ignoreWhitespace If true, whitespace tokens will not
+ * be reported by the tokenizer.
+ * @constructor
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_ =
+ function(data, opt_ignoreWhitespace) {
+
+ /**
+ * Whether to skip whitespace tokens on output.
+ * @type {boolean}
+ * @private
+ */
+ this.ignoreWhitespace_ = !!opt_ignoreWhitespace;
+
+ /**
+ * The data being tokenized.
+ * @type {string}
+ * @private
+ */
+ this.data_ = data;
+
+ /**
+ * The current index in the data.
+ * @type {number}
+ * @private
+ */
+ this.index_ = 0;
+
+ /**
+ * The data string starting at the current index.
+ * @type {string}
+ * @private
+ */
+ this.currentData_ = data;
+
+ /**
+ * The current token type.
+ * @type {goog.proto2.TextFormatSerializer.Tokenizer_.Token}
+ * @private
+ */
+ this.current_ = {
+ type: goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes.END,
+ value: null
+ };
+};
+
+
+/**
+ * @typedef {{type: goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes,
+ * value: ?string}}
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.Token;
+
+
+/**
+ * @return {goog.proto2.TextFormatSerializer.Tokenizer_.Token} The current
+ * token.
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.prototype.getCurrent = function() {
+ return this.current_;
+};
+
+
+/**
+ * An enumeration of all the token types.
+ * @enum {*}
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes = {
+ END: /---end---/,
+ IDENTIFIER: /^[a-zA-Z][a-zA-Z0-9_]*/,
+ NUMBER: /^(0x[0-9a-f]+)|(([-])?[0-9][0-9]*(\.?[0-9]+)?([f])?)/,
+ COMMENT: /^#.*/,
+ OPEN_BRACE: /^{/,
+ CLOSE_BRACE: /^}/,
+ OPEN_TAG: /^</,
+ CLOSE_TAG: /^>/,
+ OPEN_LIST: /^\[/,
+ CLOSE_LIST: /^\]/,
+ STRING: new RegExp('^"([^"\\\\]|\\\\.)*"'),
+ COLON: /^:/,
+ COMMA: /^,/,
+ SEMI: /^;/,
+ WHITESPACE: /^\s/
+};
+
+
+/**
+ * Advances to the next token.
+ * @return {boolean} True if a valid token was found, false if the end was
+ * reached or no valid token was found.
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.prototype.next = function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+
+ // Skip any whitespace if requested.
+ while (this.nextInternal_()) {
+ if (this.getCurrent().type != types.WHITESPACE || !this.ignoreWhitespace_) {
+ return true;
+ }
+ }
+
+ // If we reach this point, set the current token to END.
+ this.current_ = {
+ type: goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes.END,
+ value: null
+ };
+
+ return false;
+};
+
+
+/**
+ * Internal method for determining the next token.
+ * @return {boolean} True if a next token was found, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Tokenizer_.prototype.nextInternal_ =
+ function() {
+ if (this.index_ >= this.data_.length) {
+ return false;
+ }
+
+ var data = this.currentData_;
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ var next = null;
+
+ // Loop through each token type and try to match the beginning of the string
+ // with the token's regular expression.
+ goog.object.forEach(types, function(type, id) {
+ if (next || type == types.END) {
+ return;
+ }
+
+ // Note: This regular expression check is at, minimum, O(n).
+ var info = type.exec(data);
+ if (info && info.index == 0) {
+ next = {
+ type: type,
+ value: info[0]
+ };
+ }
+ });
+
+ // Advance the index by the length of the token.
+ if (next) {
+ this.current_ =
+ (/** @type {goog.proto2.TextFormatSerializer.Tokenizer_.Token} */next);
+ this.index_ += next.value.length;
+ this.currentData_ = this.currentData_.substring(next.value.length);
+ }
+
+ return !!next;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+
+/**
+ * Helper class for parsing the text format.
+ * @constructor
+ */
+goog.proto2.TextFormatSerializer.Parser = function() {
+ /**
+ * The error during parsing, if any.
+ * @type {?string}
+ * @private
+ */
+ this.error_ = null;
+
+ /**
+ * The current tokenizer.
+ * @type {goog.proto2.TextFormatSerializer.Tokenizer_}
+ * @private
+ */
+ this.tokenizer_ = null;
+
+ /**
+ * Whether to ignore missing fields in the proto when parsing.
+ * @type {boolean}
+ * @private
+ */
+ this.ignoreMissingFields_ = false;
+};
+
+
+/**
+ * Parses the given data, filling the message as it goes.
+ * @param {goog.proto2.Message} message The message to fill.
+ * @param {string} data The text format data.
+ * @param {boolean=} opt_ignoreMissingFields If true, fields missing in the
+ * proto will be ignored.
+ * @return {boolean} True on success, false on failure. On failure, the
+ * getError method can be called to get the reason for failure.
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.parse =
+ function(message, data, opt_ignoreMissingFields) {
+ this.error_ = null;
+ this.ignoreMissingFields_ = !!opt_ignoreMissingFields;
+ this.tokenizer_ = new goog.proto2.TextFormatSerializer.Tokenizer_(data, true);
+ this.tokenizer_.next();
+ return this.consumeMessage_(message, '');
+};
+
+
+/**
+ * @return {?string} The parse error, if any.
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.getError = function() {
+ return this.error_;
+};
+
+
+/**
+ * Reports a parse error.
+ * @param {string} msg The error message.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.reportError_ =
+ function(msg) {
+ this.error_ = msg;
+};
+
+
+/**
+ * Attempts to consume the given message.
+ * @param {goog.proto2.Message} message The message to consume and fill. If
+ * null, then the message contents will be consumed without ever being set
+ * to anything.
+ * @param {string} delimiter The delimiter expected at the end of the message.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeMessage_ =
+ function(message, delimiter) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ while (!this.lookingAt_('>') && !this.lookingAt_('}') &&
+ !this.lookingAtType_(types.END)) {
+ if (!this.consumeField_(message)) { return false; }
+ }
+
+ if (delimiter) {
+ if (!this.consume_(delimiter)) { return false; }
+ } else {
+ if (!this.lookingAtType_(types.END)) {
+ this.reportError_('Expected END token');
+ }
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to consume the value of the given field.
+ * @param {goog.proto2.Message} message The parent message.
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeFieldValue_ =
+ function(message, field) {
+ var value = this.getFieldValue_(field);
+ if (goog.isNull(value)) { return false; }
+
+ if (field.isRepeated()) {
+ message.add(field, value);
+ } else {
+ message.set(field, value);
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to convert a string to a number.
+ * @param {string} num in hexadecimal or float format.
+ * @return {?number} The converted number or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.getNumberFromString_ =
+ function(num) {
+ var numberString = num;
+ var numberBase = 10;
+ if (num.substr(0, 2) == '0x') {
+ // ASCII output can be printed in unsigned hexadecimal format
+ // occasionally. e.g. 0xaed9b43
+ numberString = num.substr(2);
+ numberBase = 16;
+ } else if (goog.string.endsWith(num, 'f')) {
+ numberString = num.substring(0, num.length - 1);
+ }
+
+ var actualNumber = numberBase == 10 ?
+ parseFloat(numberString) : parseInt(numberString, numberBase);
+ if (actualNumber.toString(numberBase) != numberString) {
+ this.reportError_('Unknown number: ' + num);
+ return null;
+ }
+ return actualNumber;
+};
+
+
+/**
+ * Attempts to parse the given field's value from the stream.
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @return {*} The field's value or null if none.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.getFieldValue_ =
+ function(field) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ switch (field.getFieldType()) {
+ case goog.proto2.FieldDescriptor.FieldType.DOUBLE:
+ case goog.proto2.FieldDescriptor.FieldType.FLOAT:
+ case goog.proto2.FieldDescriptor.FieldType.INT32:
+ case goog.proto2.FieldDescriptor.FieldType.UINT32:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED32:
+ case goog.proto2.FieldDescriptor.FieldType.SINT32:
+ var num = this.consumeNumber_();
+ if (!num) { return null; }
+
+ return this.getNumberFromString_(num);
+
+ case goog.proto2.FieldDescriptor.FieldType.INT64:
+ case goog.proto2.FieldDescriptor.FieldType.UINT64:
+ case goog.proto2.FieldDescriptor.FieldType.FIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SFIXED64:
+ case goog.proto2.FieldDescriptor.FieldType.SINT64:
+ var num = this.consumeNumber_();
+ if (!num) { return null; }
+
+ if (field.getNativeType() == Number) {
+ // 64-bit number stored as a number.
+ return this.getNumberFromString_(num);
+ }
+
+ return num; // 64-bit numbers are by default stored as strings.
+
+ case goog.proto2.FieldDescriptor.FieldType.BOOL:
+ var ident = this.consumeIdentifier_();
+ if (!ident) { return null; }
+
+ switch (ident) {
+ case 'true': return true;
+ case 'false': return false;
+ default:
+ this.reportError_('Unknown type for bool: ' + ident);
+ return null;
+ }
+
+ case goog.proto2.FieldDescriptor.FieldType.ENUM:
+ if (this.lookingAtType_(types.NUMBER)) {
+ return this.consumeNumber_();
+ } else {
+ // Search the enum type for a matching key.
+ var name = this.consumeIdentifier_();
+ if (!name) {
+ return null;
+ }
+
+ var enumValue = field.getNativeType()[name];
+ if (enumValue == null) {
+ this.reportError_('Unknown enum value: ' + name);
+ return null;
+ }
+
+ return enumValue;
+ }
+
+ case goog.proto2.FieldDescriptor.FieldType.BYTES:
+ case goog.proto2.FieldDescriptor.FieldType.STRING:
+ return this.consumeString_();
+ }
+};
+
+
+/**
+ * Attempts to consume a nested message.
+ * @param {goog.proto2.Message} message The parent message.
+ * @param {goog.proto2.FieldDescriptor} field The field.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeNestedMessage_ =
+ function(message, field) {
+ var delimiter = '';
+
+ // Messages support both < > and { } as delimiters for legacy reasons.
+ if (this.tryConsume_('<')) {
+ delimiter = '>';
+ } else {
+ if (!this.consume_('{')) { return false; }
+ delimiter = '}';
+ }
+
+ var msg = field.getFieldMessageType().createMessageInstance();
+ var result = this.consumeMessage_(msg, delimiter);
+ if (!result) { return false; }
+
+ // Add the message to the parent message.
+ if (field.isRepeated()) {
+ message.add(field, msg);
+ } else {
+ message.set(field, msg);
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to consume the value of an unknown field. This method uses
+ * heuristics to try to consume just the right tokens.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeUnknownFieldValue_ =
+ function() {
+ // : is optional.
+ this.tryConsume_(':');
+
+ // Handle form: [.. , ... , ..]
+ if (this.tryConsume_('[')) {
+ while (true) {
+ this.tokenizer_.next();
+ if (this.tryConsume_(']')) {
+ break;
+ }
+ if (!this.consume_(',')) { return false; }
+ }
+
+ return true;
+ }
+
+ // Handle nested messages/groups.
+ if (this.tryConsume_('<')) {
+ return this.consumeMessage_(null /* unknown */, '>');
+ } else if (this.tryConsume_('{')) {
+ return this.consumeMessage_(null /* unknown */, '}');
+ } else {
+ // Otherwise, consume a single token for the field value.
+ this.tokenizer_.next();
+ }
+
+ return true;
+};
+
+
+/**
+ * Attempts to consume a field under a message.
+ * @param {goog.proto2.Message} message The parent message. If null, then the
+ * field value will be consumed without being assigned to anything.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeField_ =
+ function(message) {
+ var fieldName = this.consumeIdentifier_();
+ if (!fieldName) {
+ this.reportError_('Missing field name');
+ return false;
+ }
+
+ var field = null;
+ if (message) {
+ field = message.getDescriptor().findFieldByName(fieldName.toString());
+ }
+
+ if (field == null) {
+ if (this.ignoreMissingFields_) {
+ return this.consumeUnknownFieldValue_();
+ } else {
+ this.reportError_('Unknown field: ' + fieldName);
+ return false;
+ }
+ }
+
+ if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.MESSAGE ||
+ field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.GROUP) {
+ // : is optional here.
+ this.tryConsume_(':');
+ if (!this.consumeNestedMessage_(message, field)) { return false; }
+ } else {
+ // Long Format: "someField: 123"
+ // Short Format: "someField: [123, 456, 789]"
+ if (!this.consume_(':')) { return false; }
+
+ if (field.isRepeated() && this.tryConsume_('[')) {
+ // Short repeated format, e.g. "foo: [1, 2, 3]"
+ while (true) {
+ if (!this.consumeFieldValue_(message, field)) { return false; }
+ if (this.tryConsume_(']')) {
+ break;
+ }
+ if (!this.consume_(',')) { return false; }
+ }
+ } else {
+ // Normal field format.
+ if (!this.consumeFieldValue_(message, field)) { return false; }
+ }
+ }
+
+ // For historical reasons, fields may optionally be separated by commas or
+ // semicolons.
+ this.tryConsume_(',') || this.tryConsume_(';');
+ return true;
+};
+
+
+/**
+ * Attempts to consume a token with the given string value.
+ * @param {string} value The string value for the token.
+ * @return {boolean} True if the token matches and was consumed, false
+ * otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.tryConsume_ =
+ function(value) {
+ if (this.lookingAt_(value)) {
+ this.tokenizer_.next();
+ return true;
+ }
+ return false;
+};
+
+
+/**
+ * Consumes a token of the given type.
+ * @param {goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes} type The type
+ * of the token to consume.
+ * @return {?string} The string value of the token or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeToken_ =
+ function(type) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ if (!this.lookingAtType_(type)) {
+ this.reportError_('Expected token type: ' + type);
+ return null;
+ }
+
+ var value = this.tokenizer_.getCurrent().value;
+ this.tokenizer_.next();
+ return value;
+};
+
+
+/**
+ * Consumes an IDENTIFIER token.
+ * @return {?string} The string value or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeIdentifier_ =
+ function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ return this.consumeToken_(types.IDENTIFIER);
+};
+
+
+/**
+ * Consumes a NUMBER token.
+ * @return {?string} The string value or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeNumber_ =
+ function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ return this.consumeToken_(types.NUMBER);
+};
+
+
+/**
+ * Consumes a STRING token.
+ * @return {?string} The *deescaped* string value or null on error.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consumeString_ =
+ function() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ var value = this.consumeToken_(types.STRING);
+ if (!value) {
+ return null;
+ }
+
+ return goog.json.parse(value).toString();
+};
+
+
+/**
+ * Consumes a token with the given value. If not found, reports an error.
+ * @param {string} value The string value expected for the token.
+ * @return {boolean} True on success, false otherwise.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.consume_ = function(value) {
+ if (!this.tryConsume_(value)) {
+ this.reportError_('Expected token "' + value + '"');
+ return false;
+ }
+
+ return true;
+};
+
+
+/**
+ * @param {string} value The value to check against.
+ * @return {boolean} True if the current token has the given string value.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.lookingAt_ =
+ function(value) {
+ return this.tokenizer_.getCurrent().value == value;
+};
+
+
+/**
+ * @param {goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes} type The
+ * token type.
+ * @return {boolean} True if the current token has the given type.
+ * @private
+ */
+goog.proto2.TextFormatSerializer.Parser.prototype.lookingAtType_ =
+ function(type) {
+ return this.tokenizer_.getCurrent().type == type;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer_test.html b/contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer_test.html
new file mode 100644
index 0000000..0879654
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/textformatserializer_test.html
@@ -0,0 +1,530 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2011 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<!--
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.proto2 - textformatserializer.js</title>
+<script src="../base.js"></script>
+<script>
+ goog.require('goog.proto2.TextFormatSerializer');
+ goog.require('goog.testing.jsunit');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testSerialization() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalUint32(103);
+ message.setOptionalSint32(105);
+ message.setOptionalFixed32(107);
+ message.setOptionalSfixed32(109);
+ message.setOptionalInt64('102');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ // Serialize to a simplified text format.
+ var simplified = new goog.proto2.TextFormatSerializer().serialize(message);
+ var expected = 'optional_int32: 101\n' +
+ 'optional_int64: 102\n' +
+ 'optional_uint32: 103\n' +
+ 'optional_sint32: 105\n' +
+ 'optional_fixed32: 107\n' +
+ 'optional_sfixed32: 109\n' +
+ 'optional_float: 111.5\n' +
+ 'optional_double: 112.5\n' +
+ 'optional_bool: true\n' +
+ 'optional_string: "test"\n' +
+ 'optional_bytes: "abcd"\n' +
+ 'optionalgroup {\n' +
+ ' a: 111\n' +
+ '}\n' +
+ 'optional_nested_message {\n' +
+ ' b: 112\n' +
+ '}\n' +
+ 'optional_nested_enum: FOO\n' +
+ 'repeated_int32: 201\n' +
+ 'repeated_int32: 202\n';
+
+ assertEquals(expected, simplified);
+}
+
+function testSerializationOfUnknown() {
+ var nestedUnknown = new proto2.TestAllTypes();
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Known.
+ message.setOptionalInt32(101);
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+
+ nestedUnknown.addRepeatedInt32(301);
+ nestedUnknown.addRepeatedInt32(302);
+
+ // Unknown.
+ message.setUnknown(1000, 301);
+ message.setUnknown(1001, 302);
+ message.setUnknown(1002, 'hello world');
+ message.setUnknown(1002, nestedUnknown);
+
+ nestedUnknown.setUnknown(2000, 401);
+
+ // Serialize.
+ var simplified = new goog.proto2.TextFormatSerializer().serialize(message);
+ var expected = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'repeated_int32: 202\n' +
+ '1000: 301\n' +
+ '1001: 302\n' +
+ '1002 {\n' +
+ ' repeated_int32: 301\n' +
+ ' repeated_int32: 302\n' +
+ ' 2000: 401\n' +
+ '}';
+
+ assertEquals(expected, simplified);
+}
+
+/**
+ * Asserts that the given string value parses into the given set of tokens.
+ * @param {string} value The string value to parse.
+ * @param {Array.<Token> | Token} tokens The tokens to check against. If not
+ * an array, a single token is expected.
+ * @param {boolean=} opt_ignoreWhitespace Whether whitespace tokens should be
+ * skipped by the tokenizer.
+ */
+function assertTokens(value, tokens, opt_ignoreWhitespace) {
+ var tokenizer = new goog.proto2.TextFormatSerializer.Tokenizer_(
+ value, opt_ignoreWhitespace);
+ var tokensFound = [];
+
+ while (tokenizer.next()) {
+ tokensFound.push(tokenizer.getCurrent());
+ }
+
+ if (goog.typeOf(tokens) != 'array') {
+ tokens = [tokens];
+ }
+
+ assertEquals(tokens.length, tokensFound.length);
+ for (var i = 0; i < tokens.length; ++i) {
+ assertToken(tokens[i], tokensFound[i]);
+ }
+}
+
+function assertToken(expected, found) {
+ assertEquals(expected.type, found.type);
+ if (expected.value) {
+ assertEquals(expected.value, found.value);
+ }
+}
+
+function testTokenizer() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens('{ 123 }', [
+ { type: types.OPEN_BRACE },
+ { type: types.WHITESPACE, value: ' ' },
+ { type: types.NUMBER, value: '123' },
+ { type: types.WHITESPACE, value: ' '},
+ { type: types.CLOSE_BRACE }
+ ]);
+}
+
+function testTokenizerNoWhitespace() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens('{ "hello world" }', [
+ { type: types.OPEN_BRACE },
+ { type: types.STRING, value: '"hello world"' },
+ { type: types.CLOSE_BRACE }
+ ], true);
+}
+
+
+function assertIdentifier(identifier) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(identifier, { type: types.IDENTIFIER, value: identifier });
+}
+
+function assertComment(comment) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(comment, { type: types.COMMENT, value: comment });
+}
+
+function assertString(str) {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(str, { type: types.STRING, value: str });
+}
+
+function assertNumber(num) {
+ num = num.toString();
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens(num, { type: types.NUMBER, value: num });
+}
+
+function testTokenizerSingleTokens() {
+ var types = goog.proto2.TextFormatSerializer.Tokenizer_.TokenTypes;
+ assertTokens('{', { type: types.OPEN_BRACE });
+ assertTokens('}', { type: types.CLOSE_BRACE });
+ assertTokens('<', { type: types.OPEN_TAG });
+ assertTokens('>', { type: types.CLOSE_TAG });
+ assertTokens(':', { type: types.COLON });
+ assertTokens(',', { type: types.COMMA });
+ assertTokens(';', { type: types.SEMI });
+
+ assertIdentifier('abcd');
+ assertIdentifier('Abcd');
+ assertIdentifier('ABcd');
+ assertIdentifier('ABcD');
+ assertIdentifier('a123nc');
+ assertIdentifier('a45_bC');
+ assertIdentifier('A45_bC');
+
+ assertIdentifier('inf');
+ assertIdentifier('infinity');
+ assertIdentifier('nan');
+
+ assertNumber(0);
+ assertNumber(10);
+ assertNumber(123);
+ assertNumber(1234);
+ assertNumber(123.56);
+ assertNumber(-124);
+ assertNumber(-1234);
+ assertNumber(-123.56);
+ assertNumber('123f');
+ assertNumber('123.6f');
+ assertNumber('-123f');
+ assertNumber('-123.8f');
+ assertNumber('0x1234');
+ assertNumber('0x12ac34');
+ assertNumber('0x49e281db686fb');
+
+ assertString('""');
+ assertString('"hello world"');
+ assertString('"hello # world"');
+ assertString('"hello #\\" world"');
+ assertString('"|"');
+ assertString('"\\"\\""');
+ assertString('"\\"foo\\""');
+ assertString('"\\"foo\\" and \\"bar\\""');
+ assertString('"foo \\"and\\" bar"');
+
+ assertComment('# foo bar baz');
+ assertComment('# foo ## bar baz');
+ assertComment('# foo "bar" baz');
+}
+
+function testSerializationOfStringWithQuotes() {
+ var nestedUnknown = new proto2.TestAllTypes();
+ var message = new proto2.TestAllTypes();
+ message.setOptionalString('hello "world"');
+
+ // Serialize.
+ var simplified = new goog.proto2.TextFormatSerializer().serialize(message);
+ var expected = 'optional_string: "hello \\"world\\""\n';
+ assertEquals(expected, simplified);
+}
+
+function testDeserialization() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationOfList() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: [201, 202]\n' +
+ 'optional_float: 123.4';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationOfIntegerAsHexadecimalString() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 0x1\n' +
+ 'optional_sint32: 0xf\n' +
+ 'optional_uint32: 0xffffffff\n' +
+ 'repeated_int32: [0x0, 0xff]\n';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(1, message.getOptionalInt32());
+ assertEquals(15, message.getOptionalSint32());
+ assertEquals(4294967295, message.getOptionalUint32());
+ assertEquals(0, message.getRepeatedInt32(0));
+ assertEquals(255, message.getRepeatedInt32(1));
+}
+
+function testDeserializationOfInt64AsHexadecimalString() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int64: 0xf';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals('0xf', message.getOptionalInt64());
+}
+
+function testDeserializationOfZeroFalseAndEmptyString() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 0\n' +
+ 'optional_bool: false\n' +
+ 'optional_string: ""';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(0, message.getOptionalInt32());
+ assertEquals(false, message.getOptionalBool());
+ assertEquals('', message.getOptionalString());
+}
+
+function testDeserializationSkipUnknown() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: true\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertTrue(parser.parse(message, value, true));
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationSkipUnknownList() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: [true, 1, 201, "hello"]\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertTrue(parser.parse(message, value, true));
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationSkipUnknownNested() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: <\n' +
+ ' a: 1\n' +
+ ' b: 2\n' +
+ '>\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertTrue(parser.parse(message, value, true));
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationSkipUnknownNestedInvalid() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: <\n' +
+ ' a: \n' + // Missing value.
+ ' b: 2\n' +
+ '>\n' +
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertFalse(parser.parse(message, value, true));
+}
+
+function testDeserializationSkipUnknownNestedInvalid2() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'repeated_int32: 201\n' +
+ 'some_unknown: <\n' +
+ ' a: 2\n' +
+ ' b: 2\n' +
+ '}\n' + // Delimiter mismatch
+ 'repeated_int32: 202\n' +
+ 'optional_float: 123.4';
+
+ var parser = new goog.proto2.TextFormatSerializer.Parser();
+ assertFalse(parser.parse(message, value, true));
+}
+
+
+function testDeserializationLegacyFormat() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101,\n' +
+ 'repeated_int32: 201,\n' +
+ 'repeated_int32: 202;\n' +
+ 'optional_float: 123.4';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(201, message.getRepeatedInt32(0));
+ assertEquals(202, message.getRepeatedInt32(1));
+ assertEquals(123.4, message.getOptionalFloat());
+}
+
+function testDeserializationError() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int33: 101\n';
+ var result =
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+ assertEquals(result, 'Unknown field: optional_int33');
+}
+
+function testNestedDeserialization() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'optional_nested_message: {\n' +
+ ' b: 301\n' +
+ '}';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(301, message.getOptionalNestedMessage().getB());
+}
+
+function testNestedDeserializationLegacyFormat() {
+ var message = new proto2.TestAllTypes();
+ var value = 'optional_int32: 101\n' +
+ 'optional_nested_message: <\n' +
+ ' b: 301\n' +
+ '>';
+
+ new goog.proto2.TextFormatSerializer().deserializeTo(message, value);
+
+ assertEquals(101, message.getOptionalInt32());
+ assertEquals(301, message.getOptionalNestedMessage().getB());
+}
+
+function testBidirectional() {
+ var message = new proto2.TestAllTypes();
+
+ // Set the fields.
+ // Singular.
+ message.setOptionalInt32(101);
+ message.setOptionalInt64('102');
+ message.setOptionalUint32(103);
+ message.setOptionalUint64('104');
+ message.setOptionalSint32(105);
+ message.setOptionalSint64('106');
+ message.setOptionalFixed32(107);
+ message.setOptionalFixed64('108');
+ message.setOptionalSfixed32(109);
+ message.setOptionalSfixed64('110');
+ message.setOptionalFloat(111.5);
+ message.setOptionalDouble(112.5);
+ message.setOptionalBool(true);
+ message.setOptionalString('test');
+ message.setOptionalBytes('abcd');
+
+ var group = new proto2.TestAllTypes.OptionalGroup();
+ group.setA(111);
+
+ message.setOptionalgroup(group);
+
+ var nestedMessage = new proto2.TestAllTypes.NestedMessage();
+ nestedMessage.setB(112);
+
+ message.setOptionalNestedMessage(nestedMessage);
+
+ message.setOptionalNestedEnum(proto2.TestAllTypes.NestedEnum.FOO);
+
+ // Repeated.
+ message.addRepeatedInt32(201);
+ message.addRepeatedInt32(202);
+ message.addRepeatedString('hello "world"');
+
+ // Serialize the message to text form.
+ var serializer = new goog.proto2.TextFormatSerializer();
+ var textform = serializer.serialize(message);
+
+ // Create a copy and deserialize into the copy.
+ var copy = new proto2.TestAllTypes();
+ serializer.deserializeTo(copy, textform);
+
+ // Assert that the messages are structurally equivalent.
+ assertTrue(copy.equals(message));
+}
+
+
+function testBidirectional64BitNumber() {
+ var message = new proto2.TestAllTypes();
+ message.setOptionalInt64Number(10000000);
+ message.setOptionalInt64String('200000000000000000');
+
+ // Serialize the message to text form.
+ var serializer = new goog.proto2.TextFormatSerializer();
+ var textform = serializer.serialize(message);
+
+ // Create a copy and deserialize into the copy.
+ var copy = new proto2.TestAllTypes();
+ serializer.deserializeTo(copy, textform);
+
+ // Assert that the messages are structurally equivalent.
+ assertTrue(copy.equals(message));
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/proto2/util.js b/contexts/data/lib/closure-library/closure/goog/proto2/util.js
new file mode 100644
index 0000000..cb60f9e
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/proto2/util.js
@@ -0,0 +1,54 @@
+// Copyright 2009 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Utility methods for Protocol Buffer 2 implementation.
+ */
+
+goog.provide('goog.proto2.Util');
+
+goog.require('goog.asserts');
+
+
+/**
+ * @define {boolean} Defines a PBCHECK constant that can be turned off by
+ * clients of PB2. This for is clients that do not want assertion/checking
+ * running even in non-COMPILED builds.
+ */
+goog.proto2.Util.PBCHECK = !COMPILED;
+
+
+/**
+ * Asserts that the given condition is true, if and only if the PBCHECK
+ * flag is on.
+ *
+ * @param {*} condition The condition to check.
+ * @param {string=} opt_message Error message in case of failure.
+ * @throws {Error} Assertion failed, the condition evaluates to false.
+ */
+goog.proto2.Util.assert = function(condition, opt_message) {
+ if (goog.proto2.Util.PBCHECK) {
+ goog.asserts.assert(condition, opt_message);
+ }
+};
+
+
+/**
+ * Returns true if debug assertions (checks) are on.
+ *
+ * @return {boolean} The value of the PBCHECK constant.
+ */
+goog.proto2.Util.conductChecks = function() {
+ return goog.proto2.Util.PBCHECK;
+};