• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1goog.module('protobuf.runtime.Storage');
2
3/**
4 * Interface for getting and storing fields of a protobuf message.
5 *
6 * @interface
7 * @package
8 * @template FieldType
9 */
10class Storage {
11  /**
12   * Returns the pivot value.
13   *
14   * @return {number}
15   */
16  getPivot() {}
17
18  /**
19   * Sets a field in the specified field number.
20   *
21   * @param {number} fieldNumber
22   * @param {!FieldType} field
23   */
24  set(fieldNumber, field) {}
25
26  /**
27   * Returns a field at the specified field number.
28   *
29   * @param {number} fieldNumber
30   * @return {!FieldType|undefined}
31   */
32  get(fieldNumber) {}
33
34  /**
35   * Deletes a field from the specified field number.
36   *
37   * @param {number} fieldNumber
38   */
39  delete(fieldNumber) {}
40
41  /**
42   * Executes the provided function once for each field.
43   *
44   * @param {function(!FieldType, number): void} callback
45   */
46  forEach(callback) {}
47
48  /**
49   * Creates a shallow copy of the storage.
50   *
51   * @return {!Storage}
52   */
53  shallowCopy() {}
54}
55
56/**
57 * 85% of the proto fields have a field number <= 24:
58 * https://plx.corp.google.com/scripts2/script_5d._f02af6_0000_23b1_a15f_001a1139dd02
59 *
60 * @type {number}
61 */
62// LINT.IfChange
63Storage.DEFAULT_PIVOT = 24;
64// LINT.ThenChange(//depot/google3/third_party/protobuf/javascript/runtime/kernel/binary_storage_test.js,
65// //depot/google3/net/proto2/contrib/js_proto/internal/kernel_message_generator.cc)
66
67exports = Storage;
68