Bug 1557504 - remove [array] use in xpidl from calIIcsParser.idl. r=pmorris
authorKhushil Mistry <khushil324@gmail.com>
Mon, 25 Nov 2019 23:28:18 +0530
changeset 36728 8ec25287b8814365572429a76daba6000b1dc855
parent 36727 f6af99c9ff9d90f6086e77addd21ba425ce6ac9b
child 36729 2b3dd54098bf6af5fb58ba8fb98f068f3f0193c6
push id2534
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:52:51 +0000
treeherdercomm-beta@055c50840778 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspmorris
bugs1557504
Bug 1557504 - remove [array] use in xpidl from calIIcsParser.idl. r=pmorris
calendar/base/content/calendar-clipboard.js
calendar/base/content/calendar-dnd-listener.js
calendar/base/public/calIIcsParser.idl
calendar/base/src/calIcsParser.js
calendar/base/src/calItipItem.js
calendar/import-export/calIcsImportExport.js
calendar/lightning/components/lightningTextCalendarConverter.js
calendar/providers/caldav/calDavCalendar.js
calendar/providers/ics/calICSCalendar.js
calendar/test/unit/head_consts.js
calendar/test/unit/test_ics_parser.js
calendar/test/unit/test_ltninvitationutils.js
calendar/test/unit/test_recurrence_utils.js
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -162,17 +162,17 @@ function pasteFromClipboard() {
       let icsParser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
       try {
         icsParser.parseString(data);
       } catch (e) {
         // Ignore parser errors from the clipboard data, if it fails
         // there will just be 0 items.
       }
 
-      let items = icsParser.getItems({});
+      let items = icsParser.getItems();
       if (items.length == 0) {
         return;
       }
 
       // If there are multiple items on the clipboard, the earliest
       // should be set to the selected day and the rest adjusted.
       let earliestDate = null;
       for (let item of items) {
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -238,17 +238,17 @@ calDNDBaseObserver.prototype = {
     switch (bestFlavor.value) {
       case "text/calendar": {
         if (AppConstants.platform == "macosx") {
           // Mac likes to convert all \r to \n, we need to reverse this.
           data = data.data.replace(/\n\n/g, "\r\n");
         }
         let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
         parser.parseString(data);
-        this.onDropItems(parser.getItems({}).concat(parser.getParentlessItems({})));
+        this.onDropItems(parser.getItems().concat(parser.getParentlessItems()));
         break;
       }
       case "text/unicode": {
         let droppedUrl = this.retrieveURLFromData(data, bestFlavor.value);
         if (!droppedUrl) {
           return;
         }
 
@@ -292,17 +292,17 @@ calDNDBaseObserver.prototype = {
         let listener = {
           onStreamComplete: function(aLoader, aContext, aStatus, aResultLength, aResult) {
             let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
             let encoding = channel.contentCharset || "utf-8";
             let result = aResultLength
               ? new TextDecoder(encoding).decode(Uint8Array.from(aResult))
               : "";
             parser.parseString(result);
-            self.onDropItems(parser.getItems({}).concat(parser.getParentlessItems({})));
+            self.onDropItems(parser.getItems().concat(parser.getParentlessItems()));
           },
         };
 
         try {
           loader.init(listener);
           channel.asyncOpen(loader);
         } catch (e) {
           cal.ERROR(e);
--- a/calendar/base/public/calIIcsParser.idl
+++ b/calendar/base/public/calIIcsParser.idl
@@ -63,50 +63,28 @@ interface calIIcsParser : nsISupports
                        [optional] in calITimezoneProvider aTzProvider,
                        [optional] in calIIcsParsingListener aAsyncParsing);
 
   /**
    * Get the items that were in the string or stream. In case an item represents a
    * recurring series, the (unexpanded) parent item is returned only.
    * Please keep in mind that any parentless items (see below) are not contained
    * in the returned set of items.
-   *
-   * @param aCount
-   *    Will hold the number of items that were parsed
-   * @param aItems
-   *    The items
    */
-  void getItems(out uint32_t aCount,
-                [array,size_is(aCount),retval] out calIItemBase aItems);
+  Array<calIItemBase> getItems();
 
   /**
    * Get the parentless items that may have occurred, i.e. overridden items of a
    * recurring series (having a RECURRENCE-ID) missing their parent item in the
    * parsed content.
-   *
-   * @param aCount
-   *    Will hold the number of items that were parsed
-   * @param aItems
-   *    The items
    */
-  void getParentlessItems(out uint32_t aCount,
-                          [array,size_is(aCount),retval] out calIItemBase aItems);
+  Array<calIItemBase> getParentlessItems();
 
   /**
    * Get the top-level properties that were not interpreted as anything special
-   * @param aCount
-   *    Will hold the number of properties that were found
-   * @param aProperties
-   *    The properties
    */
-  void getProperties(out uint32_t aCount,
-                     [array,size_is(aCount),retval] out calIIcalProperty aProperties);
+  Array<calIIcalProperty> getProperties();
 
   /**
    * Get the top-level components that were not interpreted as anything special
-   * @param aCount
-   *    Will hold the number of components that were found
-   * @param aComponents
-   *    The components
    */
-  void getComponents(out uint32_t aCount,
-                     [array,size_is(aCount),retval] out calIIcalComponent aComponents);
+  Array<calIIcalComponent> getComponents();
 };
--- a/calendar/base/src/calIcsParser.js
+++ b/calendar/base/src/calIcsParser.js
@@ -161,33 +161,29 @@ calIcsParser.prototype = {
     // 'chars' in this string. So call it an array of octets for now.
 
     let stringData = NetUtil.readInputStreamToString(aStream, aStream.available(), {
       charset: "utf-8",
     });
     this.parseString(stringData, aTzProvider, aAsyncParsing);
   },
 
-  getItems: function(aCount) {
-    aCount.value = this.mItems.length;
+  getItems: function() {
     return this.mItems.concat([]);
   },
 
-  getParentlessItems: function(aCount) {
-    aCount.value = this.mParentlessItems.length;
+  getParentlessItems: function() {
     return this.mParentlessItems.concat([]);
   },
 
-  getProperties: function(aCount) {
-    aCount.value = this.mProperties.length;
+  getProperties: function() {
     return this.mProperties.concat([]);
   },
 
-  getComponents: function(aCount) {
-    aCount.value = this.mComponents.length;
+  getComponents: function() {
     return this.mComponents.concat([]);
   },
 };
 
 /**
  * The parser state, which helps process ical components without clogging up the
  * event queue.
  *
--- a/calendar/base/src/calItipItem.js
+++ b/calendar/base/src/calItipItem.js
@@ -127,17 +127,17 @@ calItipItem.prototype = {
         removeSchedulingParams(item.organizer);
       }
 
       item.setProperty("DTSTAMP", stamp);
       item.setProperty("LAST-MODIFIED", lastModified); // need to be last to undirty the item
     }
 
     this.mItemList = [];
-    for (let item of cal.iterate.items(parser.getItems({}))) {
+    for (let item of cal.iterate.items(parser.getItems())) {
       cleanItem(item);
       // only push non-faked master items or
       // the overridden instances of faked master items
       // to the list:
       if (item == item.parentItem) {
         if (!item.hasProperty("X-MOZ-FAKED-MASTER")) {
           this.mItemList.push(item);
         }
@@ -146,17 +146,17 @@ calItipItem.prototype = {
       }
     }
 
     // We set both methods now for safety's sake. It's the ItipProcessor's
     // responsibility to properly ascertain what the correct response
     // method is (using user feedback, prefs, etc.) for the given
     // receivedMethod.  The RFC tells us to treat items without a METHOD
     // as if they were METHOD:REQUEST.
-    for (let prop of parser.getProperties({})) {
+    for (let prop of parser.getProperties()) {
       if (prop.propertyName == "METHOD") {
         this.mReceivedMethod = prop.value;
         this.mResponseMethod = prop.value;
         break;
       }
     }
 
     this.mIsInitialized = true;
--- a/calendar/import-export/calIcsImportExport.js
+++ b/calendar/import-export/calIcsImportExport.js
@@ -29,17 +29,17 @@ calIcsImporter.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.calIImporter]),
   classID: Components.ID("{1e3e33dc-445a-49de-b2b6-15b2a050bb9d}"),
 
   getFileTypes: getIcsFileTypes,
 
   importFromStream: function(aStream) {
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     parser.parseFromStream(aStream, null);
-    return parser.getItems({});
+    return parser.getItems();
   },
 };
 
 // Exporter
 function calIcsExporter() {
   this.wrappedJSObject = this;
 }
 
--- a/calendar/lightning/components/lightningTextCalendarConverter.js
+++ b/calendar/lightning/components/lightningTextCalendarConverter.js
@@ -16,17 +16,17 @@ ltnMimeConverter.prototype = {
   classID: Components.ID("{c70acb08-464e-4e55-899d-b2c84c5409fa}"),
 
   uri: null,
 
   convertToHTML: function(contentType, data) {
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     parser.parseString(data);
     let event = null;
-    for (let item of parser.getItems({})) {
+    for (let item of parser.getItems()) {
       if (cal.item.isEvent(item)) {
         if (item.hasProperty("X-MOZ-FAKED-MASTER")) {
           // if it's a faked master, take any overridden item to get a real occurrence:
           let exc = item.recurrenceInfo.getExceptionFor(item.startDate);
           cal.ASSERT(exc, "unexpected!");
           if (exc) {
             item = exc;
           }
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -1110,18 +1110,18 @@ calDavCalendar.prototype = {
       // Warn and continue.
       // TODO As soon as we have activity manager integration,
       // this should be replace with logic to notify that a
       // certain event failed.
       cal.WARN("Failed to parse item: " + calData + "\n\nException:" + e);
       return;
     }
     // with CalDAV there really should only be one item here
-    let items = parser.getItems({});
-    let propertiesList = parser.getProperties({});
+    let items = parser.getItems();
+    let propertiesList = parser.getProperties();
     let method;
     for (let prop of propertiesList) {
       if (prop.propertyName == "METHOD") {
         method = prop.value;
         break;
       }
     }
     let isReply = method == "REPLY";
--- a/calendar/providers/ics/calICSCalendar.js
+++ b/calendar/providers/ics/calICSCalendar.js
@@ -259,21 +259,21 @@ calICSCalendar.prototype = {
     // for non-existing or empty files, but not good for invalid files.
     // That's why we put them in readOnly mode
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     let self = this;
     let listener = {
       // calIIcsParsingListener
       onParsingComplete: function(rc, parser_) {
         try {
-          for (let item of parser_.getItems({})) {
+          for (let item of parser_.getItems()) {
             self.mMemoryCalendar.adoptItem(item, null);
           }
-          self.unmappedComponents = parser_.getComponents({});
-          self.unmappedProperties = parser_.getProperties({});
+          self.unmappedComponents = parser_.getComponents();
+          self.unmappedProperties = parser_.getProperties();
           cal.LOG("[calICSCalendar] Parsing ICS succeeded for " + self.uri.spec);
         } catch (exc) {
           cal.LOG("[calICSCalendar] Parsing ICS failed for \nException: " + exc);
           self.mObserver.onError(self.superCalendar, exc.result, exc.toString());
           self.mObserver.onError(self.superCalendar, calIErrors.READ_FAILED, "");
         }
         self.mObserver.onEndBatch();
         self.mObserver.onLoad(self);
--- a/calendar/test/unit/head_consts.js
+++ b/calendar/test/unit/head_consts.js
@@ -58,17 +58,17 @@ function createDate(aYear, aMonth, aDay,
   date.isDate = !aHasTime;
   return date;
 }
 
 function createEventFromIcalString(icalString) {
   if (/^BEGIN:VCALENDAR/.test(icalString)) {
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     parser.parseString(icalString);
-    let items = parser.getItems({});
+    let items = parser.getItems();
     cal.ASSERT(items.length == 1);
     return items[0].QueryInterface(Ci.calIEvent);
   } else {
     let event = Cc["@mozilla.org/calendar/event;1"].createInstance(Ci.calIEvent);
     event.icalString = icalString;
     return event;
   }
 }
--- a/calendar/test/unit/test_ics_parser.js
+++ b/calendar/test/unit/test_ics_parser.js
@@ -27,22 +27,22 @@ function test_props_comps() {
     "END:VJOURNAL",
     "BEGIN:VEVENT",
     "UID:123",
     "END:VEVENT",
     "END:VCALENDAR",
   ].join("\r\n");
   parser.parseString(str);
 
-  let props = parser.getProperties({});
+  let props = parser.getProperties();
   equal(props.length, 1);
   equal(props[0].propertyName, "X-WR-CALNAME");
   equal(props[0].value, "CALNAME");
 
-  let comps = parser.getComponents({});
+  let comps = parser.getComponents();
   equal(comps.length, 1);
   equal(comps[0].componentType, "VJOURNAL");
   equal(comps[0].location, "BEFORE TIME");
 }
 
 function test_failures() {
   let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
 
@@ -55,18 +55,18 @@ function test_failures() {
     },
   });
 
   // No real error here, but there is a message...
   parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
   let str = ["BEGIN:VWORLD", "BEGIN:VEVENT", "UID:123", "END:VEVENT", "END:VWORLD"].join("\r\n");
   dump("Note: The following error message is expected:\n");
   parser.parseString(str);
-  equal(parser.getComponents({}).length, 0);
-  equal(parser.getItems({}).length, 0);
+  equal(parser.getComponents().length, 0);
+  equal(parser.getItems().length, 0);
 }
 
 function test_fake_parent() {
   let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
 
   let str = [
     "BEGIN:VCALENDAR",
     "BEGIN:VEVENT",
@@ -75,34 +75,34 @@ function test_fake_parent() {
     "DTSTART:20120101T010102",
     "LOCATION:HELL",
     "END:VEVENT",
     "END:VCALENDAR",
   ].join("\r\n");
 
   parser.parseString(str);
 
-  let items = parser.getItems({});
+  let items = parser.getItems();
   equal(items.length, 1);
   let item = items[0].QueryInterface(Ci.calIEvent);
 
   equal(item.id, "123");
   ok(!!item.recurrenceInfo);
   equal(item.startDate.icalString, "20120101T010101");
   equal(item.getProperty("X-MOZ-FAKED-MASTER"), "1");
 
   let rinfo = item.recurrenceInfo;
 
   equal(rinfo.countRecurrenceItems(), 1);
   let excs = rinfo.getOccurrences(cal.createDateTime("20120101T010101"), null, 0, {});
   equal(excs.length, 1);
   let exc = excs[0].QueryInterface(Ci.calIEvent);
   equal(exc.startDate.icalString, "20120101T010102");
 
-  equal(parser.getParentlessItems({})[0], exc);
+  equal(parser.getParentlessItems()[0], exc);
 }
 
 function test_async() {
   let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
   let str = [
     "BEGIN:VCALENDAR",
     "BEGIN:VTODO",
     "UID:1",
@@ -115,17 +115,17 @@ function test_async() {
     "DUE:20120101T010104",
     "END:VTODO",
     "END:VCALENDAR",
   ].join("\r\n");
 
   do_test_pending();
   parser.parseString(str, null, {
     onParsingComplete: function(rc, opparser) {
-      let items = parser.getItems({});
+      let items = parser.getItems();
       equal(items.length, 2);
       let item = items[0];
       ok(cal.item.isToDo(item));
 
       equal(item.entryDate.icalString, "20120101T010101");
       equal(item.dueDate.icalString, "20120101T010102");
 
       item = items[1];
@@ -162,21 +162,21 @@ function test_roundtrip() {
     "LOCATION:BEFORE TIME",
     "END:VJOURNAL",
     "END:VCALENDAR",
     "",
   ].join("\r\n");
 
   parser.parseString(str);
 
-  let items = parser.getItems({});
+  let items = parser.getItems();
   serializer.addItems(items);
 
-  parser.getProperties({}).forEach(serializer.addProperty, serializer);
-  parser.getComponents({}).forEach(serializer.addComponent, serializer);
+  parser.getProperties().forEach(serializer.addProperty, serializer);
+  parser.getComponents().forEach(serializer.addComponent, serializer);
 
   equal(
     serializer
       .serializeToString()
       .split("\r\n")
       .sort()
       .join("\r\n"),
     str
@@ -186,19 +186,19 @@ function test_roundtrip() {
   );
 
   // Test parseFromStream
   parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
   let stream = serializer.serializeToInputStream();
 
   parser.parseFromStream(stream);
 
-  items = parser.getItems({});
-  let comps = parser.getComponents({});
-  let props = parser.getProperties({});
+  items = parser.getItems();
+  let comps = parser.getComponents();
+  let props = parser.getProperties();
   equal(items.length, 1);
   equal(comps.length, 1);
   equal(props.length, 1);
 
   let everything = items[0].icalString
     .split("\r\n")
     .concat(comps[0].serializeToICS().split("\r\n"));
   everything.push(props[0].icalString.split("\r\n")[0]);
@@ -216,19 +216,19 @@ function test_roundtrip() {
   // Test serializeToStream/parseFromStream
   parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
   let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
   pipe.init(true, true, 0, 0, null);
 
   serializer.serializeToStream(pipe.outputStream);
   parser.parseFromStream(pipe.inputStream);
 
-  items = parser.getItems({});
-  comps = parser.getComponents({});
-  props = parser.getProperties({});
+  items = parser.getItems();
+  comps = parser.getComponents();
+  props = parser.getProperties();
   equal(items.length, 1);
   equal(comps.length, 1);
   equal(props.length, 1);
 
   everything = items[0].icalString.split("\r\n").concat(comps[0].serializeToICS().split("\r\n"));
   everything.push(props[0].icalString.split("\r\n")[0]);
   everything.sort();
 
--- a/calendar/test/unit/test_ltninvitationutils.js
+++ b/calendar/test/unit/test_ltninvitationutils.js
@@ -409,17 +409,17 @@ add_task(async function createInvitation
           item = item.replace(/URL:[^\r]+\r\n/, test.input.url);
           break;
       }
     }
     let itipItem = Cc["@mozilla.org/calendar/itip-item;1"].createInstance(Ci.calIItipItem);
     itipItem.init(item);
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     parser.parseString(item);
-    let dom = ltn.invitation.createInvitationOverlay(parser.getItems({})[0], itipItem);
+    let dom = ltn.invitation.createInvitationOverlay(parser.getItems()[0], itipItem);
     let observed = dom.getElementById(test.expected.node).innerHTML;
     // we remove line-breaks and leading white spaces here so we can keep expected test results
     // above more comprehensive
     if (test.expected.node.endsWith("-table")) {
       observed = observed.replace(/(?:\n|\r\n|\r)[ ]{2,}/g, "");
     }
     equal(observed, test.expected.value, "(test #" + i + ")");
   }
@@ -437,17 +437,17 @@ add_task(async function compareInvitatio
           prop.toUpperCase() + (["summary", "location"].includes(prop) ? ":" : ";") + "[^\r]+\r\n";
         item = item.replace(new RegExp(regex), aInput[prop]);
       }
     }
     let itipItem = Cc["@mozilla.org/calendar/itip-item;1"].createInstance(Ci.calIItipItem);
     itipItem.init(item);
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     parser.parseString(item);
-    let dom = ltn.invitation.createInvitationOverlay(parser.getItems({})[0], itipItem);
+    let dom = ltn.invitation.createInvitationOverlay(parser.getItems()[0], itipItem);
     return cal.xml.serializeDOM(dom);
   }
   let data = [
     {
       input: {
         previous: { location: "LOCATION:This place\r\n" },
         current: { location: "LOCATION:Another location\r\n" },
         ignore: "",
--- a/calendar/test/unit/test_recurrence_utils.js
+++ b/calendar/test/unit/test_recurrence_utils.js
@@ -350,17 +350,17 @@ add_task(async function countOccurrences
 
   let i = 0;
   for (let test of data) {
     i++;
 
     let ics = getIcs(test.input);
     let parser = Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser);
     parser.parseString(ics);
-    let items = parser.getItems({});
+    let items = parser.getItems();
 
     ok(items.length > 0, "parsing input succeeded (test #" + i + ")");
     for (let item of items) {
       equal(
         countOccurrences(item),
         test.expected,
         "expected number of occurrences (test #" + i + " - '" + item.title + "')"
       );