/usr/include/thunderbird-11.0.1/nsCycleCollectionParticipant.h is in thunderbird-dev 11.0.1+build1-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCycleCollectionParticipant_h__
#define nsCycleCollectionParticipant_h__
#include "nsISupports.h"
// NOTE: If you use header files to define DEBUG_CC, you must do so here
// *and* in nsCycleCollector.h
//#define DEBUG_CC
#define NS_CYCLECOLLECTIONPARTICIPANT_IID \
{ \
0x9674489b, \
0x1f6f, \
0x4550, \
{ 0xa7, 0x30, 0xcc, 0xae, 0xdd, 0x10, 0x4c, 0xf9 } \
}
/**
* Special IID to get at the base nsISupports for a class. Usually this is the
* canonical nsISupports pointer, but in the case of tearoffs for example it is
* the base nsISupports pointer of the tearoff. This allow the cycle collector
* to have separate nsCycleCollectionParticipant's for tearoffs or aggregated
* classes.
*/
#define NS_CYCLECOLLECTIONISUPPORTS_IID \
{ \
0xc61eac14, \
0x5f7a, \
0x4481, \
{ 0x96, 0x5e, 0x7e, 0xaa, 0x6e, 0xff, 0xa8, 0x5f } \
}
/**
* Just holds the IID so NS_GET_IID works.
*/
class nsCycleCollectionISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CYCLECOLLECTIONISUPPORTS_IID)
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionISupports,
NS_CYCLECOLLECTIONISUPPORTS_IID)
class nsCycleCollectionParticipant;
class NS_NO_VTABLE nsCycleCollectionTraversalCallback
{
public:
// You must call DescribeRefCountedNode() with an accurate
// refcount, otherwise cycle collection will fail, and probably crash.
// If the callback cares about objsz or objname, it should
// put WANT_DEBUG_INFO in mFlags.
NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refcount,
size_t objsz,
const char *objname) = 0;
NS_IMETHOD_(void) DescribeGCedNode(bool ismarked,
size_t objsz,
const char *objname) = 0;
NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root) = 0;
NS_IMETHOD_(void) NoteRoot(PRUint32 langID, void *root,
nsCycleCollectionParticipant* helper) = 0;
NS_IMETHOD_(void) NoteScriptChild(PRUint32 langID, void *child) = 0;
NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child) = 0;
NS_IMETHOD_(void) NoteNativeChild(void *child,
nsCycleCollectionParticipant *helper) = 0;
// Give a name to the edge associated with the next call to
// NoteScriptChild, NoteXPCOMChild, or NoteNativeChild.
// Callbacks who care about this should set WANT_DEBUG_INFO in the
// flags.
NS_IMETHOD_(void) NoteNextEdgeName(const char* name) = 0;
NS_IMETHOD_(void) NoteWeakMapping(void *map, void *key, void *val) = 0;
enum {
// Values for flags:
// Caller should pass useful objsz and objname to
// DescribeRefCountedNode and DescribeGCedNode and should call
// NoteNextEdgeName.
WANT_DEBUG_INFO = (1<<0),
// Caller should not skip objects that we know will be
// uncollectable.
WANT_ALL_TRACES = (1<<1)
};
PRUint32 Flags() const { return mFlags; }
bool WantDebugInfo() const { return (mFlags & WANT_DEBUG_INFO) != 0; }
bool WantAllTraces() const { return (mFlags & WANT_ALL_TRACES) != 0; }
protected:
nsCycleCollectionTraversalCallback() : mFlags(0) {}
PRUint32 mFlags;
};
class NS_NO_VTABLE nsCycleCollectionParticipant
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CYCLECOLLECTIONPARTICIPANT_IID)
NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb) = 0;
NS_IMETHOD Root(void *p) = 0;
NS_IMETHOD Unlink(void *p) = 0;
NS_IMETHOD Unroot(void *p) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionParticipant,
NS_CYCLECOLLECTIONPARTICIPANT_IID)
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_COM_GLUE
typedef void
(* TraceCallback)(PRUint32 langID, void *p, const char *name, void *closure);
class NS_NO_VTABLE nsScriptObjectTracer : public nsCycleCollectionParticipant
{
public:
NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure) = 0;
void NS_COM_GLUE TraverseScriptObjects(void *p,
nsCycleCollectionTraversalCallback &cb);
};
class NS_COM_GLUE nsXPCOMCycleCollectionParticipant
: public nsScriptObjectTracer
{
public:
NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb);
NS_IMETHOD Root(void *p);
NS_IMETHOD Unlink(void *p);
NS_IMETHOD Unroot(void *p);
NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure);
NS_IMETHOD_(void) UnmarkPurple(nsISupports *p);
bool CheckForRightISupports(nsISupports *s);
};
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing a QI to nsXPCOMCycleCollectionParticipant
///////////////////////////////////////////////////////////////////////////////
#define NS_CYCLE_COLLECTION_INNERCLASS \
cycleCollection
#define NS_CYCLE_COLLECTION_CLASSNAME(_class) \
_class::NS_CYCLE_COLLECTION_INNERCLASS
#define NS_CYCLE_COLLECTION_INNERNAME \
_cycleCollectorGlobal
#define NS_CYCLE_COLLECTION_NAME(_class) \
_class::NS_CYCLE_COLLECTION_INNERNAME
#define NS_IMPL_QUERY_CYCLE_COLLECTION(_class) \
if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) { \
*aInstancePtr = & NS_CYCLE_COLLECTION_NAME(_class); \
return NS_OK; \
} else
#define NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class) \
if ( aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ) { \
*aInstancePtr = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
return NS_OK; \
} else
#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class) \
NS_IMPL_QUERY_CYCLE_COLLECTION(_class)
#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class) \
NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)
#define NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class) \
NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class) \
NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)
#define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(_class) \
NS_INTERFACE_MAP_BEGIN(_class) \
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
#define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(_class) \
NS_INTERFACE_MAP_BEGIN(_class) \
NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class)
#define NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(_class) \
if (rv == NS_OK) return rv; \
nsISupports* foundInterface; \
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
#define NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(_class) \
NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
{ \
NS_PRECONDITION(aInstancePtr, "null out param"); \
\
if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) { \
*aInstancePtr = &NS_CYCLE_COLLECTION_NAME(_class); \
return NS_OK; \
} \
nsresult rv;
#define NS_CYCLE_COLLECTION_UPCAST(obj, clazz) \
NS_CYCLE_COLLECTION_CLASSNAME(clazz)::Upcast(obj)
///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing nsCycleCollectionParticipant::Unlink
///////////////////////////////////////////////////////////////////////////////
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p) \
{ \
nsISupports *s = static_cast<nsISupports*>(p); \
NS_ASSERTION(CheckForRightISupports(s), \
"not the nsISupports pointer we expect"); \
_class *tmp = Downcast(s);
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p) \
{ \
nsISupports *s = static_cast<nsISupports*>(p); \
NS_ASSERTION(CheckForRightISupports(s), \
"not the nsISupports pointer we expect"); \
_class *tmp = static_cast<_class*>(Downcast(s)); \
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Unlink(s);
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p) \
{ \
_class *tmp = static_cast<_class*>(p);
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_field) \
tmp->_field = NULL;
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(_field) \
tmp->_field.Clear();
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(_field) \
tmp->_field.Clear();
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
return NS_OK; \
}
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_0(_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p) \
{ \
NS_ASSERTION(CheckForRightISupports(static_cast<nsISupports*>(p)), \
"not the nsISupports pointer we expect"); \
return NS_OK; \
}
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NATIVE_0(_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p) \
{ \
return NS_OK; \
}
///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing nsCycleCollectionParticipant::Traverse
///////////////////////////////////////////////////////////////////////////////
#define NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, _refcnt) \
cb.DescribeRefCountedNode(_refcnt, sizeof(_class), #_class);
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Traverse \
(void *p, \
nsCycleCollectionTraversalCallback &cb) \
{ \
nsISupports *s = static_cast<nsISupports*>(p); \
NS_ASSERTION(CheckForRightISupports(s), \
"not the nsISupports pointer we expect"); \
_class *tmp = static_cast<_class*>(Downcast(s));
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, tmp->mRefCnt.get())
// Base class' CC participant should return NS_SUCCESS_INTERRUPTED_TRAVERSE
// from Traverse if it wants derived classes to not traverse anything from
// their CC participant.
#define NS_SUCCESS_INTERRUPTED_TRAVERSE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 2)
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \
if (NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Traverse(s, cb) == \
NS_SUCCESS_INTERRUPTED_TRAVERSE) { \
return NS_SUCCESS_INTERRUPTED_TRAVERSE; \
}
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(_class) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Traverse \
(void *p, \
nsCycleCollectionTraversalCallback &cb) \
{ \
_class *tmp = static_cast<_class*>(p); \
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, tmp->mRefCnt.get())
#define NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(_cb, _name) \
PR_BEGIN_MACRO \
if (NS_UNLIKELY((_cb).WantDebugInfo())) { \
(_cb).NoteNextEdgeName(_name); \
} \
PR_END_MACRO
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(_field) \
PR_BEGIN_MACRO \
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field); \
cb.NoteXPCOMChild(tmp->_field); \
PR_END_MACRO;
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_field) \
PR_BEGIN_MACRO \
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field); \
cb.NoteXPCOMChild(tmp->_field.get()); \
PR_END_MACRO;
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(_field, _base) \
PR_BEGIN_MACRO \
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field); \
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(_base*, tmp->_field)); \
PR_END_MACRO;
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(_field) \
{ \
PRInt32 i; \
for (i = 0; i < tmp->_field.Count(); ++i) { \
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field "[i]"); \
cb.NoteXPCOMChild(tmp->_field[i]); \
} \
}
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(_ptr, _ptr_class, _name) \
PR_BEGIN_MACRO \
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, _name); \
cb.NoteNativeChild(_ptr, &NS_CYCLE_COLLECTION_NAME(_ptr_class)); \
PR_END_MACRO;
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(_field, _field_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(tmp->_field, _field_class, \
#_field)
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY(_array, _element_class, \
_name) \
{ \
PRUint32 i, length = (_array).Length(); \
for (i = 0; i < length; ++i) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR((_array)[i], \
_element_class, \
_name "[i]"); \
}
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(_field) \
{ \
PRUint32 i, length = tmp->_field.Length(); \
for (i = 0; i < length; ++i) { \
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field "[i]"); \
cb.NoteXPCOMChild(tmp->_field[i].get()); \
} \
}
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_MEMBER(_field, \
_element_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY(tmp->_field, _element_class, \
#_field)
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \
TraverseScriptObjects(p, cb);
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \
return NS_OK; \
}
///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing nsScriptObjectTracer::Trace
///////////////////////////////////////////////////////////////////////////////
#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class) \
void \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \
TraceCallback aCallback, \
void *aClosure) \
{ \
nsISupports *s = static_cast<nsISupports*>(p); \
NS_ASSERTION(CheckForRightISupports(s), \
"not the nsISupports pointer we expect"); \
_class *tmp = Downcast(s);
#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(_class, _base_class) \
void \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \
TraceCallback aCallback, \
void *aClosure) \
{ \
nsISupports *s = static_cast<nsISupports*>(p); \
NS_ASSERTION(CheckForRightISupports(s), \
"not the nsISupports pointer we expect"); \
_class *tmp = static_cast<_class*>(Downcast(s)); \
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Trace(s, \
aCallback, \
aClosure);
#define NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(_class) \
void \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \
TraceCallback aCallback, \
void *aClosure) \
{ \
_class *tmp = static_cast<_class*>(p);
#define NS_IMPL_CYCLE_COLLECTION_TRACE_CALLBACK(_langID, _object, _name) \
if (_object) \
aCallback(_langID, _object, _name, aClosure);
#define NS_IMPL_CYCLE_COLLECTION_TRACE_MEMBER_CALLBACK(_langID, _field) \
NS_IMPL_CYCLE_COLLECTION_TRACE_CALLBACK(_langID, tmp->_field, #_field)
#define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(_object, _name) \
NS_IMPL_CYCLE_COLLECTION_TRACE_CALLBACK(nsIProgrammingLanguage::JAVASCRIPT, \
_object, _name)
#define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(_field) \
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->_field, #_field)
// NB: The (void)tmp; hack in the TRACE_END macro exists to support
// implementations that don't need to do anything in their Trace method.
// Without this hack, some compilers warn about the unused tmp local.
#define NS_IMPL_CYCLE_COLLECTION_TRACE_END \
(void)tmp; \
}
///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing a concrete nsCycleCollectionParticipant
///////////////////////////////////////////////////////////////////////////////
#define NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE \
static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
#define NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \
public: \
NS_IMETHOD Traverse(void *p, \
nsCycleCollectionTraversalCallback &cb); \
NS_IMETHOD_(void) UnmarkPurple(nsISupports *s) \
{ \
Downcast(s)->UnmarkPurple(); \
} \
static _class* Downcast(nsISupports* s) \
{ \
return static_cast<_class*>(static_cast<_base*>(s)); \
} \
static nsISupports* Upcast(_class *p) \
{ \
return NS_ISUPPORTS_CAST(_base*, p); \
}
#define NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \
NS_IMETHOD Unlink(void *p);
#define NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _base) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsXPCOMCycleCollectionParticipant \
{ \
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_DECL_CYCLE_COLLECTION_CLASS(_class) \
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _class)
// Cycle collector helper for classes that don't want to unlink anything.
// Note: if this is used a lot it might make sense to have a base class that
// doesn't do anything in Root/Unlink/Unroot.
#define NS_DECL_CYCLE_COLLECTION_CLASS_NO_UNLINK(_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsXPCOMCycleCollectionParticipant \
{ \
NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _class) \
NS_IMETHOD Root(void *p) \
{ \
return NS_OK; \
} \
NS_IMETHOD Unlink(void *p) \
{ \
return NS_OK; \
} \
NS_IMETHOD Unroot(void *p) \
{ \
return NS_OK; \
} \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _base) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsXPCOMCycleCollectionParticipant \
{ \
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure); \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(_class) \
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, \
_base_class) \
public: \
NS_IMETHOD Traverse(void *p, \
nsCycleCollectionTraversalCallback &cb); \
static _class* Downcast(nsISupports* s) \
{ \
return static_cast<_class*>(static_cast<_base_class*>( \
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Downcast(s))); \
}
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \
NS_IMETHOD Unlink(void *p);
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(_class, _base_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
{ \
public: \
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(_class, \
_base_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
{ \
public: \
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(_class, \
_base_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
{ \
public: \
NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure); \
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
/**
* This implements a stub UnmarkPurple function for classes that want to be
* traversed but whose AddRef/Release functions don't add/remove them to/from
* the purple buffer. If you're just using NS_DECL_CYCLE_COLLECTING_ISUPPORTS
* then you don't need this.
*/
#define NS_DECL_CYCLE_COLLECTION_UNMARK_PURPLE_STUB(_class) \
NS_IMETHODIMP_(void) UnmarkPurple() \
{ \
} \
#define NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_CYCLE_COLLECTION_CLASSNAME(_class) NS_CYCLE_COLLECTION_NAME(_class);
#define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY \
public: \
NS_IMETHOD Root(void *n); \
NS_IMETHOD Unlink(void *n); \
NS_IMETHOD Unroot(void *n); \
NS_IMETHOD Traverse(void *n, \
nsCycleCollectionTraversalCallback &cb);
#define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsCycleCollectionParticipant \
{ \
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class) \
class NS_CYCLE_COLLECTION_INNERCLASS \
: public nsScriptObjectTracer \
{ \
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY \
NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure); \
}; \
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
#define NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(_class, _root_function) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Root(void *p) \
{ \
_class *tmp = static_cast<_class*>(p); \
tmp->_root_function(); \
return NS_OK; \
}
#define NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(_class, _unroot_function) \
NS_IMETHODIMP \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unroot(void *p) \
{ \
_class *tmp = static_cast<_class*>(p); \
tmp->_unroot_function(); \
return NS_OK; \
}
#define NS_IMPL_CYCLE_COLLECTION_0(_class) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_1(_class, _f) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_2(_class, _f1, _f2) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_3(_class, _f1, _f2, _f3) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_4(_class, _f1, _f2, _f3, _f4) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_5(_class, _f1, _f2, _f3, _f4, _f5) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_6(_class, _f1, _f2, _f3, _f4, _f5, _f6) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f6) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f6) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_7(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f6) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f7) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f6) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f7) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#define NS_IMPL_CYCLE_COLLECTION_8(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8) \
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f6) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f7) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f8) \
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f6) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f7) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f8) \
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
#endif // nsCycleCollectionParticipant_h__
|