bool nsSmallVoidArray::SizeTo(int32_t aMin) { if (!HasSingle()) { return AsArray()->SizeTo(aMin); } if (aMin <= 0) { mImpl = nullptr; return true; } if (aMin == 1) { return true; } void* single = GetSingle(); mImpl = nullptr; if (!AsArray()->SizeTo(aMin)) { SetSingle(single); return false; } AsArray()->AppendElement(single); return true; }
PRBool nsSmallVoidArray::SizeTo(PRInt32 aMin) { if (!HasSingle()) { return AsArray()->SizeTo(aMin); } if (aMin <= 0) { mImpl = nsnull; return PR_TRUE; } if (aMin == 1) { return PR_TRUE; } void* single = GetSingle(); mImpl = nsnull; if (!AsArray()->SizeTo(aMin)) { SetSingle(single); return PR_FALSE; } AsArray()->AppendElement(single); return PR_TRUE; }
CP CLispEng::CopyVector(CP p) { Push(p); CArrayValue *oav = AsArray(p); size_t size = oav->DataLength; CArrayValue *av = CreateVector(size, oav->GetElementType()); oav = AsArray(Pop()); memcpy(av->m_pData, oav->m_pData, oav->GetByteLength()); return FromSValue(av); }
void nsSmallVoidArray::Compact() { if (!HasSingle()) { AsArray()->Compact(); } }
void nsSmallVoidArray::Sort(nsVoidArrayComparatorFunc aFunc, void* aData) { if (!HasSingle()) { AsArray()->Sort(aFunc,aData); } }
FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const { if (this == pOther) return TRUE; if (!pOther) return FALSE; if (pOther->m_Type != m_Type) { if (IsReference() && GetDirect()) return GetDirect()->IsIdentical(pOther); if (pOther->IsReference()) return IsIdentical(pOther->GetDirect()); return FALSE; } switch (m_Type) { case PDFOBJ_BOOLEAN: return AsBoolean()->Identical(pOther->AsBoolean()); case PDFOBJ_NUMBER: return AsNumber()->Identical(pOther->AsNumber()); case PDFOBJ_STRING: return AsString()->Identical(pOther->AsString()); case PDFOBJ_NAME: return AsName()->Identical(pOther->AsName()); case PDFOBJ_ARRAY: return AsArray()->Identical(pOther->AsArray()); case PDFOBJ_DICTIONARY: return AsDictionary()->Identical(pOther->AsDictionary()); case PDFOBJ_NULL: return TRUE; case PDFOBJ_STREAM: return AsStream()->Identical(pOther->AsStream()); case PDFOBJ_REFERENCE: return AsReference()->Identical(pOther->AsReference()); } return FALSE; }
CArrayValue *CLispEng::ToVector(CP p) { if (Type(p) == TS_ARRAY) { CArrayValue *av = AsArray(p); if (Type(av->m_dims) == TS_FIXNUM) return av; } E_TypeErr(p, S(L_VECTOR)); }
PRBool nsSmallVoidArray::EnumerateBackwards(nsVoidArrayEnumFunc aFunc, void* aData) { if (HasSingle()) { return (*aFunc)(GetSingle(), aData); } return AsArray()->EnumerateBackwards(aFunc,aData); }
inline std::vector<std::string> Object::Get<std::vector<std::string>>(const std::string &key) const { auto value = Find(key); std::vector<std::string> result; for(auto &entry : value->AsArray()) result.push_back(entry->AsString()); return result; }
CClosure *CLispEng::CopyClosure(CP oldClos) { CClosure *oc = ToCClosure(oldClos); size_t len = AsArray(oldClos)->DataLength; CClosure *nc = CreateClosure(len); nc->NameOrClassVersion = oc->NameOrClassVersion; nc->CodeVec = oc->CodeVec; memcpy(nc->Consts, oc->Consts, len*sizeof(CP)); return nc; }
PRInt32 nsSmallVoidArray::IndexOf(void* aPossibleElement) const { if (HasSingle()) { return aPossibleElement == GetSingle() ? 0 : -1; } return AsArray()->IndexOf(aPossibleElement); }
PRInt32 nsSmallVoidArray::Count() const { if (HasSingle()) { return 1; } return AsArray()->Count(); }
PRInt32 nsSmallVoidArray::GetArraySize() const { if (HasSingle()) { return 1; } return AsArray()->GetArraySize(); }
void nsSmallVoidArray::Clear() { if (HasSingle()) { mImpl = nsnull; } else { AsArray()->Clear(); } }
bool CLispEng::StringP(CP p) { if (!VectorP(p)) return false; switch (AsArray(p)->GetElementType()) { case ELTYPE_CHARACTER: case ELTYPE_BASECHAR: return true; } return false; }
void* nsSmallVoidArray::FastElementAt(PRInt32 aIndex) const { NS_ASSERTION(0 <= aIndex && aIndex < Count(), "nsSmallVoidArray::FastElementAt: index out of range"); if (HasSingle()) { return GetSingle(); } return AsArray()->FastElementAt(aIndex); }
void nsSmallVoidArray::RemoveElementAt(int32_t aIndex) { if (HasSingle()) { if (aIndex == 0) { mImpl = nullptr; } return; } AsArray()->RemoveElementAt(aIndex); }
PRBool nsSmallVoidArray::RemoveElement(void* aElement) { if (HasSingle()) { if (aElement == GetSingle()) { mImpl = nsnull; return PR_TRUE; } return PR_FALSE; } return AsArray()->RemoveElement(aElement); }
bool nsSmallVoidArray::RemoveElement(void* aElement) { if (HasSingle()) { if (aElement == GetSingle()) { mImpl = nullptr; return true; } return false; } return AsArray()->RemoveElement(aElement); }
void nsSmallVoidArray::RemoveElementsAt(int32_t aIndex, int32_t aCount) { if (HasSingle()) { if (aIndex == 0) { if (aCount > 0) { mImpl = nullptr; } } return; } AsArray()->RemoveElementsAt(aIndex, aCount); }
PRBool nsSmallVoidArray::RemoveElementAt(PRInt32 aIndex) { if (HasSingle()) { if (aIndex == 0) { mImpl = nsnull; return PR_TRUE; } return PR_FALSE; } return AsArray()->RemoveElementAt(aIndex); }
bool nsSmallVoidArray::RemoveElementAt(PRInt32 aIndex) { if (HasSingle()) { if (aIndex == 0) { mImpl = nsnull; return true; } return false; } return AsArray()->RemoveElementAt(aIndex); }
PRBool nsSmallVoidArray::EnsureArray() { if (!HasSingle()) { return PR_TRUE; } void* single = GetSingle(); mImpl = nsnull; if (!AsArray()->AppendElement(single)) { SetSingle(single); return PR_FALSE; } return PR_TRUE; }
bool nsSmallVoidArray::EnsureArray() { if (!HasSingle()) { return true; } void* single = GetSingle(); mImpl = nullptr; if (!AsArray()->AppendElement(single)) { SetSingle(single); return false; } return true; }
bool nsSmallVoidArray::InsertElementAt(void* aElement, int32_t aIndex) { NS_ASSERTION(!(NS_PTR_TO_INT32(aElement) & 0x1), "Attempt to add element with 0x1 bit set to nsSmallVoidArray"); if (aIndex == 0 && IsEmpty()) { SetSingle(aElement); return true; } if (!EnsureArray()) { return false; } return AsArray()->InsertElementAt(aElement, aIndex); }
PRBool nsSmallVoidArray::ReplaceElementAt(void* aElement, PRInt32 aIndex) { NS_ASSERTION(!(NS_PTR_TO_INT32(aElement) & 0x1), "Attempt to add element with 0x1 bit set to nsSmallVoidArray"); if (aIndex == 0 && (IsEmpty() || HasSingle())) { SetSingle(aElement); return PR_TRUE; } if (!EnsureArray()) { return PR_FALSE; } return AsArray()->ReplaceElementAt(aElement, aIndex); }
PRBool nsSmallVoidArray::AppendElement(void* aElement) { NS_ASSERTION(!(NS_PTR_TO_INT32(aElement) & 0x1), "Attempt to add element with 0x1 bit set to nsSmallVoidArray"); if (IsEmpty()) { SetSingle(aElement); return PR_TRUE; } if (!EnsureArray()) { return PR_FALSE; } return AsArray()->AppendElement(aElement); }
nsSmallVoidArray& nsSmallVoidArray::operator=(nsSmallVoidArray& other) { PRInt32 count = other.Count(); switch (count) { case 0: Clear(); break; case 1: Clear(); AppendElement(other.ElementAt(0)); break; default: if (GetArraySize() >= count || SizeTo(count)) { *AsArray() = *other.AsArray(); } } return *this; }
void CPDF_Object::Destroy() { switch (m_Type) { case PDFOBJ_STRING: delete AsString(); break; case PDFOBJ_NAME: delete AsName(); break; case PDFOBJ_ARRAY: delete AsArray(); break; case PDFOBJ_DICTIONARY: delete AsDictionary(); break; case PDFOBJ_STREAM: delete AsStream(); break; default: delete this; } }
PRBool nsSmallVoidArray::InsertElementsAt(const nsVoidArray &aOther, PRInt32 aIndex) { #ifdef DEBUG for (int i = 0; i < aOther.Count(); i++) { NS_ASSERTION(!(NS_PTR_TO_INT32(aOther.ElementAt(i)) & 0x1), "Attempt to add element with 0x1 bit set to nsSmallVoidArray"); } #endif if (aIndex == 0 && IsEmpty() && aOther.Count() == 1) { SetSingle(aOther.FastElementAt(0)); return PR_TRUE; } if (!EnsureArray()) { return PR_FALSE; } return AsArray()->InsertElementsAt(aOther, aIndex); }