Exemplo n.º 1
0
featureset_ptr Map::query_point(unsigned index, double x, double y) const
{
    if ( index< layers_.size())
    {
        mapnik::layer const& layer = layers_[index];
        try
        {
            double z = 0;
            mapnik::projection dest(srs_);
            mapnik::projection source(layer.srs());
            proj_transform prj_trans(source,dest);
            prj_trans.backward(x,y,z);

            double minx = current_extent_.minx();
            double miny = current_extent_.miny();
            double maxx = current_extent_.maxx();
            double maxy = current_extent_.maxy();

            prj_trans.backward(minx,miny,z);
            prj_trans.backward(maxx,maxy,z);
            double tol = (maxx - minx) / width_ * 3;
            mapnik::datasource_ptr ds = layer.datasource();
            if (ds)
            {
#ifdef MAPNIK_DEBUG
                std::clog << " query at point tol = " << tol << " (" << x << "," << y << ")\n";
#endif
                featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y));
                if (fs)
                    return boost::make_shared<filter_featureset<hit_test_filter> >(fs,
                                                                                   hit_test_filter(x,y,tol));
            }
        }
        catch (...)
        {
#ifdef MAPNIK_DEBUG
            std::clog << "exception caught in \"query_point\"\n";
#endif
        }
    }
    return featureset_ptr();
}
Exemplo n.º 2
0
int main()
{
    std::ifstream src1("src1");
    if (!src1.is_open()) {													// checking
   	    	std::cout << "Error in openning file " <<std::endl;
   	    	return -1;
   	  }
    std::ifstream src2("src2");
    if (!src2.is_open()) {													// checking
      	    	std::cout << "Error in openning file " <<std::endl;
      	    	return -1;
      	  }
    std::ofstream dest("dest");
    if (!dest.is_open()) {													// checking
      	    	std::cout << "Error in openning file " <<std::endl;
      	    	return -1;
      	  }

    std::string line_buf;

    while (src1.good() || src2.good())
    {

    		if (src1.good()) {
    			std::getline(src1, line_buf);
    	    	dest << line_buf << " ";
    		}
    		if (src2.good()) {
    			std::getline(src2, line_buf);
    	    	dest << line_buf << " ";
    		}
    		dest << std::endl;
    }

    src1.close();
	src2.close();
	dest.close();

	std::cout << "All done" << std::endl;

    return 0;
}
Exemplo n.º 3
0
/**
 * Handle a netlink message. If this message is a routing table message and it
 * contains the default route, then either:
 *   i) default_gateway is updated with the address of the gateway.
 *   ii) if_index is updated with the interface index for the default route.
 * @param if_index[out] possibly updated with interface index for the default
 *   route.
 * @param default_gateway[out] possibly updated with the default gateway.
 * @param nl_hdr the netlink message.
 */
void MessageHandler(int32_t *if_index,
                    IPV4Address *default_gateway,
                    const struct nlmsghdr *nl_hdr) {
  // Unless RTA_DST is provided, an RTA_GATEWAY or RTA_OIF attribute implies
  // it's the default route.
  IPV4Address gateway;
  int32_t index = Interface::DEFAULT_INDEX;

  bool is_default_route = true;

  // Loop over the attributes looking for RTA_GATEWAY and/or RTA_DST
  const rtmsg *rt_msg = reinterpret_cast<const rtmsg*>(NLMSG_DATA(nl_hdr));
  if (rt_msg->rtm_family == AF_INET && rt_msg->rtm_table == RT_TABLE_MAIN) {
    int rt_len = RTM_PAYLOAD(nl_hdr);

    for (const rtattr* rt_attr = reinterpret_cast<const rtattr*>(
            RTM_RTA(rt_msg));
         RTA_OK(rt_attr, rt_len);
         rt_attr = RTA_NEXT(rt_attr, rt_len)) {
      switch (rt_attr->rta_type) {
        case RTA_OIF:
          index = *(reinterpret_cast<int32_t*>(RTA_DATA(rt_attr)));
          break;
        case RTA_GATEWAY:
          gateway = IPV4Address(
              reinterpret_cast<const in_addr*>(RTA_DATA(rt_attr))->s_addr);
          break;
        case RTA_DST:
          IPV4Address dest(
              reinterpret_cast<const in_addr*>(RTA_DATA(rt_attr))->s_addr);
          is_default_route = dest.IsWildcard();
          break;
      }
    }
  }

  if (is_default_route &&
      (!gateway.IsWildcard() || index != Interface::DEFAULT_INDEX)) {
    *default_gateway = gateway;
    *if_index = index;
  }
}
Exemplo n.º 4
0
void mdeath::boomer(monster *z)
{
    std::string explode = string_format(_("a %s explode!"), z->name().c_str());
    sounds::sound(z->pos(), 24, explode);
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            tripoint dest( z->posx() + i, z->posy() + j, z->posz() );
            g->m.bash( dest, 10 );
            g->m.add_field( dest, fd_bile, 1, 0 );
            int mondex = g->mon_at( dest );
            if (mondex != -1) {
                g->zombie(mondex).stumble(false);
                g->zombie(mondex).moves -= 250;
            }
        }
    }
    if (rl_dist( z->pos(), g->u.pos() ) == 1) {
        g->u.add_env_effect("boomered", bp_eyes, 2, 24);
    }
}
Exemplo n.º 5
0
nglString nuiSocket::GetDesc() const
{
  nuiNetworkHost source(0, 0, nuiNetworkHost::eTCP);
  nuiNetworkHost dest(0, 0, nuiNetworkHost::eTCP);
  GetLocalHost(source);
  GetDistantHost(dest);
  uint32 S = source.GetIP();
  uint32 D = dest.GetIP();
  uint8* s = (uint8*)&S;
  uint8* d = (uint8*)&D;

  nglString str;
  str.CFormat("%5d: %s - from %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d [ %s ]",
                      GetSocket(),
                      IsNonBlocking() ? "NoBlock" : "Block  ",
                      s[0], s[1], s[2], s[3], ntohs(source.GetPort()),
                      d[0], d[1], d[2], d[3], ntohs(dest.GetPort()),
                      mName.GetChars());
  return str;
}
Exemplo n.º 6
0
 void TileSetImage::draw(GMSpriteBatch* s, const GMRect2D &_dest, double radian, int gid) const{
     if(!gid) return;
     gid -= m_parent->getFirstGit();
     GMRect2D dest(_dest.x, _dest.y, _dest.width, _dest.height);
     if(radian==0.5*M_PI || radian == -0.5*M_PI){
         dest.width = _dest.height;
         dest.height = _dest.width;
     }
     if(radian == -0.5*M_PI){
         dest.y+=dest.width;
     }else if(radian == 0.5*M_PI){
         dest.x+=dest.height;
     }
     GMRect2D src(
                  (gid%m_TileXNum)*m_parent->getTileWidth(),
                  (gid/m_TileXNum)*m_parent->getTileHeight(),
                  m_parent->getTileWidth(),
                  m_parent->getTileHeight());
     s->draw(m_tex, dest, src, GMColor::White, radian, 0, GMSpriteFlipHorizontally);
 }
Exemplo n.º 7
0
/* Make something local to an image descriptor ... pass in a constructor
 * and a destructor, plus three args.
 */
void *
im_local( IMAGE *im, 
	im_construct_fn cons, im_callback_fn dest, void *a, void *b, void *c )
{
	void *obj;

	if( !im ) {
		im_error( "im_local", "%s", _( "NULL image descriptor" ) );
		return( NULL );
	}

        if( !(obj = cons( a, b, c )) )
                return( NULL );
        if( im_add_close_callback( im, (im_callback_fn) dest, obj, a ) ) {
                dest( obj, a );
                return( NULL );
        }
 
        return( obj );
}
Exemplo n.º 8
0
bool Arena::HookHandleRepop(Player * plr)
{
	// 559, 562, 572
	/*
	A start
	H start
	Repop
	572 1295.322388 1585.953369 31.605387
	572 1277.105103 1743.956177 31.603209
	572 1286.112061 1668.334961 39.289127

	562 6184.806641 236.643463 5.037095
	562 6292.032227 287.570343 5.003577
	562 6241.171875 261.067322 0.891833

	559 4085.861328 2866.750488 12.417445
	559 4027.004883 2976.964844 11.600499
	559 4057.042725 2918.686523 13.051933
	*/
	LocationVector dest(0,0,0,0);
	switch(m_mapMgr->GetMapId())
	{
		/* loraedeon */
	case 572: {
			dest.ChangeCoords(1286.112061f, 1668.334961f, 39.289127f);
		}break;

		/* blades edge arena */
	case 562: {
			dest.ChangeCoords(6241.171875f, 261.067322f, 0.891833f);
		}break;

		/* nagrand arena */
	case 559: {
			dest.ChangeCoords(4057.042725f, 2918.686523f, 13.051933f);
		}break;
	}

	plr->SafeTeleport(m_mapMgr->GetMapId(), m_mapMgr->GetInstanceID(), dest);
	return true;
}
Exemplo n.º 9
0
void
BasicCompositor::EndFrame()
{
  // Pop aClipRectIn/bounds rect
  mRenderTarget->mDrawTarget->PopClip();

  if (gfxPrefs::WidgetUpdateFlashing()) {
    float r = float(rand()) / RAND_MAX;
    float g = float(rand()) / RAND_MAX;
    float b = float(rand()) / RAND_MAX;
    // We're still clipped to mInvalidRegion, so just fill the bounds.
    mRenderTarget->mDrawTarget->FillRect(ToRect(mInvalidRegion.GetBounds()),
                                         ColorPattern(Color(r, g, b, 0.2f)));
  }

  // Pop aInvalidregion
  mRenderTarget->mDrawTarget->PopClip();

  // Note: Most platforms require us to buffer drawing to the widget surface.
  // That's why we don't draw to mDrawTarget directly.
  RefPtr<SourceSurface> source = mRenderTarget->mDrawTarget->Snapshot();
  RefPtr<DrawTarget> dest(mTarget ? mTarget : mDrawTarget);

  nsIntPoint offset = mTarget ? mTargetBounds.TopLeft() : nsIntPoint();

  // The source DrawTarget is clipped to the invalidation region, so we have
  // to copy the individual rectangles in the region or else we'll draw blank
  // pixels.
  nsIntRegionRectIterator iter(mInvalidRegion);
  for (const IntRect *r = iter.Next(); r; r = iter.Next()) {
    dest->CopySurface(source,
                      IntRect(r->x - mInvalidRect.x, r->y - mInvalidRect.y, r->width, r->height),
                      IntPoint(r->x - offset.x, r->y - offset.y));
  }
  if (!mTarget) {
    mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
  }

  mDrawTarget = nullptr;
  mRenderTarget = nullptr;
}
Exemplo n.º 10
0
int
gams::platforms::BasePlatform::move(const pose::Position & target,
    const pose::PositionBounds &bounds)
{
  int result = 0;

  pose::Position current(get_location());

  pose::Position dest(get_frame(), 0, 0);
  dest.from_container(self_->agent.dest);

  pose::Position gps_target(get_frame(), target);

  /**
   * if we are not paused, we are not already at the target,
   * and we are either not moving or the target is different
   * from the existing move location, then set status to
   * moving and return 1(moving to the new location)
   **/
  if (!*status_.paused_moving && !(gps_target == current) &&
     (!*status_.moving || !(gps_target == dest)))
  {
    self_->agent.source = self_->agent.location;
    gps_target.to_container(self_->agent.dest);

    result = 1;
    status_.moving = 1;
  }
  /**
   * otherwise, if we are approximately at the target location,
   * change status and paused to 0 and return 2(arrived)
   **/
  else if (bounds.check_position(target, current))
  {
    status_.moving = 0;
    status_.paused_moving = 0;
    result = 2;
  }

  return result;
}
Exemplo n.º 11
0
TUint8 *cstrFromUtf16(const TText *aUtf16, TInt aLength, TInt &outputBytes)
{
	TPtrC16 src(aUtf16, aLength);
	
	TPtr8 nulldest(0,0);

	TInt len = CnvUtfConverter::ConvertFromUnicodeToUtf8(nulldest, src);
	if(len<0)
		{
		dbg << Log::Indent() << "ConvertFromUnicodeToUtf8 failed" << Log::Endl();
		FatalError();
		}
	
	TUint8 *buf = new TUint8[len+1];
	TPtr8 dest(buf, len);

	(void) CnvUtfConverter::ConvertFromUnicodeToUtf8(dest, src);
	buf[len] = 0; // Add NUL termination in case it is used with windows APIs
	outputBytes = dest.Length();
	return buf;
}
Exemplo n.º 12
0
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool /*forceDest*/)
{
    float x, y, z;
    _sourceUnit->GetPosition(x, y, z);

    if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
        return false;

    G3D::Vector3 dest(destX, destY, destZ);
    SetEndPosition(dest);
    SetActualEndPosition(GetEndPosition());

    G3D::Vector3 start(x, y, z);
    SetStartPosition(start);

    TC_LOG_DEBUG("maps", "++ PathGenerator::CalculatePath() for %u\n", _sourceUnit->GetGUIDLow());

    BuildShortcut();
    _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    return true;
}
Exemplo n.º 13
0
const math::matrix<4> math::frustum(float l, float r, float b, float t, float n, float f)
{
    float n2 = 2 * n;
    float rl = r - l;
    float tb = t - b;
    float fn = f - n;

    matrix<4> dest = zero;

    dest(0,0) = n2/rl;
    dest(0,2) = (r+l)/rl;
    dest(1,1) = n2/tb;
    dest(1,2) = (t+b)/tb;
    dest(2,2) = -(f+n)/fn;
    dest(2,3) = -2*f*n/fn;
    dest(3,2) = -1;

    return dest;
}
Exemplo n.º 14
0
void Stoneship::telescopeLighthouseDraw() {
	if (_telescopePosition > 1137 && _telescopePosition < 1294) {
		uint16 imageId = _telescopeLighthouseOff;

		if (_state.generatorPowerAvailable == 1 && _telescopeLighthouseState)
			imageId = _telescopeLighthouseOn;

		Common::Rect src(1205, 0, 1205 + 131, 112);
		src.clip(Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112));
		src.translate(-1205, 0);
		src.clip(131, 112);

		Common::Rect dest(_telescopePosition, 0, _telescopePosition + 112, 112);
		dest.clip(Common::Rect(1205, 0, 1205 + 131, 112));
		dest.translate(-_telescopePosition, 0);
		dest.clip(112, 112);
		dest.translate(222, 112);

		_vm->_gfx->copyImageSectionToScreen(imageId, src, dest);
	}
}
Exemplo n.º 15
0
bool FileEntry::Extract(const StringRef& outDir) const
{
	auto path = Path::Combine(outDir, mPath);
	Directory::CreateDirectoryForFile(path);
	FileStream dest(path, FileOpenMode::DestoryWriteOrCreate, FileDataType::Binary);
	if (!dest.IsOpen())
	{
		Log::FormatError("Cannot create {}", path);
		return false;
	}

	auto readStream = Read(FileDataType::Binary);
	auto writeSize = readStream->CopyTo(dest);
	auto extractSize = ExtractedSize();
	if (writeSize!= extractSize)
	{
		Log::FormatError("Cannot Extract {}", path);
		return false;
	}
	return true;
}
Exemplo n.º 16
0
void ModEditWindow::CopyFiles(wxWindow *window, wxArrayString files, wxString destDir)
{
	for (wxArrayString::const_iterator iter = files.begin(); iter != files.end(); ++iter)
	{
		wxFileName source (*iter);
		wxString fileName = source.GetFullName();
		wxFileName dest(Path::Combine(destDir, fileName));
		if (wxFileName::DirExists(*iter))
		{
			// TODO make the file copy task copy the file list all in one go.
			FileCopyTask *task = new FileCopyTask(*iter, dest.GetFullPath());
			TaskProgressDialog dlg(window);
			dlg.ShowModal(task);
			delete task;
		}
		else
		{
			wxCopyFile(*iter, dest.GetFullPath());
		}
	}
}
Exemplo n.º 17
0
        value snow_iosrc_file_read(value _handle, value _dest, value _size, value _maxnum) {

            snow::io::iosrc_file* iosrc = snow::from_hx<snow::io::iosrc_file>( _handle );
            QuickVec<unsigned char> buffer;

            if( iosrc ) {

                if(!val_is_null(_dest)) {

                    ByteArray dest(_dest);

                    int res = snow::io::read(iosrc->file_source, dest.Bytes(), val_int(_size), val_int(_maxnum));

                    return alloc_int(res);
                }

            } //object from hx

            return alloc_int(-1);

        } DEFINE_PRIM(snow_iosrc_file_read, 4);
Exemplo n.º 18
0
void CPixmap::toBlackAndWhite() {
    m_effects.push_back(CEffect::BlackAndWhite);
    QImage img = this->toImage();
    QImage dest(img.size(), img.format());
    QColor pixel;
    for(int x=0; x<img.width(); x++) {
        for (int y=0; y<img.height(); y++) {
            pixel = img.pixel(x, y);
            unsigned int average = (pixel.green()+ pixel.red() + pixel.blue()) / 3;
            if(average > 127)
                average = 255;
            else
                average = 0;
            pixel.setGreen(average);
            pixel.setBlue(average);
            pixel.setRed(average);
            dest.setPixel(x,y,pixel.rgb());
        }
    }
    updateImage(dest);
}
Exemplo n.º 19
0
//==============================================================================
string stringarray::joinintostring (const string& separator, int start, int numbertojoin) const
{
    const int last = (numbertojoin < 0) ? size()
                                        : std::min (size(), start + numbertojoin);

    if (start < 0)
        start = 0;

    if (start >= last)
        return string::empty;

    if (start == last - 1)
        return strings.getreference (start);

    const size_t separatorbytes = separator.getcharpointer().sizeinbytes() - sizeof (string::charpointertype::chartype);
    size_t bytesneeded = separatorbytes * (size_t) (last - start - 1);

    for (int i = start; i < last; ++i)
        bytesneeded += strings.getreference(i).getcharpointer().sizeinbytes() - sizeof (string::charpointertype::chartype);

    string result;
    result.preallocatebytes (bytesneeded);

    string::charpointertype dest (result.getcharpointer());

    while (start < last)
    {
        const string& s = strings.getreference (start);

        if (! s.isempty())
            dest.writeall (s.getcharpointer());

        if (++start < last && separatorbytes > 0)
            dest.writeall (separator.getcharpointer());
    }

    dest.writenull();

    return result;
}
Exemplo n.º 20
0
    void AiCombat::buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target)
    {
        Ogre::Vector3 newPathTarget = Ogre::Vector3(target.getRefData().getPosition().pos);

        float dist;

        if(!mPathFinder.getPath().empty())
        {
            ESM::Pathgrid::Point lastPt = mPathFinder.getPath().back();
            Ogre::Vector3 currPathTarget(PathFinder::MakeOgreVector3(lastPt));
            dist = (newPathTarget - currPathTarget).length();
        }
        else dist = 1e+38F; // necessarily construct a new path

        float targetPosThreshold = (actor.getCell()->getCell()->isExterior())? 300.0f : 100.0f;

        //construct new path only if target has moved away more than on [targetPosThreshold]
        if(dist > targetPosThreshold)
        {
            ESM::Position pos = actor.getRefData().getPosition();

            ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos));

            ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(newPathTarget));

            if(!mPathFinder.isPathConstructed())
                mPathFinder.buildPath(start, dest, actor.getCell(), false);
            else
            {
                PathFinder newPathFinder;
                newPathFinder.buildPath(start, dest, actor.getCell(), false);

                if(!mPathFinder.getPath().empty())
                {
                    newPathFinder.syncStart(mPathFinder.getPath());
                    mPathFinder = newPathFinder;
                }
            }
        }
    }
Exemplo n.º 21
0
bool SimpleWater::initialize()
{
	try {
		Ogre::Plane waterPlane(Ogre::Vector3::UNIT_Y, 0);

		Ogre::Real farClipDistance = mCamera.getFarClipDistance();
		float textureSize = 10.0f;
		float planeSize = (farClipDistance + textureSize) * 2;

		// create a water plane/scene node
		Ogre::MeshManager::getSingleton().createPlane("SimpleWaterPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, waterPlane, planeSize, planeSize, 5, 5, true, 1, planeSize / textureSize, planeSize / textureSize, Ogre::Vector3::UNIT_Z);

		mWaterNode = mSceneMgr.getRootSceneNode()->createChildSceneNode("water");
		mWaterBobbingNode = mWaterNode->createChildSceneNode();

		mWaterEntity = mSceneMgr.createEntity("water", "SimpleWaterPlane");
		mWaterEntity->setMaterialName("/global/environment/water/ocean");
		//Render the water very late on, so that any transparent entity which is half submerged is already rendered.
		mWaterEntity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
		mWaterEntity->setCastShadows(false);
		mWaterEntity->setQueryFlags(MousePicker::CM_NATURE);

		mWaterBobbingNode->attachObject(mWaterEntity);

		mRenderTargetListener = new WaterAdjustRenderTargetListener(mWaterNode, textureSize, textureSize);
		mMainRenderTarget.addListener(mRenderTargetListener);

		Ogre::ControllerFunctionRealPtr func(OGRE_NEW Ogre::WaveformControllerFunction(Ogre::WFT_SINE, 0, 0.1));
		Ogre::ControllerValueRealPtr dest(OGRE_NEW NodeAnimator(*mWaterBobbingNode, Ogre::Vector3(0, 1, 0)));
		Ogre::ControllerManager& cm = Ogre::ControllerManager::getSingleton();
		mWaterBobbingController = cm.createController(cm.getFrameTimeSource(), dest, func);

		return true;
	} catch (const std::exception& ex) {
		S_LOG_FAILURE("Error when creating simple water." << ex);
		return false;
	}

}
Exemplo n.º 22
0
UVector *AlphabeticIndex::firstStringsInScript(UErrorCode &status) {
    if (U_FAILURE(status)) {
        return NULL;
    }
    LocalPointer<UVector> dest(new UVector(status), status);
    if (U_FAILURE(status)) {
        return NULL;
    }
    dest->setDeleter(uprv_deleteUObject);
    // Fetch the script-first-primary contractions which are defined in the root collator.
    // They all start with U+FDD1.
    UnicodeSet set;
    collatorPrimaryOnly_->internalAddContractions(0xFDD1, set, status);
    if (U_FAILURE(status)) {
        return NULL;
    }
    if (set.isEmpty()) {
        status = U_UNSUPPORTED_ERROR;
        return NULL;
    }
    UnicodeSetIterator iter(set);
    while (iter.next()) {
        const UnicodeString &boundary = iter.getString();
        uint32_t gcMask = U_GET_GC_MASK(boundary.char32At(1));
        if ((gcMask & (U_GC_L_MASK | U_GC_CN_MASK)) == 0) {
            // Ignore boundaries for the special reordering groups.
            // Take only those for "real scripts" (where the sample character is a Letter,
            // and the one for unassigned implicit weights (Cn).
            continue;
        }
        UnicodeString *s = new UnicodeString(boundary);
        if (s == NULL) {
            status = U_MEMORY_ALLOCATION_ERROR;
            return NULL;
        }
        dest->addElement(s, status);
    }
    return dest.orphan();
}
Exemplo n.º 23
0
void ImageViewWidget::displayImage(cv::Mat3b image, bool scale)
{
    origW = image.cols;
    origH = image.rows;
    QImage dest(image.cols, image.rows, QImage::Format_ARGB32);
    for (int y = 0; y < image.rows; ++y) {
            const cv::Vec3b *srcrow = image[y];
            QRgb *destrow = (QRgb*)dest.scanLine(y);
            for (int x = 0; x < image.cols; ++x) {
                    destrow[x] = qRgba(srcrow[x][2], srcrow[x][1], srcrow[x][0], 255);
            }
    }


    if(scale){
        dest = dest.scaled(size(),Qt::KeepAspectRatio,
                           hq? Qt::SmoothTransformation : Qt::FastTransformation);
    }


    displayImage(dest);
}
void CodeBuffer::copy_code_to(CodeBlob* dest_blob) {
#ifndef PRODUCT
  if (PrintNMethods && (WizardMode || Verbose)) {
    tty->print("done with CodeBuffer:");
    ((CodeBuffer*)this)->print();
  }
#endif //PRODUCT

  CodeBuffer dest(dest_blob);
  assert(dest_blob->content_size() >= total_content_size(), "good sizing");
  this->compute_final_layout(&dest);
  relocate_code_to(&dest);

  // transfer strings and comments from buffer to blob
  dest_blob->set_strings(_strings);

  // Done moving code bytes; were they the right size?
  assert(round_to(dest.total_content_size(), oopSize) == dest_blob->content_size(), "sanity");

  // Flush generated code
  ICache::invalidate_range(dest_blob->code_begin(), dest_blob->code_size());
}
Exemplo n.º 25
0
vector<Point2i> perturb(const vector<Point2i>& src_curve, vector<uint8_t> perturbation,int idx)
{
  auto pt = src_curve[idx];
  auto pt_list = getPointList(perturbation);
  for(auto& pt_elem : pt_list)
  {
    pt_elem.x += pt.x;
    pt_elem.y += pt.y;
  }

  vector<Point2i> dest(src_curve.begin(), src_curve.begin() + idx - 1);
  for(auto& pert : pt_list)
    dest.push_back(pert);
  auto it = src_curve.begin() + idx + 2;
  while(it != src_curve.end())
  {
    dest.push_back(*it);
    it++;
  }

  return dest;
}
// Call with a check to see if we need to deal with the added
// expense of relocation and if we overflow the displacement
// of the quick call instruction.
inline void MacroAssembler::call( address d, relocInfo::relocType rt ) {
#ifdef _LP64
  intptr_t disp;
  // NULL is ok because it will be relocated later.
  // Must change NULL to a reachable address in order to
  // pass asserts here and in wdisp.
  if ( d == NULL )
    d = pc();

  // Is this address within range of the call instruction?
  // If not, use the expensive instruction sequence
  if (is_far_target(d)) {
    relocate(rt);
    AddressLiteral dest(d);
    jumpl_to(dest, O7, O7);
  } else {
    Assembler::call(d, rt);
  }
#else
  Assembler::call( d, rt );
#endif
}
Exemplo n.º 27
0
int KU_User::copySkel()
{
  QDir source(QFile::decodeName(SKELDIR));
  QDir dest(d->HomeDir);
  mode_t mode;

  if (!source.exists()) {
    KMessageBox::error( 0, i18n("Folder %1 does not exist, cannot copy skeleton for %2.", source.absolutePath(), d->Name) );
    return (-1);
  }

  if (!dest.exists()) {
    KMessageBox::error( 0, i18n("Folder %1 does not exist, cannot copy skeleton.", dest.absolutePath()) );
    return (-1);
  }

  mode = umask(0007);
  copyDir(source.absolutePath(), dest.absolutePath(), d->UID, d->GID);
  umask( mode );

  return 0;
}
Exemplo n.º 28
0
int t4p::FinderClass::ReplaceAllMatches(UnicodeString& text) const {
    int matches = 0;

    // no check for ReplaceExpression.isEmpty() allow for empty replacements
    // this allows the user to 'delete' parts of a strin
    if (IsPrepared) {
        UnicodeString replacement = ReplaceExpression;
        RegexMatcher* matcher = NULL;
        UErrorCode error = U_ZERO_ERROR;
        UnicodeString dest(text.length(), ' ', 0);
        int32_t pos = 0;
        if (EXACT == Mode || (REGULAR_EXPRESSION == Mode && ReplaceExpression.isEmpty())) {
            pos = text.indexOf(Expression, 0);
            while (pos >= 0) {
                text.replaceBetween(pos, pos + Expression.length(), replacement);
                pos = text.indexOf(Expression, pos + replacement.length());
                ++matches;
            }
        } else {
            matcher = Pattern->matcher(text, error);
            if (U_SUCCESS(error) && matcher) {
                while (matcher->find()) {
                    if (U_SUCCESS(error)) {
                        matcher->appendReplacement(dest, replacement, error);
                        if (U_SUCCESS(error)) {
                            ++matches;
                        }
                    }
                }
                matcher->appendTail(dest);
                text = dest;
            }
        }
        if (matcher) {
            delete matcher;
        }
    }
    return matches;
}
Exemplo n.º 29
0
bool NzDirectory::Copy(const NzString& sourcePath, const NzString& destPath)
{
	if (sourcePath.IsEmpty() || destPath.IsEmpty())
		return false;

	NzString dirPath(sourcePath);
	NzString dest(NzFile::NormalizePath(destPath));

	if (!Create(destPath, true))
	{
		NazaraError("Unable to create \"" + destPath + '"');
		return false;
	}

	NzDirectory dir(dirPath);
	if (!dir.Open())
	{
		NazaraError("Unable to open \"" + destPath + '"');
		return false;
	}

	while (dir.NextResult(true))
	{
		if (dir.IsResultDirectory())
		{
			if (!Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName()))
				return false;
		}
		else if (!NzFile::Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName()))
		{
			NazaraError("Failed to copy \"" + dir.GetResultPath() + "\" to \"" + dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName() + '"');
			return false;
		}
	}

	dir.Close();

	return true;
}
Exemplo n.º 30
0
nglString nuiTCPClient::GetDesc() const
{
  nuiNetworkHost source(0, 0, nuiNetworkHost::eTCP);
  nuiNetworkHost dest(0, 0, nuiNetworkHost::eTCP);
  GetLocalHost(source);
  GetDistantHost(dest);
  uint32 S = source.GetIP();
  uint32 D = dest.GetIP();
  uint8* s = (uint8*)&S;
  uint8* d = (uint8*)&D;

  nglString str;
  str.CFormat("%5d: %s - from %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d | i:%d / o:%d / a:%d / r:%lld / s:%lld| pool: %p%s [ %s ]",
              GetSocket(),
              IsNonBlocking() ? "NoBlock" : "Block  ",
              s[0], s[1], s[2], s[3], ntohs(source.GetPort()),
              d[0], d[1], d[2], d[3], ntohs(dest.GetPort()),
              (int)mIn.GetSize(), (int)mOut.GetSize(), GetAvailable(), mReceived, mSent,
              mpPool, (mpAutoPool?" (auto)":""),
              mName.GetChars());
  return str;
}