Closed Bug 814752 Opened 13 years ago Closed 13 years ago

Make NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER generic

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: mccr8, Assigned: mccr8)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Right now, this has two cases, one for natives and one for nsISupports: #define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \ nsContentUtils::ReleaseWrapper(static_cast<nsISupports*>(p), tmp); #define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER_NATIVE \ nsContentUtils::ReleaseWrapper(tmp, tmp); After some of the cleanup patches I have in the pipeline are applied, this is the only thing stopping at least AudioContext from using the generic NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_n macros. bjacob's templatization technique should work here.
Attached patch drop the unnecessary cast (obsolete) — Splinter Review
As far as I can tell, the cast to nsISupports doesn't really do anything: it static casts from void* to nsISupports*, which I assume is always a no-op. For the native case, tmp is the result of calling DowncastCCParticipant, which just just doing a static cast from void* to T*, where T is the CC class, which again should be a no-op. Thus I think we can combine the two functions by just dropping the cast, and using the raw void* argument as the first argument. Am I wrong about that? This lets us shorten up the existing users of the _NATIVE unlink.
Assignee: nobody → continuation
Attachment #685298 - Attachment is obsolete: true
Comment on attachment 685301 [details] [diff] [review] drop the unnecessary cast Hopefully you understand why the cache stuff enough (eg more than me) to understand why the existing code is the way it is. The important stuff is in nsWrapperCache.h, the rest is just taking advantage of the other changes to boil away some macros.
Attachment #685301 - Flags: review?(bugs)
Comment on attachment 685301 [details] [diff] [review] drop the unnecessary cast ehsan might want to look at this just to know that audio code is being changed.
Attachment #685301 - Flags: review?(bugs) → review+
Comment on attachment 685301 [details] [diff] [review] drop the unnecessary cast Just for the Audio changes. I merged together the two UNLINK_PRESERVED_WRAPPER macros, so now we can use the WRAPPER_CACHE_N macros for a few audio classes.
Attachment #685301 - Flags: review?(ehsan)
Comment on attachment 685301 [details] [diff] [review] drop the unnecessary cast Review of attachment 685301 [details] [diff] [review]: ----------------------------------------------------------------- Yay!
Attachment #685301 - Flags: review?(ehsan) → review+
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: