void nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length ) { // unfortunately, some callers pass null :-( if (!data) { length = 0; } else { if (length == size_type(-1)) length = char_traits::length(data); if (IsDependentOn(data, data + length)) { nsTAutoString_CharT temp(data, length); Replace(cutStart, cutLength, temp); return; } } cutStart = XPCOM_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, length) && length > 0) char_traits::copy(mData + cutStart, data, length); }
void nsTSubstring_CharT::AssignASCII( const char* data, size_type length ) { // A Unicode string can't depend on an ASCII string buffer, // so this dependence check only applies to CStrings. #ifdef CharT_is_char if (IsDependentOn(data, data + length)) { // take advantage of sharing here... Assign(string_type(data, length)); return; } #endif if (ReplacePrep(0, mLength, length)) char_traits::copyASCII(mData, data, length); }
bool nsTSubstring_CharT::AssignASCII( const char* data, size_type length, const fallible_t& ) { // A Unicode string can't depend on an ASCII string buffer, // so this dependence check only applies to CStrings. #ifdef CharT_is_char if (IsDependentOn(data, data + length)) { return Assign(string_type(data, length), fallible_t()); } #endif if (!ReplacePrep(0, mLength, length)) return false; char_traits::copyASCII(mData, data, length); return true; }
void nsTSubstring_CharT::ReplaceASCII( index_type cutStart, size_type cutLength, const char* data, size_type length ) { if (length == size_type(-1)) length = strlen(data); // A Unicode string can't depend on an ASCII string buffer, // so this dependence check only applies to CStrings. #ifdef CharT_is_char if (IsDependentOn(data, data + length)) { nsTAutoString_CharT temp(data, length); Replace(cutStart, cutLength, temp); return; } #endif cutStart = XPCOM_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, length) && length > 0) char_traits::copyASCII(mData + cutStart, data, length); }
bool nsTSubstring_CharT::Assign( const char_type* data, size_type length, const fallible_t& ) { if (!data) { Truncate(); return true; } if (length == size_type(-1)) length = char_traits::length(data); if (IsDependentOn(data, data + length)) { return Assign(string_type(data, length), fallible_t()); } if (!ReplacePrep(0, mLength, length)) return false; char_traits::copy(mData, data, length); return true; }
void nsTSubstring_CharT::Assign( const char_type* data, size_type length ) { // unfortunately, some callers pass null :-( if (!data) { Truncate(); return; } if (length == size_type(-1)) length = char_traits::length(data); if (IsDependentOn(data, data + length)) { // take advantage of sharing here... Assign(string_type(data, length)); return; } if (ReplacePrep(0, mLength, length)) char_traits::copy(mData, data, length); }
bool FClasses::IsDependentOn(const FClass* Suspect, const FClass* Source) const { check(Suspect != Source); TSet<const FClass*> VisitedDpendencies; return IsDependentOn(Suspect, Source, VisitedDpendencies); }
bool FClasses::IsDependentOn(const FClass* Suspect, const FClass* Source, TSet<const FClass*>& VisitedDpendencies) const { // Children are all implicitly dependent on their parent, that is, children require their parent // to be compiled first therefore if the source is a parent of the suspect, the suspect is // dependent on the source. if (Suspect->Inherits(Source)) { return true; } // Prevent circular #includes from causing inifinite recursion // Note that although it may mean there's a circular dependency somewhere, it does not // necessarily mean it's the one we're looking for if (VisitedDpendencies.Contains(Suspect)) { return false; } else { VisitedDpendencies.Add(Suspect); } // Now consider all dependents of the suspect. If any of them are dependent on the source, the // suspect is too. for (auto It : Suspect->GetDependentNames()) { auto DependentName = It.ToString(); const FClass* Dependency = FindClass(*DependentName); if (!Dependency) { // Check if DependentName is a header file. If so, rerun the check on name without ".h" extension. if (DependentName.EndsWith(TEXT(".h"))) { DependentName.RemoveFromEnd(TEXT(".h")); Dependency = FindClass(*DependentName); } // If still no class found, we're out of luck. if (!Dependency) { continue; } } // the parser disallows declaring the parent class as a dependency, so the only way this could occur is // if the parent for a native class has been changed (which causes the new parent to be inserted as a dependency), // if this is the case, skip it or we'll go into a loop if (Suspect->GetSuperClass() == Dependency) { continue; } // Ignore inter-module dependencies, since modules should be self-contained when they are compiled. if (Dependency->GetOutermost() != Suspect->GetOutermost()) { continue; } if (Dependency == Source || IsDependentOn(Dependency, Source, VisitedDpendencies)) { return true; } } return false; }