rc = aResult->SetAsArray(nsIDataType::VTYPE_INTERFACE,&NS_GET_IID(nsIVariant),count,a);
rc = aResult->SetAsArray(nsIDataType::VTYPE_INTERFACE_IS,&NS_GET_IID(nsIVariant),count,a);
static nsresult CreateArray(nsIWritableVariant* aResult, PRUint16 aType, const nsIID* aIID,   PRUint32 aDimensionCount, PRInt32* aDimensionSizes, PRUint32 aSizeof, PRUint8* aArray){  if (aSizeof == 0) {  //  Variants do not support construction of null-sized arrays    return aResult->SetAsEmptyArray();  }  if (aDimensionCount > 1) {                  //  We cannot reuse variants because they are kept by resulting array    PRInt32 count = aDimensionSizes[0];    PRUint32 size = aSizeof / count;    PRInt32 i;    nsIVariant** a = new nsIVariant*[count];  //  Create variant array.    if (!a)      return NS_ERROR_OUT_OF_MEMORY;    nsresult rc = NS_OK;    for (i = 0; i < count; i++) {      nsCOMPtr<nsIWritableVariant> v = do_CreateInstance(NS_VARIANT_CONTRACTID, &rc);      if (NS_FAILED(rc))        break;      nsresult rc = CreateArray(v, aType, aIID, aDimensionCount - 1, aDimensionSizes + 1,        size, aArray);      if (NS_FAILED(rc))        break;      a[i] = v;      NS_ADDREF(a[i]);                       //  Addref for array reference      aArray += size;    }    if (!NS_FAILED(rc)) {      rc = aResult->SetAsArray(nsIDataType::VTYPE_INTERFACE,&NS_GET_IID(nsIVariant),count,a);    }    for (i = 0; i < count; i++) {            //  Release variants for array      nsIVariant* v = a[i];      if (v)        NS_RELEASE(v);    }    delete[] a;    return rc;  }  else {    return aResult->SetAsArray(aType,aIID,aDimensionSizes[0],aArray);  }}