void DataFileDB::SaveToDisk() { Dump("SaveToDisk()","save all data"); if(dbtype==DBSingleFile) { WriteFile("type",TypeToString(DBSingleFile)); WriteFile("value",tostr(*this).String()); } else if(dbtype==DBStringKeys) { WriteFile("type",TypeToString(DBStringKeys)); Data keys; keys.MakeList(status.size()); for(size_t i=0; i<status.size(); i++) { keys[i].MakeList(2); keys[i][0]=vec[i][0]; SaveCache(i); } WriteFile("keys",tostr(keys).String()); } else throw Error::NotYetImplemented("DataToDisk::SaveContent()"); MarkAllClean(); }
void Rule::save(QDomElement* root, QDomDocument* document) { QDomElement rule = document->createElement("rule"); for(std::vector<Condition*>::iterator it = m_listConditions.begin(); it != m_listConditions.end(); it++) { (*it)->save(&rule, document); } for(std::vector<Action*>::iterator it = m_listActions.begin(); it != m_listActions.end(); it++) { (*it)->save(&rule, document); } // save name QDomElement name = document->createElement("name"); QDomText nameText = document->createTextNode(QString::fromStdString(this->m_name)); name.appendChild(nameText); rule.appendChild(name); // save type QDomElement type = document->createElement("type"); QDomText typeText = document->createTextNode( QString::fromStdString( TypeToString(m_type) ) ); type.appendChild(typeText); rule.appendChild(type); root->appendChild(rule); }
void DOSBoxMenu::dump_log_displaylist(DOSBoxMenu::displaylist &ls, unsigned int indent) { std::string prep; for (unsigned int i=0;i < indent;i++) prep += "+ "; for (auto &id : ls.disp_list) { DOSBoxMenu::item &item = get_item(id); if (!item.is_allocated()) { LOG_MSG("%s (NOT ALLOCATED!!!)",prep.c_str()); continue; } LOG_MSG("%sid=%u type=\"%s\" name=\"%s\" text=\"%s\"", prep.c_str(), (unsigned int)item.master_id, TypeToString(item.type), item.name.c_str(), item.text.c_str()); if (item.type == submenu_type_id) dump_log_displaylist(item.display_list, indent+1); } }
void Token::PrintToken () { fout << line << "\t" << column << "\t" << TypeToString(type) <<"\t" << lexeme << "\n"; }
LLBC_String LLBC_Variant::ToString() const { LLBC_String desc = "type:"; desc += TypeToString(); desc += ", value:"; desc += ValueToString(); return desc; }
/** * Write a log message. * * @param type Log message type. * @param msg Message to log. */ void WiiLogger::Write(LoggerType type, string msg) { std::ostringstream out; out << TypeToString(type) << " "; out << Utils::DateTime::GetCurrent() << ": "; out << msg << std::endl; string s = out.str(); net_print_string(NULL, 0, s.c_str()); }
void PrintSymbolTable() { int i; printf("\n --- Symbol Table ---------------\n\n"); for (i=0; i < HASH_TABLE_SIZE; i++) { if (HashTable[i] != NULL) { printf("\t \"%s\" of type %s with offset %d\n", HashTable[i]->name, TypeToString(HashTable[i]->type), HashTable[i]->offset); } } printf("\n --------------------------------\n\n"); }
/** * @brief Logs the specified message with a timestamp and category prefix * The constant TIMESTAMP_BUFFER_SIZE was calculated as the maximum number of * characters required for the timestamp "[HH:MM:SS MM/DD/YY] ". * * @param type The category of message to write based on the enum Log::Type * @param message The message to be sent * @return True if the log was successful */ bool Log::log( const Type& type, const std::string& message ) { if( type <= m_threshold ) { static const int TIMESTAMP_BUFFER_SIZE = 21; char buffer[TIMESTAMP_BUFFER_SIZE]; time_t timestamp; time( ×tamp ); strftime( buffer, sizeof( buffer ), "%X %x", localtime( ×tamp ) ); write( "[%s] %s - %s", buffer, TypeToString( type ), message.c_str() ); return true; } return false; }
void DataFileDB::CreateEmpty() { Dump("CreateEmpty()","initialize"); if(DatabaseExist()) throw Error::IO("DataFileDB::CreateEmpty()","database "+dir+" already created"); if(dbtype==DBNone) throw Error::IO("DataFileDB::CreateEmpty()","cannot create database of type DBNone"); else if(dbtype==DBSingleFile) { #ifdef WIN32 _mkdir(dir.c_str()); #else mkdir(dir.c_str(),0700); #endif WriteFile("type",TypeToString(dbtype)); WriteFile("value","NULL"); } else if(dbtype==DBStringKeys) { #ifdef WIN32 _mkdir(dir.c_str()); _mkdir((dir+"/data").c_str()); #else mkdir(dir.c_str(),0700); mkdir((dir+"/data").c_str(),0700); #endif WriteFile("type",TypeToString(dbtype)); WriteFile("keys","(,)"); status=vector<DBEntryStatus>(); MakeList(); } else throw Error::NotYetImplemented("DataFileDB::CreateEmpty()"); }
void WhileStatement::ExecuteStatement() { ResultValue r = condition->Evaluate(); if (TypeToString(r.type)!="None"){ while (r.value.bool_value){ loop_body->ExecuteStatement(); r = condition->Evaluate(); } } else cout << " ERROR en While ("<<line<<","<<column<<"): Condicion no pudo evaluarse."<<endl; }
SSRecord::SSRecord (eType type, const void* buffer, int len) : m_Offset(0), m_pBuffer(NULL), m_Len (0) { m_Header.checksum = calc_crc16 (buffer, len); strncpy (m_Header.type, TypeToString (type).c_str(), 2); m_Header.size = len; // OPTIMIZE: We do not nead to read all the record payload in advance (esp. for FD records) if (m_Header.size > 0) { m_pBuffer = new byte[m_Header.size]; memcpy (m_pBuffer, buffer, m_Header.size); } m_Len = m_Header.size; }
T Pop(){ if( internalCount == 0 ){ throw std::out_of_range("Tried to pop argument after stack was exhausted"); } void *savedPtr = internalPtr; size_t savedSize = internalSize; type_t type = ReadInt(internalPtr, internalSize); if( type != GenType<T>::value ){ internalPtr = savedPtr; internalSize = savedSize; throw std::invalid_argument("Attempted to read type " + TypeToString(type) + " as " + TypeToString(GenType<T>::value) ); } //Ensure any exception throwing doesn't corrupt internal state... auto ret = ReadData<T>::Call(internalPtr, internalSize); --internalCount; return ret; }
void IfStatement::ExecuteStatement() { ResultValue r = condition->Evaluate(); if (TypeToString(r.type)!="None"){ if (r.value.bool_value){ if (true_part!=0) true_part->ExecuteStatement(); } else{ if (false_part!=0) false_part->ExecuteStatement(); } } else cout << " ERROR en If ("<<line<<","<<column<<"): Condicion no pudo evaluarse."<<endl; }
bool DatagramSocket::Connect() { addrinfo hints; addrinfo* serverInfo; int ret; int fd = -1; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; if ((ret = getaddrinfo(m_hostAddr.c_str(), TypeToString(m_hostPort).c_str(), &hints, &serverInfo)) != 0) { std::cerr << "getaddrinfo failed: " << gai_strerror(ret) << std::endl; return false; } // Loop all the results from getaddrinfo until we get a valid connection for (; serverInfo != NULL; serverInfo = serverInfo->ai_next) { if ((fd = socket(serverInfo->ai_family, serverInfo->ai_socktype, serverInfo->ai_protocol)) < 0) { continue; } // connect() the fd so that we can use send and recv if (connect(fd, serverInfo->ai_addr, serverInfo->ai_addrlen) != -1) { break; } close(fd); fd = -1; } if (fd < 0) { std::cerr << "Unable to connect to " << m_hostAddr << ":" << m_hostPort << std::endl; return false; } m_socketFd = fd; m_hostInfo = serverInfo; m_isConnected = true; return true; }
void DOSBoxMenu::dump_log_debug(void) { LOG_MSG("Menu dump log (%p)",(void*)this); LOG_MSG("---- Master list ----"); for (auto &id : master_list) { if (id.is_allocated()) { LOG_MSG("+ id=%u type=\"%s\" name=\"%s\" text=\"%s\" shortcut=\"%s\" desc=\"%s\"", (unsigned int)id.master_id, TypeToString(id.type), id.name.c_str(), id.text.c_str(), id.shortcut_text.c_str(), id.description.c_str()); if (!id.get_mapper_event().empty()) LOG_MSG("+ + mapper_event=\"%s\"",id.get_mapper_event().c_str()); } } LOG_MSG("---- display list ----"); dump_log_displaylist(display_list, 1); }
/* * Logs the result of a test case to the file in the following form: * <TestDir>,<Section>,<SubSection>,<Name>,<type>,<result>,<Output> */ void LogResult(FILE *ResultsFile, const char *Section, const char *SubSection, const char *Name, TEST_TYPE Type, const char *TestDir, const char *Phase, const char *Result, const char *Output) { int MaxSize; size_t nChars; char logBuffer[LINE_BUF_SIZE * 2]; char *testType; testType = TypeToString(Type); MaxSize = sizeof(logBuffer); if (Output == NULL) { Output = ""; } /* * Silently fail if we run out of buffer space, but throw a null in to be * safe. */ AppendDelimitedStringsVA(logBuffer, MaxSize, C_COMMA, C_ESCAPE, TestDir, Section, SubSection, Name, testType, Phase, Result, Output, NULL); logBuffer[MaxSize - 1] = 0; RemoveLinefeeds(logBuffer); nChars = fprintf(ResultsFile, "%s\n", logBuffer); if (nChars < strlen(logBuffer)+1) { HarnessError("ERROR: Failed to write to the file to log the " "results. This is a fatal error. errno is %d.\n",errno); } }
QVariant CNeighboursTableModel::data(const QModelIndex& index, int role) const { if( !index.isValid() ) return QVariant(); if( index.row() > m_lNodes.size() || index.row() < 0 ) return QVariant(); if ( role == Qt::DecorationRole ) { const sNeighbour& n = m_lNodes.at(index.row()); if (index.column() == 0) { return n.iNetwork; } if(index.column() == 10) { return n.iCountry; } } if( role == Qt::DisplayRole ) { const sNeighbour& n = m_lNodes.at(index.row()); switch( index.column() ) { case 0: return n.pNode->GetAddress().toString(); case 1: return StateToString(n.nState); case 2: return QString().sprintf("%.2u:%.2u:%.2u", n.tConnected / 3600, (n.tConnected % 3600 / 60), (n.tConnected % 3600) % 60); case 3: return QString().sprintf("%1.3f / %1.3f", n.nBandwidthIn / 1024.0f, n.nBandwidthOut / 1024.0f); case 4: return QString().sprintf("%1.3f / %1.3f KB (%1.2f / %1.2f %%)", n.nBytesReceived / 1024.0f, n.nBytesSent / 1024.0f, 100.0f * n.nBytesReceived / n.nCompressionIn, 100.0f * n.nBytesSent / n.nCompressionOut ); case 5: return QString().sprintf("%u - %u", n.nPacketsIn, n.nPacketsOut); case 6: return TypeToString(n.nType); case 7: if( n.nType == G2_HUB ) { return QString().sprintf("%u / %u", n.nLeafCount, n.nLeafMax); } else return QString(); case 8: return QString().sprintf("%u msec", n.nRTT); case 9: return n.sUserAgent; case 10: return n.sCountry; } } else if( role == Qt::ForegroundRole ) { if( m_lNodes.at(index.row()).nState == nsConnected ) return skinSettings.neighborsColorConnected; else return skinSettings.neighborsColorConnecting; } return QVariant(); }
/** * Returns the type of surface in a string. */ string IND_Surface::getTypeString() { return TypeToString(_surface->_attributes._type); }
string AssignmentStatement::GenerateCode(){ stringstream varCode; ResultValue lvalue_r = lvalue->GenerateCode(); ResultValue rvalue_r = expr->GenerateCode(); LValueExpression* n = (LValueExpression*)lvalue; cout << " 1: " << lvalue_r.code << " 2: " << rvalue_r.code << endl; if (!ExistVarGlobal(n->variable_name) && !ExistVarTemp(n->variable_name)){ cout << "("<<line<<","<<column<<"): Variable \'" << n->variable_name << "\' no ha sido declarada."<<endl; } else if (lvalue_r.type == rvalue_r.type){ if (ExistVarGlobal(n->variable_name)){ if (rvalue_r.isConstant){ string p = newTemp(); varCode << rvalue_r.code; varCode << " li " << p << ", " << rvalue_r.value.int_value << endl; // VALIDAR los demas tipos (bool, string) varCode << " sw " << p << ", " << n->variable_name << endl; releaseTemp(p); } else { string p = newTemp(); varCode << rvalue_r.code; varCode << " sw " << rvalue_r.place << ", " << n->variable_name << endl; releaseTemp(p); } } if (ExistVarTemp(n->variable_name)){ if (rvalue_r.isConstant) varCode << " li " << varsTemp[n->variable_name].place << ", " << rvalue_r.value.int_value << endl; else varCode << " move " << varsTemp[n->variable_name].place << ", " << rvalue_r.place << endl; } } else cout << " ERROR en Statement ("<<line<<","<<column<<"): Variable \'"<< n->variable_name << "\' No se puede convertir \'" << TypeToString(rvalue_r.type) << "\' a \'" << TypeToString(lvalue_r.type) << "\'"<<endl; return varCode.str(); }
/** * Write a log message. * * @param type Log message type. * @param msg Message to log. */ void StreamLogger::Write(LoggerType type, string msg) { *stream << TypeToString(type) << " "; *stream << Utils::DateTime::GetCurrent() << ": "; *stream << msg << std::endl; }
static void APIENTRY logVertexPointer( GLint size, GLenum type, GLsizei stride, const void* pointer ) { QGL_Log( "glVertexPointer( %d, %s, %d, MEM )\n", size, TypeToString( type ), stride ); glVertexPointer( size, type, stride, pointer ); }
static void APIENTRY logDrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices ) { QGL_Log( "glDrawElements( %s, %d, %s, MEM )\n", PrimToString( mode ), count, TypeToString( type ) ); glDrawElements( mode, count, type, indices ); }
BOOL DumpProcess(HANDLE hp) { ULONG64 base; ULONG64 next; MEMORY_BASIC_INFORMATION mbi; printf(" %12s %8s %8s: %3s %3s %4s %3s : %8s\n", "Address", "Offset", "Size", "Typ", "Sta", "Prot", "Ini", "Contents"); printf(" %12s %8s %8s: %3s %3s %4s %3s : %8s\n", "------------", "--------", "--------", "---", "---", "----", "---", "-----------------"); for (next = 0;;) { base = next; ZeroMemory(&mbi, sizeof(mbi)); if (VirtualQueryEx(hp, (PVOID)base, &mbi, sizeof(mbi)) == 0) { break; } if ((mbi.RegionSize & 0xfff) == 0xfff) { break; } next = (ULONG64)mbi.BaseAddress + mbi.RegionSize; if (mbi.State == MEM_FREE) { continue; } CHAR szType[16]; TypeToString(mbi.Type, szType, ARRAYSIZE(szType)); CHAR szState[16]; StateToString(mbi.State, szState, ARRAYSIZE(szState)); CHAR szProtect[16]; ProtectToString(mbi.Protect, szProtect, ARRAYSIZE(szProtect)); CHAR szAllocProtect[16]; ProtectToString(mbi.AllocationProtect, szAllocProtect, ARRAYSIZE(szAllocProtect)); CHAR szFile[MAX_PATH]; szFile[0] = '\0'; DWORD cb = 0; PCHAR pszFile = szFile; if (base == (ULONG64)mbi.AllocationBase) { #if 0 cb = pfGetMappedFileName(hp, (PVOID)mbi.AllocationBase, szFile, ARRAYSIZE(szFile)); #endif if (GetSections(hp, (PBYTE)mbi.AllocationBase)) { next = base + 0x1000; sprintf_s(szFile, ARRAYSIZE(szFile), "%d-bit PE", Bitness); } } if (cb > 0) { for (DWORD c = 0; c < cb; c++) { szFile[c] = (szFile[c] >= 'a' && szFile[c] <= 'z') ? szFile[c] - 'a' + 'A' : szFile[c]; } szFile[cb] = '\0'; } if ((pszFile = strrchr(szFile, '\\')) == NULL) { pszFile = szFile; } else { pszFile++; } PBYTE pbEnd; PCHAR pszSect = FindSectionName((PBYTE)base, pbEnd); if (pszSect != NULL) { pszFile = pszSect; if (next > (ULONG64)pbEnd) { next = (ULONG64)pbEnd; } } CHAR szDesc[128]; ZeroMemory(&szDesc, ARRAYSIZE(szDesc)); if (base == (ULONG64)mbi.AllocationBase) { sprintf_s(szDesc, ARRAYSIZE(szDesc), " %12I64x %8I64x %8I64x: %3s %3s %4s %3s : %s", (ULONG64)base, (ULONG64)base - (ULONG64)mbi.AllocationBase, (ULONG64)next - (ULONG64)base, szType, szState, szProtect, szAllocProtect, pszFile); } else { sprintf_s(szDesc, ARRAYSIZE(szDesc), " %12s %8I64x %8I64x: %3s %3s %4s %3s : %s", "-", (ULONG64)base - (ULONG64)mbi.AllocationBase, (ULONG64)next - (ULONG64)base, szType, szState, szProtect, szAllocProtect, pszFile); } printf("%s\n", szDesc); } return TRUE; }
void WriteCode(iface::cellml_services::CodeInformation* cci, uint32_t useida) { iface::cellml_services::ModelConstraintLevel mcl = cci->constraintLevel(); if (mcl == iface::cellml_services::UNDERCONSTRAINED) { ObjRef<iface::cellml_services::ComputationTarget> ctMissingIV(cci->missingInitial()); if (ctMissingIV != NULL) { ObjRef<iface::cellml_api::CellMLVariable> v = ctMissingIV->variable(); std::wstring n = v->name(); std::wstring c = v->componentName(); std::wstring str; uint32_t deg = ctMissingIV->degree(); if (deg != 0) { str += L"d^"; wchar_t buf[20]; any_swprintf(buf, 20, L"%u", deg); str += buf; str += L"/dt^"; str += buf; str += L" "; } str += n; str += L" (in "; str += c; str += L")\n"; printf("/* Model is underconstrained due to missing initial_value on %S\n", str.c_str()); } else { printf("/* Model is underconstrained.\n" " * List of undefined targets follows...\n"); iface::cellml_services::ComputationTargetIterator* cti = cci->iterateTargets(); iface::cellml_services::ComputationTarget* ct; std::vector<std::wstring> messages; while (true) { ct = cti->nextComputationTarget(); if (ct == NULL) break; if (ct->type() != iface::cellml_services::FLOATING) { ct->release_ref(); continue; } iface::cellml_api::CellMLVariable* v = ct->variable(); std::wstring n = v->name(); std::wstring c = v->componentName(); std::wstring str = L" * * "; uint32_t deg = ct->degree(); if (deg != 0) { str += L"d^"; wchar_t buf[20]; any_swprintf(buf, 20, L"%u", deg); str += buf; str += L"/dt^"; str += buf; str += L" "; } str += n; str += L" (in "; str += c; str += L")\n"; messages.push_back(str); v->release_ref(); ct->release_ref(); } cti->release_ref(); // Sort the messages... std::sort(messages.begin(), messages.end()); std::vector<std::wstring>::iterator msgi; for (msgi = messages.begin(); msgi != messages.end(); msgi++) printf("%S", (*msgi).c_str()); printf(" */\n"); } return; } else if (mcl == iface::cellml_services::OVERCONSTRAINED) { printf("/* Model is overconstrained.\n" " * List variables defined at time of error follows...\n"); iface::cellml_services::ComputationTargetIterator* cti = cci->iterateTargets(); iface::cellml_services::ComputationTarget* ct; std::vector<std::wstring> messages; while (true) { ct = cti->nextComputationTarget(); if (ct == NULL) break; if (ct->type() == iface::cellml_services::FLOATING) { ct->release_ref(); continue; } iface::cellml_api::CellMLVariable* v = ct->variable(); std::wstring n = v->name(); std::wstring str = L" * * "; uint32_t deg = ct->degree(); if (deg != 0) { str += L"d^"; wchar_t buf[20]; any_swprintf(buf, 20, L"%u", deg); str += buf; str += L"/dt^"; str += buf; str += L" "; } str += n; str += L"\n"; messages.push_back(str); v->release_ref(); ct->release_ref(); } cti->release_ref(); // Sort the messages... std::sort(messages.begin(), messages.end()); std::vector<std::wstring>::iterator msgi; for (msgi = messages.begin(); msgi != messages.end(); msgi++) printf("%S", (*msgi).c_str()); // Get flagged equations... iface::mathml_dom::MathMLNodeList* mnl = cci->flaggedEquations(); printf(" * Extraneous equation was:\n"); iface::dom::Node* n = mnl->item(0); mnl->release_ref(); iface::dom::Element* el = reinterpret_cast<iface::dom::Element*>(n->query_interface("dom::Element")); n->release_ref(); std::wstring cmeta = el->getAttribute(L"id"); if (cmeta == L"") printf(" * <equation with no cmeta ID>\n"); else printf(" * %S\n", cmeta.c_str()); n = el->parentNode(); el->release_ref(); if (n != NULL) { el = reinterpret_cast<iface::dom::Element*> (n->query_interface("dom::Element")); n->release_ref(); cmeta = el->getAttribute(L"id"); if (cmeta == L"") printf(" * in <math with no cmeta ID>\n"); else printf(" * in math with cmeta:id %S\n", cmeta.c_str()); el->release_ref(); } printf(" */\n"); return; } else if (mcl == iface::cellml_services::UNSUITABLY_CONSTRAINED) { printf("/* Model is unsuitably constrained (i.e. would need capabilities" " beyond those of the CCGS to solve).\n" " * The status of variables at time of error follows...\n"); iface::cellml_services::ComputationTargetIterator* cti = cci->iterateTargets(); iface::cellml_services::ComputationTarget* ct; std::vector<std::wstring> messages; while (true) { ct = cti->nextComputationTarget(); if (ct == NULL) break; std::wstring str = L" * * "; if (ct->type() == iface::cellml_services::FLOATING) str += L" Undefined: "; else str += L" Defined: "; uint32_t deg = ct->degree(); if (deg != 0) { str += L"d^"; wchar_t buf[20]; any_swprintf(buf, 20, L"%u", deg); str += buf; str += L"/dt^"; str += buf; str += L" "; } iface::cellml_api::CellMLVariable* v = ct->variable(); std::wstring n = v->name(); str += n; str += L"\n"; messages.push_back(str); v->release_ref(); ct->release_ref(); } cti->release_ref(); // Sort the messages... std::sort(messages.begin(), messages.end()); std::vector<std::wstring>::iterator msgi; for (msgi = messages.begin(); msgi != messages.end(); msgi++) printf("%S", (*msgi).c_str()); printf(" */\n"); return; } printf("/* Model is correctly constrained.\n"); iface::mathml_dom::MathMLNodeList* mnl = cci->flaggedEquations(); uint32_t i, l = mnl->length(); if (l == 0) printf(" * No equations needed Newton-Raphson evaluation.\n"); else printf(" * The following equations needed Newton-Raphson evaluation:\n"); std::vector<std::wstring> messages; for (i = 0; i < l; i++) { iface::dom::Node* n = mnl->item(i); iface::dom::Element* el = reinterpret_cast<iface::dom::Element*>(n->query_interface("dom::Element")); n->release_ref(); std::wstring cmeta = el->getAttribute(L"id"); std::wstring str; if (cmeta == L"") str += L" * <equation with no cmeta ID>\n"; else { str += L" * "; str += cmeta; str += L"\n"; } n = el->parentNode(); el->release_ref(); el = reinterpret_cast<iface::dom::Element*> (n->query_interface("dom::Element")); n->release_ref(); cmeta = el->getAttribute(L"id"); if (cmeta == L"") str += L" * in <math with no cmeta ID>\n"; else { str += L" * in math with cmeta:id "; str += cmeta; str += L"\n"; } el->release_ref(); messages.push_back(str); } mnl->release_ref(); // Sort the messages... std::sort(messages.begin(), messages.end()); std::vector<std::wstring>::iterator msgi; for (msgi = messages.begin(); msgi != messages.end(); msgi++) printf("%S", (*msgi).c_str()); printf(" * The rate and state arrays need %u entries.\n", cci->rateIndexCount()); printf(" * The algebraic variables array needs %u entries.\n", cci->algebraicIndexCount()); printf(" * The constant array needs %u entries.\n", cci->constantIndexCount()); printf(" * Variable storage is as follows:\n"); messages.clear(); iface::cellml_services::ComputationTargetIterator* cti = cci->iterateTargets(); while (true) { iface::cellml_services::ComputationTarget* ct = cti->nextComputationTarget(); if (ct == NULL) break; iface::cellml_api::CellMLVariable* v = ct->variable(); iface::cellml_api::CellMLElement* el = v->parentElement(); iface::cellml_api::CellMLComponent* c = reinterpret_cast<iface::cellml_api::CellMLComponent*> (el->query_interface("cellml_api::CellMLComponent")); el->release_ref(); std::wstring str; std::wstring vn = v->name(), cn = c->name(); str += L" * * Target "; uint32_t deg = ct->degree(); if (deg != 0) { str += L"d^"; wchar_t buf[20]; any_swprintf(buf, 20, L"%u", deg); str += buf; str += L"/dt^"; str += buf; str += L" "; } str += vn; str += L" in component "; str += cn; str += L"\n"; c->release_ref(); v->release_ref(); str += L" * * * Variable type: "; str += TypeToString(ct->type()); str += L"\n * * * Variable index: "; wchar_t buf[40]; any_swprintf(buf, 40, L"%u\n", ct->assignedIndex()); str += buf; str += L" * * * Variable storage: "; std::wstring vsn = ct->name(); str += vsn; str += '\n'; ct->release_ref(); messages.push_back(str); } cti->release_ref(); // Sort the messages... std::sort(messages.begin(), messages.end()); for (msgi = messages.begin(); msgi != messages.end(); msgi++) printf("%S", (*msgi).c_str()); printf(" */\n"); std::wstring frag = cci->functionsString(); printf("%S", frag.c_str()); // Now start the code... frag = cci->initConstsString(); printf("void SetupFixedConstants(double* CONSTANTS, double* RATES, double* STATES)\n{\n%S}\n", frag.c_str()); frag = cci->variablesString(); printf("void EvaluateVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)\n" "{\n%S}\n", frag.c_str()); if (useida) { iface::cellml_services::IDACodeInformation* icci = reinterpret_cast<iface::cellml_services::IDACodeInformation*>(cci->query_interface("cellml_services::IDACodeInformation")); frag = icci->essentialVariablesString(); printf("void EvaluateEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)\n" "{\n%S}\n", frag.c_str()); frag = cci->ratesString(); printf("void ComputeResiduals(double VOI, double* STATES, double* RATES, double* CONSTANTS, " "double* ALGEBRAIC)\n" "{\n%S}\n", frag.c_str()); frag = icci->stateInformationString(); printf("void SetupStateInfo(double * SI)\n{\n%S}\n", frag.c_str()); frag = icci->rootInformationString(); printf("void RootInformation()\n{\n%S}\n", frag.c_str()); icci->release_ref(); } else { frag = cci->ratesString(); printf("void ComputeRates(double VOI, double* STATES, double* RATES, double* CONSTANTS, " "double* ALGEBRAIC)\n" "{\n%S}\n", frag.c_str()); } }
/* * ExecuteStatement */ void AssignmentStatement::ExecuteStatement() { ResultValue lvalue_r = lvalue->Evaluate(); ResultValue rvalue_r = expr->Evaluate(); LValueExpression* n = (LValueExpression*)lvalue; if (!ExistVarGlobal(n->variable_name) && !ExistVarTemp(n->variable_name)){ cout << "("<<line<<","<<column<<"): Variable \'" << n->variable_name << "\' no ha sido declarada."<<endl; } else if (lvalue_r.type == rvalue_r.type){ if (ExistVarGlobal(n->variable_name)){ vars[n->variable_name] = rvalue_r; } if (ExistVarTemp(n->variable_name)){ varsTemp[n->variable_name] = rvalue_r; } } else cout << " ERROR en Statement ("<<line<<","<<column<<"): Variable \'"<< n->variable_name << "\' No se puede convertir \'" << TypeToString(rvalue_r.type) << "\' a \'" << TypeToString(lvalue_r.type) << "\'"<<endl; }
string BlockStatement::GenerateCode(){ stringstream varCode; if (variable_def_list!=0){ VariableDefList::iterator itv = variable_def_list->begin(); varCode << " addi $sp, $sp, -" << (variable_def_list->size()+1)*4 << endl; int i = 0; while (itv!=variable_def_list->end()){ VariableDef* n = *itv; ResultValue r; r.place = newTempsS(); // revisar que no se pase del limite de registros varCode << " sw " << r.place << ", " << i << "($sp)" << endl; i+=4; if (!ExistVarTemp(n->name) && !ExistVarGlobal(n->name)){ r.type = n->variable_type; if (n->initial_value!=0){ r = n->initial_value->Evaluate(); if (r.type != n->variable_type){ cout << " ERROR en Statement (" << n->line << "," << n->column << "): No se puede convertir " << TypeToString(n->variable_type) << " a " << TypeToString(r.type) << endl; r.type = n->variable_type; } } varsTemp[n->name] = r; //cout << " BlockST: " << n->name << " Tipo: " << r.type << endl; } else cout << " ERROR en Statement (" << n->line << "," << n->column << "): Variable \'" << n->name << "\' ya ha sido declarada." << endl; itv++; } varCode << " sw $ra, " << i << "($sp)" << endl; } if (statement_list!=0){ StatementList::iterator its = statement_list->begin(); while (its!=statement_list->end()){ Statement* n = *its; varCode << n->GenerateCode(); its++; } } // Release Temp // if (variable_def_list!=0){ VariableDefList::iterator it = variable_def_list->begin(); int i = 0; while (it!=variable_def_list->end()){ VariableDef* n = *it; varCode << " lw " << varsTemp[n->name].place << ", " << i << "($sp)" << endl; releaseTempS(varsTemp[n->name].place); // Libero los registros S. varsTemp.erase(n->name); it++; i+=4; } varCode << " lw $ra, " << i << "($sp)" << endl; varCode << " addi $sp, $sp, " << i+4 << endl; } return varCode.str(); }
void BlockStatement::ExecuteStatement() { if (variable_def_list!=0){ VariableDefList::iterator itv = variable_def_list->begin(); while (itv!=variable_def_list->end()){ VariableDef* n = *itv; if (!ExistVarTemp(n->name) && !ExistVarGlobal(n->name)){ ResultValue r; r.type = n->variable_type; if (n->initial_value!=0){ r = n->initial_value->Evaluate(); if (r.type != n->variable_type){ cout << " ERROR en Statement (" << n->line << "," << n->column << "): No se puede convertir " << TypeToString(n->variable_type) << " a " << TypeToString(r.type) << endl; r.type = n->variable_type; } } varsTemp[n->name] = r; //cout << " BlockST: " << n->name << " Tipo: " << r.type << endl; } else cout << " ERROR en Statement (" << n->line << "," << n->column << "): Variable \'" << n->name << "\' ya ha sido declarada." << endl; itv++; } } if (statement_list!=0){ StatementList::iterator its = statement_list->begin(); while (its!=statement_list->end()){ Statement* n = *its; n->ExecuteStatement(); //cout << n->GetKind()<<endl; its++; } } // Release Temp // if (variable_def_list!=0){ VariableDefList::iterator it = variable_def_list->begin(); while (it!=variable_def_list->end()){ VariableDef* n = *it; varsTemp.erase(n->name); it++; } } }
//***************************************************************************** // Function: TypeToString // Purpose: Takes a variant, returns a pointer to a string that is the variant type //***************************************************************************** const WCHAR *TypeToString(VARIANT *p) { return TypeToString(p->vt); }
// --------------------------------------------------------------------------- // * PlugInShell_ProcessRequest // // inData : A pointer to a data structure representing the current // server call. // // This routine is called continuiously throughout the operation of the // Directory Services process. // --------------------------------------------------------------------------- long PlugInShell_ProcessRequest(void *inData) { long macError = eDSNoErr; bool isAcquired = false; sHeader * pMsgHdr = (sHeader *)inData; unsigned long msgType = pMsgHdr ? pMsgHdr->fType : 0; LOG_ENTER("inData = @%p => { fType = %lu (%s) }", inData, msgType, TypeToString(msgType)); if (!inData) { macError = eDSNullParameter; GOTO_CLEANUP(); } GS_ACQUIRE_SHARED(); isAcquired = true; GS_VERIFY_INITIALIZED(macError); // // We currently do not handle anything while not "active". // if ( !FlagOn(GlobalState.PluginState, kActive) ) { macError = ePlugInNotActive; GOTO_CLEANUP(); } // // We also do not handle anything while not "startup complete". // if (GlobalState.IsStartupComplete == false && msgType != kDoPlugInCustomCall && msgType != kServerRunLoop && msgType != kKerberosMutex) { GS_RELEASE(); GS_ACQUIRE_EXCLUSIVE(); if (GlobalState.IsStartupComplete == false) { BOOLEAN bIsStarted; LOG("Re-verify that LSASS service is operational"); GetLsaStatus(&bIsStarted); if (bIsStarted) { LOG("LSASS service is now operational"); GlobalState.IsStartupComplete = true; } else { if (msgType == kOpenDirNode) { /* * Apple says kOpenDirNode should return * eDSOpenNodeFailed if we're offline. */ macError = eDSOpenNodeFailed; } else { macError = ePlugInNotActive; } LOG("Startup of dependent services not complete, therefore network accounts are offline"); GOTO_CLEANUP(); } } GS_RELEASE(); GS_ACQUIRE_SHARED(); } // ISSUE-2007/05/30-dalmeida -- We should use r/w locks instead so that // we can behave sensibly when someone tries to de-activate the plug-in // while we are processing something... try { switch ( msgType ) { case kHandleNetworkTransition: LOG("Got Network Transition change notice"); macError = eDSNoErr; break; case kHandleSystemWillSleep: LOG("Got Handle System Will Sleep notice"); macError = eDSNoErr; break; case kHandleSystemWillPowerOn: LOG("Got Handle System Will Power On notice"); macError = eDSNoErr; break; case kOpenDirNode: LOG("Start of directory node query"); macError = LWIDirNodeQuery::Open((sOpenDirNode *)inData); break; case kDoDirNodeAuth: macError = LWIDirNodeQuery::DoDirNodeAuth((sDoDirNodeAuth *)inData, GlobalState.IsJoinedToAD, GlobalState.pAllowAdminCheckData, GlobalState.Flags); break; case kCloseDirNode: macError = LWIDirNodeQuery::Close((sCloseDirNode *)inData); break; case kGetDirNodeInfo: macError = LWIDirNodeQuery::GetInfo((sGetDirNodeInfo *)inData, GlobalState.Flags, GlobalState.pNetAdapterList); break; case kGetAttributeEntry: macError = LWIDirNodeQuery::GetAttributeEntry((sGetAttributeEntry *)inData); break; case kGetRecordEntry: macError = LWIDirNodeQuery::GetAttributeEntry((sGetAttributeEntry *)inData); break; case kGetAttributeValue: macError = LWIDirNodeQuery::GetAttributeValue((sGetAttributeValue *)inData); break; case kCloseAttributeValueList: macError = LWIDirNodeQuery::CloseValueList((sCloseAttributeValueList *)inData); break; case kCloseAttributeList: macError = LWIDirNodeQuery::CloseAttributeList((sCloseAttributeList *)inData); break; case kGetRecordList: macError = LWIRecordListQuery::Run((sGetRecordList *)inData, GlobalState.Flags, GlobalState.pNetAdapterList); break; case kReleaseContinueData: macError = LWIRecordListQuery::ReleaseContinueData((sReleaseContinueData *)inData); break; case kDoAttributeValueSearch: case kDoAttributeValueSearchWithData: macError = LWIAttrValDataQuery::Run((sDoAttrValueSearchWithData *)inData, GlobalState.Flags, GlobalState.pNetAdapterList); break; case kDoMultipleAttributeValueSearch: case kDoMultipleAttributeValueSearchWithData: macError = LWIAttrValDataQuery::Run((sDoMultiAttrValueSearchWithData *)inData, GlobalState.Flags, GlobalState.pNetAdapterList); break; case kOpenRecord: LOG("Start of record query"); macError = LWIRecordQuery::Open((sOpenRecord*)inData, GlobalState.Flags, GlobalState.pNetAdapterList); break; case kGetRecordReferenceInfo: macError = LWIRecordQuery::GetReferenceInfo((sGetRecRefInfo*)inData); break; case kCloseRecord: macError = LWIRecordQuery::Close((sCloseRecord*)inData); break; case kGetRecordAttributeInfo: macError = LWIRecordQuery::GetAttributeInfo((sGetRecAttribInfo*)inData); break; case kGetRecordAttributeValueByID: macError = LWIRecordQuery::GetAttributeValueByID((sGetRecordAttributeValueByID*)inData); break; case kGetRecordAttributeValueByIndex: macError = LWIRecordQuery::GetAttributeValueByIndex((sGetRecordAttributeValueByIndex*)inData); break; /* Supported update operations */ case kAddAttribute: macError = LWIRecordQuery::AddAttribute((sAddAttribute*)inData); break; case kAddAttributeValue: macError = LWIRecordQuery::AddAttributeValue((sAddAttributeValue*)inData); break; case kRemoveAttribute: macError = LWIRecordQuery::RemoveAttribute((sRemoveAttribute*)inData); break; case kFlushRecord: macError = LWIRecordQuery::FlushRecord((sFlushRecord*)inData); break; case kSetAttributeValues: macError = LWIRecordQuery::SetAttributeValues((sSetAttributeValues*)inData); break; case kSetAttributeValue: macError = LWIRecordQuery::SetAttributeValue((sSetAttributeValue*)inData); break; case kSetRecordName: case kSetRecordType: case kDeleteRecord: case kCreateRecord: case kCreateRecordAndOpen: /* sCreateRecord */ case kRemoveAttributeValue: case kDoPlugInCustomCall: default: if ((msgType < kDSPlugInCallsBegin) || (msgType > kDSPlugInCallsEnd)) { LOG("Unsupported request type: %lu (%s)", msgType, TypeToString(msgType)); } else { LOG("Unknown request type: %lu", msgType); } macError = eNotHandledByThisNode; break; } } catch (LWIException& lwi) { macError = lwi.getErrorCode(); } cleanup: if (isAcquired) { GS_RELEASE(); } if (pMsgHdr) { pMsgHdr->fResult = macError; } LOG_LEAVE("--> %d", macError); return macError; }
void CRegEditorGUI::UpdateKeyValue(int ListViewItemIndex,EmulatedRegistry::CKeyValue* pValue) { BOOL bStringIcon=FALSE; int SubItemIndex = 0; // set Name this->pListviewValues->SetItemText(ListViewItemIndex,SubItemIndex,(TCHAR*)pValue->Name.c_str()); SubItemIndex++; // set type this->pListviewValues->SetItemText(ListViewItemIndex,SubItemIndex,TypeToString(pValue->Type)); SubItemIndex++; if (this->pRegistry->pOptions->GetSpyMode()) { TCHAR szAccess[MAX_PATH]; *szAccess=0; if (pValue->EmulatedRegistry_Flag & CKeyValue_EmulatedRegistry_Flag_ACCESS_READ) _tcscat(szAccess,_T("R")); if (pValue->EmulatedRegistry_Flag & CKeyValue_EmulatedRegistry_Flag_ACCESS_WRITE) _tcscat(szAccess,_T("W")); this->pListviewValues->SetItemText(ListViewItemIndex,SubItemIndex,szAccess); SubItemIndex++; } // set content switch (pValue->Type) { default: { TCHAR* str = CStrToHex::ByteArrayToStrHexArray(pValue->Buffer,pValue->BufferSize,_T(" ")); if (str) { this->pListviewValues->SetItemText(ListViewItemIndex,SubItemIndex,str); SubItemIndex++; delete[] str; } } break; // case REG_DWORD: // REG_DWORD == REG_DWORD_LITTLE_ENDIAN case REG_DWORD_LITTLE_ENDIAN: { TCHAR str[64]; _stprintf(str,_T("0x%.8X"),*((DWORD*)pValue->Buffer)); this->pListviewValues->SetItemText(ListViewItemIndex,SubItemIndex,str); SubItemIndex++; } break; case REG_SZ: case REG_EXPAND_SZ: { bStringIcon = TRUE; TCHAR* str=NULL; BOOL bAnsi=FALSE; if (pValue->GetStringValue(&str,&bAnsi)) { this->pListviewValues->SetItemText(ListViewItemIndex,SubItemIndex,(TCHAR*)str); delete [] str; } SubItemIndex++; } break; } if (bStringIcon) this->pListviewValues->SetItemIconIndex(ListViewItemIndex,this->ListViewIconIndexRegistryString); else this->pListviewValues->SetItemIconIndex(ListViewItemIndex,this->ListViewIconIndexRegistryBinary); }