本文整理汇总了C++中framework::CMemStream::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CMemStream::GetLength方法的具体用法?C++ CMemStream::GetLength怎么用?C++ CMemStream::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类framework::CMemStream
的用法示例。
在下文中一共展示了CMemStream::GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoMarshalInterface
void CWin32EmbedServer::WriteInterfaceToConsole()
{
Framework::CMemStream marshalStream;
{
auto comStream = Framework::Win32::CComPtr<Framework::Win32::CComStreamAdapter>(
new Framework::Win32::CComStreamAdapter(marshalStream));
DWORD dstContext = 0;
HRESULT result = S_OK;
result = CoMarshalInterface(comStream, IID_IEmbedApplication, this, MSHCTX_LOCAL, NULL, 0);
assert(SUCCEEDED(result));
}
{
BOOL result = FALSE;
DWORD numberWritten = 0;
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
assert(stdoutHandle != 0);
DWORD marshalSize = marshalStream.GetLength();
result = WriteFile(stdoutHandle, &marshalSize, sizeof(DWORD), &numberWritten, nullptr);
assert(result);
assert(numberWritten == sizeof(DWORD));
result = WriteFile(stdoutHandle, marshalStream.GetBuffer(), marshalSize, &numberWritten, nullptr);
assert(result);
assert(numberWritten == marshalSize);
}
}
示例2: Compile
//.........这里部分代码省略.........
if(!strcmp(imageFormatName, "coff"))
{
objectFile = std::make_unique<Jitter::CCoffObjectFile>(cpuArch);
}
else if(!strcmp(imageFormatName, "macho"))
{
objectFile = std::make_unique<Jitter::CMachoObjectFile>(cpuArch);
}
else
{
throw std::runtime_error("Invalid executable image type (must be coff or macho).");
}
codeGen->RegisterExternalSymbols(objectFile.get());
objectFile->AddExternalSymbol("_MemoryUtils_GetByteProxy", &MemoryUtils_GetByteProxy);
objectFile->AddExternalSymbol("_MemoryUtils_GetHalfProxy", &MemoryUtils_GetHalfProxy);
objectFile->AddExternalSymbol("_MemoryUtils_GetWordProxy", &MemoryUtils_GetWordProxy);
objectFile->AddExternalSymbol("_MemoryUtils_SetByteProxy", &MemoryUtils_SetByteProxy);
objectFile->AddExternalSymbol("_MemoryUtils_SetHalfProxy", &MemoryUtils_SetHalfProxy);
objectFile->AddExternalSymbol("_MemoryUtils_SetWordProxy", &MemoryUtils_SetWordProxy);
objectFile->AddExternalSymbol("_LWL_Proxy", &LWL_Proxy);
objectFile->AddExternalSymbol("_LWR_Proxy", &LWR_Proxy);
objectFile->AddExternalSymbol("_SWL_Proxy", &SWL_Proxy);
objectFile->AddExternalSymbol("_SWR_Proxy", &SWR_Proxy);
filesystem::path databasePath(databasePathName);
auto blocks = GetBlocksFromCache(databasePath);
//Initialize Jitter Service
auto jitter = new CMipsJitter(codeGen);
for(unsigned int i = 0; i < 4; i++)
{
jitter->SetVariableAsConstant(
offsetof(CMIPS, m_State.nGPR[CMIPS::R0].nV[i]),
0
);
}
printf("Got %d blocks to compile.\r\n", blocks.size());
FunctionTable functionTable;
functionTable.reserve(blocks.size());
for(const auto& blockCachePair : blocks)
{
const auto& blockKey = blockCachePair.first;
auto functionName = "aotblock_" + std::to_string(blockKey.crc) + "_" + std::to_string(blockKey.begin) + "_" + std::to_string(blockKey.end);
unsigned int functionSymbolIndex = CompileFunction(virtualMachine, jitter, blockCachePair.second, *objectFile, functionName, blockKey.begin, blockKey.end);
FUNCTION_TABLE_ITEM tableItem = { blockKey, functionSymbolIndex };
functionTable.push_back(tableItem);
}
std::sort(functionTable.begin(), functionTable.end(),
[] (const FUNCTION_TABLE_ITEM& item1, const FUNCTION_TABLE_ITEM& item2)
{
return item1.key < item2.key;
}
);
{
Framework::CMemStream blockTableStream;
Jitter::CObjectFile::INTERNAL_SYMBOL blockTableSymbol;
blockTableSymbol.name = "__aot_firstBlock";
blockTableSymbol.location = Jitter::CObjectFile::INTERNAL_SYMBOL_LOCATION_DATA;
for(const auto& functionTableItem : functionTable)
{
blockTableStream.Write32(functionTableItem.key.crc);
blockTableStream.Write32(functionTableItem.key.begin);
blockTableStream.Write32(functionTableItem.key.end);
{
Jitter::CObjectFile::SYMBOL_REFERENCE ref;
ref.offset = static_cast<uint32>(blockTableStream.Tell());
ref.type = Jitter::CObjectFile::SYMBOL_TYPE_INTERNAL;
ref.symbolIndex = functionTableItem.symbolIndex;
blockTableSymbol.symbolReferences.push_back(ref);
}
blockTableStream.Write32(0);
}
blockTableSymbol.data = std::vector<uint8>(blockTableStream.GetBuffer(), blockTableStream.GetBuffer() + blockTableStream.GetLength());
objectFile->AddInternalSymbol(blockTableSymbol);
}
{
Jitter::CObjectFile::INTERNAL_SYMBOL blockCountSymbol;
blockCountSymbol.name = "__aot_blockCount";
blockCountSymbol.location = Jitter::CObjectFile::INTERNAL_SYMBOL_LOCATION_DATA;
blockCountSymbol.data = std::vector<uint8>(4);
*reinterpret_cast<uint32*>(blockCountSymbol.data.data()) = functionTable.size();
objectFile->AddInternalSymbol(blockCountSymbol);
}
objectFile->Write(Framework::CStdStream(outputPath, "wb"));
}