storage.js 1.4 KB

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