本文整理汇总了C++中SourceFile::ReleaseReference方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceFile::ReleaseReference方法的具体用法?C++ SourceFile::ReleaseReference怎么用?C++ SourceFile::ReleaseReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFile
的用法示例。
在下文中一共展示了SourceFile::ReleaseReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
status_t
TeamDebugInfo::LoadSourceCode(LocatableFile* file, FileSourceCode*& _sourceCode)
{
AutoLocker<BLocker> locker(fLock);
// If we don't know the source file, there's nothing we can do.
SourceFileEntry* entry = fSourceFiles->Lookup(file);
if (entry == NULL)
return B_ENTRY_NOT_FOUND;
// the source might already be loaded
FileSourceCode* sourceCode = entry->GetSourceCode();
if (sourceCode != NULL) {
sourceCode->AcquireReference();
_sourceCode = sourceCode;
return B_OK;
}
// get the source language from some function's image debug info
Function* function = entry->FunctionAt(0);
if (function == NULL)
return B_ENTRY_NOT_FOUND;
FunctionDebugInfo* functionDebugInfo
= function->FirstInstance()->GetFunctionDebugInfo();
SourceLanguage* language;
status_t error = functionDebugInfo->GetSpecificImageDebugInfo()
->GetSourceLanguage(functionDebugInfo, language);
if (error != B_OK)
return error;
BReference<SourceLanguage> languageReference(language, true);
// no source code yet
// locker.Unlock();
// TODO: It would be nice to unlock here, but we need to iterate through
// the images below. We could clone the list, acquire references, and
// unlock. Then we have to compare the list with the then current list when
// we're done loading.
// load the source file
SourceFile* sourceFile;
error = fFileManager->LoadSourceFile(file, sourceFile);
if (error != B_OK)
return error;
// create the source code
sourceCode = new(std::nothrow) FileSourceCode(file, sourceFile, language);
sourceFile->ReleaseReference();
if (sourceCode == NULL)
return B_NO_MEMORY;
BReference<FileSourceCode> sourceCodeReference(sourceCode, true);
error = sourceCode->Init();
if (error != B_OK)
return error;
// Iterate through all images that know the source file and ask them to add
// information.
bool anyInfo = false;
for (int32 i = 0; ImageDebugInfo* imageDebugInfo = fImages.ItemAt(i); i++)
anyInfo |= imageDebugInfo->AddSourceCodeInfo(file, sourceCode) == B_OK;
if (!anyInfo)
return B_ENTRY_NOT_FOUND;
entry->SetSourceCode(sourceCode);
_sourceCode = sourceCodeReference.Detach();
return B_OK;
}