DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (5b81998bb7ab)

VCS Links

Line Code
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 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsCycleCollectionParticipant_h__
#define nsCycleCollectionParticipant_h__

#include "nsCycleCollectionNoteChild.h"
#include "jspubtd.h"

#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)

/**
 * Forward declarations
 */
class nsCycleCollectionParticipant;
class nsScriptObjectTracer;
class nsXPCOMCycleCollectionParticipant;

namespace JS {
template <class T> class Heap;
} /* namespace JS */

/*
 * A struct defining pure virtual methods which are called when tracing cycle
 * collection paticipants.  The appropriate method is called depending on the
 * type of JS GC thing.
 */
struct TraceCallbacks
{
    virtual void Trace(JS::Heap<JS::Value>* p, const char* name, void* closure) const = 0;
    virtual void Trace(JS::Heap<jsid>* p, const char* name, void* closure) const = 0;
    virtual void Trace(JS::Heap<JSObject*>* p, const char* name, void* closure) const = 0;
    virtual void Trace(JS::Heap<JSString*>* p, const char* name, void* closure) const = 0;
    virtual void Trace(JS::Heap<JSScript*>* p, const char* name, void* closure) const = 0;
};

/*
 * An implementation of TraceCallbacks that calls a single function for all JS
 * GC thing types encountered.
 */
struct TraceCallbackFunc : public TraceCallbacks
{
    typedef void (* Func)(void* p, const char* name, void* closure);

    explicit TraceCallbackFunc(Func cb) : mCallback(cb) {}

    virtual void Trace(JS::Heap<JS::Value>* p, const char* name, void* closure) const MOZ_OVERRIDE;
    virtual void Trace(JS::Heap<jsid>* p, const char* name, void* closure) const MOZ_OVERRIDE;
    virtual void Trace(JS::Heap<JSObject*>* p, const char* name, void* closure) const MOZ_OVERRIDE;
    virtual void Trace(JS::Heap<JSString*>* p, const char* name, void* closure) const MOZ_OVERRIDE;
    virtual void Trace(JS::Heap<JSScript*>* p, const char* name, void* closure) const MOZ_OVERRIDE;

  private:
    Func mCallback;
};

/**
 * VTables
 *
 * When using global scope static initialization for simple types with virtual
 * member functions, GCC creates static initializer functions. In order to
 * avoid this from happening, cycle collection participants are defined as
 * function tables.
 *
 * The Traverse function may require calling another function from the cycle
 * collection participant function table, so a pointer to the function table
 * is given to it. Using member function pointers would be less awkward, but
 * in MSVC, the size of such a member function pointer depends on the class
 * the function is member of. This makes it hard to make them compatible with
 * a generic function table. Moreover, static initialization of the function
 * table then uses a static initializer function.
 *
 * Finally, it is not possible to use an initializer list for non-aggregate
 * types. Separate types are thus required for static initialization. For
 * convenience and to avoid repetitions that could lead to discrepancies,
 * function table members for sub-types are declared independently, and
 * different aggregate types are defined for static initialization.
 */

/* Base functions for nsCycleCollectionParticipant */
template <typename T>
struct nsCycleCollectionParticipantVTableCommon
{
    nsresult (NS_STDCALL *TraverseReal)
        (T *that, void *p, nsCycleCollectionTraversalCallback &cb);

    nsresult (NS_STDCALL *Root)(void *p);
    nsresult (NS_STDCALL *Unlink)(void *p);
    nsresult (NS_STDCALL *Unroot)(void *p);

    void (NS_STDCALL *UnmarkIfPurple)(void *p);

    bool (NS_STDCALL *CanSkipReal)(void *p, bool aRemovingAllowed);
    bool (NS_STDCALL *CanSkipInCCReal)(void *p);
    bool (NS_STDCALL *CanSkipThisReal)(void *p);
};

typedef nsCycleCollectionParticipantVTableCommon<nsCycleCollectionParticipant>
    nsCycleCollectionParticipantVTable;

/* Additional functions for nsScriptObjectTracer */
struct nsScriptObjectTracerVTable
{
    void (NS_STDCALL *Trace)(void *p, const TraceCallbacks &cb, void *closure);
};

/**
 * Types for static initialization
 *
 * Considering T, the cycle collection participant class, subclass of either
 * nsCycleCollectionParticipant, nsScriptObjectTracer or
 * nsXPCOMCycleCollectionParticipant, static initialization goes as follows:
 *
 *   CCParticipantVTable<T>::type T::_cycleCollectorGlobal = {{...} ...};
 *
 * CCParticipantVTable<T>::type automatically defines the right type considering
 * what particular cycle collection participant class T derives from.
 *
 * The NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(classname),
 * NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(classname), and
 * NS_IMPL_CYCLE_COLLECTION_VTABLE(classname) macros may be used as helpers
 * for static initialization:
 *
 *   CCParticipantVTable<T>::type T::_cycleCollectorGlobal = {
 *     NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(classname);
 *   };
 */

enum nsCycleCollectionParticipantType
{
  eInvalid,
  eCycleCollectionParticipant,
  eScriptObjectTracer,
  eXPCOMCycleCollectionParticipant
};

template <typename T, enum nsCycleCollectionParticipantType ParticipantType>
struct CCParticipantVTableImpl { };

/* CCParticipantVTable for nsCycleCollectionParticipant */
template <typename T>
struct CCParticipantVTableImpl<T, eCycleCollectionParticipant>
{
    nsCycleCollectionParticipant *GetParticipant() const
    {
        return const_cast<nsCycleCollectionParticipant *>
               (reinterpret_cast<const nsCycleCollectionParticipant *>(this));
    }
    nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant;
};

/* CCParticipantVTable for nsScriptObjectTracer */
template <typename T>
struct CCParticipantVTableImpl<T, eScriptObjectTracer>
{
    nsScriptObjectTracer *GetParticipant() const
    {
        return const_cast<nsScriptObjectTracer *>
               (reinterpret_cast<const nsScriptObjectTracer *>(this));
    }
    nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant;
    nsScriptObjectTracerVTable scriptObjectTracer;
};

/* CCParticipantVTable for nsXPCOMCycleCollectionParticipant */
template <typename T>
struct CCParticipantVTableImpl<T, eXPCOMCycleCollectionParticipant>
{
    nsXPCOMCycleCollectionParticipant *GetParticipant() const
    {
        return const_cast<nsXPCOMCycleCollectionParticipant *>
               (reinterpret_cast<const nsXPCOMCycleCollectionParticipant *>(this));
    }
    nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant;
    nsScriptObjectTracerVTable scriptObjectTracer;
};

template <typename T>
struct CCParticipantVTable
{
    static const enum nsCycleCollectionParticipantType ParticipantType =
        mozilla::IsBaseOf<nsXPCOMCycleCollectionParticipant, T>::value ? eXPCOMCycleCollectionParticipant :
        mozilla::IsBaseOf<nsScriptObjectTracer, T>::value ? eScriptObjectTracer :
        mozilla::IsBaseOf<nsCycleCollectionParticipant, T>::value ? eCycleCollectionParticipant :
        eInvalid;
    typedef CCParticipantVTableImpl<T, ParticipantType> Type;
};

/**
 * Participant implementation classes
 */
class nsCycleCollectionParticipant : public nsCycleCollectionParticipantVTable
{
public:
    static const bool isSkippable = false;

    NS_DECLARE_STATIC_IID_ACCESSOR(NS_CYCLECOLLECTIONPARTICIPANT_IID)

    // Helper function to avoid painful syntax for member function call using
    // the VTable entry.
    NS_METHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb) {
        return TraverseReal(this, p, cb);
    }
    // If CanSkip returns true, p is removed from the purple buffer during
    // a call to nsCycleCollector_forgetSkippable().
    // Note, calling CanSkip may remove objects from the purple buffer!
    // If aRemovingAllowed is true, p can be removed from the purple buffer.
    bool CanSkip(void *p, bool aRemovingAllowed)
    {
        return CanSkipReal ? CanSkipReal(p, aRemovingAllowed) : false;
    }

    // If CanSkipInCC returns true, p is skipped when selecting roots for the
    // cycle collector graph.
    // Note, calling CanSkipInCC may remove other objects from the purple buffer!
    bool CanSkipInCC(void *p)
    {
        return CanSkipInCCReal ? CanSkipInCCReal(p) : false;
    }

    // If CanSkipThis returns true, p is not added to the graph.
    // This method is called during cycle collection, so don't
    // change the state of any objects!
    bool CanSkipThis(void *p)
    {
        return CanSkipThisReal ? CanSkipThisReal(p) : false;
    }
};

NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionParticipant,
                              NS_CYCLECOLLECTIONPARTICIPANT_IID)

class nsScriptObjectTracer
    : public nsCycleCollectionParticipant, public nsScriptObjectTracerVTable
{
public:
    static void NS_COM_GLUE NoteJSChild(void *aScriptThing, const char *name,
                                        void *aClosure);
};

class nsXPCOMCycleCollectionParticipant : public nsScriptObjectTracer
{
public:
    static NS_METHOD RootImpl(void *p);
    static NS_METHOD UnrootImpl(void *p);

    static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure);

    static bool CheckForRightISupports(nsISupports *s);
};

///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing a QI to nsXPCOMCycleCollectionParticipant
///////////////////////////////////////////////////////////////////////////////

#define NS_CYCLE_COLLECTION_CLASSNAME(_class)                                  \
        _class::NS_CYCLE_COLLECTION_INNERCLASS

#define NS_IMPL_QUERY_CYCLE_COLLECTION(_class)                                 \
  if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) {          \
    *aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(_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_PARTICIPANT(_class);                \
      return NS_OK;                                                           \
    }                                                                         \
    nsresult rv;

#define NS_CYCLE_COLLECTION_UPCAST(obj, clazz)                                 \
  NS_CYCLE_COLLECTION_CLASSNAME(clazz)::Upcast(obj)

// The default implementation of this class template is empty, because it
// should never be used: see the partial specializations below.
template <typename T,
          bool IsXPCOM = mozilla::IsBaseOf<nsISupports, T>::value>
struct DowncastCCParticipantImpl
{
};

// Specialization for XPCOM CC participants
template <typename T>
struct DowncastCCParticipantImpl<T, true>
{
  static T* Run(void *p)
  {
    nsISupports *s = static_cast<nsISupports*>(p);
    MOZ_ASSERT(NS_CYCLE_COLLECTION_CLASSNAME(T)::CheckForRightISupports(s),
               "not the nsISupports pointer we expect");
    return NS_CYCLE_COLLECTION_CLASSNAME(T)::Downcast(s);
  }
};

// Specialization for native CC participants
template <typename T>
struct DowncastCCParticipantImpl<T, false>
{
  static T* Run(void *p)
  {
    return static_cast<T*>(p);
  }
};

template <typename T>
T* DowncastCCParticipant(void *p)
{
  return DowncastCCParticipantImpl<T>::Run(p);
}

///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing CanSkip methods
///////////////////////////////////////////////////////////////////////////////

#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(_class)                        \
  NS_METHOD_(bool)                                                             \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipImpl(void *p,                  \
                                                     bool aRemovingAllowed)    \
  {                                                                            \
    _class *tmp = DowncastCCParticipant<_class >(p);

#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END                                  \
    (void)tmp;                                                                 \
    return false;                                                              \
  }

#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(_class)                  \
  NS_METHOD_(bool)                                                             \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipInCCImpl(void *p)              \
  {                                                                            \
    _class *tmp = DowncastCCParticipant<_class >(p);

#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END                            \
    (void)tmp;                                                                 \
    return false;                                                              \
  }

#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(_class)                   \
  NS_METHOD_(bool)                                                             \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipThisImpl(void *p)              \
  {                                                                            \
    _class *tmp = DowncastCCParticipant<_class >(p);

#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END                             \
    (void)tmp;                                                                 \
    return false;                                                              \
  }

///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing nsCycleCollectionParticipant::Unlink
//
// You need to use NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED if you want
// the base class Unlink version to be called before your own implementation.
// You can use NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED if you want the
// base class Unlink to get called after your own implementation.  You should
// never use them together.
///////////////////////////////////////////////////////////////////////////////

#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                          \
  NS_METHOD                                                                    \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p)                   \
  {                                                                            \
    _class *tmp = DowncastCCParticipant<_class >(p);

#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base_class)   \
  NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                \
    nsISupports *s = static_cast<nsISupports*>(p);                             \
    NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::UnlinkImpl(s);

#define NS_IMPL_CYCLE_COLLECTION_UNLINK(_field)                                \
    ImplCycleCollectionUnlink(tmp->_field);

#define NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                    \
    (void)tmp;                                                                 \
    return NS_OK;                                                              \
  }

#define NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(_base_class)             \
    nsISupports *s = static_cast<nsISupports*>(p);                             \
    NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::UnlinkImpl(s);                 \
    (void)tmp;                                                                 \
    return NS_OK;                                                              \
  }

#define NS_IMPL_CYCLE_COLLECTION_UNLINK_0(_class)                              \
  NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                \
  NS_IMPL_CYCLE_COLLECTION_UNLINK_END


///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing nsCycleCollectionParticipant::Traverse
///////////////////////////////////////////////////////////////////////////////

#define NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, _refcnt)                     \
    cb.DescribeRefCountedNode(_refcnt, #_class);

#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class)               \
  NS_METHOD                                                                    \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraverseImpl                          \
                         (NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, void *p,\
                          nsCycleCollectionTraversalCallback &cb)              \
  {                                                                            \
    _class *tmp = DowncastCCParticipant<_class >(p);

#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_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base_class) \
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class)                     \
    nsISupports *s = static_cast<nsISupports*>(p);                             \
    if (NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::TraverseImpl(that, s, cb)  \
        == NS_SUCCESS_INTERRUPTED_TRAVERSE) {                                  \
      return NS_SUCCESS_INTERRUPTED_TRAVERSE;                                  \
    }

#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_field)                              \
  ImplCycleCollectionTraverse(cb, tmp->_field, #_field, 0);

#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(_field)                       \
  CycleCollectionNoteChild(cb, tmp->_field, #_field);

#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS                       \
  {                                                                            \
  TraceCallbackFunc noteJsChild(&nsScriptObjectTracer::NoteJSChild);           \
  that->Trace(p, noteJsChild, &cb);                                            \
  }

#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END                                  \
    (void)tmp;                                                                 \
    return NS_OK;                                                              \
  }

///////////////////////////////////////////////////////////////////////////////
// Helpers for implementing nsScriptObjectTracer::Trace
///////////////////////////////////////////////////////////////////////////////

#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class)                                 \
  void                                                                               \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraceImpl(void *p,                          \
                                                   const TraceCallbacks &aCallbacks, \
                                                   void *aClosure)                   \
  {                                                                                  \
    _class *tmp = DowncastCCParticipant<_class >(p);

#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(_class, _base_class)    \
  NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class)                                 \
    nsISupports *s = static_cast<nsISupports*>(p);                             \
    NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::TraceImpl(s,                   \
                                                          aCallbacks,          \
                                                          aClosure);

#define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(_field)              \
  if (tmp->_field)                                                             \
    aCallbacks.Trace(&tmp->_field, #_field, aClosure);

#define NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(_field)           \
  if (JSVAL_IS_TRACEABLE(tmp->_field)) {                                       \
    aCallbacks.Trace(&tmp->_field, #_field, aClosure);                         \
  }

// 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_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base)           \
public:                                                                        \
  static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that,   \
                            void *p, nsCycleCollectionTraversalCallback &cb);  \
  static NS_METHOD_(void) UnmarkIfPurpleImpl(void *s)                          \
  {                                                                            \
    Downcast(static_cast<nsISupports *>(s))->UnmarkIfPurple();                 \
  }                                                                            \
  static _class* Downcast(nsISupports* s)                                      \
  {                                                                            \
    return static_cast<_class*>(static_cast<_base*>(s));                       \
  }                                                                            \
  static nsISupports* Upcast(_class *p)                                        \
  {                                                                            \
    return NS_ISUPPORTS_CAST(_base*, p);                                       \
  }                                                                            \
  template <typename T>                                                        \
  friend nsISupports*                                                          \
  ToSupports(T* p, NS_CYCLE_COLLECTION_INNERCLASS* dummy);

#define NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base)                     \
  NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base)                 \
  static NS_METHOD UnlinkImpl(void *p);

#define NS_PARTICIPANT_AS(type, participant)                                   \
  const_cast<type*>(reinterpret_cast<const type*>(participant))

#define NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                 \
  static nsXPCOMCycleCollectionParticipant* GetParticipant()                   \
  {                                                                            \
    static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)>    \
      ::Type p = {                                                             \
        NS_IMPL_CYCLE_COLLECTION_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) \
      };                                                                       \
    return NS_PARTICIPANT_AS(nsXPCOMCycleCollectionParticipant, &p);           \
  }

/**
 * We use this macro to force that classes that inherit from a ccable class and
 * declare their own participant declare themselves as inherited cc classes.
 * To avoid possibly unnecessary vtables we only do this checking in debug
 * builds.
 */
#ifdef DEBUG
#define NOT_INHERITED_CANT_OVERRIDE virtual void BaseCycleCollectable() MOZ_FINAL {}
#else
#define NOT_INHERITED_CANT_OVERRIDE
#endif

#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_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                       \
};                                                                             \
  NOT_INHERITED_CANT_OVERRIDE

#define NS_DECL_CYCLE_COLLECTION_CLASS(_class)                                 \
  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _class)

// Cycle collector helper for ambiguous classes that can sometimes be skipped.
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS_AMBIGUOUS(_class, _base)        \
class NS_CYCLE_COLLECTION_INNERCLASS                                             \
 : public nsXPCOMCycleCollectionParticipant                                      \
{                                                                                \
  NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base)                             \
  static const bool isSkippable = true;                                          \
  static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed);           \
  static NS_METHOD_(bool) CanSkipInCCImpl(void *p);                              \
  static NS_METHOD_(bool) CanSkipThisImpl(void *p);                              \
  NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                       \
};                                                                             \
NOT_INHERITED_CANT_OVERRIDE

#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(_class)                       \
        NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS_AMBIGUOUS(_class, _class)

#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)                                   \
  static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \
  NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                               \
};                                                                                     \
NOT_INHERITED_CANT_OVERRIDE

#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _base)   \
class NS_CYCLE_COLLECTION_INNERCLASS                                                      \
 : public nsXPCOMCycleCollectionParticipant                                               \
{                                                                                         \
  NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base)                                      \
  static const bool isSkippable = true;                                                   \
  static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure);    \
  static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed);                    \
  static NS_METHOD_(bool) CanSkipInCCImpl(void *p);                                       \
  static NS_METHOD_(bool) CanSkipThisImpl(void *p);                                       \
  NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                                  \
};                                                                                        \
NOT_INHERITED_CANT_OVERRIDE

#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(_class)  \
  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)

#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(_class,       \
                                                                         _base_class)  \
class NS_CYCLE_COLLECTION_INNERCLASS                                                   \
 : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class)                                   \
{                                                                                      \
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class)                   \
  static const bool isSkippable = true;                                                \
  static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \
  static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed);                 \
  static NS_METHOD_(bool) CanSkipInCCImpl(void *p);                                    \
  static NS_METHOD_(bool) CanSkipThisImpl(void *p);                                    \
  NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                               \
};

#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:                                                                        \
  static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that,   \
                         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) \
  static NS_METHOD UnlinkImpl(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_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                       \
};

#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_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                       \
};

#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(_class,                 \
                                                               _base_class)            \
class NS_CYCLE_COLLECTION_INNERCLASS                                                   \
 : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class)                                   \
{                                                                                      \
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class)                   \
  static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \
  NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class)                               \
};

/**
 * This implements a stub UnmarkIfPurple 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) UnmarkIfPurple()                                        \
  {                                                                            \
  }                                                                            \

/**
 * Dummy class with a definition for CanSkip* function members, but no
 * implementation.
 * Implementation was added to please Win PGO. (See bug 765159)
 */
struct SkippableDummy
{
  static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed) { return false; }
  static NS_METHOD_(bool) CanSkipInCCImpl(void *p) { return false; }
  static NS_METHOD_(bool) CanSkipThisImpl(void *p) { return false; }
};

/**
 * Skippable<T> defines a class that always has definitions for CanSkip*
 * function members, so that T::isSkippable ? &Skippable<T>::CanSkip* : NULL
 * can compile when T::isSkippable is false and T doesn't have CanSkip*
 * definitions (which, as not being skippable, it's not supposed to have). 
 */
template <class T>
struct Skippable
 : public mozilla::Conditional<T::isSkippable, T, SkippableDummy>::Type
{ };


// VTables for the cycle collector participant implementations.

#define NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(_class)                         \
  {                                                                            \
    &_class::TraverseImpl,                                                     \
    &_class::RootImpl,                                                         \
    &_class::UnlinkImpl,                                                       \
    &_class::UnrootImpl,                                                       \
    &_class::UnmarkIfPurpleImpl,                                               \
    _class::isSkippable ? &Skippable<_class>::CanSkipImpl : NULL,              \
    _class::isSkippable ? &Skippable<_class>::CanSkipInCCImpl : NULL,          \
    _class::isSkippable ? &Skippable<_class>::CanSkipThisImpl : NULL           \
  }

#define NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(_class)           \
  NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(_class),                              \
  { &_class::TraceImpl }

#define NS_IMPL_CYCLE_COLLECTION_VTABLE(_class)                                \
  NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(_class)


// Cycle collector participant declarations.

#define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class)                     \
  public:                                                                      \
    static NS_METHOD RootImpl(void *n);                                        \
    static NS_METHOD UnlinkImpl(void *n);                                      \
    static NS_METHOD UnrootImpl(void *n);                                      \
    static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \
                           void *n, nsCycleCollectionTraversalCallback &cb);

#define NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class)               \
    static NS_METHOD_(void) UnmarkIfPurpleImpl(void *p)                        \
    {                                                                          \
        _class *tmp = static_cast<_class *>(p);                                \
        if (MOZ_LIKELY(tmp->mRefCnt.HasPurpleBufferEntry()))                   \
            tmp->mRefCnt.ReleasePurpleBufferEntry();                           \
    }

#define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(_class)                          \
  class NS_CYCLE_COLLECTION_INNERCLASS                                         \
   : public nsCycleCollectionParticipant                                       \
  {                                                                            \
     NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class)                        \
     NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class)                  \
     static nsCycleCollectionParticipant* GetParticipant()                     \
     {                                                                         \
        static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
        ::Type p = {                                                          \
           NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(                             \
              NS_CYCLE_COLLECTION_CLASSNAME(_class))                           \
        };                                                                     \
        return NS_PARTICIPANT_AS(nsCycleCollectionParticipant, &p);            \
    }                                                                          \
  };

#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class)            \
  class NS_CYCLE_COLLECTION_INNERCLASS                                         \
   : public nsScriptObjectTracer                                               \
  {                                                                            \
    NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class)                         \
    NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class)                   \
    static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb,       \
                                      void *closure);                          \
    static nsScriptObjectTracer* GetParticipant()                              \
    {                                                                          \
      static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)>  \
        ::Type participant = {                                                 \
          NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(                \
            NS_CYCLE_COLLECTION_CLASSNAME(_class))                             \
        };                                                                     \
      return NS_PARTICIPANT_AS(nsScriptObjectTracer, &participant);            \
    }                                  \
  };

#define NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(_class, _root_function)           \
  NS_METHOD                                                                    \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::RootImpl(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_METHOD                                                                    \
  NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnrootImpl(void *p)                   \
  {                                                                            \
    _class *tmp = static_cast<_class*>(p);                                     \
    tmp->_unroot_function();                                                   \
    return NS_OK;                                                              \
  }

// NS_IMPL_CYCLE_COLLECTION_0 is not defined because most of the time it doesn't
// make sense to add something to the CC that doesn't traverse to anything.

#define NS_IMPL_CYCLE_COLLECTION_1(_class, _f)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f)                                           \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f)                                         \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_2(_class, _f1, _f2)                           \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_3(_class, _f1, _f2, _f3)                      \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_4(_class, _f1, _f2, _f3, _f4)                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_5(_class, _f1, _f2, _f3, _f4, _f5)            \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_6(_class, _f1, _f2, _f3, _f4, _f5, _f6)       \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_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_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_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_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_9(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f9)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f9)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_10(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, _f10) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f9)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f10)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f9)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f10)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_17(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, \
                                    _f10, _f11, _f12, _f13, _f14, _f15, _f16, _f17)      \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                                 \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f9)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f10)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f11)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f12)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f13)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f14)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f15)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f16)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f17)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class)                               \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f9)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f10)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f11)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f12)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f13)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f14)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f15)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f16)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f17)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_1(_class, _base, _f1)               \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_2(_class, _base, _f1, _f2)          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_3(_class, _base, _f1, _f2, _f3)     \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_4(_class, _base, _f1, _f2, _f3, _f4) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_5(_class, _base, _f1, _f2, _f3, _f4, _f5) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_6(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_7(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_8(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_9(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f9)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f9)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_IMPL_CYCLE_COLLECTION_INHERITED_10(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, _f10) \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base)                \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f3)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f4)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f5)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f6)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f7)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f8)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f9)                                          \
 NS_IMPL_CYCLE_COLLECTION_UNLINK(_f10)                                         \
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END                                           \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base)              \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f1)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f2)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f3)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f4)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f5)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f6)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f7)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f8)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f9)                                        \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_f10)                                       \
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

#define NS_CYCLE_COLLECTION_NOTE_EDGE_NAME CycleCollectionNoteEdgeName

#endif // nsCycleCollectionParticipant_h__