/* * Class: mapnik_FeatureTypeStyle * Method: collectAttributes * Signature: ()Ljava/util/Set; */ JNIEXPORT jobject JNICALL Java_mapnik_FeatureTypeStyle_collectAttributes (JNIEnv *env, jobject styleobject) { mapnik::feature_type_style* style=LOAD_FEATURE_TYPE_STYLE_POINTER(styleobject); const std::vector<mapnik::rule>& rules(style->get_rules()); std::set<std::string> attrs; mapnik::attribute_collector collector(attrs); BOOST_FOREACH(mapnik::rule const& r, rules) { collector(r); }
void factor_vm::collect_to_tenured() { /* Copy live objects from aging space to tenured space. */ to_tenured_collector collector(this); mark_stack.clear(); collector.trace_roots(); collector.trace_contexts(); gc_event* event = current_gc->event; if (event) event->started_card_scan(); collector.trace_cards(data->tenured, card_points_to_aging, full_unmarker()); if (event) event->ended_card_scan(collector.cards_scanned, collector.decks_scanned); if (event) event->started_code_scan(); collector.trace_code_heap_roots(&code->points_to_aging); if (event) event->ended_code_scan(collector.code_blocks_scanned); collector.tenure_reachable_objects(); data->reset_generation(&nursery); data->reset_generation(data->aging); code->clear_remembered_set(); }
void makeAndDisplayCM( char* name, char* pool ) { Daemon collector( DT_COLLECTOR, name, pool ); Daemon negotiator( DT_NEGOTIATOR, name, pool ); Daemon view_collector( DT_VIEW_COLLECTOR, name, pool ); if( ! collector.locate() ) { dprintf( dflag, "%s\n", collector.error() ); } else { collector.display( dflag ); } dprintf( dflag, "\n" ); if( ! negotiator.locate() ) { dprintf( dflag, "%s\n", negotiator.error() ); } else { negotiator.display( dflag ); } dprintf( dflag, "\n" ); if( ! view_collector.locate() ) { dprintf( dflag, "%s\n", view_collector.error() ); } else { view_collector.display( dflag ); } dprintf( dflag, "\n" ); }
void ElementRuleCollector::matchSlottedPseudoElementRules(MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { auto* maybeSlotted = &m_element; for (auto* hostShadowRoot = m_element.parentNode()->shadowRoot(); hostShadowRoot; hostShadowRoot = maybeSlotted->parentNode()->shadowRoot()) { auto* slot = hostShadowRoot->findAssignedSlot(*maybeSlotted); if (!slot) return; matchRequest.treeContextOrdinal++; // In nested case the slot may itself be assigned to a slot. Collect ::slotted rules from all the nested trees. maybeSlotted = slot; if (!hostShadowRoot->styleScope().resolver().ruleSets().isAuthorStyleDefined()) continue; // Find out if there are any ::slotted rules in the shadow tree matching the current slot. // FIXME: This is really part of the slot style and could be cached when resolving it. ElementRuleCollector collector(*slot, hostShadowRoot->styleScope().resolver().ruleSets().authorStyle(), nullptr); auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(matchRequest.includeEmptyRules); if (!slottedPseudoElementRules) continue; // Match in the current scope. SetForScope<bool> change(m_isMatchingSlottedPseudoElements, true); MatchRequest scopeMatchRequest(nullptr, matchRequest.includeEmptyRules, matchRequest.treeContextOrdinal); collectMatchingRulesForList(slottedPseudoElementRules.get(), scopeMatchRequest, ruleRange); m_keepAliveSlottedPseudoElementRules.append(WTFMove(slottedPseudoElementRules)); } }
hkvVec3 RPG_Projectile::SweepPhantom(hkvVec3 newPosition) { hkVector4 hCurrentPosition, hNewPosition; RPG_VisionHavokConversion::VisionToHavokPoint(m_currentPosition, hCurrentPosition); RPG_VisionHavokConversion::VisionToHavokPoint(newPosition, hNewPosition); hkpLinearCastInput lci; { lci.m_startPointTolerance = 0.01f; lci.m_maxExtraPenetration = 0.01f; lci.m_to = hNewPosition; } RPG_ProjectilePointCollector collector(this); VASSERT(m_shapePhantom); if(m_shapePhantom) { // move shape phantom to the last frame's position, and sweep toward the current frame's position vHavokPhysicsModule::GetInstance()->MarkForWrite(); m_shapePhantom->setPositionAndLinearCast(hCurrentPosition, lci, collector, HK_NULL); vHavokPhysicsModule::GetInstance()->UnmarkForWrite(); } if(collector.m_hit) { return collector.m_hitPoint; } else { return newPosition; } }
void DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine, StyleResolverUpdateMode updateMode) { StyleSheetCollection collection; ActiveDocumentStyleSheetCollector collector(collection); collectStyleSheets(engine, collector); StyleSheetChange change; analyzeStyleSheetChange(updateMode, collection, change); if (change.styleResolverUpdateType == Reconstruct) { engine->clearMasterResolver(); // FIMXE: The following depends on whether StyleRuleFontFace was modified or not. // No need to always-clear font cache. engine->clearFontCache(); } else if (StyleResolver* styleResolver = engine->resolver()) { if (change.styleResolverUpdateType != Additive) { ASSERT(change.styleResolverUpdateType == Reset); styleResolver->resetAuthorStyle(treeScope()); engine->removeFontFaceRules(change.fontFaceRulesToRemove); styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets); styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAuthorStyleSheets()); } else { styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection.activeAuthorStyleSheets()); } } if (change.requiresFullStyleRecalc) document().setNeedsStyleRecalc(SubtreeStyleChange); collection.swap(*this); updateUsesRemUnits(); }
/** * Performs selection operation on the global scenegraph. * If delete_bounds_src is true, then the objects which were * used as source for the selection aabbs will be deleted. */ static void DoSelection(bool deleteBoundsSrc = true) { if (GlobalSelectionSystem().Mode() != SelectionSystem::ePrimitive) { // Wrong selection mode return; } // we may not need all AABBs since not all selected objects have to be brushes const std::size_t max = GlobalSelectionSystem().countSelected(); AABB* aabbs = new AABB[max]; CollectSelectedBrushesBounds collector(aabbs, max); GlobalSelectionSystem().foreachSelected(collector); std::size_t count = collector.getCount(); // nothing usable in selection if (!count) { delete[] aabbs; return; } // delete selected objects? if (deleteBoundsSrc) { UndoableCommand undo("deleteSelected"); selection::algorithm::deleteSelection(); } // Instantiate a "self" object SelectByBounds and use it as visitor SelectByBounds<TSelectionPolicy> walker(aabbs, count); Node_traverseSubgraph(GlobalSceneGraph().root(), walker); SceneChangeNotify(); delete[] aabbs; }
void cAnnunciator::GetChildren( cObject::Children& children ) const { cObject::GetChildren( children ); ObjectCollector collector( children ); std::for_each( m_as.begin(), m_as.end(), collector ); }
hkDemo::Result UserRayHitCollectorDemo::stepDemo() { // // shoot two times four colored rays. // 1. each ray should only hit the object with the same color // 2. each ray should only hit the triangles (which are at the same x-coord as the object) // m_time += m_timestep; { // // Setup the ray coordinates // hkpWorldRayCastInput ray; { ray.m_from.set(-4.f, 0.f, 0.0f ); ray.m_to.set ( 25.f, 0.f, 2.5f * hkMath::cos(m_time * 0.5f)); } // // Do the raycaster // { UserRayHitCollector collector(ray); m_world->lock(); m_world->castRay( ray, collector ); m_world->unlock(); collector.displayFinalRay(); } } return hkDefaultPhysicsDemo::stepDemo(); }
void factor_vm::collect_nursery() { /* Copy live objects from the nursery (as determined by the root set and marked cards in aging and tenured) to aging space. */ nursery_collector collector(this); collector.trace_roots(); collector.trace_contexts(); gc_event* event = current_gc->event; if (event) event->started_card_scan(); collector.trace_cards(data->tenured, card_points_to_nursery, simple_unmarker(card_points_to_nursery)); if (data->aging->here != data->aging->start) { collector.trace_cards(data->aging, card_points_to_nursery, full_unmarker()); } if (event) event->ended_card_scan(collector.cards_scanned, collector.decks_scanned); if (event) event->started_code_scan(); collector.trace_code_heap_roots(&code->points_to_nursery); if (event) event->ended_code_scan(collector.code_blocks_scanned); collector.cheneys_algorithm(); data->reset_generation(&nursery); code->points_to_nursery.clear(); }
void QUCoverGroup::showCovers() { list->model()->clear(); list->hide(); foreach(QFileInfo fi, collector()->results()) list->model()->addCover(fi.filePath()); list->selectionModel()->setCurrentIndex(list->model()->index(0), QItemSelectionModel::Select); if(list->model()->rowCount() > 0) { // TODO: fix this mess! - I just want to see all content all the time ... T_T list->show(); int itemCount = list->model()->rowCount(); int maxItemHeight = 1; for(int i = 0; i < itemCount; i++) maxItemHeight = qMax(maxItemHeight, list->sizeHintForRow(i)); int rowCount = qRound((double)itemCount / 5.0); if(rowCount * 5 < itemCount) rowCount++; list->setMinimumHeight(maxItemHeight * qMax(1, rowCount)); } }
int main(int argc, char* argv[]) { try { terrama2::core::TerraMA2Init terramaRaii("example", 0); terrama2::core::registerFactories(); { QCoreApplication app(argc, argv); auto& serviceManager = terrama2::core::ServiceManager::getInstance(); te::core::URI uri("pgsql://"+TERRAMA2_DATABASE_USERNAME+":"+TERRAMA2_DATABASE_PASSWORD+"@"+TERRAMA2_DATABASE_HOST+":"+TERRAMA2_DATABASE_PORT+"/"+TERRAMA2_DATABASE_DBNAME); serviceManager.setLogConnectionInfo(uri); serviceManager.setInstanceId(1); auto dataManager = std::make_shared<terrama2::services::collector::core::DataManager>(); addInput(dataManager); addOutput(dataManager); terrama2::services::collector::core::Service service(dataManager); auto logger = std::make_shared<terrama2::services::collector::core::CollectorLogger>(); logger->setConnectionInfo(uri); service.setLogger(logger); service.start(); terrama2::services::collector::core::Collector* collector(new terrama2::services::collector::core::Collector()); terrama2::services::collector::core::CollectorPtr collectorPtr(collector); collector->id = 777; collector->projectId = 1; collector->serviceInstanceId = 1; collector->filter.region = terrama2::core::ewktToGeom("SRID=4326;POLYGON((-73.8036991603083 -9.81412714740936,-73.8036991603083 2.24662115728613,-56.097053202293 2.24662115728613,-56.097053202293 -9.81412714740936,-73.8036991603083 -9.81412714740936))"); collector->filter.cropRaster = true; collector->filter.discardBefore = terrama2::core::TimeUtils::stringToTimestamp("2016-11-25T06:00:00.000-02:00", terrama2::core::TimeUtils::webgui_timefacet); collector->filter.discardAfter = terrama2::core::TimeUtils::stringToTimestamp("2016-11-25T12:00:00.000-02:00", terrama2::core::TimeUtils::webgui_timefacet); collector->inputDataSeries = 1; collector->outputDataSeries = 2; collector->inputOutputMap.emplace(1, 2); dataManager->add(collectorPtr); service.addToQueue(collectorPtr->id, terrama2::core::TimeUtils::nowUTC()); QTimer timer; QObject::connect(&timer, SIGNAL(timeout()), QCoreApplication::instance(), SLOT(quit())); timer.start(10000); app.exec(); service.stopService(); } } catch(...) { std::cout << "\n\nException...\n" << std::endl; } return 0; }
bool plAgeLoader::IUnloadAge() { plNetClientApp* nc = plNetClientApp::GetInstance(); nc->DebugMsg( "Net: Unloading age {}", fAgeName); hsAssert( (fFlags & kLoadMask)==0, "already loading or unloading an age?"); fFlags |= kUnLoadingAge; plAgeBeginLoadingMsg* msg = new plAgeBeginLoadingMsg(); msg->fLoading = false; msg->Send(); // Note: instead of going from the .age file, we just want a list of what // is REALLY paged in for this age. So ask the resMgr! plUnloadAgeCollector collector(fAgeName); // WARNING: unsafe cast here, but it's ok, until somebody is mean and makes a non-plResManager resMgr ( (plResManager *)hsgResMgr::ResMgr() )->IterateAllPages( &collector ); // Dat was easy... plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY ); // Build up a list of all the rooms we're going to page out plKeyVec newPageOuts; int i; for( i = 0; i < collector.fPages.GetCount(); i++ ) { plRegistryPageNode *page = collector.fPages[ i ]; plKey roomKey = plKeyFinder::Instance().FindSceneNodeKey( page->GetPageInfo().GetLocation() ); if( roomKey != nil && roomKey->ObjectIsLoaded() ) { nc->DebugMsg( "\tPaging out room {}\n", page->GetPageInfo().GetPage() ); newPageOuts.push_back(roomKey); } } // Put them in our pending page outs for( i = 0; i < newPageOuts.size(); i++ ) fPendingPageOuts.push_back(newPageOuts[i]); // ...then send the unload messages. That way we ensure the list is complete // before any messages get processed for( i = 0; i < newPageOuts.size(); i++ ) { plClientMsg *pMsg1 = new plClientMsg( plClientMsg::kUnloadRoom ); pMsg1->AddRoomLoc(newPageOuts[i]->GetUoid().GetLocation()); pMsg1->Send( clientKey ); } if ( newPageOuts.size()==0 ) { // age is done unloading because it has no pages? NotifyAgeLoaded( false ); } return true; }
/** * Find all files with a specific name. */ size_t File::find(FileList &result, const std::string &fileNameRegex, bool dirs, bool special) const { FileFilterAnd filter(new FileTypeFilter(dirs, true, special), new FileRegexFilter(fileNameRegex)); FileCollector collector(&result, filter); // visit all with maxDepth 100, follow symlinks visit(collector, 100, true, special); return collector.size(); }
int main(int argc, char *argv[]) { int lport = DEFAULT_LISTEN_PORT; std::string proto = "udp"; msg_setlevel(MSG_DEBUG); signal(SIGINT, sigint); if (!(argc == 1 || argc == 2 || argc == 3)) { usage(); return -1; } if (argc == 2) proto = argv[1]; if (argc == 3) lport = atoi(argv[2]); IpfixReceiver* ipfixReceiver = 0; if (proto == "udp") { msg(MSG_INFO, "Creating UDP listener on port %i", lport); ipfixReceiver = new IpfixReceiverUdpIpV4(lport); } else if (proto == "sctp") { #ifdef SUPPORT_SCTP ipfixReceiver = new IpfixReceiverSctpIpV4(lport, "127.0.0.1"); #else msg(MSG_FATAL, "testcollector has been compiled without sctp support"); return -1; #endif } else { msg(MSG_FATAL, "Protocol %s is not supported as a transport protocol for IPFIX data", proto.c_str()); return -1; } IpfixCollector collector(ipfixReceiver); ConnectionQueue<IpfixRecord*> queue(100); IpfixPrinter printer; collector.connectTo(&queue); queue.connectTo(&printer); printer.start(); queue.start(); collector.start(); msg(MSG_DIALOG, "Hit Ctrl+C to quit"); pause(); msg(MSG_DIALOG, "Stopping threads and tidying up.\n"); msg(MSG_DIALOG, "stopping collector\n"); collector.shutdown(); queue.shutdown(); printer.shutdown(); return 0; }
void factor_vm::collect_aging() { /* Promote objects referenced from tenured space to tenured space, copy everything else to the aging semi-space, and reset the nursery pointer. */ { /* Change the op so that if we fail here, an assertion will be raised. */ current_gc->op = collect_to_tenured_op; to_tenured_collector collector(this); gc_event* event = current_gc->event; if (event) event->started_card_scan(); collector.trace_cards(data->tenured, card_points_to_aging, 0xff); if (event) event->ended_card_scan(collector.cards_scanned, collector.decks_scanned); if (event) event->started_code_scan(); collector.trace_code_heap_roots(&code->points_to_aging); if (event) event->ended_code_scan(collector.code_blocks_scanned); collector.visitor.visit_mark_stack(&mark_stack); } { /* If collection fails here, do a to_tenured collection. */ current_gc->op = collect_aging_op; std::swap(data->aging, data->aging_semispace); data->reset_aging(); copying_collector<aging_space, aging_policy> collector(this, this->data->aging, aging_policy(this)); collector.visitor.visit_all_roots(); collector.cheneys_algorithm(); data->reset_nursery(); code->clear_remembered_set(); } }
void LayerCache::collect(const Rect& viewport, std::vector<int32_t>& index_list) { CacheTree::Node * node = m_tree->find_container(viewport); CacheTreeCollector collector(index_list, viewport); node->apply_visitor(collector); node = node->parent(); while(node) { collector.visit(node); node = node->parent(); } }
/* Assembles all instructions of an interpretation. ROSE allows blocks to be non-contiguous (i.e., an unconditiona jump can * appear in the middle of a basic block). However, we need to disassemble contiguous instructions. */ static void assemble_all(SgAsmInterpretation *interp) { size_t nassembled = 0; Assembler *assembler = Assembler::create(interp); ROSE_ASSERT(assembler!=NULL); InstructionCollector collector(interp); for (Disassembler::InstructionMap::iterator ii=collector.insns.begin(); ii!=collector.insns.end(); ++ii) { rose_addr_t original_va = ii->first; /* The new_va is the virtual address of the instruction now that we may have moved it to a new location in memory. * We're leaving this implementation for later. For now, just assume that instructions don't move in memory. */ rose_addr_t new_va = original_va; SgAsmx86Instruction *insn = isSgAsmx86Instruction(ii->second); ROSE_ASSERT(insn!=NULL); SgUnsignedCharList machine_code; try { insn->set_address(new_va); machine_code = assembler->assembleOne(insn); ROSE_ASSERT(!machine_code.empty()); ++nassembled; } catch (const Assembler::Exception &e) { std::cerr <<"assembly failed at " <<StringUtility::addrToString(e.insn->get_address()) <<": " <<e.what() <<std::endl; if (!assembler->get_debug()) { assembler->set_debug(stderr); try { assembler->assembleOne(insn); } catch (...) { /*void*/ } assembler->set_debug(false); } //return; } #if 0 /* Don't worry about writing the instruction back out to the section. [RPM 2011-08-23] */ /* We don't handle the case where an instruction grows because that could cause us to require that the section * containing the instruction grows, which opens a whole can of worms. */ ROSE_ASSERT(machine_code.size() <= insn->get_size()); /* We're using the same memory map as what was used when we loaded the binary and disassembled it. Therefore, the * machine code that we're writing back needs to fall within those same areas of the virtual address space: we cannot * write past the end of mapped memory, nor can we write to the space (if any) between mapped memory chunks. */ size_t nwritten = interp->get_map()->write(&(machine_code[0]), new_va, machine_code.size(), MemoryMap::MM_PROT_NONE); ROSE_ASSERT(nwritten==machine_code.size()); #endif } std::cout <<"Assembled " <<nassembled <<" instruction" <<(1==nassembled?"":"s") <<"\n"; delete assembler; }
static nsRect GetSVGBBox(nsIFrame* aNonSVGFrame, nsIFrame* aCurrentFrame, const nsRect& aCurrentOverflow, const nsRect& aUserSpaceRect) { NS_ASSERTION(!aNonSVGFrame->GetPrevContinuation(), "Need first continuation here"); // Compute union of all overflow areas relative to 'first'. BBoxCollector collector(aNonSVGFrame, aCurrentFrame, aCurrentOverflow); nsLayoutUtils::GetAllInFlowBoxes(aNonSVGFrame, &collector); // Get it into "user space" for non-SVG frames return collector.mResult - aUserSpaceRect.TopLeft(); }
/* * Class: mapnik_FeatureTypeStyle * Method: collectAttributes * Signature: ()Ljava/util/Set; */ JNIEXPORT jobject JNICALL Java_mapnik_FeatureTypeStyle_collectAttributes (JNIEnv *env, jobject styleobject) { PREAMBLE; mapnik::feature_type_style* style=LOAD_FEATURE_TYPE_STYLE_POINTER(styleobject); const std::vector<mapnik::rule>& rules(style->get_rules()); std::set<std::string> attrs; mapnik::attribute_collector collector(attrs); for (mapnik::rule const& r : rules) { collector(r); } jobject ret=env->NewObject(CLASS_HASHSET, CTOR_HASHSET); for (std::set<std::string>::iterator iter=attrs.begin(); iter!=attrs.end(); iter++) { env->CallBooleanMethod(ret, METHOD_HASHSET_ADD, env->NewStringUTF(iter->c_str())); } return ret; TRAILER(0); }
//-------------------------------------------------------------------------------------------------------- void CFuncNavBlocker::UpdateBlocked() { NavAreaCollector collector( true ); Extent extent; extent.Init( this ); TheNavMesh->ForAllAreasOverlappingExtent( collector, extent ); for ( int i=0; i<collector.m_area.Count(); ++i ) { CNavArea *area = collector.m_area[i]; area->UpdateBlocked( true ); } }
int main(int argc, char *argv[]) { int lport = DEFAULT_LISTEN_PORT; msg_setlevel(MSG_DEFAULT); signal(SIGINT, sigint); if(argv[1]) { lport=atoi(argv[1]); } // needs to be a pointer because its freed in d'tor of IpfixCollector IpfixReceiverUdpIpV4* ipfixReceiver = new IpfixReceiverUdpIpV4(lport); IpfixCollector collector(ipfixReceiver); ConnectionQueue<IpfixRecord*> queue(100); IpfixPrinter printer; collector.connectTo(&queue); queue.connectTo(&printer); printer.start(); queue.start(); collector.start(); // FIXME: test temporarily deactivated /*IpfixParser ipfixParser; ipfixParser.addFlowSink(&ipfixPrinter); IpfixCollector ipfixCollector; ipfixCollector.addIpfixReceiver(&ipfixReceiver); ipfixCollector.addIpfixPacketProcessor(&ipfixParser); ipfixCollector.start();*/ msg(MSG_DIALOG, "Listening on %d. Hit Ctrl+C to quit\n", lport); pause(); msg(MSG_DIALOG, "Stopping threads and tidying up.\n"); collector.shutdown(); queue.shutdown(); printer.shutdown(); return 0; }
void LLViewerControlListener::vars(LLSD const & request) { // This method doesn't use Info, because we're not looking up a specific // control name. Response response(LLSD(), request); std::string groupname(request["group"]); LLControlGroup* group(LLControlGroup::getInstance(groupname)); if (! group) { return response.error(STRINGIZE("Unrecognized group '" << groupname << "'")); } CollectVars collector(group); group->applyToAll(&collector); response["vars"] = collector.vars; }
/** * Gets the union of the pre-effects visual overflow rects of all of a frame's * continuations, in "user space". */ static nsRect GetPreEffectsVisualOverflowUnion(nsIFrame* aFirstContinuation, nsIFrame* aCurrentFrame, const nsRect& aCurrentFramePreEffectsOverflow, const nsPoint& aFirstContinuationToUserSpace) { NS_ASSERTION(!aFirstContinuation->GetPrevContinuation(), "Need first continuation here"); PreEffectsVisualOverflowCollector collector(aFirstContinuation, aCurrentFrame, aCurrentFramePreEffectsOverflow); // Compute union of all overflow areas relative to aFirstContinuation: nsLayoutUtils::GetAllInFlowBoxes(aFirstContinuation, &collector); // Return the result in user space: return collector.GetResult() + aFirstContinuationToUserSpace; }
// Do a breadth-first search to find a good retreat spot. // Don't pick a spot that a Player is currently occupying. const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange) { CNavArea *area = me->GetLastKnownArea(); if (!area) return nullptr; // collect spots that enemies cannot see CollectRetreatSpotsFunctor collector(me, maxRange); SearchSurroundingAreas(area, &me->pev->origin, collector, maxRange); if (collector.m_count == 0) return nullptr; // select a hiding spot at random int which = RANDOM_LONG(0, collector.m_count - 1); return collector.m_spot[which]; }
TypeSet getGreatestCommonSubtypes(const Type& a, const Type& b) { // make sure they are in the same type environment assert(a.getTypeEnvironment().isType(a) && a.getTypeEnvironment().isType(b)); // if they are equal it is easy if (a == b) { return TypeSet(a); } // equally simple - check whether one is a sub-type of the other if (isSubtypeOf(a,b)) { return TypeSet(a); } if (isSubtypeOf(b,a)) { return TypeSet(b); } // last option: if both are unions with common sub-types TypeSet res; if (isUnion(a) && isUnion(b)) { // collect common sub-types of union types struct collector : public TypeVisitor<void> { const Type& b; TypeSet& res; collector(const Type& b, TypeSet& res) : b(b), res(res) {} void visit(const Type& type) const { if (isSubtypeOf(type, b)) { res.insert(type); } else { TypeVisitor<void>::visit(type); } } void visitUnionType(const UnionType& type) const { for(const auto& cur : type.getElementTypes()) visit(*cur); } }; // collect all common sub-types collector(b,res).visit(a); } // otherwise there is no common super type return res; }
Variable ObjectContext::field(const std::string &key, bool createIfNeeded) { for (Object* object = &_object; object != nullptr; object = object->parent()) { ObjectContext* context = object->context(); if (context != nullptr) { auto it = context->_fields.find(key); if (it != context->_fields.end()) { return it->second; } } } if (createIfNeeded) { return _fields[key] = collector().null(); } else { return Variable(); } }
void InstanceTree::findInstances(const ModelCoordinate& point, int32_t w, int32_t h, InstanceTree::InstanceList& list) { list.clear(); InstanceTreeNode * node = m_tree.find_container(point.x, point.y, w, h); Rect rect(point.x, point.y, w, h); InstanceListCollector collector(list,rect); node->apply_visitor(collector); node = node->parent(); while( node ) { for(InstanceList::const_iterator it(node->data().begin()); it != node->data().end(); ++it) { ModelCoordinate coords = (*it)->getLocationRef().getLayerCoordinates(); if( rect.contains(Point(coords.x,coords.y)) ) { list.push_back(*it); } } node = node->parent(); } }
void CxxUsingNamespaceCollectorThread::ProcessRequest(ThreadRequest* request) { CxxUsingNamespaceCollectorThread::Request* req = dynamic_cast<CxxUsingNamespaceCollectorThread::Request*>(request); CHECK_PTR_RET(req); CxxPreProcessor pp; pp.SetMaxDepth(20); CxxUsingNamespaceCollector collector(&pp, req->filename); for(size_t i = 0; i < req->includePaths.GetCount(); ++i) { pp.AddIncludePath(req->includePaths.Item(i)); } CL_DEBUG("Collecting 'using namespace' statements for file '%s' started\n", req->filename); collector.Parse(); CL_DEBUG("Collecting 'using namespace' statements for file '%s' completed\n", req->filename); CodeCompletionManager::Get().CallAfter( &CodeCompletionManager::OnFindUsingNamespaceDone, collector.GetUsingNamespaces(), req->filename); }
PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent) { ASSERT(m_document.frame()); ASSERT(m_document.settings()); StyleResolverState state(m_document, element, defaultParent); if (state.parentStyle()) { SharedStyleFinder styleFinder(state.elementContext(), *this); if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) return sharedStyle.release(); } if (state.parentStyle()) { state.setStyle(RenderStyle::create()); state.style()->inheritFrom(state.parentStyle()); } else { state.setStyle(defaultStyleForElement()); state.setParentStyle(RenderStyle::clone(state.style())); } state.fontBuilder().initForStyleResolve(&state.document(), state.style()); { ElementRuleCollector collector(state.elementContext(), state.style()); matchRules(*element, collector); applyMatchedProperties(state, collector.matchedResult()); } // Cache our original display. state.style()->setOriginalDisplay(state.style()->display()); StyleAdjuster adjuster; adjuster.adjustRenderStyle(state.style(), state.parentStyle(), *element); if (state.style()->hasViewportUnits()) m_document.setHasViewportUnits(); // Now return the style. return state.takeStyle(); }