/** transform a BSON array into a vector of BSONElements. we match array # positions with their vector position, and ignore any fields with non-numeric field names. */ std::vector<BSONElement> BSONElement::Array() const { chk(mongo::Array); std::vector<BSONElement> v; BSONObjIterator i(Obj()); while (i.more()) { BSONElement e = i.next(); const char* f = e.fieldName(); unsigned u; Status status = parseNumberFromString(f, &u); if (status.isOK()) { verify(u < 1000000); if (u >= v.size()) v.resize(u + 1); v[u] = e; } else { // ignore? } } return v; }
void CGObjectInstance::setType(si32 ID, si32 subID) { const TerrainTile &tile = cb->gameState()->map->getTile(visitablePos()); this->ID = Obj(ID); this->subID = subID; //recalculate blockvis tiles - new appearance might have different blockmap than before cb->gameState()->map->removeBlockVisTiles(this, true); auto handler = VLC->objtypeh->getHandlerFor(ID, subID); if(!handler) { logGlobal->error("Unknown object type %d:%d at %s", ID, subID, visitablePos().toString()); return; } if(!handler->getTemplates(tile.terType).empty()) appearance = handler->getTemplates(tile.terType)[0]; else appearance = handler->getTemplates()[0]; // get at least some appearance since alternative is crash cb->gameState()->map->addBlockVisTiles(this); }
static float Objective (const Matrix<cxfl>& ffdbx, const Matrix<cxfl>& ffdbg, const Matrix<cxfl>& ttdbx, const Matrix<cxfl>& ttdbg, const Matrix<cxfl>& x, const Matrix<cxfl>& g, const Matrix<cxfl>& data, const float t, float& rmse, const CSParam& cgp) { float obj; float nz = (float) nnz (data); obj = Obj (ffdbx, ffdbg, data, t); rmse = sqrt(obj/nz); if (cgp.tvw) obj += ObjTV (ttdbx, ttdbg, t, cgp); if (cgp.xfmw) obj += ObjXFM (x, g, t, cgp); return obj; }
void CallInstr(int num_args){ VyObj func_obj = StackPop(); VyFunction* func = (VyFunction*) Obj(func_obj); VyObj arguments[num_args]; int i; for(i = 0; i < num_args; i++){ arguments[i] = StackPop(); } /* if(ObjEq(func_obj, VariableValue(CreateSymbol_NoObj("="))))printf("\nRead args:\n"); for(i = 0; i < num_args; i++){ if(ObjEq(func_obj, VariableValue(CreateSymbol_NoObj("=")))){ printf("Obj %d: ", i); PrintObj(stdout, arguments[i]); printf("\n"); } } */ if(!func->native){ Scope* caller_scope = CurrentScope(); Scope* new_scope = CreateScope(func->creation_scope); EnterScope(new_scope); BindArguments(func->arguments, arguments, num_args); VyObj return_val = EvalBytecode(func->code.bytecode); DeleteScope(new_scope); EnterScope(caller_scope); StackPush(return_val); } else { VyObj return_val = func->code.native(&arguments[0], num_args); StackPush(return_val); } }
void main (int argc, char **argv) { for (int argi = 1; argi < argc; argi++) { kFile * pFile = NULL; try { pFile = new kFile(argv[argi]); kFileOMFLib Lib(pFile); Lib.dump(&kFile::StdOut); } catch (kError err) { if (pFile) { try { pFile = new kFile(argv[argi]); kFileOMF Obj(pFile); Obj.dump(&kFile::StdOut); } catch (kError err) { kFile::StdOut.printf("Failed to open %s - not obj/lib? err=%d\n", argv[argi], err.getErrno()); } } else { kFile::StdOut.printf("Failed to open %s. err=%d\n", argv[argi], err.getErrno()); } } } /* for */ }
void AObjectTypeHandler::addTemplate(const ObjectTemplate & templ) { templates.push_back(templ); templates.back().id = Obj(type); templates.back().subid = subtype; }
/* Bind a value to a variable in the current scope */ void VariableBind(VySymbol* symb, VyObj obj) { Scope* current = CurrentScope(); g_hash_table_insert(current->var_values, symb->symb, Obj(obj)); g_hash_table_insert(current->type_values, symb->symb, (gpointer) (Type(obj).name)); g_hash_table_insert(current->size_values, symb->symb, (gpointer) (Type(obj).size)); }
StatusWith<CursorResponse> CursorResponse::parseFromBSON(const BSONObj& cmdResponse) { Status cmdStatus = getStatusFromCommandResult(cmdResponse); if (!cmdStatus.isOK()) { if (ErrorCodes::isStaleShardVersionError(cmdStatus.code())) { auto vWanted = ChunkVersion::fromBSON(cmdResponse, "vWanted"); auto vReceived = ChunkVersion::fromBSON(cmdResponse, "vReceived"); if (!vWanted.hasEqualEpoch(vReceived)) { return Status(ErrorCodes::StaleEpoch, cmdStatus.reason()); } } return cmdStatus; } std::string fullns; BSONObj batchObj; CursorId cursorId; BSONElement cursorElt = cmdResponse[kCursorField]; if (cursorElt.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, str::stream() << "Field '" << kCursorField << "' must be a nested object in: " << cmdResponse}; } BSONObj cursorObj = cursorElt.Obj(); BSONElement idElt = cursorObj[kIdField]; if (idElt.type() != BSONType::NumberLong) { return { ErrorCodes::TypeMismatch, str::stream() << "Field '" << kIdField << "' must be of type long in: " << cmdResponse}; } cursorId = idElt.Long(); BSONElement nsElt = cursorObj[kNsField]; if (nsElt.type() != BSONType::String) { return {ErrorCodes::TypeMismatch, str::stream() << "Field '" << kNsField << "' must be of type string in: " << cmdResponse}; } fullns = nsElt.String(); BSONElement batchElt = cursorObj[kBatchField]; if (batchElt.eoo()) { batchElt = cursorObj[kBatchFieldInitial]; } if (batchElt.type() != BSONType::Array) { return {ErrorCodes::TypeMismatch, str::stream() << "Must have array field '" << kBatchFieldInitial << "' or '" << kBatchField << "' in: " << cmdResponse}; } batchObj = batchElt.Obj(); std::vector<BSONObj> batch; for (BSONElement elt : batchObj) { if (elt.type() != BSONType::Object) { return {ErrorCodes::BadValue, str::stream() << "getMore response batch contains a non-object element: " << elt}; } batch.push_back(elt.Obj()); } for (auto& doc : batch) { doc.shareOwnershipWith(cmdResponse); } auto latestOplogTimestampElem = cmdResponse[kInternalLatestOplogTimestampField]; if (latestOplogTimestampElem && latestOplogTimestampElem.type() != BSONType::bsonTimestamp) { return { ErrorCodes::BadValue, str::stream() << "invalid _internalLatestOplogTimestamp format; expected timestamp but found: " << latestOplogTimestampElem.type()}; } auto writeConcernError = cmdResponse["writeConcernError"]; if (writeConcernError && writeConcernError.type() != BSONType::Object) { return {ErrorCodes::BadValue, str::stream() << "invalid writeConcernError format; expected object but found: " << writeConcernError.type()}; } return {{NamespaceString(fullns), cursorId, std::move(batch), boost::none, latestOplogTimestampElem ? latestOplogTimestampElem.timestamp() : boost::optional<Timestamp>{}, writeConcernError ? writeConcernError.Obj().getOwned() : boost::optional<BSONObj>{}}}; }
AboutWindow::AboutWindow() : ::vl::presentation::controls::GuiWindow(::vl::presentation::theme::ThemeName::Window) { auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"demo::AboutWindow", false)); auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); ::vl::__vwsn::This(this)->__vwsn_demo_AboutWindow_Initialize(this); }
void foo() { C Obj("foo"); printf("Longjmping from foo() function\n"); longjmp(buf, 37); }
const T& operator[](int index)const { if(index<0)index+=_count; if(index<0 || index>=_count) throw ArrayIndexOutOfRange(); return Obj(index); }
/////////////////////////////////////////////////////////////////////////////// // Export eines Objektes HRESULT CArcViewLayer::ExportData ( GSTRUCT *pGS, MFELD *pMF, LPCSTR pcUIdent, CArcViewLayerAttributes *pMap) { OBJECTTYPE rgType = GetType(); int iShapeId = -1; int iObjTyp = pGS -> Typ; _ASSERTE(rgType == ObjType2OBJECTTYPE(pGS -> Typ, true)); // Objekttyp muß stimmen // Geometrie erzeugen if (OBJECTTYPE_Area == rgType) { // Anzahl der Konturen feststellen und Konturfeld zusammenbauen int iKCnt = 1; vector<int> Cnts(1); int iCurr = 0; Cnts[0] = 0; for (int i = 0; 0 != pGS -> cnt[i]; ++i) { if (i > 0) Cnts.push_back(iCurr); iCurr += pGS -> cnt[i]; } iKCnt = i; _ASSERTE(iKCnt > 0 && iKCnt == Cnts.size()); // Objekt erzeugen CArcViewObject Obj(SHPCreateObject(m_nShapeType, -1, iKCnt, Cnts.begin(), NULL, pGS -> GSize, pGS -> x, pGS -> y, NULL, NULL)); iShapeId = SHPWriteObject(m_hSHP, -1, Obj); } else { // Objekt erzeugen CArcViewObject Obj(SHPCreateSimpleObject(m_nShapeType, pGS -> GSize, pGS -> x, pGS -> y, NULL)); iShapeId = SHPWriteObject(m_hSHP, -1, Obj); } if (iShapeId == -1) return E_FAIL; // Attribute sicherstellen (bei TRiAS-Datenquellen jedesmal) if (!HasFields() || DEX_GetTRiASDataSourceEx(DEX_GetObjectsProject(pGS -> Id))) { // sämtliche Attribute dieses Layers durchgehen und ggf. erzeugen for (CArcViewLayerAttributes::iterator it = pMap -> begin(); it != pMap -> end(); ++it) { // Feld in Datei erzeugen int iField = -1; CArcViewAttribute &rAttr = (*it).second; LPCSTR pcName = rAttr.GetName(); if (OBJECTTYPE_Text != m_rgType && !strcmp (pcName, g_cbLabelText)) continue; // Labeltext nur für Textobjekte if (FAILED(FieldExists (pcName, rAttr.GetTyp(), &iField))) { RETURN_FAILED_HRESULT(AddField(pcName, rAttr.GetTyp(), rAttr.GetLen(), rAttr.GetDecimals(), &iField)); } _ASSERTE(-1 != iField); // mehrerer Objekttypen eines Idents haben identischen Satz von Attributen _ASSERTE(-1 == (*it).second.GetField(iObjTyp) || (*it).second.GetField(iObjTyp) == iField || DEX_GetTRiASDataSourceEx(DEX_GetObjectsProject(pGS -> Id))); // Feldnummer beim Attribut speichern (*it).second.SetField(iField, iObjTyp); } // Textlabel für Textobjekte if (OBJECTTYPE_Text == m_rgType) { pair<CArcViewLayerAttributes::iterator, bool> p = pMap -> insert (CArcViewLayerAttributes::value_type (-1, CArcViewAttribute(g_cbLabelText, 'a', _MAX_PATH))); if (p.second) { int iField = -1; it = p.first; if (FAILED(FieldExists (g_cbLabelText, FTString, &iField))) { RETURN_FAILED_HRESULT(AddField(g_cbLabelText, FTString, _MAX_PATH, 0, &iField)); } _ASSERTE(-1 != iField); (*it).second.SetField(iField, iObjTyp); } } SetHasFields(); } // Attributwerte schreiben if (NULL != pMF) { // nur, wenn mindestens ein Attribut ausgegeben werden soll for (MFELD *pMFT = pMF; 0 != pMFT -> MCode; ++pMFT) { if (NULL != pMap) { CArcViewLayerAttributes::iterator it = pMap -> find (pMFT -> MCode); _ASSERTE(it != pMap -> end()); // Attribut sollte (jetzt) existieren if (it != pMap -> end()) { // Feld muß bereits erzeugt worden sein und Typ muß mit DBF übereinstimmen int iField = (*it).second.GetField(iObjTyp); _ASSERTE(-1 != iField); _ASSERTE((*it).second.GetTyp() == DBFGetFieldInfo (m_hDBF, iField, NULL, NULL, NULL)); // Wert je nach Typ in die Datenbank schreiben switch ((*it).second.GetTyp()) { case FTString: { char cbBuffer[_MAX_PATH] = { '\0' }; if (NULL != pMFT -> MText) OemToCharBuff(pMFT -> MText, cbBuffer, min(MAX_DBASEFIELD_LEN, strlen(pMFT -> MText))+1); // '\0' mit konvertieren DBFWriteStringAttribute(m_hDBF, iShapeId, iField, cbBuffer); } break; case FTInteger: DBFWriteIntegerAttribute(m_hDBF, iShapeId, iField, (NULL != pMFT -> MText) ? atol(pMFT -> MText) : 0); break; case FTDouble: DBFWriteDoubleAttribute(m_hDBF, iShapeId, iField, (NULL != pMFT -> MText) ? atof(pMFT -> MText) : 0.0); break; } } } else { _ASSERTE(NULL != pMap); // eigentlich sollte eine Map da sein // keine Map, also erstmal leeren Datensatz schreiben int iCnt = DBFGetFieldCount(m_hDBF); for (int i = 0; i < iCnt; ++i) { switch (DBFGetFieldInfo(m_hDBF, i, NULL, NULL, NULL)) { case FTString: DBFWriteStringAttribute(m_hDBF, iShapeId, i, g_cbNil); break; case FTInteger: DBFWriteIntegerAttribute(m_hDBF, iShapeId, i, 0); break; case FTDouble: DBFWriteDoubleAttribute(m_hDBF, iShapeId, i, 0.0); break; } } } } } return S_OK; }
BSONElement BSONElement::operator[](StringData field) const { BSONObj o = Obj(); return o[field]; }
void BSONElement::Val(BSONObj& v) const { v = Obj(); }
virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, BSONObjBuilder& result) { /* currently request to arbiter is (somewhat arbitrarily) an ismaster request that is not authenticated. */ if (cmdObj["forShell"].trueValue()) { LastError::get(opCtx->getClient()).disable(); } transport::Session::TagMask sessionTagsToSet = 0; transport::Session::TagMask sessionTagsToUnset = 0; // Tag connections to avoid closing them on stepdown. auto hangUpElement = cmdObj["hangUpOnStepDown"]; if (!hangUpElement.eoo() && !hangUpElement.trueValue()) { sessionTagsToSet |= transport::Session::kKeepOpen; } auto& clientMetadataIsMasterState = ClientMetadataIsMasterState::get(opCtx->getClient()); bool seenIsMaster = clientMetadataIsMasterState.hasSeenIsMaster(); if (!seenIsMaster) { clientMetadataIsMasterState.setSeenIsMaster(); } BSONElement element = cmdObj[kMetadataDocumentName]; if (!element.eoo()) { if (seenIsMaster) { uasserted(ErrorCodes::ClientMetadataCannotBeMutated, "The client metadata document may only be sent in the first isMaster"); } auto swParseClientMetadata = ClientMetadata::parse(element); uassertStatusOK(swParseClientMetadata.getStatus()); invariant(swParseClientMetadata.getValue()); swParseClientMetadata.getValue().get().logClientMetadata(opCtx->getClient()); clientMetadataIsMasterState.setClientMetadata( opCtx->getClient(), std::move(swParseClientMetadata.getValue())); } // Parse the optional 'internalClient' field. This is provided by incoming connections from // mongod and mongos. auto internalClientElement = cmdObj["internalClient"]; if (internalClientElement) { sessionTagsToSet |= transport::Session::kInternalClient; uassert(ErrorCodes::TypeMismatch, str::stream() << "'internalClient' must be of type Object, but was of type " << typeName(internalClientElement.type()), internalClientElement.type() == BSONType::Object); bool foundMaxWireVersion = false; for (auto&& elem : internalClientElement.Obj()) { auto fieldName = elem.fieldNameStringData(); if (fieldName == "minWireVersion") { // We do not currently use 'internalClient.minWireVersion'. continue; } else if (fieldName == "maxWireVersion") { foundMaxWireVersion = true; uassert(ErrorCodes::TypeMismatch, str::stream() << "'maxWireVersion' field of 'internalClient' must be " "of type int, but was of type " << typeName(elem.type()), elem.type() == BSONType::NumberInt); // All incoming connections from mongod/mongos of earlier versions should be // closed if the featureCompatibilityVersion is bumped to 3.6. if (elem.numberInt() >= WireSpec::instance().incomingInternalClient.maxWireVersion) { sessionTagsToSet |= transport::Session::kLatestVersionInternalClientKeepOpen; } else { sessionTagsToUnset |= transport::Session::kLatestVersionInternalClientKeepOpen; } } else { uasserted(ErrorCodes::BadValue, str::stream() << "Unrecognized field of 'internalClient': '" << fieldName << "'"); } } uassert(ErrorCodes::BadValue, "Missing required field 'maxWireVersion' of 'internalClient'", foundMaxWireVersion); } else { sessionTagsToUnset |= (transport::Session::kInternalClient | transport::Session::kLatestVersionInternalClientKeepOpen); sessionTagsToSet |= transport::Session::kExternalClientKeepOpen; } auto session = opCtx->getClient()->session(); if (session) { session->mutateTags( [sessionTagsToSet, sessionTagsToUnset](transport::Session::TagMask originalTags) { // After a mongos sends the initial "isMaster" command with its mongos client // information, it sometimes sends another "isMaster" command that is forwarded // from its client. Once kInternalClient has been set, we assume that any future // "isMaster" commands are forwarded in this manner, and we do not update the // session tags. if ((originalTags & transport::Session::kInternalClient) == 0) { return (originalTags | sessionTagsToSet) & ~sessionTagsToUnset; } else { return originalTags; } }); } appendReplicationInfo(opCtx, result, 0); if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { const int configServerModeNumber = 2; result.append("configsvr", configServerModeNumber); } result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize); result.appendNumber("maxMessageSizeBytes", MaxMessageSizeBytes); result.appendNumber("maxWriteBatchSize", write_ops::kMaxWriteBatchSize); result.appendDate("localTime", jsTime()); result.append("logicalSessionTimeoutMinutes", localLogicalSessionTimeoutMinutes); result.appendNumber("connectionId", opCtx->getClient()->getConnectionId()); if (internalClientElement) { result.append("minWireVersion", WireSpec::instance().incomingInternalClient.minWireVersion); result.append("maxWireVersion", WireSpec::instance().incomingInternalClient.maxWireVersion); } else { result.append("minWireVersion", WireSpec::instance().incomingExternalClient.minWireVersion); result.append("maxWireVersion", WireSpec::instance().incomingExternalClient.maxWireVersion); } result.append("readOnly", storageGlobalParams.readOnly); const auto parameter = mapFindWithDefault(ServerParameterSet::getGlobal()->getMap(), "automationServiceDescriptor", static_cast<ServerParameter*>(nullptr)); if (parameter) parameter->append(opCtx, result, "automationServiceDescriptor"); if (opCtx->getClient()->session()) { MessageCompressorManager::forSession(opCtx->getClient()->session()) .serverNegotiate(cmdObj, &result); } auto& saslMechanismRegistry = SASLServerMechanismRegistry::get(opCtx->getServiceContext()); saslMechanismRegistry.advertiseMechanismNamesForUser(opCtx, cmdObj, &result); return true; }
void FuncInstr(){ VyObj func_obj = StackPeek(); VyFunction* func = (VyFunction*) Obj(func_obj); func->creation_scope = CurrentScope(); }
void ValueInstr(VyObj obj){ VySymbol* name = (VySymbol*) Obj(obj); VyObj val = VariableValue(name); StackPush(val); }
void BindInstr(){ VyObj name_obj = StackPop(); VyObj val = StackPeek(); VySymbol* name = (VySymbol*) Obj(name_obj); VariableBind(name, val); }
MainWindow::MainWindow(::vl::Ptr<::demo::IViewModel> __vwsn_ctor_parameter_ViewModel) : ::vl::presentation::controls::GuiWindow(::vl::presentation::theme::ThemeName::Window) , __vwsn_parameter_ViewModel(::vl::Ptr<::demo::IViewModel>()) { (this->__vwsn_parameter_ViewModel = __vwsn_ctor_parameter_ViewModel); auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"demo::MainWindow", false)); auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); ::vl::__vwsn::This(this)->__vwsn_demo_MainWindow_Initialize(this); }
ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { MutexGuard locked(lock); std::unique_ptr<ObjectImage> Obj(InputObject); if (!Obj) return NULL; // Save information about our target Arch = (Triple::ArchType)Obj->getArch(); IsTargetLittleEndian = Obj->getObjectFile()->isLittleEndian(); // Compute the memory size required to load all sections to be loaded // and pass this information to the memory manager if (MemMgr->needsToReserveAllocationSpace()) { uint64_t CodeSize = 0, DataSizeRO = 0, DataSizeRW = 0; computeTotalAllocSize(*Obj, CodeSize, DataSizeRO, DataSizeRW); MemMgr->reserveAllocationSpace(CodeSize, DataSizeRO, DataSizeRW); } // Symbols found in this object StringMap<SymbolLoc> LocalSymbols; // Used sections from the object file ObjSectionToIDMap LocalSections; // Common symbols requiring allocation, with their sizes and alignments CommonSymbolMap CommonSymbols; // Maximum required total memory to allocate all common symbols uint64_t CommonSize = 0; // Parse symbols DEBUG(dbgs() << "Parse symbols:\n"); for (symbol_iterator I = Obj->begin_symbols(), E = Obj->end_symbols(); I != E; ++I) { object::SymbolRef::Type SymType; StringRef Name; Check(I->getType(SymType)); Check(I->getName(Name)); uint32_t Flags = I->getFlags(); bool IsCommon = Flags & SymbolRef::SF_Common; if (IsCommon) { // Add the common symbols to a list. We'll allocate them all below. uint32_t Align; Check(I->getAlignment(Align)); uint64_t Size = 0; Check(I->getSize(Size)); CommonSize += Size + Align; CommonSymbols[*I] = CommonSymbolInfo(Size, Align); } else { if (SymType == object::SymbolRef::ST_Function || SymType == object::SymbolRef::ST_Data || SymType == object::SymbolRef::ST_Unknown) { uint64_t FileOffset; StringRef SectionData; bool IsCode; section_iterator SI = Obj->end_sections(); Check(I->getFileOffset(FileOffset)); Check(I->getSection(SI)); if (SI == Obj->end_sections()) continue; Check(SI->getContents(SectionData)); Check(SI->isText(IsCode)); const uint8_t *SymPtr = (const uint8_t *)Obj->getData().data() + (uintptr_t)FileOffset; uintptr_t SectOffset = (uintptr_t)(SymPtr - (const uint8_t *)SectionData.begin()); unsigned SectionID = findOrEmitSection(*Obj, *SI, IsCode, LocalSections); LocalSymbols[Name.data()] = SymbolLoc(SectionID, SectOffset); DEBUG(dbgs() << "\tFileOffset: " << format("%p", (uintptr_t)FileOffset) << " flags: " << Flags << " SID: " << SectionID << " Offset: " << format("%p", SectOffset)); GlobalSymbolTable[Name] = SymbolLoc(SectionID, SectOffset); } } DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name << "\n"); } // Allocate common symbols if (CommonSize != 0) emitCommonSymbols(*Obj, CommonSymbols, CommonSize, LocalSymbols); // Parse and process relocations DEBUG(dbgs() << "Parse relocations:\n"); for (section_iterator SI = Obj->begin_sections(), SE = Obj->end_sections(); SI != SE; ++SI) { unsigned SectionID = 0; StubMap Stubs; section_iterator RelocatedSection = SI->getRelocatedSection(); if (SI->relocation_empty() && !ProcessAllSections) continue; bool IsCode = false; Check(RelocatedSection->isText(IsCode)); SectionID = findOrEmitSection(*Obj, *RelocatedSection, IsCode, LocalSections); DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n"); for (relocation_iterator I = SI->relocation_begin(), E = SI->relocation_end(); I != E;) I = processRelocationRef(SectionID, I, *Obj, LocalSections, LocalSymbols, Stubs); } // Give the subclasses a chance to tie-up any loose ends. finalizeLoad(LocalSections); return Obj.release(); }
bool BSONElement::coerce<std::vector<std::string>>(std::vector<std::string>* out) const { if (type() != mongo::Array) return false; return Obj().coerceVector<std::string>(out); }
va_dcl #else UnsignedInt_t* UnsignedInt (Msg_t msg, ...) #endif { char blank[64], buf[16]; String_t* image; size_t indent; UnsignedInt_t* obj; va_init(ap, msg, obj); if (!obj) return NULL; switch (msg) { case _Init: Obj(_Init, obj, UnsignedInt); obj->vlast = -1; obj->value = 0; obj->unit = 0; return String(_Relay, _Init, &obj->image, ap) ? obj : NULL; case _Destroy: Destroy(&obj->image); if (obj->unit) { Destroy(obj->unit); free(obj->unit); obj->unit = 0; } return NULL; case _SetVal: obj->value = va_arg(ap, unsigned int); obj->vlast = 1; return obj; case _Val: if (obj->vlast < 0) { if (sscanf(Val(&obj->image), "%u", &obj->value) != 1) return NULL; obj->vlast = 0; } return (UnsignedInt_t*) &obj->value; case _Unit_of: return (UnsignedInt_t*) Val(obj->unit); case _SetUnit: return (obj->unit = va_arg(ap, Unit_t*), obj); case _Image: image = va_arg(ap, String_t*); if ((indent = va_arg(ap, size_t)) >= sizeof(blank)) return NULL; if (indent > 0) memset(blank, ' ', indent); blank[indent] = 0; if (obj->vlast > 0) { sprintf(buf, "%u", obj->value); if (! SetVal(&obj->image, buf)) return NULL; obj->vlast = 0; } return (UnsignedInt_t*) String(_Cat, image, blank, Val(&obj->image), 0); default: return NULL; } }
MapManager::MAPDATA MapManager::ReadMap( std::string Path ) { std::ifstream F; try { F.open(Path.c_str(), std::ios::in | std::ios::binary | std::ios::ate); if(!F.is_open()) throw FILE_NOT_OPENED; int /*std::ifstream::pos_type*/ fsize = (int)F.tellg(); if(fsize <= 0) throw INVALID_FILE; F.seekg(0, std::ios::beg); char* temp = new char[fsize]; F.read(temp, fsize); unsigned char* data = (unsigned char*)temp; //The char* must be converted in order to be interpreted correctly int cPos = 0; //To keep track that we don't extend beyond the data length unsigned char Version = read_uchar(data, fsize, cPos); unsigned short Year = read_ushort(data, fsize, cPos); unsigned char Month = read_uchar(data, fsize, cPos); unsigned char Day = read_uchar(data, fsize, cPos); std::string LevelName = read_string(data, fsize, cPos, 25); int PlayerPosX = read_int(data, fsize, cPos); int PlayerPosY = read_int(data, fsize, cPos); std::vector<BACKGROUND_STRUCT> BGs; unsigned char numBG = read_uchar(data, fsize, cPos); for(unsigned char i = 0; i < numBG; i++) BGs.push_back(BACKGROUND_STRUCT(BACKGROUND, read_uchar(data, fsize, cPos))); unsigned char numMid = read_uchar(data, fsize, cPos); for(unsigned char i = 0; i < numMid; i++) BGs.push_back(BACKGROUND_STRUCT(MIDDLEGROUND, read_uchar(data, fsize, cPos))); unsigned char numFG = read_uchar(data, fsize, cPos); for(unsigned char i = 0; i < numFG; i++) BGs.push_back(BACKGROUND_STRUCT(FOREGROUND, read_uchar(data, fsize, cPos))); unsigned short numObj = read_ushort(data, fsize, cPos); std::vector<GAMEOBJECT_STRUCT> Objects; for(unsigned char i = 0; i < numObj; i++) { unsigned char TypeId = read_uchar(data, fsize, cPos); int PosX = read_int(data, fsize, cPos); int PosY = read_int(data, fsize, cPos); GAMEOBJECT_STRUCT Obj(TypeId, PosX, PosY); Objects.push_back(Obj); } if(cPos != fsize) Util::msgWarn(Util::BuildString("Read size does not match file size (%d byte / %dbyte), possibly corrupt file (%s).", cPos, fsize, Path.c_str())); Util::msgNote(Util::BuildString("Read map: %s", Path.c_str())); return MAPDATA( Version, LevelName, Year, Month, Day, sf::Vector2i(PlayerPosX,PlayerPosY), Objects, BGs, numBG, numMid, numFG, numObj ); } catch (ERRORS e) { F.close(); return MAPDATA(e); } F.close(); return MAPDATA(INVALID_FILE); }
Status V2UserDocumentParser::checkValidUserDocument(const BSONObj& doc) const { auto userIdElement = doc[AuthorizationManager::USERID_FIELD_NAME]; auto userElement = doc[AuthorizationManager::USER_NAME_FIELD_NAME]; auto userDBElement = doc[AuthorizationManager::USER_DB_FIELD_NAME]; auto credentialsElement = doc[CREDENTIALS_FIELD_NAME]; auto rolesElement = doc[ROLES_FIELD_NAME]; // Validate the "userId" element. if (!userIdElement.eoo()) { if (!userIdElement.isBinData(BinDataType::newUUID)) { return _badValue("User document needs 'userId' field to be a UUID"); } } // Validate the "user" element. if (userElement.type() != String) return _badValue("User document needs 'user' field to be a string"); if (userElement.valueStringData().empty()) return _badValue("User document needs 'user' field to be non-empty"); // Validate the "db" element if (userDBElement.type() != String || userDBElement.valueStringData().empty()) { return _badValue("User document needs 'db' field to be a non-empty string"); } StringData userDBStr = userDBElement.valueStringData(); if (!NamespaceString::validDBName(userDBStr, NamespaceString::DollarInDbNameBehavior::Allow) && userDBStr != "$external") { return _badValue(mongoutils::str::stream() << "'" << userDBStr << "' is not a valid value for the db field."); } // Validate the "credentials" element if (credentialsElement.eoo()) { return _badValue("User document needs 'credentials' object"); } if (credentialsElement.type() != Object) { return _badValue("User document needs 'credentials' field to be an object"); } BSONObj credentialsObj = credentialsElement.Obj(); if (credentialsObj.isEmpty()) { return _badValue("User document needs 'credentials' field to be a non-empty object"); } if (userDBStr == "$external") { BSONElement externalElement = credentialsObj[MONGODB_EXTERNAL_CREDENTIAL_FIELD_NAME]; if (externalElement.eoo() || externalElement.type() != Bool || !externalElement.Bool()) { return _badValue( "User documents for users defined on '$external' must have " "'credentials' field set to {external: true}"); } } else { const auto validateScram = [&credentialsObj](const auto& fieldName) { auto scramElement = credentialsObj[fieldName]; if (scramElement.eoo()) { return Status(ErrorCodes::NoSuchKey, str::stream() << fieldName << " does not exist"); } if (scramElement.type() != Object) { return _badValue(str::stream() << fieldName << " credential must be an object, if present"); } return Status::OK(); }; const auto sha1status = validateScram(SCRAMSHA1_CREDENTIAL_FIELD_NAME); if (!sha1status.isOK() && (sha1status.code() != ErrorCodes::NoSuchKey)) { return sha1status; } const auto sha256status = validateScram(SCRAMSHA256_CREDENTIAL_FIELD_NAME); if (!sha256status.isOK() && (sha256status.code() != ErrorCodes::NoSuchKey)) { return sha256status; } if (!sha1status.isOK() && !sha256status.isOK()) { return _badValue( "User document must provide credentials for all " "non-external users"); } } // Validate the "roles" element. Status status = _checkV2RolesArray(rolesElement); if (!status.isOK()) return status; // Validate the "authenticationRestrictions" element. status = initializeAuthenticationRestrictionsFromUserDocument(doc, nullptr); if (!status.isOK()) { return status; } return Status::OK(); }
/*! * \brief Get one binary object from page * \param r r th obj in the page */ inline Obj operator[](int r) { Assert(r < Size(), "index excceed bound"); return Obj(this->offset(data_[ r + 2 ]), data_[ r + 2 ] - data_[ r + 1 ]); }
Obj TerrainTile::topVisitableId(bool excludeTop) const { return topVisitableObj(excludeTop) ? topVisitableObj(excludeTop)->ID : Obj(Obj::NO_OBJ); }
DocumentEditorBase::DocumentEditorBase() : ::vl::presentation::controls::GuiCustomControl(::vl::presentation::theme::ThemeName::CustomControl) , __vwsn_prop_EditModeCommand(static_cast<::vl::presentation::controls::GuiToolstripCommand*>(nullptr)) , __vwsn_prop_HasEditableSelection(false) , __vwsn_prop_HasEditableSelectionInSingleParagraph(false) { auto __vwsn_resource_ = ::vl::__vwsn::This(::vl::presentation::GetResourceManager())->GetResourceFromClassName(::vl::WString(L"demo::DocumentEditorBase", false)); auto __vwsn_resolver_ = ::vl::Ptr<::vl::presentation::GuiResourcePathResolver>(new ::vl::presentation::GuiResourcePathResolver(__vwsn_resource_, ::vl::__vwsn::This(__vwsn_resource_.Obj())->GetWorkingDirectory())); ::vl::__vwsn::This(this)->SetResourceResolver(__vwsn_resolver_); ::vl::__vwsn::This(this)->__vwsn_demo_DocumentEditorBase_Initialize(this); this->__vwsn_instance_ctor_(); }
void AObjectTypeHandler::addTemplate(ObjectTemplate templ) { templ.id = Obj(type); templ.subid = subtype; templates.push_back(templ); }
/*********************************************************************************************************************** Function: DoReq Description: Called By: Input: Output: Return: Others: ************************************************************************************************************************/ S32 CNetServer::DoReq(Socket_t sHandle) { CNetObj Obj(sHandle, &m_Crowd, 1 * 1024 * 1024, 64*1024); return Obj.Run(); }