Example #1
0
void Document::copyNodes(const NodeList& nodeList) {
	if (!isValid() || _xmlDoc->children == NULL) {
		return; // is not Valid, place an assertion here?
	}

	// Copy the child nodes one by one
	for (std::size_t i = 0; i < nodeList.size(); i++) {
		// Copy the node
		xmlNodePtr node = xmlCopyNode(nodeList[i].getNodePtr(), 1);
		// Add this node to the top level node of this document
		xmlAddChild(xmlDocGetRootElement(_xmlDoc), node);
	}
}
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      NodeList elementList;
      Node nameNode;
      CharacterData child;
      doc = (Document) baseT::load("staff", true);
      elementList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
      nameNode = elementList.item(0);
      child = (CharacterData) nameNode.getFirstChild();
      
      {
         boolean success = false;
         try {
            child.replaceData(40, 3, SA::construct_from_utf8("ABC"));
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::INDEX_SIZE_ERR);
         }
         assertTrue(success);
      }

   }
Example #3
0
NodeSet Liveness::getAllReachingDefsRec(RegisterRef RefRR,
                                        NodeAddr<RefNode*> RefA, NodeSet &Visited, const NodeSet &Defs) {
    // Collect all defined registers. Do not consider phis to be defining
    // anything, only collect "real" definitions.
    RegisterAggr DefRRs(DFG.getLMI(), TRI);
    for (NodeId D : Defs) {
        const auto DA = DFG.addr<const DefNode*>(D);
        if (!(DA.Addr->getFlags() & NodeAttrs::PhiRef))
            DefRRs.insert(DA.Addr->getRegRef());
    }

    NodeList RDs = getAllReachingDefs(RefRR, RefA, true, DefRRs);
    if (RDs.empty())
        return Defs;

    // Make a copy of the preexisting definitions and add the newly found ones.
    NodeSet TmpDefs = Defs;
    for (NodeAddr<NodeBase*> R : RDs)
        TmpDefs.insert(R.Id);

    NodeSet Result = Defs;

    for (NodeAddr<DefNode*> DA : RDs) {
        Result.insert(DA.Id);
        if (!(DA.Addr->getFlags() & NodeAttrs::PhiRef))
            continue;
        NodeAddr<PhiNode*> PA = DA.Addr->getOwner(DFG);
        if (Visited.count(PA.Id))
            continue;
        Visited.insert(PA.Id);
        // Go over all phi uses and get the reaching defs for each use.
        for (auto U : PA.Addr->members_if(DFG.IsRef<NodeAttrs::Use>, DFG)) {
            const auto &T = getAllReachingDefsRec(RefRR, U, Visited, TmpDefs);
            Result.insert(T.begin(), T.end());
        }
    }

    return Result;
}
Example #4
0
void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeType, bool shouldSendStats) {
    // change the logging target name while the assignment is running
    Logging::setTargetName(targetName);
    
    NodeList* nodeList = NodeList::getInstance();
    nodeList->setOwnerType(nodeType);
    
    QTimer* domainServerTimer = new QTimer(this);
    connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
    domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
    
    QTimer* silentNodeRemovalTimer = new QTimer(this);
    connect(silentNodeRemovalTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
    silentNodeRemovalTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
    
    if (shouldSendStats) {
        // send a stats packet every 1 second
        QTimer* statsTimer = new QTimer(this);
        connect(statsTimer, &QTimer::timeout, this, &ThreadedAssignment::sendStatsPacket);
        statsTimer->start(1000);
    }
}
Example #5
0
void MetavoxelServer::run() {
    commonInit(METAVOXEL_SERVER_LOGGING_NAME, NodeType::MetavoxelServer);
    
    NodeList* nodeList = NodeList::getInstance();
    nodeList->addNodeTypeToInterestSet(NodeType::Agent);
    
    connect(nodeList, &NodeList::nodeAdded, this, &MetavoxelServer::maybeAttachSession);
    connect(nodeList, &NodeList::nodeKilled, this, &MetavoxelServer::maybeDeleteSession);
    
    // initialize Bitstream before using it in multiple threads
    Bitstream::preThreadingInit();
    
    // create the senders, each with its own thread
    int threadCount = QThread::idealThreadCount();
    if (threadCount == -1) {
        const int DEFAULT_THREAD_COUNT = 4;
        threadCount = DEFAULT_THREAD_COUNT;
    }
    qDebug() << "Creating" << threadCount << "sender threads";
    for (int i = 0; i < threadCount; i++) {
        QThread* thread = new QThread(this);
        MetavoxelSender* sender = new MetavoxelSender(this);
        sender->moveToThread(thread);
        connect(thread, &QThread::finished, sender, &QObject::deleteLater);
        thread->start();
        QMetaObject::invokeMethod(sender, "start");
        _senders.append(sender);
    }
    
    // create the persister and start it in its own thread
    _persister = new MetavoxelPersister(this);
    QThread* persistenceThread = new QThread(this);
    _persister->moveToThread(persistenceThread);
    connect(persistenceThread, &QThread::finished, _persister, &QObject::deleteLater);
    persistenceThread->start();
    
    // queue up the load
    QMetaObject::invokeMethod(_persister, "load");
}
Example #6
0
void AudioMixer::readPendingDatagrams() {
    QByteArray receivedPacket;
    HifiSockAddr senderSockAddr;
    NodeList* nodeList = NodeList::getInstance();
    
    while (readAvailableDatagram(receivedPacket, senderSockAddr)) {
        if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
            // pull any new audio data from nodes off of the network stack
            PacketType mixerPacketType = packetTypeForPacket(receivedPacket);
            if (mixerPacketType == PacketTypeMicrophoneAudioNoEcho
                || mixerPacketType == PacketTypeMicrophoneAudioWithEcho
                || mixerPacketType == PacketTypeInjectAudio
                || mixerPacketType == PacketTypeSilentAudioFrame) {
                
                nodeList->findNodeAndUpdateWithDataFromPacket(receivedPacket);
            } else {
                // let processNodeData handle it.
                nodeList->processNodeData(senderSockAddr, receivedPacket);
            }
        }
    }
}
Example #7
0
void AssignmentClient::sendAssignmentRequest() {
    if (!_currentAssignment) {
        
        NodeList* nodeList = NodeList::getInstance();
        
        if (_assignmentServerHostname == "localhost") {
            // we want to check again for the local domain-server port in case the DS has restarted
            if (!_localASPortSharedMem) {
                _localASPortSharedMem = new QSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this);
                
                if (!_localASPortSharedMem->attach(QSharedMemory::ReadOnly)) {
                    qWarning() << "Could not attach to shared memory at key" << DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY
                        << "- will attempt to connect to domain-server on" << _assignmentServerSocket.getPort();
                }
            }
            
            if (_localASPortSharedMem->isAttached()) {
                _localASPortSharedMem->lock();
                
                quint16 localAssignmentServerPort;
                memcpy(&localAssignmentServerPort, _localASPortSharedMem->data(), sizeof(localAssignmentServerPort));
                
                _localASPortSharedMem->unlock();
                
                if (localAssignmentServerPort != _assignmentServerSocket.getPort()) {
                    qDebug() << "Port for local assignment server read from shared memory is"
                        << localAssignmentServerPort;
                    
                    _assignmentServerSocket.setPort(localAssignmentServerPort);
                    nodeList->setAssignmentServerSocket(_assignmentServerSocket);
                }
            }
            
        }
        
        nodeList->sendAssignment(_requestAssignment);
    }
}
Example #8
0
/*! Gets the boot device, scans all of its partitions, gets the
	boot partition, and mounts its file system.

	\param args The stage 2 arguments.
	\param _bootVolume On success set to the boot volume.
	\return \c B_OK on success, another error code otherwise.
*/
status_t
get_boot_file_system(stage2_args* args, BootVolume& _bootVolume)
{
	Node *device;
	status_t error = platform_add_boot_device(args, &gBootDevices);
	if (error != B_OK)
		return error;

	// the boot device must be the first device in the list
	device = gBootDevices.First();

	error = add_partitions_for(device, false, true);
	if (error != B_OK)
		return error;

	Partition *partition;
	error = platform_get_boot_partition(args, device, &gPartitions, &partition);
	if (error != B_OK)
		return error;

	Directory *fileSystem;
	error = partition->Mount(&fileSystem, true);
	if (error != B_OK) {
		// this partition doesn't contain any known file system; we
		// don't need it anymore
		gPartitions.Remove(partition);
		delete partition;
		return error;
	}

	// init the BootVolume
	error = _bootVolume.SetTo(fileSystem);
	if (error != B_OK)
		return error;

	sBootDevice = device;
	return B_OK;
}
Example #9
0
void SplitTree::rdsTryMerge( SplitNode* n, SplitShaderHeuristics& outHeuristics )
{
  assert( n );

//  dumpFile << "TRY MERGE " << (void*)n << std::endl;
//  n->dump( dumpFile );
//  dumpFile << std::endl;

  // first try to merge with all children
  if( rdsCompile( n, outHeuristics ) )
    return;

//  dumpFile << "whole thing didn't work, trying to split" << std::endl;

  // count the number of unsaved kids
  size_t childCount = n->getGraphChildCount();
  NodeList unsavedChildren;
  for( size_t i = 0; i < childCount; i++ )
  {
    SplitNode* child = n->getIndexedGraphChild(i);
    if( !child->isMarkedAsSplit() )
      unsavedChildren.push_back( child );
  }
  size_t unsavedChildCount = unsavedChildren.size();

  assert( unsavedChildCount > 0 );

  size_t subsetSize = unsavedChildCount;
  while( subsetSize-- > 0 )
  {
    // try to do merges with the given subset size
//    dumpFile << "trying merges of " << subsetSize << " of the " << unsavedChildCount << " children" << std::endl;
    if( rdsMergeSome( n, unsavedChildren, subsetSize, outHeuristics ) )
      return;
  }

  assert( false );
}
Example #10
0
// This method is called when the edit packet layer has determined that it has a fully formed packet destined for
// a known nodeID. However, we also want to handle the case where the 
void VoxelEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer, ssize_t length) {
    NodeList* nodeList = NodeList::getInstance();
    for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
        // only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
        if (node->getType() == NODE_TYPE_VOXEL_SERVER &&
            ((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
            if (nodeList->getNodeActiveSocketOrPing(&(*node))) {
                sockaddr* nodeAddress = node->getActiveSocket();
                queuePacketForSending(*nodeAddress, buffer, length);
                
                // debugging output...
                bool wantDebugging = false;
                if (wantDebugging) {
                    int numBytesPacketHeader = numBytesForPacketHeader(buffer);
                    unsigned short int sequence = (*((unsigned short int*)(buffer + numBytesPacketHeader)));
                    uint64_t createdAt = (*((uint64_t*)(buffer + numBytesPacketHeader + sizeof(sequence))));
                    uint64_t queuedAt = usecTimestampNow();
                    uint64_t transitTime = queuedAt - createdAt;

                    const char* messageName;
                    switch (buffer[0]) {
                        case PACKET_TYPE_SET_VOXEL: 
                            messageName = "PACKET_TYPE_SET_VOXEL"; 
                            break;
                        case PACKET_TYPE_SET_VOXEL_DESTRUCTIVE: 
                            messageName = "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE"; 
                            break;
                        case PACKET_TYPE_ERASE_VOXEL: 
                            messageName = "PACKET_TYPE_ERASE_VOXEL"; 
                            break;
                    }
                    printf("VoxelEditPacketSender::queuePacketToNode() queued %s - command to node bytes=%ld sequence=%d transitTimeSoFar=%llu usecs\n",
                        messageName, length, sequence, transitTime);
                }                
            }
        }
    }
}
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList elementList;
     NodeList childList;
     Node childNode;
     Node newChild;
     Node memberNode;
     String memberName;
     std::vector<string_type> refreshedActual;
     
     std::vector<string_type> actual;
     
     int nodeType;
     std::vector<string_type> expected;
     expected.push_back(SA::construct_from_utf8("strong"));
     expected.push_back(SA::construct_from_utf8("code"));
     expected.push_back(SA::construct_from_utf8("sup"));
     expected.push_back(SA::construct_from_utf8("var"));
     expected.push_back(SA::construct_from_utf8("acronym"));
     expected.push_back(SA::construct_from_utf8("em"));
     
     Node appendedChild;
     doc = (Document) baseT::load("hc_staff", true);
     elementList = doc.getElementsByTagName(SA::construct_from_utf8("p"));
     childNode = elementList.item(1);
     childList = ((Element) /*Node */childNode).getElementsByTagName(SA::construct_from_utf8("*"));
     newChild = childList.item(0);
     appendedChild = childNode.appendChild(newChild);
     for (unsigned int indexN65669 = 0; indexN65669 != childList.getLength(); indexN65669++) {
         memberNode = (Node) childList.item(indexN65669);
   memberName = memberNode.getNodeName();
     actual.push_back(memberName);
       }
     baseT::assertEquals(expected, actual, __LINE__, __FILE__);
 childList = childNode.getChildNodes();
     for (unsigned int indexN65692 = 0; indexN65692 != childList.getLength(); indexN65692++) {
         memberNode = (Node) childList.item(indexN65692);
   nodeType = (int) memberNode.getNodeType();
     
     if (baseT::equals(1, nodeType)) {
         memberName = memberNode.getNodeName();
     refreshedActual.push_back(memberName);
     }
     }
     baseT::assertEquals(expected, refreshedActual, __LINE__, __FILE__);
 
  }
Example #12
0
void BlockNode::render( OutputStream *stream, Context *c )
{
  QVariant &variant = c->renderContext()->data( BLOCK_CONTEXT_KEY );
  BlockContext blockContext = variant.value<BlockContext>();

  c->push();

  if ( blockContext.isEmpty() ) {
    m_context = c;
    m_stream = stream;
    c->insert( QLatin1String( "block" ), QVariant::fromValue( static_cast<QObject *>( this ) ) );
    m_list.render( stream, c );
    m_stream = 0;
  } else {
    BlockNode *block = blockContext.pop( m_name );
    variant.setValue( blockContext );
    BlockNode *push = block;
    if ( !block )
      block = this;

    // BIC Make const when render() is const.
    NodeList list = block->m_list;

    block = new BlockNode( block->m_name, 0 );
    block->setNodeList( list );
    block->m_context = c;
    block->m_stream = stream;
    c->insert( QLatin1String( "block" ), QVariant::fromValue( static_cast<QObject *>( block ) ) );
    list.render( stream, c );

    delete block;
    if ( push ) {
      blockContext.push( m_name, push );
      variant.setValue( blockContext );
    }
  }
  c->pop();
}
    /*
     * Runs the test case.
     */
    void runTest()
    {
        Document doc;
        NodeList elementList;
        Node docNode;
        Document ownerDocument;
        Element docElement;
        String elementName;
        doc = (Document) baseT::load("hc_staff", false);
        elementList = doc.getElementsByTagName(SA::construct_from_utf8("p"));
        docNode = elementList.item(1);
        ownerDocument = docNode.getOwnerDocument();
        docElement = ownerDocument.getDocumentElement();
        elementName = docElement.getNodeName();

        if (("image/svg+xml" == baseT::getContentType())) {
            baseT::assertEquals("svg", elementName, __LINE__, __FILE__);
        } else {
            baseT::assertEquals("html", elementName, __LINE__, __FILE__);
        }


    }
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      Node oldChild;
      NodeList elementList;
      Node elementNode;
      Node removedChild;
      doc = (Document) baseT::load("staff", true);
      oldChild = doc.createElement(SA::construct_from_utf8("oldChild"));
      elementList = doc.getElementsByTagName(SA::construct_from_utf8("employee"));
      elementNode = elementList.item(1);
      
      {
         boolean success = false;
         try {
            removedChild = elementNode.removeChild(oldChild);
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::NOT_FOUND_ERR);
         }
         assertTrue(success);
      }

   }
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList nameList;
     Element lChild;
     NodeList childNodes;
     CDATASection cdataN;
     String data;
     doc = (Document) baseT::load("staff", true);
     nameList = doc.getElementsByTagName(SA::construct_from_utf8("name"));
     lChild = (Element) nameList.item(1);
     lChild.normalize();
     childNodes = lChild.getChildNodes();
     cdataN = (CDATASection) childNodes.item(1);
     baseT::assertNotNull(cdataN, __LINE__, __FILE__);
     data = cdataN.getData();
     baseT::assertEquals("This is a CDATASection with EntityReference number 2 &ent2;", data, __LINE__, __FILE__);
 cdataN = (CDATASection) childNodes.item(3);
     baseT::assertNotNull(cdataN, __LINE__, __FILE__);
     data = cdataN.getData();
     baseT::assertEquals("This is an adjacent CDATASection with a reference to a tab &tab;", data, __LINE__, __FILE__);
 
  }
Example #16
0
void
device_node::AddChild(device_node* node)
{
	// we must not be destroyed	as long as we have children
	Acquire();
	node->fParent = this;

	int32 priority = node->Priority();

	// Enforce an order in which the children are traversed - from most
	// specific to least specific child.
	NodeList::Iterator iterator = fChildren.GetIterator();
	device_node* before = NULL;
	while (iterator.HasNext()) {
		device_node* child = iterator.Next();
		if (child->Priority() <= priority) {
			before = child;
			break;
		}
	}

	fChildren.Insert(before, node);
}
Example #17
0
void ApplicationOverlay::renderDomainConnectionStatusBorder() {
    NodeList* nodeList = NodeList::getInstance();

    if (nodeList && !nodeList->getDomainHandler().isConnected()) {
        GLCanvas* glWidget = Application::getInstance()->getGLWidget();
        int right = glWidget->width();
        int bottom = glWidget->height();

        glColor3f(CONNECTION_STATUS_BORDER_COLOR[0],
                  CONNECTION_STATUS_BORDER_COLOR[1],
                  CONNECTION_STATUS_BORDER_COLOR[2]);
        glLineWidth(CONNECTION_STATUS_BORDER_LINE_WIDTH);

        glBegin(GL_LINE_LOOP);

        glVertex2i(0, 0);
        glVertex2i(0, bottom);
        glVertex2i(right, bottom);
        glVertex2i(right, 0);

        glEnd();
    }
}
   /*
    * Runs the test case.
    */
   void runTest()
   {
      Document doc;
      Node newChild;
      NodeList elementList;
      Node employeeNode;
      Node appendedChild;
      doc = (Document) baseT::load("staff", true);
      newChild = doc.getDocumentElement();
      elementList = doc.getElementsByTagName(SA::construct_from_utf8("employee"));
      employeeNode = elementList.item(1);
      
      {
         boolean success = false;
         try {
            appendedChild = employeeNode.appendChild(newChild);
          } catch (const DOMException& ex) {
            success = (ex.code() == DOMException::HIERARCHY_REQUEST_ERR);
         }
         assertTrue(success);
      }

   }
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList elementList;
     Node employeeNode;
     NodeList employeeList;
     Node child;
     String childName;
     doc = (Document) baseT::load("hc_staff", false);
     elementList = doc.getElementsByTagName(SA::construct_from_utf8("p"));
     employeeNode = elementList.item(2);
     employeeList = employeeNode.getChildNodes();
     child = employeeList.item(3);
     childName = child.getNodeName();
     
     if (baseT::equals("#text", childName)) {
         baseT::assertEquals("#text", childName, __LINE__, __FILE__);
 } else {
         baseT::assertEquals("strong", childName, __LINE__, __FILE__);
 }
       
   
  }
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    NodeList addressList;
    Node testAddress;
    NamedNodeMap attributes;
    DocumentType docType;
    NamedNodeMap notations;
    Notation notationNode;
    String notationName;
    doc = (Document) baseT::load("staff", false);
    docType = doc.getDoctype();
    baseT::assertNotNull(docType, __LINE__, __FILE__);
    notations = docType.getNotations();
    baseT::assertNotNull(notations, __LINE__, __FILE__);
    notationNode = (Notation) notations.getNamedItem(SA::construct_from_utf8("notation1"));
    baseT::skipIfNull(notationNode);
    addressList = doc.getElementsByTagName(SA::construct_from_utf8("address"));
    testAddress = addressList.item(0);
    attributes = testAddress.getAttributes();
    baseT::assertSize(2, attributes, __LINE__, __FILE__);
    
 }
 /*
  * Runs the test case.
  */
 void runTest()
 {
    Document doc;
    NodeList childList;
    Node childNode;
    NamedNodeMap attrList;
    int nodeType;
    doc = (Document) baseT::load("staff", false);
    childList = doc.getChildNodes();
    for (unsigned int indexN65603 = 0; indexN65603 != childList.getLength(); indexN65603++) {
        childNode = (Node) childList.item(indexN65603);
  nodeType = (int) childNode.getNodeType();
    
    if (baseT::equals(8, nodeType)) {
        attrList = childNode.getAttributes();
    baseT::assertNull(attrList, __LINE__, __FILE__);
    }
    }
    childNode = doc.createComment(SA::construct_from_utf8("This is a comment"));
    attrList = childNode.getAttributes();
    baseT::assertNull(attrList, __LINE__, __FILE__);
    
 }
Example #22
0
void
XmlRenderer::displayNodeList(zstring tagName, const NodeList& nodelist)
{
  if (!nodelist.empty()) {
    displayOpenTag(tagName);

    for (auto& nd : nodelist) {
      if (nd)
        render(*nd);
    }

    displayCloseTag(tagName);
  }
}
Example #23
0
void MetavoxelServer::run() {
    commonInit(METAVOXEL_SERVER_LOGGING_NAME, NodeType::MetavoxelServer);
    
    NodeList* nodeList = NodeList::getInstance();
    nodeList->addNodeTypeToInterestSet(NodeType::Agent);
    
    connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), SLOT(maybeAttachSession(const SharedNodePointer&)));
    
    _lastSend = QDateTime::currentMSecsSinceEpoch();
    _sendTimer.start(SEND_INTERVAL);
    
    // initialize Bitstream before using it in multiple threads
    Bitstream::preThreadingInit();
    
    // create the persister and start it in its own thread
    _persister = new MetavoxelPersister(this);
    QThread* persistenceThread = new QThread(this);
    _persister->moveToThread(persistenceThread);
    persistenceThread->start();
    
    // queue up the load
    QMetaObject::invokeMethod(_persister, "load");
}
  /*
   * Runs the test case.
   */
  void runTest()
  {
     Document doc;
     NodeList testList;
     Node commentNode;
     String commentNodeName;
     int nodeType;
     doc = (Document) baseT::load("hc_staff", false);
     testList = doc.getChildNodes();
     for (unsigned int indexN65600 = 0; indexN65600 != testList.getLength(); indexN65600++) {
         commentNode = (Node) testList.item(indexN65600);
   commentNodeName = commentNode.getNodeName();
     
     if (baseT::equals("#comment", commentNodeName)) {
         nodeType = (int) commentNode.getNodeType();
     baseT::assertEquals(8, nodeType, __LINE__, __FILE__);
 }
     }
     commentNode = doc.createComment(SA::construct_from_utf8("This is a comment"));
     nodeType = (int) commentNode.getNodeType();
     baseT::assertEquals(8, nodeType, __LINE__, __FILE__);
 
  }
Example #25
0
void HexagonOptAddrMode::getAllRealUses(NodeAddr<StmtNode *> SA,
                                        NodeList &UNodeList) {
  for (NodeAddr<DefNode *> DA : SA.Addr->members_if(DFG->IsDef, *DFG)) {
    DEBUG(dbgs() << "\t\t[DefNode]: " << Print<NodeAddr<DefNode *>>(DA, *DFG)
                 << "\n");
    RegisterRef DR = DA.Addr->getRegRef();
    auto UseSet = LV->getAllReachedUses(DR, DA);

    for (auto UI : UseSet) {
      NodeAddr<UseNode *> UA = DFG->addr<UseNode *>(UI);
      NodeAddr<StmtNode *> TempIA = UA.Addr->getOwner(*DFG);
      (void)TempIA;
      DEBUG(dbgs() << "\t\t\t[Reached Use]: "
                   << Print<NodeAddr<InstrNode *>>(TempIA, *DFG) << "\n");

      if (UA.Addr->getFlags() & NodeAttrs::PhiRef) {
        NodeAddr<PhiNode *> PA = UA.Addr->getOwner(*DFG);
        NodeId id = PA.Id;
        const Liveness::RefMap &phiUse = LV->getRealUses(id);
        DEBUG(dbgs() << "\t\t\t\tphi real Uses"
                     << Print<Liveness::RefMap>(phiUse, *DFG) << "\n");
        if (phiUse.size() > 0) {
          for (auto I : phiUse) {
            if (DR != I.first)
              continue;
            auto phiUseSet = I.second;
            for (auto phiUI : phiUseSet) {
              NodeAddr<UseNode *> phiUA = DFG->addr<UseNode *>(phiUI);
              UNodeList.push_back(phiUA);
            }
          }
        }
      } else
        UNodeList.push_back(UA);
    }
  }
}
ParallelBFS::ParallelBFS(const mpi::communicator &comm,
                         const NodeList &vertices,
                         const NodeList &edges) :
    comm(comm) {
  NodeId part = (NodeId)vertices.size() / comm.size(),
      left_vertices = (NodeId)vertices.size() % comm.size(),
      first_vertex = 0, first_edge = 0;
  NodeList part_vertices((size_t)comm.size());
  NodeList first_vertices((size_t)comm.size());
  NodeList part_edges((size_t)comm.size());
  NodeList first_edges((size_t)comm.size());
  NodeList all_description((size_t)(comm.size() << 2));
  for (int i = 0; i < comm.size(); ++i) {
    NodeId this_part = part + (i < left_vertices);
    NodeId last_edge = first_vertex + this_part == vertices.size() ?
                      (NodeId)edges.size() :
                      vertices[first_vertex + this_part];
    all_description[(i<<2)] = (NodeId)vertices.size();
    all_description[(i<<2) + 1] = first_vertices[i] = first_vertex;
    all_description[(i<<2) + 2] = part_vertices[i] = this_part;
    all_description[(i<<2) + 3] = part_edges[i] = last_edge - first_edge;
    first_edges[i] = first_edge;
    first_edge = last_edge;
    first_vertex += this_part;
  }
  NodeList description(4);
  mpi::scatter(comm, all_description.data(), description.data(), 4, 0);
  this->vertex_total_count = description[0];
  this->first_vertex = description[1];
  this->vertices.resize((size_t)description[2]);
  mpi::scatterv(comm, vertices, part_vertices, first_vertices,
                this->vertices, 0);
  this->edges.resize((size_t)description[3]);
  mpi::scatterv(comm, edges, part_edges, first_edges,
                this->edges, 0);
  prepare();
}
Example #27
0
// Evaluate an XPath expression and return matching Nodes.
NodeList Document::findXPath(const std::string& path) const
{
	std::lock_guard<std::mutex> lock(_lock);

    // Set up the XPath context
    xmlXPathContextPtr context = xmlXPathNewContext(_xmlDoc);

    if (context == NULL) {
        rConsoleError() << "ERROR: xml::findPath() failed to create XPath context "
                  << "when searching for " << path << std::endl;
        throw XPathException("Failed to create XPath context");
    }

    // Evaluate the expression
    const xmlChar* xpath = reinterpret_cast<const xmlChar*>(path.c_str());
    xmlXPathObjectPtr result = xmlXPathEvalExpression(xpath, context);
    xmlXPathFreeContext(context);

    if (result == NULL) {
        rConsoleError() << "ERROR: xml::findPath() failed to evaluate expression "
                  << path << std::endl;
        throw XPathException("Failed to evaluate XPath expression");
    }

    // Construct the return vector. This may be empty if the provided XPath
    // expression does not identify any nodes.
    NodeList retval;
    xmlNodeSetPtr nodeset = result->nodesetval;
	if (nodeset != NULL) {
	    for (int i = 0; i < nodeset->nodeNr; i++) {
	        retval.push_back(Node(nodeset->nodeTab[i]));
	    }
	}

    xmlXPathFreeObject(result);
    return retval;
}
Example #28
0
void AudioMixer::readPendingDatagram(const QByteArray& receivedPacket, const HifiSockAddr& senderSockAddr) {
    NodeList* nodeList = NodeList::getInstance();
    
    if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
        // pull any new audio data from nodes off of the network stack
        PacketType mixerPacketType = packetTypeForPacket(receivedPacket);
        if (mixerPacketType == PacketTypeMicrophoneAudioNoEcho
            || mixerPacketType == PacketTypeMicrophoneAudioWithEcho
            || mixerPacketType == PacketTypeInjectAudio
            || mixerPacketType == PacketTypeSilentAudioFrame
            || mixerPacketType == PacketTypeAudioStreamStats) {
            
            nodeList->findNodeAndUpdateWithDataFromPacket(receivedPacket);
        } else if (mixerPacketType == PacketTypeMuteEnvironment) {
            QByteArray packet = receivedPacket;
            populatePacketHeader(packet, PacketTypeMuteEnvironment);
            
            foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
                if (node->getType() == NodeType::Agent && node->getActiveSocket() && node->getLinkedData() && node != nodeList->sendingNodeForPacket(receivedPacket)) {
                    nodeList->writeDatagram(packet, packet.size(), node);
                }
            }
            
        } else {
Example #29
0
/**
 * Generates a buffer with the Nintendo tagged parameters of an 802.11 Beacon frame
 * for UDS communication.
 * @returns A buffer with the Nintendo tagged parameters of the beacon frame.
 */
std::vector<u8> GenerateNintendoTaggedParameters(const NetworkInfo& network_info,
                                                 const NodeList& nodes) {
    ASSERT_MSG(network_info.max_nodes == nodes.size(), "Inconsistent network state.");

    std::vector<u8> buffer = GenerateNintendoDummyTag();
    std::vector<u8> network_info_tag = GenerateNintendoNetworkInfoTag(network_info);
    std::vector<u8> first_data_tag = GenerateNintendoFirstEncryptedDataTag(network_info, nodes);
    std::vector<u8> second_data_tag = GenerateNintendoSecondEncryptedDataTag(network_info, nodes);

    buffer.insert(buffer.end(), network_info_tag.begin(), network_info_tag.end());
    buffer.insert(buffer.end(), first_data_tag.begin(), first_data_tag.end());
    buffer.insert(buffer.end(), second_data_tag.begin(), second_data_tag.end());

    return buffer;
}
Example #30
0
  DOMElement::NodeList DOMElement::selectChildNodes(const char * tagname) const
  {
    
    NodeList list; 

    if(!m_wrapped)
      return list;

    xercesc::DOMNodeList * xList = XELEM(m_wrapped)->getChildNodes();

    for(XMLSize_t i = 0; i < xList->getLength(); i++) {
      xercesc::DOMElement * xe = dynamic_cast<xercesc::DOMElement *> (xList->item(i));
      if(!xe) continue;
      
      char * name = xercesc::XMLString::transcode(XELEM((Wrapped *) xe)->getTagName());

      if(strcmp(name, tagname) == 0)
	list.push_back(DOMElement(ELEM(xe)));

      xercesc::XMLString::release(&name);
    }
    
    return list; 
  }