Closed Bug 523651 Opened 15 years ago Closed 15 years ago

Add a CallQueryInterface that can work with nsCOMPtr

Categories

(Core :: XPCOM, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(1 file)

I'm tired of all the casting if I want to QI something with ambiguous nsISupports inheritance.
Attached patch FixSplinter Review
Attachment #407554 - Flags: review?(benjamin)
Comment on attachment 407554 [details] [diff] [review]
Fix

The static_cast *looks* wrong... I thought static_cast wasn't supposed to run cast operators, which is obviously what's happening here. I'd be happier with a c-style cast here: (DestinationType**) aDestination
Attachment #407554 - Flags: review?(benjamin) → review+
static_cast does do cast operators.  Testcase:

#include "stdio.h"
class A {
public:
  operator int() { return 5; }
};
int main() {
  A a;
  printf("%d\n", static_cast<int>(a));
}

prints 5 over here.  I can switch to c-style, though.
I think static_cast is better; less risk of accidentally turning into a reinterpret_cast.
Pushed http://hg.mozilla.org/mozilla-central/rev/a75d7681fa2f
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: