mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-01 21:07:30 +09:00
Issue #2304 - Part 2 - Prerequisite: Teach GCPolicy about Maybe. https://bugzilla.mozilla.org/show_bug.cgi?id=1377008
This commit is contained in:
parent
3c9bbc9665
commit
64dc722b28
1 changed files with 18 additions and 0 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
#ifndef GCPolicyAPI_h
|
#ifndef GCPolicyAPI_h
|
||||||
#define GCPolicyAPI_h
|
#define GCPolicyAPI_h
|
||||||
|
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
|
|
||||||
#include "js/TraceKind.h"
|
#include "js/TraceKind.h"
|
||||||
|
|
@ -160,6 +161,23 @@ struct GCPolicy<mozilla::UniquePtr<T, D>>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// GCPolicy<Maybe<T>> forwards tracing/sweeping to GCPolicy<T*> if
|
||||||
|
// when the Maybe<T> is full.
|
||||||
|
template <typename T>
|
||||||
|
struct GCPolicy<mozilla::Maybe<T>>
|
||||||
|
{
|
||||||
|
static mozilla::Maybe<T> initial() { return mozilla::Maybe<T>(); }
|
||||||
|
static void trace(JSTracer* trc, mozilla::Maybe<T>* tp, const char* name) {
|
||||||
|
if (tp->isSome())
|
||||||
|
GCPolicy<T>::trace(trc, tp->ptr(), name);
|
||||||
|
}
|
||||||
|
static bool needsSweep(mozilla::Maybe<T>* tp) {
|
||||||
|
if (tp->isSome())
|
||||||
|
return GCPolicy<T>::needsSweep(tp->ptr());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace JS
|
} // namespace JS
|
||||||
|
|
||||||
#endif // GCPolicyAPI_h
|
#endif // GCPolicyAPI_h
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue