Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsDialogParamBlock.h" |
michael@0 | 7 | #include "nsString.h" |
michael@0 | 8 | #include "nsReadableUtils.h" |
michael@0 | 9 | |
michael@0 | 10 | NS_IMPL_ISUPPORTS(nsDialogParamBlock, nsIDialogParamBlock) |
michael@0 | 11 | |
michael@0 | 12 | nsDialogParamBlock::nsDialogParamBlock() : mNumStrings(0), mString(nullptr) |
michael@0 | 13 | { |
michael@0 | 14 | for(int32_t i = 0; i < kNumInts; i++) |
michael@0 | 15 | mInt[i] = 0; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | nsDialogParamBlock::~nsDialogParamBlock() |
michael@0 | 19 | { |
michael@0 | 20 | delete [] mString; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | NS_IMETHODIMP nsDialogParamBlock::SetNumberStrings(int32_t inNumStrings) |
michael@0 | 24 | { |
michael@0 | 25 | if (mString != nullptr) |
michael@0 | 26 | return NS_ERROR_ALREADY_INITIALIZED; |
michael@0 | 27 | |
michael@0 | 28 | mString = new nsString[inNumStrings]; |
michael@0 | 29 | if (!mString) |
michael@0 | 30 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 31 | mNumStrings = inNumStrings; |
michael@0 | 32 | return NS_OK; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | NS_IMETHODIMP nsDialogParamBlock::GetInt(int32_t inIndex, int32_t *_retval) |
michael@0 | 37 | { |
michael@0 | 38 | nsresult rv = InBounds(inIndex, kNumInts); |
michael@0 | 39 | if (rv == NS_OK) |
michael@0 | 40 | *_retval = mInt[inIndex]; |
michael@0 | 41 | return rv; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | NS_IMETHODIMP nsDialogParamBlock::SetInt(int32_t inIndex, int32_t inInt) |
michael@0 | 45 | { |
michael@0 | 46 | nsresult rv = InBounds(inIndex, kNumInts); |
michael@0 | 47 | if (rv == NS_OK) |
michael@0 | 48 | mInt[inIndex]= inInt; |
michael@0 | 49 | return rv; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | |
michael@0 | 53 | NS_IMETHODIMP nsDialogParamBlock::GetString(int32_t inIndex, char16_t **_retval) |
michael@0 | 54 | { |
michael@0 | 55 | if (mNumStrings == 0) |
michael@0 | 56 | SetNumberStrings(kNumStrings); |
michael@0 | 57 | nsresult rv = InBounds(inIndex, mNumStrings); |
michael@0 | 58 | if (rv == NS_OK) |
michael@0 | 59 | *_retval = ToNewUnicode(mString[inIndex]); |
michael@0 | 60 | return rv; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | NS_IMETHODIMP nsDialogParamBlock::SetString(int32_t inIndex, const char16_t *inString) |
michael@0 | 64 | { |
michael@0 | 65 | if (mNumStrings == 0) |
michael@0 | 66 | SetNumberStrings(kNumStrings); |
michael@0 | 67 | nsresult rv = InBounds(inIndex, mNumStrings); |
michael@0 | 68 | if (rv == NS_OK) |
michael@0 | 69 | mString[inIndex]= inString; |
michael@0 | 70 | return rv; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | NS_IMETHODIMP |
michael@0 | 74 | nsDialogParamBlock::GetObjects(nsIMutableArray * *aObjects) |
michael@0 | 75 | { |
michael@0 | 76 | NS_ENSURE_ARG_POINTER(aObjects); |
michael@0 | 77 | NS_IF_ADDREF(*aObjects = mObjects); |
michael@0 | 78 | return NS_OK; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | NS_IMETHODIMP |
michael@0 | 82 | nsDialogParamBlock::SetObjects(nsIMutableArray * aObjects) |
michael@0 | 83 | { |
michael@0 | 84 | mObjects = aObjects; |
michael@0 | 85 | return NS_OK; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 |