Node* nextSibling(const Node* node)
{
    ComposedShadowTreeWalker walker(node);
    if (node->isBeforePseudoElement()) {
        walker.parent();
        walker.firstChild();
    } else
        walker.nextSibling();

    if (walker.get() || node->isAfterPseudoElement())
        return walker.get();

    Node* parent = walker.traverseParent(node);
    if (parent && parent->isElementNode())
        return toElement(parent)->pseudoElement(AFTER);

    return 0;
}
void
nsXULColorPickerAccessible::CacheChildren()
{
  nsAccTreeWalker walker(mWeakShell, mContent, PR_TRUE);

  nsRefPtr<nsAccessible> child;
  while ((child = walker.GetNextChild())) {
    // XXX: do not call nsAccessible::GetRole() while accessible not in tree
    // (bug 574588).
    PRUint32 role = nsAccUtils::Role(child);

    // Get an accessbile for menupopup or panel elements.
    if (role == nsIAccessibleRole::ROLE_ALERT) {
      AppendChild(child);
      return;
    }
  }
}
void NonConstBoundDismantlerPass::do_file_set_block( FileSetBlock* file_set_block ) {
    SuifEnv *env = get_suif_env();
    ReplacingWalker walker(env);
    ReverseMap rev_map;
    NonConstDimExpressionWalker ew1(env,walker,rev_map,MultiDimArrayExpression::get_class_name());
    NonConstDimExpressionWalker ew2(env,walker,rev_map,ArrayReferenceExpression::get_class_name());

    NonConstBoundArrayTypeWalker  aw1(env,rev_map,MultiDimArrayType::get_class_name());
    NonConstBoundArrayTypeWalker  aw2(env,rev_map,ArrayType::get_class_name());
    walker.append_walker(ew1);
    walker.append_walker(ew2);
    file_set_block->walk(walker);
    ReplacingWalker type_walker(env);
    type_walker.append_walker(aw1);
    type_walker.append_walker(aw2);

    file_set_block->walk(type_walker);
}
Example #4
0
 void DebugManager::ValidateDebugAPICall()
 {
     Js::JavascriptStackWalker walker(this->pThreadContext->GetScriptEntryExit()->scriptContext);
     Js::JavascriptFunction* javascriptFunction = nullptr;
     if (walker.GetCaller(&javascriptFunction))
     {
         if (javascriptFunction != nullptr)
         {
             void *topJsFrameAddr = (void *)walker.GetCurrentArgv();
             Assert(this->dispatchHaltFrameAddress != nullptr);
             if (topJsFrameAddr < this->dispatchHaltFrameAddress)
             {
                 // we found the script frame after the break mode.
                 AssertMsg(false, "There are JavaScript frames between current API and dispatch halt");
             }
         }
     }
 }
Example #5
0
void FunctionChecker::checkASTDecl(const FunctionTemplateDecl *TD, AnalysisManager& mgr,
                    BugReporter &BR) const {

	if ( TD->hasAttr<CMSThreadSafeAttr>()) return;
 	const char *sfile=BR.getSourceManager().getPresumedLoc(TD->getLocation ()).getFilename();
   	if (!support::isCmsLocalFile(sfile)) return;
	std::string fname(sfile);
	if ( fname.find("/test/") != std::string::npos) return;
	for (FunctionTemplateDecl::spec_iterator I = const_cast<clang::FunctionTemplateDecl *>(TD)->spec_begin(), 
			E = const_cast<clang::FunctionTemplateDecl *>(TD)->spec_end(); I != E; ++I) 
		{
			if (I->doesThisDeclarationHaveABody()) {
				FWalker walker(BR, mgr.getAnalysisDeclContext(*I));
				walker.Visit(I->getBody());
				}
		}
	return;
}
Example #6
0
APCHandle* APCObject::MakeAPCObject(
    APCHandle* obj, size_t& size, const Variant& value) {
  if (!value.is(KindOfObject) || obj->objAttempted()) {
    return nullptr;
  }
  obj->setObjAttempted();
  ObjectData *o = value.getObjectData();
  DataWalker walker(DataWalker::LookupFeature::DetectSerializable);
  DataWalker::DataFeature features = walker.traverseData(o);
  if (features.isCircular() ||
      features.hasCollection() ||
      features.hasSerializableReference()) {
    return nullptr;
  }
  APCHandle* tmp = APCHandle::Create(value, size, false, true, true);
  tmp->setObjAttempted();
  return tmp;
}
Example #7
0
/*=====================================================================
  Wire the vcc net.  VCCs originate from non-prims only.
======================================================================*/
void CLASS::xdlWirePower1(){
//fprintf(stderr,"%s\n",__func__);
  cMultiWireWalker walker(*hero->type->xwire);
  while(!walker.isEnd()){
    int pinst;int pindex;int busid;
    walker.getInc(pinst,pindex,busid);
    if(pinst==INST_MY){
      switch(pindex){
        case 0xFF: //vcc
        case 0xFE: //gnd
          xdlNetHeader(0,pindex);
          xdlWireInner1(pinst,pindex,0,walker); //ground and vcc are scalars
          fprintf(fout,";\n");
      }
   }
   walker.seekNext();
  }
}
Node* previousSiblingSlow(const Node* node)
{
    ComposedShadowTreeWalker walker(node);
    if (node->isAfterPseudoElement()) {
        walker.parent();
        walker.lastChild();
    } else
        walker.previousSibling();

    if (walker.get() || node->isBeforePseudoElement())
        return walker.get();

    Node* parent = walker.traverseParent(node);
    if (parent && parent->isElementNode())
        return toElement(parent)->pseudoElement(BEFORE);

    return 0;
}
Example #9
0
void CombinedPass::do_file_set_block( FileSetBlock* file_set_block ) {
    list<SymbolTable*> file_scope_tables;

    for (Iter<FileBlock*> iter = file_set_block->get_file_block_iterator();
	 iter.is_valid(); iter.next()) 
      {
	file_scope_tables.push_back(iter.current()->get_symbol_table());
      }
    file_scope_tables.push_back(file_set_block->get_file_set_symbol_table());
    
    CollisionAvoider walker(get_suif_env(),
			    file_set_block->get_external_symbol_table(),
			    &file_scope_tables,
                            (file_set_block->get_file_block(0))->
                                get_source_file_name(),
			    true);
    file_set_block->walk(walker);
    }
Example #10
0
nsresult LocationStep::appendMatchingDescendantsRev(
    const txXPathTreeWalker& aWalker, txIMatchContext* aContext,
    txNodeSet* aNodes) {
  txXPathTreeWalker walker(aWalker);
  if (!walker.moveToLastChild()) {
    return NS_OK;
  }

  do {
    nsresult rv = appendMatchingDescendantsRev(walker, aContext, aNodes);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = appendIfMatching(walker, aContext, aNodes);
    NS_ENSURE_SUCCESS(rv, rv);
  } while (walker.moveToPreviousSibling());

  return NS_OK;
}
Example #11
0
/*
 * Free all storage in a list, and optionally the pointed-to elements
 */
void
list_destroy(List *list, void (*walker)())
{
	ListCell   *cell;

	cell = list_head(list);
	while (cell != NULL)
	{
		ListCell   *tmp = cell;

		cell = lnext(cell);
		if (walker)
			walker(lfirst(tmp));
		free(tmp);
	}

	free(list);
}
//
// 注释:在压缩包中查找文件,pathInPack为查找路径
//       如果pathInPack为空,则在当前路径下查找
//       如果pathInPack 为绝对路径,则从根目录下查找
//       返回查找到的第一个文件,如果没有找到,返回NULL
// 
//  op : find 0001.png /ui/0/    <= 绝对路径
//       find 0001.png           <= 当前路径下
//
YCIAbstractFile* YCLYCPackSystem::find(const char* packFile, const char* pathInPack)
{
	SMART_ASSERT(packFile != NULL);
	if (packFile == NULL)
	{
		throw YCPackException(1002, "YCLYCFileSystem::find参数有误");
	}

	char nextPath[MAX_PATH] = {0};
	if (!YCPathWalker::isAbsolutePath(pathInPack) && myCurrent != NULL)
	{
		sprintf(nextPath, "%s\\%s", pathInPack, packFile);
		return myCurrent->get(nextPath);
	}

	YCPathWalker walker(pathInPack);
	int length;
	YCPathWalker::E_FILE_TYPE type;
	const char* first = walker.next(length, type);
	if (first == NULL || type == YCPathWalker::DISK)
	{
		throw YCPackException(1002, "YCLYCFileSystem::find包路径有误");
	}

	YCIFileDirectory * position = NULL;
	for (Item_List_T* item = myPackFiles->begin();
			item != myPackFiles->end() && !position;
			item = myPackFiles->next(item))
	{
		YCLYCFilePack* exists = (YCLYCFilePack*)myPackFiles->payload(item);
		if (strnicmp(exists->getPackName(), first, length) == 0)
		{
			position = exists;
		}
	}

	if (NULL == position)
	{
		throw YCPackException(1002, "YCLYCFileSystem::find包文件不存在");
	}

	sprintf(nextPath, "%s\\%s", walker.remain(), packFile);
	return position->get(nextPath);
}
void KisTransparencyMaskTest::testMoveParentLayer()
{
    KisImageSP image;
    KisPaintLayerSP layer;
    KisPaintDeviceSP dev;
    KisTransparencyMaskSP mask;

    initImage(image, layer, dev, mask);
    mask->initSelection(layer);
    mask->selection()->pixelSelection()->invert();
    mask->select(QRect(50, 50, 100, 100));

    KisFullRefreshWalker walker(image->bounds());
    KisAsyncMerger merger;

    walker.collectRects(layer, image->bounds());
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_before.png");

    QRect initialRect(0,0,200,100);
    QCOMPARE(layer->exactBounds(), initialRect);
    QCOMPARE(image->projection()->exactBounds(), QRect(50,50,100,50));


    layer->setX(100);
    layer->setY(100);

    dbgKrita << "Sel. rect before:" << mask->selection()->selectedExactRect();

    mask->setX(100);
    mask->setY(100);

    dbgKrita << "Sel. rect after:" << mask->selection()->selectedExactRect();

    QRect finalRect(100,100,200,100);
    QCOMPARE(layer->exactBounds(), finalRect);

    walker.collectRects(layer, initialRect | finalRect);
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_after.png");
    QCOMPARE(image->projection()->exactBounds(), QRect(150,150,100,50));
}
nsresult
txNamedAttributeStep::evaluate(txIEvalContext* aContext,
                               txAExprResult** aResult)
{
    *aResult = nsnull;

    nsRefPtr<txNodeSet> nodes;
    nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
    NS_ENSURE_SUCCESS(rv, rv);

    txXPathTreeWalker walker(aContext->getContextNode());
    if (walker.moveToNamedAttribute(mLocalName, mNamespace)) {
        rv = nodes->append(walker.getCurrentPosition());
        NS_ENSURE_SUCCESS(rv, rv);
    }
    NS_ADDREF(*aResult = nodes);

    return NS_OK;
}
Example #15
0
void
nsHTMLTableAccessible::CacheChildren()
{
  // Move caption accessible so that it's the first child. Check for the first
  // caption only, because nsAccessibilityService ensures we don't create
  // accessibles for the other captions, since only the first is actually
  // visible.
  nsAccTreeWalker walker(mWeakShell, mContent, GetAllowsAnonChildAccessibles());

  nsRefPtr<nsAccessible> child;
  while ((child = walker.GetNextChild())) {
    if (nsAccUtils::Role(child) == nsIAccessibleRole::ROLE_CAPTION) {
      InsertChildAt(0, child);
      while ((child = walker.GetNextChild()) && AppendChild(child));
      break;
    }
    AppendChild(child);
  }
}
Example #16
0
void LocationStep::fromDescendantsRev(const txXPathNode& aNode,
                                      txIMatchContext* aCs,
                                      txNodeSet* aNodes)
{
    txXPathTreeWalker walker(aNode);
    if (!walker.moveToLastChild()) {
        return;
    }

    do {
        const txXPathNode& child = walker.getCurrentPosition();
        fromDescendantsRev(child, aCs, aNodes);

        if (mNodeTest->matches(child, aCs)) {
            aNodes->append(child);
        }

    } while (walker.moveToPreviousSibling());
}
void ConstQualedVarPropagationPass::do_procedure_definition(ProcedureDefinition* proc_def)
{
  OutputInformation("Constant qualified variable propagation pass begins");

  suif_map<VariableSymbol*, ValueBlock*> temp_const_defs;
    if (proc_def){
        DefinitionBlock *proc_def_block = proc_def->get_definition_block();
        for(Iter<VariableDefinition*> iter = proc_def_block->get_variable_definition_iterator();
            iter.is_valid(); iter.next()){
            VariableDefinition *var_def = iter.current();
            VariableSymbol *var_sym = var_def->get_variable_symbol();
            QualifiedType *qualed_var_type = var_sym->get_type();
            if(is_a<IntegerType>(qualed_var_type->get_base_type())){
               bool found = 0;
               for(Iter<LString> iter2 = qualed_var_type->get_qualification_iterator();
                   iter2.is_valid(); iter2.next())
                   if(iter2.current() == LString("const"))
                      found = 1;
               if(found){
                  temp_const_defs.enter_value(var_sym, var_def->get_initialization());
               }
            }
        }
        for(Iter<StoreVariableStatement> iter = object_iterator<StoreVariableStatement>(proc_def->get_body());
            iter.is_valid(); iter.next()){
            StoreVariableStatement *store_var_stmt = &iter.current();
            Expression *store_var_value = store_var_stmt->get_value();
            if(!is_a<IntConstant>(store_var_value))
               continue;
            VariableSymbol *store_var_destination = store_var_stmt->get_destination();
            if(!is_a<IntegerType>(store_var_destination->get_type()->get_base_type()))  
               continue;
            suif_map<VariableSymbol*,ValueBlock*>::iterator iter2 =
                        temp_const_defs.find(to<LoadVariableExpression>(store_var_value)->get_source());
            if(iter2 != temp_const_defs.end())
               const_qualified_scalars.enter_value(store_var_destination, (*iter2).second);
        }
        cqvp_load_variable_expression_walker walker(get_suif_env());
        proc_def->walk(walker);
    }
  OutputInformation("Constant qualified variable propagation pass ends");
}
Example #18
0
APCHandle::Pair APCCollection::Make(const ObjectData* obj,
                                    APCHandleLevel level,
                                    bool unserializeObj) {
  auto bail = [&] {
    return APCString::MakeSerializedObject(
      apc_serialize(Variant(const_cast<ObjectData*>(obj)))
    );
  };

  auto const array = collections::asArray(obj);
  if (!array) return bail();

  /*
   * Create an uncounted array if we can.
   *
   * If this collection is an OuterHandle, then we need to do a full check on
   * this array for things like circularity.  If we're an InnerHandle, someone
   * already checked that, but we want to check for whether it's uncounted to
   * use a better representation.  For the OuterHandle case, we just delegate
   * to APCArray below (which will do the full DataWalker pass).
   */
  if (level == APCHandleLevel::Inner && apcExtension::UseUncounted &&
      !array->empty()) {
    DataWalker walker(DataWalker::LookupFeature::HasObjectOrResource);
    auto const features = walker.traverseData(const_cast<ArrayData*>(array));
    assert(!features.isCircular);
    if (!features.hasObjectOrResource) {
      return WrapArray(
        { APCArray::MakeUncountedArray(const_cast<ArrayData*>(array)),
          getMemSize(array) + sizeof(APCTypedValue) },
        obj->collectionType()
      );
    }
  }

  return WrapArray(
    APCArray::MakeSharedArray(const_cast<ArrayData*>(array),
                              level,
                              unserializeObj),
    obj->collectionType()
  );
}
Example #19
0
void subtractBrushesFromUnselected(const cmd::ArgumentList& args)
{
	if (registry::getValue<bool>(RKEY_EMIT_CSG_SUBTRACT_WARNING))
	{
		wxutil::Messagebox::Show(_("This Is Not Dromed Warning"),
			_("Note: be careful when using the CSG tool, as you might end up\n"
			"with an unnecessary number of tiny brushes and/or leaks.\n"
			"This popup will not be shown again."), ui::IDialog::MESSAGE_CONFIRM);

		// Disable this warning
        registry::setValue(RKEY_EMIT_CSG_SUBTRACT_WARNING, false);
	}

	// Collect all selected brushes
	BrushPtrVector brushes = selection::algorithm::getSelectedBrushes();

	if (brushes.empty()) {
		rMessage() << _("CSG Subtract: No brushes selected.") << std::endl;
		wxutil::Messagebox::ShowError(_("CSG Subtract: No brushes selected."));
		return;
	}

	rMessage() << "CSG Subtract: Subtracting " << brushes.size() << " brushes.\n";

	UndoableCommand undo("brushSubtract");

	// subtract selected from unselected
	std::size_t before = 0;
	std::size_t after = 0;

	// instantiate a scoped walker class
	{
		SubtractBrushesFromUnselected walker(brushes, before, after);
		GlobalSceneGraph().root()->traverse(walker);
	}

	rMessage() << "CSG Subtract: Result: "
		<< after << " fragment" << (after == 1 ? "" : "s")
		<< " from " << before << " brush" << (before == 1 ? "" : "es") << ".\n";

	SceneChangeNotify();
}
Example #20
0
void EventRelatedTargetAdjuster::adjust(Vector<EventContext>& ancestors)
{
    Vector<EventTarget*> relatedTargetStack;
    TreeScope* lastTreeScope = 0;
    Node* lastNode = 0;
    for (ComposedShadowTreeParentWalker walker(m_relatedTarget.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) {
        Node* node = walker.get();
        if (relatedTargetStack.isEmpty())
            relatedTargetStack.append(node);
        else if (isInsertionPoint(node) && toInsertionPoint(node)->contains(lastNode))
            relatedTargetStack.append(relatedTargetStack.last());
        TreeScope* scope = node->treeScope();
        // Skips adding a node to the map if treeScope does not change. Just for the performance optimization.
        if (scope != lastTreeScope)
            m_relatedTargetMap.add(scope, relatedTargetStack.last());
        lastTreeScope = scope;
        lastNode = node;
        if (node->isShadowRoot()) {
            ASSERT(!relatedTargetStack.isEmpty());
            relatedTargetStack.removeLast();
        }
    }

    lastTreeScope = 0;
    EventTarget* adjustedRelatedTarget = 0;
    for (Vector<EventContext>::iterator iter = ancestors.begin(); iter < ancestors.end(); ++iter) {
        TreeScope* scope = iter->node()->treeScope();
        if (scope == lastTreeScope) {
            // Re-use the previous adjustedRelatedTarget if treeScope does not change. Just for the performance optimization.
            iter->setRelatedTarget(adjustedRelatedTarget);
        } else {
            adjustedRelatedTarget = findRelatedTarget(scope);
            iter->setRelatedTarget(adjustedRelatedTarget);
        }
        lastTreeScope = scope;
        if (iter->target() == adjustedRelatedTarget) {
            // Event dispatching should be stopped here.
            ancestors.shrink(iter - ancestors.begin());
            break;
        }
    }
}
TEST_F(ToolsTestFileSystemWalker, Valid){   

   FtsHelper helper;
   auto FtsRealHelper = [&](FTSENT* ptr, int flag){
      return helper.FtsHelperAction(ptr, flag);
   };
      
   FileSystemWalker walker(mTestDirectory, FtsRealHelper);
   EXPECT_FALSE(walker.Action().HasFailed());
   
   EXPECT_EQ(helper.fileCounter, 0);
   EXPECT_EQ(helper.ignoredCounter, 1); // directory we're in PRE-traversal
   EXPECT_EQ(helper.directoryCounter, 1); // directory we're in POST-traversal
   
   ASSERT_EQ(helper.names.size(), 1);
   ASSERT_EQ(helper.names[0], "TempFileSystemWalker");
   
   ASSERT_EQ(helper.rootNames.size(), 1);
   ASSERT_EQ(helper.rootNames[0], "/tmp/TempFileSystemWalker");
}
Example #22
0
/**
 * Selects from the descendants of the context node
 * all nodes that match the Expr
**/
nsresult
PathExpr::evalDescendants(Expr* aStep, const txXPathNode& aNode,
                          txIMatchContext* aContext, txNodeSet* resNodes)
{
    txSingleNodeContext eContext(aNode, aContext);
    nsRefPtr<txAExprResult> res;
    nsresult rv = aStep->evaluate(&eContext, getter_AddRefs(res));
    NS_ENSURE_SUCCESS(rv, rv);

    if (res->getResultType() != txAExprResult::NODESET) {
        //XXX ErrorReport: report nonnodeset error
        return NS_ERROR_XSLT_NODESET_EXPECTED;
    }

    txNodeSet* oldSet = static_cast<txNodeSet*>
                                   (static_cast<txAExprResult*>(res));
    nsRefPtr<txNodeSet> newSet;
    rv = aContext->recycler()->getNonSharedNodeSet(oldSet,
                                                   getter_AddRefs(newSet));
    NS_ENSURE_SUCCESS(rv, rv);

    resNodes->addAndTransfer(newSet);

    MBool filterWS = aContext->isStripSpaceAllowed(aNode);

    txXPathTreeWalker walker(aNode);
    if (!walker.moveToFirstChild()) {
        return NS_OK;
    }

    do {
        const txXPathNode& node = walker.getCurrentPosition();
        if (!(filterWS && txXPathNodeUtils::isText(node) &&
              txXPathNodeUtils::isWhitespace(node))) {
            rv = evalDescendants(aStep, node, aContext, resNodes);
            NS_ENSURE_SUCCESS(rv, rv);
        }
    } while (walker.moveToNextSibling());

    return NS_OK;
} //-- evalDescendants
bool MeshObjectWriter::write(
    const MeshObject&   object,
    const char*         object_name,
    const char*         filename)
{
    assert(filename);

    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    try
    {
        OBJMeshFileWriter writer(filename);
        MeshObjectWalker walker(object, object_name);
        writer.write(walker);
    }
    catch (const ExceptionIOError&)
    {
        RENDERER_LOG_ERROR(
            "failed to write mesh file %s: i/o error.",
            filename);
        return false;
    }
    catch (const Exception& e)
    {
        RENDERER_LOG_ERROR(
            "failed to write mesh file %s: %s.",
            filename,
            e.what());
        return false;
    }

    stopwatch.measure();

    RENDERER_LOG_INFO(
        "wrote mesh file %s in %s.",
        filename,
        pretty_time(stopwatch.get_seconds()).c_str());

    return true;
}
void HW_SW_BoundaryMarkPass::do_procedure_definition(ProcedureDefinition* proc_def)
{
  OutputInformation("Determination of Hardware/Software boundary pass begins");
    if (proc_def){
	SuifEnv *env = get_suif_env();

        if(proc_def->lookup_annote_by_name("begin_hw"))
           delete (to<BrickAnnote>(proc_def->remove_annote_by_name("begin_hw")));
        if(proc_def->lookup_annote_by_name("end_hw"))
           delete (to<BrickAnnote>(proc_def->remove_annote_by_name("end_hw")));

        BrickAnnote *ba = create_brick_annote(env, "begin_hw");
        proc_def->append_annote(ba);
        ba = create_brick_annote(env, "end_hw");
        proc_def->append_annote(ba);

	hsbm_call_statement_walker walker(get_suif_env());
	proc_def->walk(walker);
    }
  OutputInformation("Determination of Hardware/Software boundary pass ends");
}
void EventRetargeter::buildRelatedNodeMap(const Node* relatedNode, RelatedNodeMap& relatedNodeMap)
{
    Vector<Node*, 32> relatedNodeStack;
    TreeScope* lastTreeScope = 0;
    for (EventPathWalker walker(relatedNode); walker.node(); walker.moveToParent()) {
        Node* node = walker.node();
        if (relatedNodeStack.isEmpty())
            relatedNodeStack.append(node);
        else if (walker.isVisitingInsertionPointInReprojection())
            relatedNodeStack.append(relatedNodeStack.last());
        TreeScope* scope = node->treeScope();
        // Skips adding a node to the map if treeScope does not change. Just for the performance optimization.
        if (scope != lastTreeScope)
            relatedNodeMap.add(scope, relatedNodeStack.last());
        lastTreeScope = scope;
        if (node->isShadowRoot()) {
            ASSERT(!relatedNodeStack.isEmpty());
            relatedNodeStack.removeLast();
        }
    }
}
Example #26
0
Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
{
    Vector<String> paths;

    PathWalker walker(directory, "*");
    if (!walker.isValid())
        return paths;

    do {
        if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            continue;

        String filename = walker.data().cFileName;
        if ((!filename.startsWith("np", false) || !filename.endsWith("dll", false)) && (!equalIgnoringCase(filename, "Plugin.dll") || !directory.endsWith("Shockwave 10", false)))
            continue;

        paths.append(directory + "\\" + filename);
    } while (walker.step());

    return paths;
}
Example #27
0
void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
                           const FloatPoint& point, int from, int to) const
{
    if (!run.length())
        return;

    SkCanvas* canvas = gc->platformContext()->canvas();
    int textMode = gc->platformContext()->getTextDrawingMode();
    bool fill = textMode & cTextFill;
    bool stroke = (textMode & cTextStroke)
               && gc->platformContext()->getStrokeStyle() != NoStroke
               && gc->platformContext()->getStrokeThickness() > 0;

    if (!fill && !stroke)
        return;

    SkPaint strokePaint, fillPaint;
    if (fill) {
        gc->platformContext()->setupPaintForFilling(&fillPaint);
        setupForTextPainting(&fillPaint, gc->fillColor().rgb());
    }
    if (stroke) {
        gc->platformContext()->setupPaintForStroking(&strokePaint, 0, 0);
        setupForTextPainting(&strokePaint, gc->strokeColor().rgb());
    }

    TextRunWalker walker(run, point.x(), this);

    while (walker.nextScriptRun()) {
        if (fill) {
            walker.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
            canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), fillPaint);
        }

        if (stroke) {
            walker.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
            canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), strokePaint);
        }
    }
}
  Graph run_one_or_two(std::mt19937 * mt, uint_fast32_t max_order, double p, uint_fast32_t initial_order, bool selfloop){
    Graph graph(max_order);
    initialize_complete_graph(graph, initial_order, selfloop);

    std::uniform_real_distribution<> dist(0,1);

    RandomWalker walker(mt, &graph);

    while(graph.order() < max_order) {
      walker.take_step();

      // Take another step with probability 1-p
      if(dist(*mt) > p){
        walker.take_step();
      }

      graph.add_vertex();
      graph.add_edge(graph.order()-1, walker.location());
    }

    return graph;
  }
Example #29
0
APCHandle::Pair
APCArray::MakeSharedArray(ArrayData* arr, APCHandleLevel level,
                          bool unserializeObj) {
  if (level == APCHandleLevel::Outer) {
    // only need to call traverseData() on the toplevel array
    DataWalker walker(DataWalker::LookupFeature::HasObjectOrResource);
    DataWalker::DataFeature features = walker.traverseData(arr);
    if (features.isCircular) {
      String s = apc_serialize(Variant{arr});
      return APCString::MakeSerializedArray(s.get());
    }

    if (apcExtension::UseUncounted && !features.hasObjectOrResource &&
        !arr->empty()) {
      return {MakeUncountedArray(arr),
              getMemSize(arr) + sizeof(APCTypedValue)};
    }
  }

  return arr->isVectorData() ? MakePacked(arr, unserializeObj) :
         MakeHash(arr, unserializeObj);
}
Example #30
0
void Doom3GroupNode::renderSolid(RenderableCollector& collector, const VolumeTest& volume) const
{
	EntityNode::renderSolid(collector, volume);

	// greebo: Check if the skin needs updating before rendering.
	if (_updateSkin) {
		if (m_contained.isModel()) {
			// Instantiate a walker class equipped with the new value
			SkinChangedWalker walker(_entity.getKeyValue("skin"));
			// Update all children
			traverse(walker);
		}

		_updateSkin = false;
	}

	m_contained.renderSolid(collector, volume, localToWorld(), isSelected());

	// Render curves always relative to the absolute map origin
	m_curveNURBS.renderComponentsSelected(collector, volume, Matrix4::getIdentity());
	m_curveCatmullRom.renderComponentsSelected(collector, volume, Matrix4::getIdentity());
}