コード例 #1
0
void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
  const auto WrongUse = anyOf(
      hasParent(
          binaryOperator(
              anyOf(has(integerLiteral(equals(0))),
                    allOf(anyOf(hasOperatorName("<"), hasOperatorName(">="),
                                hasOperatorName(">"), hasOperatorName("<=")),
                          hasEitherOperand(integerLiteral(equals(1))))))
              .bind("SizeBinaryOp")),
      hasParent(implicitCastExpr(
          hasImplicitDestinationType(isBoolType()),
          anyOf(
              hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")),
              anything()))),
      hasParent(explicitCastExpr(hasDestinationType(isBoolType()))));

  Finder->addMatcher(
      memberCallExpr(
          on(expr(anyOf(hasType(namedDecl(stlContainer())),
                        hasType(pointsTo(namedDecl(stlContainer()))),
                        hasType(references(namedDecl(stlContainer())))))
                 .bind("STLObject")),
          callee(methodDecl(hasName("size"))), WrongUse).bind("SizeCallExpr"),
      this);
}
コード例 #2
0
namespace EffectiveCPP {

    StatementMatcher ctorCallVtlMatcherEC = compoundStmt(
            hasParent(constructorDecl().bind("cDecl")),
            hasDescendant(callExpr(callee(methodDecl(isVirtual()))))
            );
    
    StatementMatcher dtorCallVtlMatcherEC = compoundStmt(
            hasParent(destructorDecl().bind("dDecl")),
            hasDescendant(callExpr(callee(methodDecl(isVirtual()))))
            );
}
コード例 #3
0
void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
  Finder->addMatcher(
      switchStmt(
          hasCondition(allOf(
              // Match on switch statements that have either a bit-field or
              // an integer condition. The ordering in 'anyOf()' is
              // important because the last condition is the most general.
              anyOf(ignoringImpCasts(memberExpr(hasDeclaration(
                        fieldDecl(isBitField()).bind("bitfield")))),
                    ignoringImpCasts(declRefExpr().bind("non-enum-condition"))),
              // 'unless()' must be the last match here and must be bound,
              // otherwise the matcher does not work correctly, because it
              // will not explicitly ignore enum conditions.
              unless(ignoringImpCasts(
                  declRefExpr(hasType(enumType())).bind("enum-condition"))))))
          .bind("switch"),
      this);

  // This option is noisy, therefore matching is configurable.
  if (WarnOnMissingElse) {
    Finder->addMatcher(
        ifStmt(allOf(hasParent(ifStmt()), unless(hasElse(anything()))))
            .bind("else-if"),
        this);
  }
}
コード例 #4
0
ファイル: node.cpp プロジェクト: argontus/3S3K3D
void Node::updateWorldTransform() const
{
    // make sure we are not doing any unnecessary function calls
    GRAPHICS_RUNTIME_ASSERT(worldTransformValid_ == false);

    if (hasParent())
    {
        // world transform of the parent node
        const Transform3 t = parent_->worldTransform();

        worldTransform_.translation = ::transform(localTransform_.translation, t);
        worldTransform_.rotation = localTransform_.rotation;
        worldTransform_.scaling = localTransform_.scaling;

        if (rotationLocked_ == false)
        {
            worldTransform_.rotation *= t.rotation;
        }

        if (scalingLocked_ == false)
        {
            worldTransform_.scaling *= t.scaling;
        }
    }
    else
    {
        // no parent node, world transform is equal to the local transform
        worldTransform_ = localTransform_;
    }

    worldTransformValid_ = true;
}
コード例 #5
0
ファイル: node.cpp プロジェクト: argontus/3S3K3D
Node::~Node()
{
    // make sure we are not deleting a node that is still attached
    GRAPHICS_RUNTIME_ASSERT(hasParent() == false);

    // TODO: unregister from scene
}
コード例 #6
0
void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) {
  // Forwarding references require C++11 or later.
  if (!getLangOpts().CPlusPlus11)
    return;

  auto ForwardingRefParm =
      parmVarDecl(
          hasType(qualType(rValueReferenceType(),
                           references(templateTypeParmType(hasDeclaration(
                               templateTypeParmDecl().bind("type-parm-decl")))),
                           unless(references(isConstQualified())))))
          .bind("parm-var");

  DeclarationMatcher findOverload =
      cxxConstructorDecl(
          hasParameter(0, ForwardingRefParm),
          unless(hasAnyParameter(
              // No warning: enable_if as constructor parameter.
              parmVarDecl(hasType(isEnableIf())))),
          unless(hasParent(functionTemplateDecl(has(templateTypeParmDecl(
              // No warning: enable_if as type parameter.
              hasDefaultArgument(isEnableIf())))))))
          .bind("ctor");
  Finder->addMatcher(findOverload, this);
}
コード例 #7
0
ファイル: Connector.cpp プロジェクト: PADrend/GUI
//! ---|> Component
void Connector::doLayout(){

	Geometry::Vec2 parentsAbsPos=hasParent()?getParent()->getAbsPosition():Geometry::Vec2();

	Geometry::Rect r;
	r.invalidate();
//	std::cout << r.getX();

	if( getFirstComponent() )
		r.include( getFirstComponent()->getAbsRect().getCenter()-parentsAbsPos );
//	std::cout << (getFirstComponent()->getAbsRect().getCenter()-parentsAbsPos).getX();

	if( getSecondComponent() )
		r.include( getSecondComponent()->getAbsRect().getCenter()-parentsAbsPos );

	if(getContentsCount()>2){
		// TODO!!!!!
	}
	setPosition(Geometry::Vec2(r.getX(),r.getY()));
	setSize(r.getWidth(),r.getHeight());
	Geometry::Vec2 myAbsPos=getAbsPosition();

	if(getFirstChild() && getFirstComponent()){
		getFirstChild()->setPosition( getFirstComponent()->getAbsRect().getCenter()-myAbsPos );
	}
	if(getLastChild() && getSecondComponent()){
		getLastChild()->setPosition( getSecondComponent()->getAbsRect().getCenter()-myAbsPos );
//		getLastChild()->setPosition(Vec2(r.getWidth(),r.getHeight()));
	}

	if(getContentsCount()>2){
		// TODO!!!!!
	}
}
コード例 #8
0
bool BinaryNode::isRightChild(){
    if(hasParent()){
        return (this == parent->rightChild);
    }
    
    return false;
}
コード例 #9
0
ファイル: PropertyItem.cpp プロジェクト: Tobias1595/libzeug
int PropertyItem::index() const
{
    if (!hasParent())
        return -1;
    
    return m_parent->indexOf(this);
}
コード例 #10
0
ファイル: AIComponent.cpp プロジェクト: Cmdu76/Rucks
bool AIComponent::hasTarget()
{
    auto t = getTarget();
    if (t != nullptr)
    {
        es::ComponentFilter targetFilter;
        targetFilter.requires(FactionComponent::getId());
        targetFilter.requires(TransformComponent::getId());
        targetFilter.requires(StatComponent::getId());
        if (t->hasComponents(targetFilter) && hasParent())
        {
            sf::Vector2f ePos = mParent->getComponent<TransformComponent>().getPosition();
            sf::Vector2f tPos = t->getComponent<TransformComponent>().getPosition();
            if (t->getId() != mParent->getId() && t->getComponent<StatComponent>().isAlive() && thor::length(ePos - tPos) < mOutOfView && mParent->hasComponent<FactionComponent>())
            {
                if (mParent->getComponent<FactionComponent>().getFaction().isEnemy(t->getComponent<FactionComponent>().getFactionId()))
                {
                    return true;
                }
            }
            else
            {
                mTarget = 0;
            }
        }
        else
        {
            mTarget = 0;
        }
    }
    return false;
}
コード例 #11
0
ファイル: NotePlayHandle.cpp プロジェクト: asmw/lmms
void NotePlayHandle::noteOff( const f_cnt_t _s )
{
	if( m_released )
	{
		return;
	}

	// first note-off all sub-notes
	for( NotePlayHandleList::Iterator it = m_subNotes.begin(); it != m_subNotes.end(); ++it )
	{
		( *it )->noteOff( _s );
	}

	// then set some variables indicating release-state
	m_framesBeforeRelease = _s;
	m_releaseFramesToDo = qMax<f_cnt_t>( 0, actualReleaseFramesToDo() );

	if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() )
	{
		// send MidiNoteOff event
		m_instrumentTrack->processOutEvent(
				MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ),
				MidiTime::fromFrames( _s, engine::framesPerTick() ), 
				_s );
	}

	// inform attached components about MIDI finished (used for recording in Piano Roll)
	if( m_origin == OriginMidiInput )
	{
		setLength( MidiTime( static_cast<f_cnt_t>( totalFramesPlayed() / engine::framesPerTick() ) ) );
		m_instrumentTrack->midiNoteOff( *this );
	}

	m_released = true;
}
コード例 #12
0
void NotePlayHandle::done()
{
	lock();
	noteOff( 0 );

	if( hasParent() == false )
	{
		delete m_baseDetuning;
		m_instrumentTrack->m_processHandles.removeAll( this );
	}
	else
	{
		m_parent->m_subNotes.removeOne( this );
	}

	if( m_pluginData != NULL )
	{
		m_instrumentTrack->deleteNotePluginData( this );
	}

	if( m_instrumentTrack->m_notes[key()] == this )
	{
		m_instrumentTrack->m_notes[key()] = NULL;
	}

	m_subNotes.clear();

	delete m_filter;

	if( buffer() ) releaseBuffer();

	unlock();
}
コード例 #13
0
ファイル: NotePlayHandle.cpp プロジェクト: asmw/lmms
NotePlayHandle::~NotePlayHandle()
{
	noteOff( 0 );
	
	if( hasParent() == false )
	{
		delete m_baseDetuning;
		m_instrumentTrack->m_processHandles.removeAll( this );
	}

	if( m_pluginData != NULL )
	{
		m_instrumentTrack->deleteNotePluginData( this );
	}

	if( m_instrumentTrack->m_notes[key()] == this )
	{
		m_instrumentTrack->m_notes[key()] = NULL;
	}

	for( NotePlayHandleList::Iterator it = m_subNotes.begin(); it != m_subNotes.end(); ++it )
	{
		delete *it;
	}
	m_subNotes.clear();

	delete m_filter;
}
コード例 #14
0
void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
  auto PrivateSpecialFn = cxxMethodDecl(
      isPrivate(),
      anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(),
                                     isCopyConstructor(), isMoveConstructor())),
            cxxMethodDecl(
                anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())),
            cxxDestructorDecl()));

  Finder->addMatcher(
      cxxMethodDecl(
          PrivateSpecialFn,
          unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
                       ast_matchers::isTemplateInstantiation(),
                       // Ensure that all methods except private special member
                       // functions are defined.
                       hasParent(cxxRecordDecl(hasMethod(unless(
                           anyOf(PrivateSpecialFn, hasBody(stmt()), isPure(),
                                 isDefaulted(), isDeleted()))))))))
          .bind(SpecialFunction),
      this);

  Finder->addMatcher(
      cxxMethodDecl(isDeleted(), unless(isPublic())).bind(DeletedNotPublic),
      this);
}
コード例 #15
0
ファイル: Node.cpp プロジェクト: ospray/OSPRay
 void Node::setChildrenModified(TimeStamp t)
 {
   if (t > properties.childrenMTime) {
     properties.childrenMTime = t;
     if (hasParent())
       parent().setChildrenModified(properties.childrenMTime);
   }
 }
コード例 #16
0
ファイル: MObject3d.cpp プロジェクト: mconbere/Newt
void MObject3d::updateMatrix(void)
{
	computeLocalMatrix();

	if(hasParent()){
		m_matrix = m_parent->m_matrix * m_matrix;
	}
}
コード例 #17
0
ファイル: GNEAttributeCarrier.cpp プロジェクト: cbrafter/sumo
SumoXMLTag
GNEAttributeCarrier::getParentType(SumoXMLTag tag) {
    if(hasParent(tag)) {
        return myAllowedAdditionalWithParentTags[tag];
    } else {
        return SUMO_TAG_NOTHING;
    }
}
コード例 #18
0
ファイル: Object.cpp プロジェクト: bagobor/Darwin
void Object::setTakesLayoutSpaceIfHidden(bool a) {
	takesLayoutSpaceIfHidden = a;
	// if parent is layout recompute
	if(hasParent() && DanvilIsOfType<Layout, Object>(parent)) {
		PTR(Layout) layout = DanvilConvert<Layout, Object>(parent);
		layout->update();
	}
}
コード例 #19
0
ファイル: TreeNode.cpp プロジェクト: hrfm/cpplib
 void TreeNode::_setParent( TreeNode * node ){
     if( !hasParent() ){
         _parent = node;
         dispatchEvent( new hrfm::events::Event(hrfm::events::Event::ADDED) );
     }else{
         _parent = node;
     }
 }
コード例 #20
0
ファイル: Component.cpp プロジェクト: gitcommit/jorm
std::string Component::toString() const {
    std::string ret;
    if (hasParent()) {
        ret += parent()->toString() + ".";
    }

    ret += name();
    return ret;
}
コード例 #21
0
ファイル: MObject3d.cpp プロジェクト: galek/MIngEd
void MObject3d::updateMatrix(void)
{
    M_PROFILE_SCOPE(MObject3d::updateMatrix);
	computeLocalMatrix();

	if(hasParent()){
		m_matrix = m_parent->m_matrix * m_matrix;
	}
}
コード例 #22
0
ファイル: component.cpp プロジェクト: gitcommit/simpleorm
StringVector Component::path() const {
    StringVector ret;
    if (hasParent()) {
        StringVector b = parent()->path();
        ret.insert(ret.begin(), b.begin(), b.end());
    }
    ret.push_back(name());
    return ret;
}
コード例 #23
0
void ProtocolSpectator::syncOpenContainers()
{
	const auto openContainers = player->getOpenContainers();
	for (const auto& it : openContainers) {
		auto openContainer = it.second;
		auto container = openContainer.container;
		sendContainer(it.first, container, container->hasParent(), openContainer.index);
	}
}
コード例 #24
0
bool hasParent(QObject* child, QObject* parent)
{
    if (!child)
        return false;

    if (child == parent)
        return true;

    return hasParent(child->parent(), parent);
}
コード例 #25
0
ファイル: base.cpp プロジェクト: nebula-engine/Nebula-Core
bool				THIS::hasScene() const
{
	if(!hasParent()) return false;

	auto shape = dynamic_cast<neb::fnd::core::shape::base*>(getParent());
	
	assert(shape);
	
	return shape->hasScene();
}
コード例 #26
0
ファイル: component.cpp プロジェクト: gitcommit/simpleorm
Component* Component::setParent(Component* c) {
    if (hasParent()) {
        parent()->remove(this);
    }
    _parent = c;
    if (0 != _parent) {
        parent()->add(this);
    }
    return parent();
}
コード例 #27
0
ファイル: Component.cpp プロジェクト: gitcommit/jorm
void Component::setParent(Component* p) {
    if (hasParent()) {
        if (p != parent()) {
            parent()->removeChild(this);
        }
    }
    _parent = p;
    if (0 != _parent) {
        _parent->addChild(this);
    }
}
コード例 #28
0
ファイル: DLPAggreg.cpp プロジェクト: mrakotom/lpaggreg
void DLPAggreg::computeAggregation(double parameter) {
	if (!hasParent()) {
		_EVALSTARTBC;
		computeBestCuts(parameter);
		_EVALSTOPBC;
		_EVALSTARTBP;
		computeBestPartitions();
		_EVALSTOPBP;
		cleanChilds();
	}
}
コード例 #29
0
bool WRMPDDirectoryTreeProvider::upLevel()
{
    if (!hasParent()) return false;
    std::string dir;
    for (size_t i=0; i<m_uriSplit.size()-1; i++) {
        if (dir.size()>0 && dir[dir.size()-1]!='/') dir += '/';
        dir+=m_uriSplit[i];
    }
    cd(dir);
    return true;
}
コード例 #30
0
ファイル: SourceLocationTest.cpp プロジェクト: 4ntoine/clang
TEST(FriendDecl, InstantiationSourceRange) {
  RangeVerifier<FriendDecl> Verifier;
  Verifier.expectRange(4, 3, 4, 35);
  EXPECT_TRUE(Verifier.match(
      "template <typename T> class S;\n"
      "template<class T> void operator+(S<T> x);\n"
      "template<class T> struct S {\n"
      "  friend void operator+<>(S<T> src);\n"
      "};\n"
      "void test(S<double> s) { +s; }",
      friendDecl(hasParent(recordDecl(isTemplateInstantiation())))));
}