Beispiel #1
0
 /// Retrieve a pointer to the data content of a given microslice
 const uint8_t* content(uint64_t component, uint64_t microslice) const {
   return data_ptr_[component] +
          desc_ptr_[component]->num_microslices *
              sizeof(MicrosliceDescriptor) +
          descriptor(component, microslice).offset -
          descriptor(component, 0).offset;
 }
Beispiel #2
0
bool InferredType::set(const ConcurrentJSLocker& locker, VM& vm, Descriptor newDescriptor)
{
    // We will trigger write barriers while holding our lock. Currently, write barriers don't GC, but that
    // could change. If it does, we don't want to deadlock. Note that we could have used
    // GCSafeConcurrentJSLocker in the caller, but the caller is on a fast path so maybe that wouldn't be
    // a good idea.
    DeferGCForAWhile deferGC(vm.heap);
    
    // Be defensive: if we're not really changing the type, then we don't have to do anything.
    if (descriptor(locker) == newDescriptor)
        return false;

    bool shouldFireWatchpointSet = false;
    
    // The new descriptor must be more general than the previous one.
    ASSERT(newDescriptor.subsumes(descriptor(locker)));

    // If the new descriptors have different structures, then it can only be because one is null.
    if (descriptor(locker).structure() != newDescriptor.structure())
        ASSERT(!descriptor(locker).structure() || !newDescriptor.structure());

    // We are changing the type, so make sure that if anyone was watching, they find out about it now. If
    // anyone is watching, we make sure to go to Top so that we don't do this sort of thing again.
    if (m_watchpointSet.state() != ClearWatchpoint) {
        // We cannot have been invalidated, since if we were, then we'd already be at Top.
        ASSERT(m_watchpointSet.state() != IsInvalidated);

        // We're about to do expensive things because some compiler thread decided to watch this type and
        // then the type changed. Assume that this property is crazy, and don't ever do any more things for
        // it.
        newDescriptor = Top;

        shouldFireWatchpointSet = true;
    }

    // Remove the old InferredStructure object if we no longer need it.
    if (!newDescriptor.structure())
        m_structure = nullptr;

    // Add a new InferredStructure object if we need one now.
    if (newDescriptor.structure()) {
        if (m_structure) {
            // We should agree on the structures if we get here.
            ASSERT(newDescriptor.structure() == m_structure->structure());
        } else {
            m_structure = adoptRef(new InferredStructure(vm, this, newDescriptor.structure()));
            newDescriptor.structure()->addTransitionWatchpoint(&m_structure->m_watchpoint);
        }
    }

    // Finally, set the descriptor kind.
    m_kind = newDescriptor.kind();

    // Assert that we did things.
    ASSERT(descriptor(locker) == newDescriptor);

    return shouldFireWatchpointSet;
}
Beispiel #3
0
 const field_desc_type *find_field( const std::string &name ) const
 {
     const field_desc_type *fld(descriptor()->FindFieldByName(name));
     if( fld ) return fld;
     fld = descriptor()->FindFieldByLowercaseName( name );
     if( fld ) return fld;
     fld = descriptor()->FindFieldByCamelcaseName( name );
     if( fld ) return fld;
     return NULL;
 }
TEST(CustomElementDescriptorTest,
    matches_customizedBuiltIn_shouldNotMatchAutonomousElement)
{
    CustomElementDescriptor descriptor("a-b", "button");
    Element* element = CreateElement("a-b");
    EXPECT_FALSE(descriptor.matches(*element));
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvAddBlobImage(const wr::ImageKey& aImageKey,
                                        const gfx::IntSize& aSize,
                                        const uint32_t& aStride,
                                        const gfx::SurfaceFormat& aFormat,
                                        const ByteBuffer& aBuffer)
{
  if (mDestroyed) {
    return IPC_OK();
  }

  // Check if key is obsoleted.
  if (aImageKey.mNamespace != mIdNamespace) {
    return IPC_OK();
  }

  MOZ_ASSERT(mApi);
  MOZ_ASSERT(mActiveImageKeys.find(wr::AsUint64(aImageKey)) == mActiveImageKeys.end());

  wr::ImageDescriptor descriptor(aSize, aStride, aFormat);
  mActiveImageKeys.insert(wr::AsUint64(aImageKey));
  mApi->AddBlobImage(aImageKey, descriptor,
                     aBuffer.AsSlice());

  return IPC_OK();
}
Beispiel #6
0
void construct_graph( const Points& points, 
		      const double epsilon,
		      Graph& graph) {
    typedef typename boost::graph_traits<Graph> graph_traits;
    typedef typename graph_traits::vertex_iterator vertex_iterator;
    typedef typename boost::graph_traits< Graph>::vertex_descriptor vertex_descriptor; 
    typedef typename boost::property_map< Graph,
					  boost::vertex_name_t>::type name_map_t;
    typedef typename boost::property_traits< name_map_t>::value_type  vertex_name_t;
    typedef std::unordered_map< vertex_name_t, vertex_descriptor> Name_to_descriptor_map;

    name_map_t name_map = boost::get( boost::vertex_name, graph);
    Name_to_descriptor_map descriptor( points.size());

    // add vertices
    for( std::size_t i = 0; i < points.size(); ++i) {
	vertex_descriptor v_descriptor = boost::add_vertex( graph);
	name_map[ v_descriptor] = i;
	descriptor.emplace( i, v_descriptor);
    }

    // add edges
    vertex_iterator vi, vj, vlast;
    double epsilon_squared = epsilon*epsilon;
    for ( std::tie( vi, vlast) = boost::vertices( graph); vi != vlast; ++vi) {
      for ( std::tie( vj, vlast) = boost::vertices (graph); vj != vi; ++vj) {
       
	if( lp(points.begin(name_map[*vi]), 
	       points.end(name_map[*vi]), 
	       points.begin(name_map[*vj])) < epsilon_squared){
             boost::add_edge(*vi, *vj, graph);
       }
      } 
    }
} 
Beispiel #7
0
      virtual QPair<QByteArray, bool> GetBulkData(int)
      {
        QByteArray data(1024, 0);
        CreateDescriptor(data);

        SetTriggered();
        int my_idx = GetGroup().GetIndex(GetLocalId());
        int bad = Random::GetInstance().GetInt(0, GetGroup().Count());
        while(bad == my_idx) {
          bad = Random::GetInstance().GetInt(0, GetGroup().Count());
        }

        qDebug() << my_idx << "setting bad hash at" << bad;
        const Descriptor &cdes = GetMyDescriptor();
        QVector<QByteArray> hashes = cdes.XorMessageHashes();

        hashes[bad] = Hash().ComputeHash(data);

        Descriptor descriptor(cdes.Length(), cdes.PublicDh(), hashes,
            cdes.CleartextHash());
        SetMyDescriptor(descriptor);

        QByteArray my_desc;
        QDataStream desstream(&my_desc, QIODevice::WriteOnly);
        desstream << GetMyDescriptor();
        return QPair<QByteArray, bool>(my_desc, false);
      }
Beispiel #8
0
template <typename PointInT, typename PointNT, typename PointOutT> void
pcl::ShapeContext3DEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut &output)
{
  assert (descriptor_length_ == 1980);

  output.is_dense = true;
  // Iterate over all points and compute the descriptors
	for (size_t point_index = 0; point_index < indices_->size (); point_index++)
  {
    //output[point_index].descriptor.resize (descriptor_length_);

    // If the point is not finite, set the descriptor to NaN and continue
    if (!isFinite ((*input_)[(*indices_)[point_index]]))
    {
      for (size_t i = 0; i < descriptor_length_; ++i)
        output[point_index].descriptor[i] = std::numeric_limits<float>::quiet_NaN ();

      memset (output[point_index].rf, 0, sizeof (output[point_index].rf[0]) * 9);
      output.is_dense = false;
      continue;
    }

    std::vector<float> descriptor (descriptor_length_);
    if (!computePoint (point_index, *normals_, output[point_index].rf, descriptor))
      output.is_dense = false;
    for (size_t j = 0; j < descriptor_length_; ++j)
      output[point_index].descriptor[j] = descriptor[j];
  }
}
  void ODFeatureDetector2D::findSiftGPUDescriptors(char const *image_name, cv::Mat &descriptors, vector<cv::KeyPoint> &keypoints)
  {
    sift_gpu_->RunSIFT(image_name);

    int nFeat = sift_gpu_->GetFeatureNum();//get feature count
    //allocate memory for readback
    vector<SiftGPU::SiftKeypoint> keys(nFeat);
    //read back keypoints and normalized descritpros
    //specify NULL if you don’t need keypoints or descriptors
    vector<float> imageDescriptors(128 * nFeat);
    sift_gpu_->GetFeatureVector(&keys[0], &imageDescriptors[0]);

    sift_gpu_->SaveSIFT("1.sift");

    //to opencv format
    keypoints.clear();
    descriptors.create(0, 128, CV_32FC1);
    for(int i = 0; i < nFeat; ++i) {
      cv::KeyPoint key(keys[i].x, keys[i].y, keys[i].s, keys[i].o);
      keypoints.push_back(key);
      cv::Mat descriptor(1, 128, CV_32FC1);
      for(int x = 0; x < 128; x++) descriptor.at<float>(x) = floor(0.5 + 512.0f * imageDescriptors[(i << 7) + x]);
      descriptors.push_back(descriptor);
    }
    cv::Mat image = cv::imread(image_name);
  }
Beispiel #10
0
// -----------------------------------------------------------------------------
// RDRMHelper::IsAutomated
// -----------------------------------------------------------------------------
//
TInt RDRMHelper::IsAutomated(
    const TDesC8& aUri,
    TInt aAutomatedType,
    TInt aIntent,
    TBool& aAutomated,
    TInt& aType ) const
{
    TPtr8 typeptr( reinterpret_cast< TUint8* >( &aType ), 0, sizeof( TInt ) );
    TPtr8 flag( reinterpret_cast< TUint8* >( &aAutomated ), 0, sizeof( TInt ) );
    TInt ret( 0 );
    TInt type = CDRMHelperServer::EActive;

    // Create descriptor to enable copying data between
    // client and server. Note: This can be local since
    // this is a synchronous call.
    // Note : Using TPtr8 since this is binary information
    TPtrC8 descriptor( aUri );

    // This call waits for the server to complete the request before
    // proceeding.
    ret = SendReceive(
              EIsRegistered,
              TIpcArgs( aIntent, type, aAutomatedType, &descriptor ) );
    if ( !ret )
    {
        type = CDRMHelperServer::EPassive;
        ret = SendReceive(
                  EIsRegistered,
                  TIpcArgs( aIntent, type, aAutomatedType, &descriptor ) );
    }
    aAutomated = ret > 0 ? ETrue : EFalse;
    aType = type;
    return KErrNone;
}
Beispiel #11
0
bool InferredType::canWatch(const ConcurrentJSLocker& locker, const Descriptor& expected)
{
    if (expected.kind() == Top)
        return false;
    
    return descriptor(locker) == expected;
}
Beispiel #12
0
// -----------------------------------------------------------------------------
// RDRMHelper::RemoveAutomatedAll
//
// Unregister one content uri
// -----------------------------------------------------------------------------
//
TInt RDRMHelper::RemoveAutomatedAll(
    const TDesC8& aUri,
    TBool aActive,
    TInt aAutomatedType,
    TInt aIntent ) const
{
    TPtrC8 descriptor( aUri );
    TInt ret;
    TInt mode(
        aActive ? CDRMHelperServer::EActive : CDRMHelperServer::EPassive );
    TBool automated = EFalse;
    TInt tempMode( 0 );

    // This call waits for the server to complete the request before
    // proceeding.
    ret = SendReceive(
              ERemove, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );
    IsAutomated( aUri, aAutomatedType, aIntent, automated, tempMode );
    while ( automated && tempMode == mode )
    {
        // unregister all
        ret = SendReceive(
                  ERemove, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );
        IsAutomated( aUri, aAutomatedType, aIntent, automated, tempMode );
    }

    if ( ret == KErrNotFound )
    {
        ret = KErrNone;
    }
    return ret;
}
Beispiel #13
0
// -----------------------------------------------------------------------------
// RDRMHelper::RemoveAutomated
//
// Unregister one content uri
// -----------------------------------------------------------------------------
//
TInt RDRMHelper::RemoveAutomated(
    const TDesC8& aUri,
    TBool aActive,
    TInt aAutomatedType,
    TInt aIntent ) const
{
    TInt ret( 0 );
    TInt mode(
        aActive ? CDRMHelperServer::EActive : CDRMHelperServer::EPassive );

    // Create descriptor to enable copying data between
    // client and server. Note: This can be local since
    // this is a synchronous call.
    // Note : Using TPtr8 since this is binary information
    TPtrC8 descriptor( aUri );

    // This call waits for the server to complete the request before
    // proceeding.
    ret = SendReceive(
              ERemove, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );

    if ( ret == KErrNotFound )
    {
        // content was never actually registered
        ret = KErrNone;
    }
    return ret;
}
Beispiel #14
0
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
    {
        SkAutoMutexAcquire  ac(gFamilyMutex);
        load_system_fonts();
    }

    SkFontDescriptor descriptor(stream);
    const char* familyName = descriptor.getFamilyName();
    const char* typefaceName = descriptor.getFontFileName();
    const SkTypeface::Style style = descriptor.getStyle();

    const uint32_t customFontDataLength = stream->readPackedUInt();
    if (customFontDataLength > 0) {

        // generate a new stream to store the custom typeface
        SkMemoryStream* fontStream = new SkMemoryStream(customFontDataLength - 1);
        stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1);

        SkTypeface* face = CreateTypefaceFromStream(fontStream);

        fontStream->unref();
        return face;
    }

    return SkFontHost::CreateTypeface(NULL, familyName, style);
}
void
NewNet::TcpClientSocket::connect(const std::string & host, unsigned int port)
{
  assert((descriptor() == -1) || (socketState() == SocketUninitialized));

  setSocketState(SocketConnecting);

  NNLOG("newnet.net.debug", "Resolving host '%s'.", host.c_str());
  struct hostent *h = gethostbyname(host.c_str());
  if(! h)
  {
    NNLOG("newnet.net.warn", "Cannot resolve host '%s'.", host.c_str());
    setSocketError(ErrorCannotResolve);
    cannotConnectEvent(this);
    return;
  }

  struct sockaddr_in address;
  memset(&address, 0, sizeof(address));
  address.sin_family = AF_INET;
  memcpy(&(address.sin_addr.s_addr), *(h->h_addr_list), sizeof(address.sin_addr.s_addr));
  address.sin_port = htons(port);

  NNLOG("newnet.net.debug", "Connecting to host '%s:%u'.", host.c_str(), port);

  int s = socket(PF_INET, SOCK_STREAM, 0);
  if (!setnonblocking(s))
    NNLOG("newnet.net.warn", "Couldn't set socket %i to non blocking (errno: %i)", s, errno);
  setDescriptor(s);

  if(s < 0)
    {
      NNLOG("newnet.net.warn", "Cannot connect to host '%s:%u', error: %i.", host.c_str(), port, WSAGetLastError());
      setSocketError(ErrorCannotConnect);
      cannotConnectEvent(this);
      return;
    }

  // Add a connection timeout
  if (reactor()) {
    m_ConnectionTimeout = reactor()->addTimeout(120000, this, &TcpClientSocket::onConnectionTimeout);
  }

  connectedEvent.connect(this, &TcpClientSocket::onConnected);

  if(::connect(s, (struct sockaddr *)&address, sizeof(struct sockaddr_in)) == 0)
  {
    // When using non blocking socket (most of the time), we don't get here.
    NNLOG("newnet.net.debug", "Connected to host '%s:%u'.", host.c_str(), port);
    setSocketState(SocketConnected);
    connectedEvent(this);
  }
  else if(WSAGetLastError() != WSAEWOULDBLOCK)
  {
    // When using non blocking socket (most of the time), we don't get here.
    NNLOG("newnet.net.warn", "Cannot connect to host '%s:%u', error: %i.", host.c_str(), port, WSAGetLastError());
    setSocketError(ErrorCannotConnect);
    cannotConnectEvent(this);
  }
}
NetworkInformationSection::NetworkInformationSection(const uint8_t * const buffer) : LongCrcSection(buffer)
{
	networkId = UINT16(&buffer[3]);
	networkDescriptorsLength = sectionLength > 9 ? DVB_LENGTH(&buffer[8]) : 0;
	
	uint16_t pos = 10;
	uint16_t bytesLeft = sectionLength > 11 ? sectionLength - 11 : 0;
	uint16_t loopLength = 0;
	uint16_t bytesLeft2 = networkDescriptorsLength;

	while ( bytesLeft >= bytesLeft2 && bytesLeft2 > 1 && bytesLeft2 >= (loopLength = 2 + buffer[pos+1])) {
		descriptor(&buffer[pos], SCOPE_SI);
		pos += loopLength;
		bytesLeft -= loopLength;
		bytesLeft2 -= loopLength;
	}

	if (!bytesLeft2 && bytesLeft > 1) {
		bytesLeft2 = transportStreamLoopLength = DVB_LENGTH(&buffer[pos]);
		bytesLeft -= 2;
		pos += 2;
		while (bytesLeft >= bytesLeft2 && bytesLeft2 > 4 && bytesLeft2 >= (loopLength = 6 + DVB_LENGTH(&buffer[pos+4]))) {
			tsInfo.push_back(new TransportStreamInfo(&buffer[pos]));
			bytesLeft -= loopLength;
			bytesLeft2 -= loopLength;
			pos += loopLength;
		}
	}
}
Beispiel #17
0
  void BulkRound::CreateDescriptor(const QByteArray &data)
  {
    int length = data.size();

    Hash hashalgo;

    QByteArray xor_message(length, 0);
    QVector<QByteArray> hashes;

    int my_idx = GetGroup().GetIndex(GetLocalId());

    foreach(const PublicIdentity &gc, GetGroup().GetRoster()) {
      QByteArray seed = _anon_dh.GetSharedSecret(gc.GetDhKey());

      if(hashes.size() == my_idx) {
        hashes.append(QByteArray());
        continue;
      }

      QByteArray msg(length, 0);
      CryptoRandom(seed).GenerateBlock(msg);
      hashes.append(hashalgo.ComputeHash(msg));
      Xor(xor_message, xor_message, msg);
    }

    QByteArray my_xor_message = QByteArray(length, 0);
    Xor(my_xor_message, xor_message, data);
    SetMyXorMessage(my_xor_message);
    hashes[my_idx] = hashalgo.ComputeHash(my_xor_message);

    QByteArray hash = hashalgo.ComputeHash(data);

    Descriptor descriptor(length, _anon_dh.GetPublicComponent(), hashes, hash);
    SetMyDescriptor(descriptor);
  }
Beispiel #18
0
std::vector<Descriptor> Image::getDescriptorsRotateInvariant(const std::vector<ImagePoint>& points, const int gaussKernelRadius, const BorderEffectType borderEffect) const
{
	const auto gradX = conv(KernelsFactory::sobelGradientXKernel(), borderEffect);
	const auto gradY = conv(KernelsFactory::sobelGradientYKernel(), borderEffect);
	const auto extraGaussKernelRadius = gaussKernelRadius * 2;
	const auto extraKernel = KernelsFactory::gaussKernel(extraGaussKernelRadius, GaussKernelType::FULL);
	auto descriptors = std::vector<Descriptor>();
	for (auto point : points) {
		auto angles = getPointMaxGradientAngles(point, extraGaussKernelRadius, gradX, gradY, extraKernel, borderEffect);
		for (auto angle : angles) {
			Descriptor descriptor(point.getX(), point.getY(), angle);
			const auto netStep = int(ceil(gaussKernelRadius * 2 / double(descriptor.getSize())));
			auto cosAngle = cos(angle);
			auto sinAngle = sin(angle);
			for (auto i = descriptor.getX() - extraGaussKernelRadius, kernel_i = 0; i < descriptor.getX() + extraGaussKernelRadius; ++i, ++kernel_i)
				for (auto j = descriptor.getY() - extraGaussKernelRadius, kernel_j = 0; j < descriptor.getY() + extraGaussKernelRadius; ++j, ++kernel_j) {
					const auto dx = gradX.getValue(i, j, borderEffect);
					const auto dy = gradY.getValue(i, j, borderEffect);
					const auto gradAngleToAdd = ImageHelper::getNormalizedAngle(atan2(dy, dx) - angle);
					const auto gradLength = sqrt(dx * dx + dy * dy) * extraKernel.get(kernel_i, kernel_j);
					auto windowRotatedX = int(round((i - descriptor.getX()) * cosAngle - (j - descriptor.getY()) * sinAngle));
					auto windowRotatedY = int(round((i - descriptor.getX()) * sinAngle + (j - descriptor.getY()) * cosAngle));
					if (windowRotatedX < -extraGaussKernelRadius || windowRotatedX > -1 || windowRotatedY < -extraGaussKernelRadius || windowRotatedY > -1) {
						continue;
					}
					descriptor.addValueOnAngleWithIndex((windowRotatedX + extraGaussKernelRadius) / netStep, (windowRotatedY + extraGaussKernelRadius) / netStep, gradAngleToAdd, gradLength);
				}
			descriptor.normalize();
			descriptors.emplace_back(std::move(descriptor));
		}
	}
	return descriptors;
}
Beispiel #19
0
void Discover::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
    QProcess *process = static_cast<QProcess*>(sender());

    // If the process was killed because guhd is shutting down...we dont't care any more about the result
    if (m_aboutToQuit)
        return;

    // Discovery
    if (process == m_discoveryProcess) {

        qCDebug(dcWallbe()) << "Discovery process finished";

        process->deleteLater();
        m_discoveryProcess = 0;

        QList<DeviceDescriptor> deviceDescriptors;
        if (exitCode != 0 || exitStatus != QProcess::NormalExit) {
            qCWarning(dcWallbe()) << "Network scan error:" << process->readAllStandardError();
            emit devicesDiscovered(deviceDescriptors);
            return;
        }

        QByteArray outputData = process->readAllStandardOutput();
        foreach (const Host &host, parseProcessOutput(outputData)) {
            DeviceDescriptor descriptor(wallbeEcoDeviceClassId, host.hostName(), host.address());
            descriptor.setParams( ParamList() << Param(wallbeEcoIpParamTypeId, host.address()));
            deviceDescriptors.append(descriptor);
        }
Object::Pointer SavePerspectiveHandler::Execute(const SmartPointer<const berry::ExecutionEvent>& event)
{

  IWorkbenchWindow::Pointer activeWorkbenchWindow = HandlerUtil::GetActiveWorkbenchWindow(event);
  if (activeWorkbenchWindow.IsNotNull())
  {
    IWorkbenchPage::Pointer page = activeWorkbenchWindow->GetActivePage();
    if (page.IsNotNull())
    {
      PerspectiveDescriptor::Pointer descriptor(page->GetPerspective().Cast<PerspectiveDescriptor>());
      if (descriptor.IsNotNull())
      {
        if (descriptor->IsSingleton())
        {
          SaveSingleton(page);
        }
        else
        {
          SaveNonSingleton(page, descriptor);
        }
      }
    }
  }
  return Object::Pointer();
}
ApplicationInformationSection::ApplicationInformationSection(const uint8_t * const buffer) : LongCrcSection(buffer)
{
	commonDescriptorsLength = sectionLength > 10 ? DVB_LENGTH(&buffer[8]) : 0;

	uint16_t pos = 10;
	uint16_t bytesLeft = sectionLength > 11 ? sectionLength - 11 : 0;
	uint16_t loopLength = 0;
	uint16_t bytesLeft2 = commonDescriptorsLength;

	while (bytesLeft >= bytesLeft && bytesLeft2 > 1 && bytesLeft2 >= (loopLength = 2 + buffer[pos+1])) {
		descriptor(&buffer[pos], SCOPE_MHP);
		pos += loopLength;
		bytesLeft -= loopLength;
		bytesLeft2 -= loopLength;
	}

	if (!bytesLeft2 && bytesLeft > 1) {
		bytesLeft2 = applicationLoopLength = DVB_LENGTH(&buffer[pos]);
		pos+=2;
		bytesLeft-=2;
		while (bytesLeft >= bytesLeft2 && bytesLeft2 > 8 && bytesLeft2 >= (loopLength = 8 + DVB_LENGTH(&buffer[pos+7]))) {
			applicationInformation.push_back(new ApplicationInformation(&buffer[pos]));
			pos += loopLength;
			bytesLeft -= loopLength;
			bytesLeft2 -= loopLength;
		}
	}
	else
		applicationLoopLength = 0;
}
Beispiel #22
0
TEST_F(CustomElementRegistryTest,
       collectCandidates_shouldOnlyIncludeCandidatesMatchingDescriptor) {
  CustomElementDescriptor descriptor("hello-world", "hello-world");

  // Does not match: namespace is not HTML
  Element* elementA = CreateElement("hello-world")
                          .inDocument(&document())
                          .inNamespace("data:text/date,1981-03-10");
  // Matches
  Element* elementB = CreateElement("hello-world").inDocument(&document());
  // Does not match: local name is not hello-world
  Element* elementC = CreateElement("button")
                          .inDocument(&document())
                          .withIsAttribute("hello-world");
  document().documentElement()->appendChild(elementA);
  elementA->appendChild(elementB);
  elementA->appendChild(elementC);

  registry().addCandidate(elementA);
  registry().addCandidate(elementB);
  registry().addCandidate(elementC);

  HeapVector<Member<Element>> elements;
  collectCandidates(descriptor, &elements);

  EXPECT_EQ(1u, elements.size())
      << "only one candidates should have been found";
  EXPECT_EQ(elementB, elements[0])
      << "the matching element should have been found";
}
TEST(CustomElementDescriptorTest,
    matches_autonomous_shouldNotMatchCustomizedBuiltInElement)
{
    CustomElementDescriptor descriptor("a-b", "a-b");
    Element* element = CreateElement("futuretag").withIsAttribute("a-b");
    EXPECT_FALSE(descriptor.matches(*element));
}
Beispiel #24
0
JNIEXPORT jint JNICALL
Java_nl_clockwork_virm_server_detect_painting_PaintingDetector_nativeDetect(JNIEnv* env, jobject obj, jint rows, jint cols, jobjectArray mat) {
	cv::Mat descriptor(rows, cols, CV_8UC1);
	for (unsigned int i = 0; i < rows; i++) {
	     jintArray rowArray = (jintArray)env->GetObjectArrayElement(mat, i);
	     jint* row = env->GetIntArrayElements(rowArray, 0);
	     for (unsigned int j = 0; j < cols; j++) {
	    	 descriptor.row(i).col(j) = row[j];
	     }
	}

	int bestMatch = -1;
	int bestMatchMatches = 0;
	int position = 0;
	for (auto trainedDescriptor : trainedDescriptors) {
		matcher->match(descriptor, trainedDescriptor, matches);

		unsigned int goodMatches = 0;
		for (auto match : matches) {
			if (match.distance < threshold) {
				goodMatches++;
			}
		}

		if ((bestMatch == -1 || goodMatches > bestMatchMatches) && goodMatches > minGoodMatches) {
			bestMatch = position;
			bestMatchMatches = goodMatches;
		}

		position++;
	}

	return bestMatch;
}
Beispiel #25
0
static void chol_driver(blas_idx_t n_global)
{
    auto grid = std::make_shared<blacs_grid_t>();    
    auto a    = make_tridiagonal(grid, n_global);    

    // Compute Cholesky factorization of A in-place
    char       uplo     ='U';
    blas_idx_t ia       = 1, ja = 1, info;

    MPI_Barrier (MPI_COMM_WORLD);
    double t0 = MPI_Wtime();
    pdpotrf_ (uplo, n_global, a->local_data(), ia, ja, a->descriptor(), info);
    assert(info == 0);

    double t1 = MPI_Wtime() - t0;
  
    double t_glob;
    MPI_Reduce(&t1, &t_glob, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);

    if (grid->iam() == 0) 
    {
        double gflops = potrf_flops(n_global)/t_glob/grid->nprocs();
        printf("\n"
            "MATRIX CHOLESKY FACTORIZATION BENCHMARK SUMMARY\n"
            "===============================================\n"
            "N = %d\tNP = %d\tNP_ROW = %d\tNP_COL = %d\n"
            "Time for PxPOTRF = %10.7f seconds\tGflops/Proc = %10.7f\n",
            n_global, grid->nprocs(), grid->nprows(), grid->npcols(), 
            t_glob, gflops);fflush(stdout);
    }
}
/*!
  \internal
  Slot to receive QSocketNotifier activation from data arriving on the socket
  */
void LocalSocketListener::receiveMessage()
{
    int resultCode;
    char msg[1024];
    QByteArray bytes;
    int clientDescriptor;
    struct sockaddr_un clientAddress;
    socklen_t addrSize = sizeof(clientAddress);

    clientDescriptor = ::accept( descriptor(), (struct sockaddr*)&clientAddress, &addrSize );
    if ( clientDescriptor == -1 )
    {
        qWarning() << "Could not accept connection" << strerror( errno );
        return;
    }

    ::memset( msg, '\0', 1024 );
    while (( resultCode = ::read( clientDescriptor, msg, 1023 )))
    {
        bytes.append( msg );
        ::memset( msg, '\0', 1024 );
    }
    ::close( clientDescriptor );
    QString command( (QChar*)bytes.constData(), bytes.size() / 2 );
    emit commandReceived( command );
}
Beispiel #27
0
void CCrashHandler::Init ( const SString& strInServerPath )
{
    SString strServerPath = strInServerPath;
    if ( strServerPath == "" )
        strServerPath = GetSystemCurrentDirectory();
    ms_strDumpPath = PathJoin( strServerPath, SERVER_DUMP_PATH );

    // Set a global filter
    #ifdef WIN32
        SetCrashHandlerFilter ( HandleExceptionGlobal );
    #else
        // Prepare initial dumpfile name
        time_t pTime = time( NULL );
        struct tm* tm = localtime( &pTime );
        SString strFilename( "server_%s_%04d%02d%02d_%02d%02d.dmp",
                                        MTA_DM_BUILDTAG_LONG,
                                        tm->tm_year + 1900,
                                        tm->tm_mon + 1,
                                        tm->tm_mday,
                                        tm->tm_hour,
                                        tm->tm_min
                                    );
        ms_strDumpPathFilename = PathJoin( ms_strDumpPath, strFilename );
        MakeSureDirExists( ms_strDumpPathFilename );

        #ifdef WITH_BACKTRACE_ONLY
            signal ( SIGSEGV, HandleExceptionGlobal );
        #else
            google_breakpad::MinidumpDescriptor descriptor( ms_strDumpPath );
            static google_breakpad::ExceptionHandler eh( descriptor, NULL, DumpCallback, NULL, true, -1 );
        #endif
    #endif
}
Beispiel #28
0
int main(int argc, char* argv[]) {
  google_breakpad::MinidumpDescriptor descriptor(".");
  google_breakpad::ExceptionHandler eh(descriptor, NULL, DumpCallback,
                                       NULL, true, -1);
  Crash();
  return 0;
}
Beispiel #29
0
void
CSDReader::implementation (DOMElement* element)
throw(CSDReadException)
{
	DOMNodeList* nodeList;
	unsigned int len = 0;
	unsigned int i = 0;

	//
	// dependency
	//
	nodeList = element->getElementsByTagName(X("dependency"));
	len = nodeList->getLength();
    for (i = 0; i < len; ++i)
    {
        dependency((DOMElement*)(nodeList->item(i)));
    }

	//
	// descriptor
	//
	nodeList = element->getElementsByTagName(X("descriptor"));
	len = nodeList->getLength();
    if(len == 1)
    {
        ccd_file_ = descriptor((DOMElement*)(nodeList->item(0)));
    }
	else if(len > 1)
	{
		NORMAL_ERR( "CSDReader: multiple descriptors" );
	}

	//
	// code
	//
	nodeList = element->getElementsByTagName(X("code"));
	len = nodeList->getLength();
	if(len == 0)
	{
		NORMAL_ERR2( "CSDReader: missing code for ", data_->uuid );
		throw CSDReadException();
	}
    for (i = 0; i < len; ++i)
    {
        code((DOMElement*)(nodeList->item(i)));
    }

	//
	// os
	//
	nodeList = element->getElementsByTagName(X("os"));
	len = nodeList->getLength();
    for (i = 0; i < len; ++i)
    {
        os((DOMElement*)(nodeList->item(i)));
    }

	// more todo
}
Beispiel #30
0
int main(int argc, char *argv[]) {
  google_breakpad::MinidumpDescriptor descriptor("/tmp");
  google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL,
                                       true, -1);
  printf("pid: %d\n", getpid());
  crash();
  return 0;
}