Exemplo n.º 1
0
Target Radar::getLockedTarget() {
    return Target(m_target, m_object);
}
void
nsMutationReceiver::ContentRemoved(nsIDocument* aDocument,
                                   nsIContent* aContainer,
                                   nsIContent* aChild,
                                   int32_t aIndexInContainer,
                                   nsIContent* aPreviousSibling)
{
  if (!IsObservable(aChild)) {
    return;
  }

  nsINode* parent = NODE_FROM(aContainer, aDocument);
  if (Subtree() && parent->SubtreeRoot() != RegisterTarget()->SubtreeRoot()) {
    return;
  }
  if (nsAutoMutationBatch::IsBatching()) {
    if (nsAutoMutationBatch::IsRemovalDone()) {
      // This can happen for example if HTML parser parses to
      // context node, but needs to move elements around.
      return;
    }
    if (nsAutoMutationBatch::GetBatchTarget() != parent) {
      return;
    }

    bool wantsChildList = ChildList() && (Subtree() || parent == Target());
    if (wantsChildList || Subtree()) {
      nsAutoMutationBatch::NodeRemoved(aChild);
      nsAutoMutationBatch::UpdateObserver(Observer(), wantsChildList);
    }

    return;
  }

  if (Subtree()) {
    // Try to avoid creating transient observer if the node
    // already has an observer observing the same set of nodes.
    nsMutationReceiver* orig = GetParent() ? GetParent() : this;
    if (Observer()->GetReceiverFor(aChild, false, false) != orig) {
      bool transientExists = false;
      nsCOMArray<nsMutationReceiver>* transientReceivers = nullptr;
      Observer()->mTransientReceivers.Get(aChild, &transientReceivers);
      if (!transientReceivers) {
        transientReceivers = new nsCOMArray<nsMutationReceiver>();
        Observer()->mTransientReceivers.Put(aChild, transientReceivers);
      } else {
        for (int32_t i = 0; i < transientReceivers->Count(); ++i) {
          nsMutationReceiver* r = transientReceivers->ObjectAt(i);
          if (r->GetParent() == orig) {
            transientExists = true;
          }
        }
      }
      if (!transientExists) {
        // Make sure the elements which are removed from the
        // subtree are kept in the same observation set.
        nsMutationReceiver* tr;
        if (orig->Animations()) {
          tr = nsAnimationReceiver::Create(aChild, orig);
        } else {
          tr = nsMutationReceiver::Create(aChild, orig);
        }
        transientReceivers->AppendObject(tr);
      }
    }
  }

  if (ChildList() && (Subtree() || parent == Target())) {
    nsDOMMutationRecord* m =
      Observer()->CurrentRecord(nsGkAtoms::childList);
    if (m->mTarget) {
      // Already handled case.
      return;
    }
    m->mTarget = parent;
    m->mRemovedNodes = new nsSimpleContentList(parent);
    m->mRemovedNodes->AppendElement(aChild);
    m->mPreviousSibling = aPreviousSibling;
    m->mNextSibling = parent->GetChildAt(aIndexInContainer);
  }
  // We need to schedule always, so that after microtask mTransientReceivers
  // can be cleared correctly.
  Observer()->ScheduleForRun();
}
Exemplo n.º 3
0
/*
====================
build
====================
*/
VOID Game::build()
{
    GUARD(Game::build);

    // build the color texture
    Image* image = GNEW(Image);
    CHECK(image);
    image->Width(256);
    image->Height(256);
    image->Depth(1);
    image->PixelFormat(PF_RGBA);
    image->DataType(DT_UNSIGNED_BYTE);
    mColorTexPtr = GNEW(Texture);
    CHECK(mColorTexPtr);
    mColorTexPtr->Load(image);

    // build the color rt
    mColorRTPtr = GNEW(Target(mColorTexPtr.Ptr()));
    CHECK(mColorRTPtr);

    // build the primitive
    mQuadPtr = GNEW(Primitive);
    CHECK(mQuadPtr);
    mQuadPtr->SetType(Primitive::PT_TRIANGLES);

    // set the wvp
    Constant* wvp_constant_ptr = GNEW(Constant);
    CHECK(wvp_constant_ptr);
    wvp_constant_ptr->SetMatrix(Matrix());
    mQuadPtr->SetConstant("gWVP",wvp_constant_ptr);

    // set the color texture
    Constant* texture_constant_ptr = GNEW(Constant);
    CHECK(texture_constant_ptr);
    texture_constant_ptr->SetTexture(mColorTexPtr.Ptr());
    mQuadPtr->SetConstant("gBaseTex",texture_constant_ptr);

    // set the shader
    Str shader_key_name = "shader/default.xml";
    KeyPtr shader_key_ptr = Key::Find(shader_key_name.c_str());
    if(shader_key_ptr == NULL)
    {
        Shader*shader = GNEW(Shader);
        CHECK(shader);
        shader->Load(GLoad(shader_key_name.c_str()));
        shader_key_ptr = GNEW(Key(shader_key_name.c_str(), shader));
        CHECK(shader_key_ptr);
    }
    mKeys.push_back(shader_key_ptr);
    mQuadPtr->SetShader(dynamic_cast<Shader*>(shader_key_ptr->Ptr()),"p0");

    // build the vertex buffer
    F32 x = 0.0f, y = 0.0f, w = 256, h = 256;
    DVT vertexes[] =
    {
        {x,		y,		0,		0,		0},
        {x+w,	y,		0,		1,		0},
        {x+w,	y+h,	0,		1,		1},
        {x,		y+h,	0,		0,		1},
    };
    VertexBufferPtr vb_ptr = GNEW(VertexBuffer);
    CHECK(vb_ptr);
    {
        GDataPtr vd_ptr = GNEW(GData);
        CHECK(vd_ptr);
        vd_ptr->Size(3*sizeof(U32) + 3*sizeof(U8) + sizeof(vertexes));
        U8*data_ptr = (U8*)vd_ptr->Ptr();
        *(U32*)data_ptr = MAKEFOURCC('G','V','B','O');
        data_ptr += sizeof(U32);
        *(U32*)data_ptr = sizeof(vertexes)/sizeof(DVT);
        data_ptr += sizeof(U32);
        *(U32*)data_ptr = sizeof(DVT);
        data_ptr += sizeof(U32);
        *(U8*)data_ptr = 2;
        data_ptr += sizeof(U8);
        *(U8*)data_ptr = VertexBuffer::VT_3F;
        data_ptr += sizeof(U8);
        *(U8*)data_ptr = VertexBuffer::VT_2F;
        data_ptr += sizeof(U8);
        ::memcpy(data_ptr, vertexes, sizeof(vertexes));
        data_ptr += sizeof(vertexes);
        vb_ptr->Load(vd_ptr.Ptr());
    }
    mQuadPtr->SetVertexBuffer(vb_ptr.Ptr());

    // build the index
    const U16 indexes[] = { 3, 0, 2, 2, 0, 1 };
    IndexBufferPtr ib_ptr = GNEW(IndexBuffer);
    CHECK(ib_ptr);
    {
        GDataPtr id_ptr = GNEW(GData);
        CHECK(id_ptr);
        id_ptr->Size(3*sizeof(U32) + sizeof(indexes));
        U8*data_ptr = (U8*)id_ptr->Ptr();
        *(U32*)data_ptr = MAKEFOURCC('G','I','B','O');
        data_ptr += sizeof(U32);
        *(U32*)data_ptr = sizeof(indexes)/sizeof(U16);
        data_ptr += sizeof(U32);
        *(U32*)data_ptr = sizeof(U16);
        data_ptr += sizeof(U32);
        ::memcpy(data_ptr, &indexes[0], sizeof(indexes));
        data_ptr += sizeof(indexes);
        ib_ptr->Load(id_ptr.Ptr());
    }
    mQuadPtr->SetIndexBuffer(ib_ptr.Ptr());

    // build the bounding box
    BoundingBox box;
    box.set(MAX_F32,MAX_F32,MAX_F32,MIN_F32,MIN_F32,MIN_F32);
    for(U32 i = 0; i < sizeof(vertexes)/sizeof(DVTN); i++)box.expand(vertexes[i].point);
    mQuadPtr->SetBox(box);

    UNGUARD;
}
Exemplo n.º 4
0
// Parse SQL Server, Sybase ASE UPDATE statememt
bool SqlParser::ParseSqlServerUpdateStatement(Token *update)
{
	Token *name = GetNextIdentToken(SQL_IDENT_OBJECT);

	if(name == NULL)
		return false;

	Token *set = TOKEN_GETNEXTW("SET");

	if(set == NULL)
	{
		PushBack(name);
		return false;
	}
	
	// Parser list of assignments: c1 = exp1, ...
	while(true)
	{
		Token *col = GetNextIdentToken();

		if(col == NULL)
			break;
		
		Token *equal = TOKEN_GETNEXT('=');

		if(equal == NULL)
			break;

		// Single value or (SELECT c1, c2, ...) can be specified
		Token *open = TOKEN_GETNEXT('(');

		Token *select = NULL;

		// Check for SELECT statement
		if(open != NULL)
		{
			select = GetNextSelectStartKeyword();

			// A subquery used to specify assignment values
			if(select != NULL)
				ParseSelectStatement(select, 0, SQL_SEL_UPDATE_SET, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

			TOKEN_GETNEXT(')');
		}
		else
		{
			Token *exp = GetNextToken();

			if(exp == NULL)
				break;

			ParseExpression(exp);
		}
		
		Token *comma = TOKEN_GETNEXT(',');

		if(comma == NULL)
			break;
	}

	Token *from = NULL;
	Token *from_end = NULL;

	// FROM clause can include inner/outer joins
	ParseSelectFromClause(NULL, false, &from, &from_end, NULL, true, NULL);
        	
    Token *where_ = NULL;
    Token *where_end = NULL;

	// optional WHERE clause
	ParseWhereClause(SQL_STMT_UPDATE, &where_, &where_end, NULL);

	// UPDATE FROM syntax is used
	if(from != NULL)
	{
		// MySQL, MariaDB use syntax UPDATE t1, t2 SET ... WHERE
		if(Target(SQL_MYSQL, SQL_MARIADB))
		{
			Token::Remove(from);

			AppendCopy(name, from, from_end, false);

			Token::Remove(name);
			Token::Remove(from, from_end);
		}
	}

    // Implement CONTINUE handler for NOT FOUND in Oracle
	if(_target == SQL_ORACLE)
		OracleContinueHandlerForUpdate(update);

	// Add statement delimiter if not set when source is SQL Server
	SqlServerAddStmtDelimiter();

	return true;
}
Exemplo n.º 5
0
void
BitmapView::MessageReceived(BMessage *msg)
{
	if (msg->WasDropped() && AcceptsDrops()) {
		// We'll handle two types of drops: those from Tracker and those from ShowImage
		if (msg->what == B_SIMPLE_DATA) {
			int32 actions;
			if (msg->FindInt32("be:actions", &actions) == B_OK) {
				// ShowImage drop. This is a negotiated drag&drop, so send a reply
				BMessage reply(B_COPY_TARGET), response;
				reply.AddString("be:types", "image/jpeg");
				reply.AddString("be:types", "image/png");
				
				msg->SendReply(&reply, &response);
				
				// now, we've gotten the response
				if (response.what == B_MIME_DATA) {
					// Obtain and translate the received data
					uint8 *imagedata;
					ssize_t datasize;
										
					// Try JPEG first
					if (response.FindData("image/jpeg", B_MIME_DATA, 
						(const void **)&imagedata, &datasize) != B_OK) {
						// Try PNG next and piddle out if unsuccessful
						if (response.FindData("image/png", B_PNG_FORMAT, 
							(const void **)&imagedata, &datasize) != B_OK)
							return;
					}
					
					// Set up to decode into memory
					BMemoryIO memio(imagedata, datasize);
					BTranslatorRoster *roster = BTranslatorRoster::Default();
					BBitmapStream bstream;
					
					if (roster->Translate(&memio, NULL, NULL, &bstream, B_TRANSLATOR_BITMAP) == B_OK)
					{
						BBitmap *bmp;
						if (bstream.DetachBitmap(&bmp) != B_OK)
							return;
						SetBitmap(bmp);
						
						if (fConstrainDrops)
							ConstrainBitmap();
						Invoke();
					}
				}
				return;
			}
			
			entry_ref ref;
			if (msg->FindRef("refs", &ref) == B_OK) {
				// Tracker drop
				BBitmap *bmp = BTranslationUtils::GetBitmap(&ref);
				if (bmp) {
					SetBitmap(bmp);
					
					if (fConstrainDrops)
						ConstrainBitmap();
					Invoke();
				}
			}
		}
		return;
	}
	
	switch (msg->what)
	{
		case M_REMOVE_IMAGE: {
			BAlert *alert = new BAlert("Mr. Peeps!", "This cannot be undone. Remove the image?",
										"Remove", "Cancel");
			int32 value = alert->Go();
			if (value == 0) {
				SetBitmap(NULL);
				
				if (Target()) {
					BMessenger msgr(Target());
					
					msgr.SendMessage(new BMessage(M_BITMAP_REMOVED));
					return;
				}
			}
		}
		case M_PASTE_IMAGE:
		{
			PasteBitmap();
			Invoke();
		}
	}
	BView::MessageReceived(msg);
}
Exemplo n.º 6
0
//------------------------------------------------------------------------------
void BSliderEditor::Init()
{
	int bottom = Bottom();
	if (!fModMsg)
	{
		bottom = Bottom();
		fModMsg = new BTextControl(BRect(10, bottom, 190, bottom + 20),
								   "modmsg", "Modification Message: ", "",
								   new BMessage(MSG_SLIDER_SET_MOD_MSG));
		fModMsg->SetDivider(be_plain_font->StringWidth("Modification Message: "));
		AddControl(fModMsg);
	}

	if (!fMinLabel)
	{
		bottom = Bottom();
		fMinLabel = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									 "minlabel", "Left Label: ", "",
									 new BMessage(MSG_SLIDER_SET_LIMIT_LABELS));
		fMinLabel->SetDivider(be_plain_font->StringWidth("Left Label: "));
		AddControl(fMinLabel);
	}

	if (!fMaxLabel)
	{
		bottom = Bottom();
		fMaxLabel = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									 "maxlabel", "Right Label: ", "",
									 new BMessage(MSG_SLIDER_SET_LIMIT_LABELS));
		fMaxLabel->SetDivider(be_plain_font->StringWidth("Right Label: "));
		AddControl(fMaxLabel);
	}

	if (!fMinValue)
	{
		bottom = Bottom();
		fMinValue = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									 "minvalue", "Min Value: ", "",
									 new BMessage(MSG_SLIDER_SET_MIN_VALUE));
		fMinValue->SetDivider(be_plain_font->StringWidth("Min Value: "));
		AddControl(fMinValue);
	}

	if (!fMaxValue)
	{
		bottom = Bottom();
		fMaxValue = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									 "maxvalue", "Max Value: ", "",
									 new BMessage(MSG_SLIDER_SET_MAX_VALUE));
		fMaxValue->SetDivider(be_plain_font->StringWidth("Max Value: "));
		AddControl(fMaxValue);
	}

	if (!fIncrValue)
	{
		bottom = Bottom();
		fIncrValue = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									  "incrvalue", "Increment: ", "",
									  new BMessage(MSG_SLIDER_SET_INCREMENT));
		fIncrValue->SetDivider(be_plain_font->StringWidth("Increment: "));
		AddControl(fMaxValue);
	}

	if (!fOrientation)
	{
		bottom = Bottom();
		fOrientation = new BMenuField(BRect(10, bottom, 190, bottom + 20),
									  "orientation", "Orientation: ",
									  new BPopUpMenu("menu"));
		fOrientation->Menu()->AddItem(new BMenuItem("Horizontal",
									  new BMessage(MSG_SLIDER_SET_ORIENT_HORZ)));
		fOrientation->Menu()->AddItem(new BMenuItem("Vertical",
									  new BMessage(MSG_SLIDER_SET_ORIENT_VERT)));
		AddControl(fOrientation);
	}

	if (!fHashStyle)
	{
		bottom = Bottom();
		fHashStyle = new BMenuField(BRect(10, bottom, 190, bottom + 20),
									"hashstyle", "Hash Marks: ",
									new BMenu("menu"));
		fHashStyle->Menu()->AddItem(new BMenuItem("Top",
									new BMessage(MSG_SLIDER_SET_HASH_TOP_LEFT)));
		fHashStyle->Menu()->AddItem(new BMenuItem("Bottom",
									new BMessage(MSG_SLIDER_SET_HASH_BOTTOM_RIGHT)));
		AddControl(fHashStyle);
	}

	if (!fHashCount)
	{
		bottom = Bottom();
		fHashCount = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									  "hashcount", "Hash Mark Count: ", "",
									  new BMessage(MSG_SLIDER_SET_HASH_COUNT));
		fHashCount->SetDivider(be_plain_font->StringWidth("Hash Mark Count: "));
		AddControl(fHashCount);
	}

	if (!fThumbStyle)
	{
		bottom = Bottom();
		fThumbStyle = new BMenuField(BRect(10, bottom, 190, bottom + 20),
									 "thumbstyle", "Thumb Style: ",
									 new BPopUpMenu("menu"));
		fThumbStyle->Menu()->AddItem(new BMenuItem("Rectangle",
									 new BMessage(MSG_SLIDER_SET_BLOCK_THUMB)));
		fThumbStyle->Menu()->AddItem(new BMenuItem("Triangle",
									 new BMessage(MSG_SLIDER_SET_TRI_THUMB)));
		AddControl(fThumbStyle);
	}

	if (!fBarColor)
	{
		bottom = Bottom();
		fBarColor = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									 "barcolor", "Bar Color: ", "",
									 new BMessage(MSG_SLIDER_SET_BAR_COLOR));
		fBarColor->SetDivider(be_plain_font->StringWidth("Bar Color: "));
		AddControl(fBarColor);
	}

	if (!fUseFillCheck)
	{
		bottom = Bottom();
		fUseFillCheck = new BCheckBox(BRect(10, bottom, 190, bottom + 20),
									  "usefillcolor", "Use Fill Color",
									  new BMessage(MSG_SLIDER_USE_FILL_COLOR));
		AddControl(fUseFillCheck);
	}

	if (!fFillColor)
	{
		bottom = Bottom();
		fFillColor = new BTextControl(BRect(10, bottom, 190, bottom + 20),
									  "fillcolor", "Fill Color: ", "",
									  new BMessage(MSG_SLIDER_SET_FILL_COLOR));
		fFillColor->SetDivider(be_plain_font->StringWidth("Bar Thickness: "));
		AddControl(fFillColor);
	}

	if (!fBarThickness)
	{
		bottom = Bottom();
		fBarThickness = new BTextControl(BRect(10, bottom, 190, bottom + 20),
										 "barthickness", "Bar Thickness: ", "",
										 new BMessage(MSG_SLIDER_SET_THICKNESS));
		fBarThickness->SetDivider(be_plain_font->StringWidth("Bar Thickness: "));
		AddControl(fBarThickness);
	}

	if (!fSnoozeAmount)
	{
		bottom = Bottom();
		fSnoozeAmount = new BTextControl(BRect(10, bottom, 190, bottom + 20),
										 "snoozeamount", "Snooze: ", "",
										 new BMessage(MSG_SLIDER_SET_SNOOZE));
		fSnoozeAmount->SetDivider(be_plain_font->StringWidth("Snooze: "));
		AddControl(fSnoozeAmount);
	}

	if (Target())
	{
		SetThumbStyle(Target()->Style());
	}
}
Exemplo n.º 7
0
void Epetra_Import::Construct_Expert( const Epetra_BlockMap &  targetMap, const Epetra_BlockMap & sourceMap, int NumRemotePIDs, const int * UserRemotePIDs,
				      const int & UserNumExportIDs, const int * UserExportLIDs,  const int * UserExportPIDs)
{
  int i,ierr;
  // Build three ID lists:
  // NumSameIDs - Number of IDs in TargetMap and SourceMap that are identical, up to the first
  //              nonidentical ID.
  // NumPermuteIDs - Number of IDs in SourceMap that must be indirectly loaded but are on this processor.
  // NumRemoteIDs - Number of IDs that are in SourceMap but not in TargetMap, and thus must be imported.
  
  int NumSourceIDs = sourceMap.NumMyElements();
  int NumTargetIDs = targetMap.NumMyElements();
  
  int_type *TargetGIDs = 0;
  if (NumTargetIDs>0) {
    TargetGIDs = new int_type[NumTargetIDs];
    targetMap.MyGlobalElements(TargetGIDs);
  }
  
  int_type * SourceGIDs = 0;
  if (NumSourceIDs>0) {
    SourceGIDs = new int_type[NumSourceIDs];
    sourceMap.MyGlobalElements(SourceGIDs);
  }
  
  int MinIDs = EPETRA_MIN(NumSourceIDs, NumTargetIDs);
    
  NumSameIDs_ = 0;
  for (i=0; i< MinIDs; i++) if (TargetGIDs[i]==SourceGIDs[i]) NumSameIDs_++; else break;
  
  // Find count of Target IDs that are truly remote and those that are local but permuted
  NumPermuteIDs_ = 0;
  NumRemoteIDs_ = 0;
  for (i=NumSameIDs_; i< NumTargetIDs; i++) 
    if (sourceMap.MyGID(TargetGIDs[i])) NumPermuteIDs_++; // Check if Target GID is a local Source GID
    else NumRemoteIDs_++; // If not, then it is remote
     
  // Define remote and permutation lists  
  int_type * RemoteGIDs=0;
  RemoteLIDs_ = 0;
  if (NumRemoteIDs_>0) {
    RemoteLIDs_ = new int[NumRemoteIDs_];
    RemoteGIDs = new int_type[NumRemoteIDs_];
  }
  if (NumPermuteIDs_>0)  {
    PermuteToLIDs_ = new int[NumPermuteIDs_];
    PermuteFromLIDs_ = new int[NumPermuteIDs_];
  }
  
  NumPermuteIDs_ = 0;
  NumRemoteIDs_ = 0;
  for (i=NumSameIDs_; i< NumTargetIDs; i++) {
    if (sourceMap.MyGID(TargetGIDs[i])) {
      PermuteToLIDs_[NumPermuteIDs_] = i;
      PermuteFromLIDs_[NumPermuteIDs_++] = sourceMap.LID(TargetGIDs[i]);
    }
    else {
      //NumRecv_ +=TargetMap.ElementSize(i); // Count total number of entries to receive
      NumRecv_ +=targetMap.MaxElementSize(); // Count total number of entries to receive (currently need max)
      RemoteGIDs[NumRemoteIDs_] = TargetGIDs[i];
      RemoteLIDs_[NumRemoteIDs_++] = i;
    }
  }

  if( NumRemoteIDs_>0 && !sourceMap.DistributedGlobal() )
    ReportError("Warning in Epetra_Import: Serial Import has remote IDs. (Importing to Subset of Target Map)", 1);
  
  // Test for distributed cases
  int * RemotePIDs = 0;
  
  if (sourceMap.DistributedGlobal()) {
    if (NumRemoteIDs_>0)  RemotePIDs = new int[NumRemoteIDs_];
  
#ifdef EPETRA_ENABLE_DEBUG
    int myeq = (NumRemotePIDs==NumRemoteIDs_);
    int globaleq=0;
    sourceMap.Comm().MinAll(&myeq,&globaleq,1);
    if(globaleq!=1) { 
      printf("[%d] UserRemotePIDs count wrong %d != %d\n",sourceMap.Comm().MyPID(),NumRemotePIDs,NumRemoteIDs_);
      fflush(stdout);
      sourceMap.Comm().Barrier();
      sourceMap.Comm().Barrier();
      sourceMap.Comm().Barrier();
      throw ReportError("Epetra_Import: UserRemotePIDs count wrong");
    }
#endif

    if(NumRemotePIDs==NumRemoteIDs_){
      // Since I need to sort these, I'll copy them
      for(i=0; i<NumRemoteIDs_; i++)  RemotePIDs[i] = UserRemotePIDs[i];
    }

    //Get rid of IDs that don't exist in SourceMap
    if(NumRemoteIDs_>0) {
      int cnt = 0;
      for( i = 0; i < NumRemoteIDs_; ++i )
        if( RemotePIDs[i] == -1 ) ++cnt;
      if( cnt ) {
        if( NumRemoteIDs_-cnt ) {
          int_type * NewRemoteGIDs = new int_type[NumRemoteIDs_-cnt];
          int * NewRemotePIDs = new int[NumRemoteIDs_-cnt];
          int * NewRemoteLIDs = new int[NumRemoteIDs_-cnt];
          cnt = 0;
          for( i = 0; i < NumRemoteIDs_; ++i )
            if( RemotePIDs[i] != -1 ) {
              NewRemoteGIDs[cnt] = RemoteGIDs[i];
              NewRemotePIDs[cnt] = RemotePIDs[i];
              NewRemoteLIDs[cnt] = targetMap.LID(RemoteGIDs[i]);
              ++cnt;
            }
          NumRemoteIDs_ = cnt;
          delete [] RemoteGIDs;
          delete [] RemotePIDs;
          delete [] RemoteLIDs_;
          RemoteGIDs = NewRemoteGIDs;
          RemotePIDs = NewRemotePIDs;
          RemoteLIDs_ = NewRemoteLIDs;
          ReportError("Warning in Epetra_Import: Target IDs not found in Source Map (Do you want to import to subset of Target Map?)", 1);
        }
        else { //valid RemoteIDs empty
          NumRemoteIDs_ = 0;
          delete [] RemoteGIDs;
          RemoteGIDs = 0;
          delete [] RemotePIDs;
          RemotePIDs = 0;
        }
      }
    }

    //Sort Remote IDs by processor so DoReverses will work
    Epetra_Util util;
    
    if(targetMap.GlobalIndicesLongLong())
      {
	util.Sort(true,NumRemoteIDs_,RemotePIDs,0,0, 1,&RemoteLIDs_, 1,(long long**)&RemoteGIDs);
      }
    else if(targetMap.GlobalIndicesInt())
      {
	int* ptrs[2] = {RemoteLIDs_, (int*)RemoteGIDs};
	util.Sort(true,NumRemoteIDs_,RemotePIDs,0,0,2,&ptrs[0], 0, 0);
      }
    else
      {
	throw ReportError("Epetra_Import::Epetra_Import: GlobalIndices Internal Error", -1);
      }
    
    // Build distributor & Export lists
    Distor_ = sourceMap.Comm().CreateDistributor();    
    
    NumExportIDs_=UserNumExportIDs;
    ExportLIDs_ = new int[NumExportIDs_];
    ExportPIDs_ = new int[NumExportIDs_];
    for(i=0; i<NumExportIDs_; i++)  {
      ExportPIDs_[i] = UserExportPIDs[i];
      ExportLIDs_[i] = UserExportLIDs[i];
    }

#ifdef HAVE_MPI
    Epetra_MpiDistributor* MpiDistor = dynamic_cast< Epetra_MpiDistributor*>(Distor_);
    bool Deterministic = true;
    if(MpiDistor)
      ierr=MpiDistor->CreateFromSendsAndRecvs(NumExportIDs_,ExportPIDs_,					      
					      NumRemoteIDs_, RemoteGIDs, RemotePIDs,Deterministic);
    else ierr=-10;
#else
    ierr=-20;
#endif
    
    if (ierr!=0) throw ReportError("Error in Epetra_Distributor.CreateFromRecvs()", ierr);   
  }  

  if( NumRemoteIDs_>0 ) delete [] RemoteGIDs;
  if( NumRemoteIDs_>0 ) delete [] RemotePIDs;
  
  if (NumTargetIDs>0) delete [] TargetGIDs;
  if (NumSourceIDs>0) delete [] SourceGIDs;


#ifdef EPETRA_ENABLE_DEBUG
// Sanity check to make sure we got the import right
  Epetra_IntVector Source(sourceMap);
  Epetra_IntVector Target(targetMap);

  for(i=0; i<Source.MyLength(); i++)
    Source[i] = (int) (Source.Map().GID(i) % INT_MAX);
  Target.PutValue(-1);
 
  Target.Import(Source,*this,Insert);
  
  bool test_passed=true;
  for(i=0; i<Target.MyLength(); i++){
    if(Target[i] != Target.Map().GID(i) % INT_MAX) test_passed=false;
  }

  if(!test_passed) {  
    printf("[%d] PROCESSOR has a mismatch... prepearing to crash or hang!\n",sourceMap.Comm().MyPID());
    fflush(stdout);
    sourceMap.Comm().Barrier();
    sourceMap.Comm().Barrier();
    sourceMap.Comm().Barrier();
    throw ReportError("Epetra_Import: ERROR. User provided IDs do not match what an import generates.");
  }
#endif
  
  return;
}
Exemplo n.º 8
0
void
BNavMenu::ResetTargets()
{
	SetTargetForItems(Target());
}
Exemplo n.º 9
0
bool Fluid::perform( Action a, const Target& t )
{

    switch ( a )
    {

        case aPolymorph:

            do
            {
                f_material = (materialClass) Random::randint( m_total );
            }
            while ( Material::data[ f_material ].state != powder
                    && Material::data[ f_material ].state != ooze
                    && Material::data[ f_material ].state != liquid);

            image.val.color = Material::data[ f_material ].color;
            return Item::perform(a, t);


        case aSpMessage:
        {
            String thisplace = "This place";
            Target parent = getTarget(tg_parent);

            if (!!parent)
            {
                thisplace = Grammar::plural(parent, Grammar::det_definite) + " here";
            }

            Message::add(thisplace + " is covered in " + menustring() + ".");
            return true;
        }

        case aCombine:

            if ( equals(t) || t->equals( Target(THIS) ) )
            {
                return true;
            }

            return false;


        case aBeQuaffed:
        {

            if (t->getVal(attrib_visible))
            {
                String adj;

                switch (f_material)
                {
                    case m_blood:
                        adj = "metallic";
                        break;
                    case m_water:
                        adj = "refreshing";
                        break;
                    default:
                        adj = "revolting";
                        break;
                }

                if ( t->istype(tg_player) )
                {
                    Message::add(Grammar::Subject(THIS, Grammar::det_definite) + " taste" + (getVal(attrib_plural) ? " " : "s ") + adj + ".");
                }
                else
                {
                    Message::add(Grammar::Subject(THIS, Grammar::det_definite) + " look" + (getVal(attrib_plural) ? " " : "s ") + adj + ".");
                }

            }

            getTarget(tg_controller)->perform(aAddBill, THIS);

            detach();

            return true;
        }

        default:
            return Item::perform(a, t);
    }

}
Exemplo n.º 10
0
 inline Target lexical_cast_noexcept_d(Source const& arg)
 {
     return lexical_cast_noexcept(arg, Target());
 }
Exemplo n.º 11
0
 inline Target lexical_cast_noexcept_d(CharType const* arg, std::size_t len)
 {
     return lexical_cast_noexcept(arg, len, Target());
 }
Exemplo n.º 12
0
    bool Init()
    {
   //    Vector3f Pos(0.0f, 23.0f, -5.0f);
  //      Vector3f Target(-1.0f, 0.0f, 0.1f);
        Vector3f Pos(0.0f, 24.0f, -38.0f);
        Vector3f Target(0.0f, -0.5f, 1.0f);

        Vector3f Up(0.0, 1.0f, 0.0f);

        m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up);

        if (!m_geomPassTech.Init()) {
            OGLDEV_ERROR("Error initializing the geometry pass technique\n");
            return false;
        }

        if (!m_SSAOTech.Init()) {
            OGLDEV_ERROR("Error initializing the SSAO technique\n");
            return false;
        }

        m_SSAOTech.Enable();
        m_SSAOTech.SetSampleRadius(1.5f);
        Matrix4f PersProjTrans;
        PersProjTrans.InitPersProjTransform(m_persProjInfo);
        m_SSAOTech.SetProjMatrix(PersProjTrans);

        if (!m_lightingTech.Init()) {
            OGLDEV_ERROR("Error initializing the lighting technique\n");
            return false;
        }
        
        m_lightingTech.Enable();
        m_lightingTech.SetDirectionalLight(m_directionalLight);
        m_lightingTech.SetScreenSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        m_lightingTech.SetShaderType(0);
        
        if (!m_blurTech.Init()) {
            OGLDEV_ERROR("Error initializing the blur technique\n");
            return false;
        }                
        
        //if (!m_mesh.LoadMesh("../Content/crytek_sponza/sponza.obj")) {
        if (!m_mesh.LoadMesh("../Content/jeep.obj")) {
            return false;            
        }        
     
        m_mesh.GetOrientation().m_scale = Vector3f(0.05f);
        m_mesh.GetOrientation().m_pos = Vector3f(0.0f, 0.0f, 0.0f);
        m_mesh.GetOrientation().m_rotation = Vector3f(0.0f, 180.0f, 0.0f);
        
        if (!m_quad.LoadMesh("../Content/quad.obj")) {
            return false;
        }
        
        if (!m_gBuffer.Init(WINDOW_WIDTH, WINDOW_HEIGHT, true, GL_RGB32F)) {
            return false;
        }

        if (!m_aoBuffer.Init(WINDOW_WIDTH, WINDOW_HEIGHT, false, GL_R32F)) {
            return false;
        }

        if (!m_blurBuffer.Init(WINDOW_WIDTH, WINDOW_HEIGHT, false, GL_R32F)) {
            return false;
        }
        
#ifndef WIN32
        if (!m_fontRenderer.InitFontRenderer()) {
            return false;
        }
#endif        	      
        return true;
    }
Exemplo n.º 13
0
void FWorldTreeItem::OnDrop(FDragDropPayload& DraggedObjects, UWorld& InWorld, const FDragValidationInfo& ValidationInfo, TSharedRef<SWidget> DroppedOnWidget)
{
	FFolderDropTarget Target(NAME_None);
	return Target.OnDrop(DraggedObjects, InWorld, ValidationInfo, DroppedOnWidget);
}
Exemplo n.º 14
0
FDragValidationInfo FWorldTreeItem::ValidateDrop(FDragDropPayload& DraggedObjects, UWorld& InWorld) const
{
	// Dropping on the world means 'moving to the root' in folder terms
	FFolderDropTarget Target(NAME_None);
	return Target.ValidateDrop(DraggedObjects, InWorld);
}
Exemplo n.º 15
0
//
// Poll
//
// Attempt to trigger this trap
//
Bool TrapObj::Poll()
{
  // Did we find a valid target
  Bool valid = FALSE;

  // Has recharging finished
  if (recharge.Test())
  {
    UnitObj *target;

    // Find an enemy within the configured range
    UnitObjIter::Tactical i
    (
      NULL, UnitObjIter::FilterData(GetTeam(), Relation::ENEMY, Position(), TrapType()->GetDistance())
    );
    
    // Step through each possible target
    while ((target = i.Next()) != NULL)
    {
      // Can this trap trigger on this target
      if (TrapType()->Test(target))
      {
        // Does this trap self destruct
        if (TrapType()->GetSelfDestruct())
        {
          SelfDestruct(TRUE, GetTeam());
          valid = TRUE;
        }

        // Does this trap attach a parasite
        if (TrapType()->GetParasite() && TrapType()->GetParasite()->Infect(target, GetTeam()))
        {
          valid = TRUE;
        }

        // Should we fire a weapon
        if (TrapType()->GetWeaponSpeed() > 0.0F)
        {
          if (GetWeapon())
          {
            Vector pos = Origin();
            pos.y += 20.0f;
            GetWeapon()->SetTarget(Target(pos));
            valid = TRUE;
          }
          else
          {
            LOG_WARN(("Trap %s configured to fire a weapon, but has none!", TypeName()));
          }
        }

        if (valid)
        {
          // Signal team radio that we were triggered
          if (GetTeam())
          {
            // "Trap::Triggered"
            GetTeam()->GetRadio().Trigger(0xA0FF29A5, Radio::Event(this));
          }

          // Signal the target that it has been trapped
          if (target->GetTeam())
          {
            // "Trap::Triggered::Target"
            target->GetTeam()->GetRadio().Trigger(0x3070E869, Radio::Event(target));
          }

          // Start charge time
          recharge.Start(TrapType()->GetChargeTime());
        }

        // Only affect one target for now
        break;
      }
    }
  }

  return (valid);
}
Exemplo n.º 16
0
bool WINAPI getCredmanData(__in PLUID logId, __in mod_pipe * monPipe, __in bool justSecurity)
{
	wostringstream message;
	if(searchCredmanFuncs())
	{
		DWORD credNb = 0;
		PCREDENTIAL * pCredential = NULL;
		DWORD CredIEnumerateFlags = (mod_system::GLOB_Version.dwMajorVersion < 6) ? 0 : CRED_ENUMERATE_ALL_CREDENTIALS;
		NTSTATUS status = (mod_system::GLOB_Version.dwBuildNumber < 8000 ) ? CredIEnumerate(logId, 0, NULL, CredIEnumerateFlags, &credNb, &pCredential) : reinterpret_cast<PCRED_I_ENUMERATE62>(CredIEnumerate)(logId, NULL, CredIEnumerateFlags, &credNb, &pCredential);

		if(NT_SUCCESS(status))
		{
			for(DWORD i = 0; i < credNb; i++)
			{
				wstring Target(pCredential[i]->TargetName);
				wstring ShortTarget = (mod_system::GLOB_Version.dwMajorVersion < 6) ? Target : Target.substr(Target.find_first_of(L'=') + 1);
					
				message << endl;
				if(justSecurity)
					message << L"\t [" << i << L"] " << Target << L'\t';
				else message <<
					L"\t * [" << i << L"] Target   : " << Target << L" / " << (pCredential[i]->TargetAlias ? pCredential[i]->TargetAlias : L"<NULL>") << endl <<
					L"\t * [" << i << L"] Comment  : " << (pCredential[i]->Comment ? pCredential[i]->Comment : L"<NULL>") << endl <<
					L"\t * [" << i << L"] User     : "******"[" << j << L"] ";
							message << descEncryptedCredential(pEncryptedCredential[j], justSecurity, prefix.str());
						}
						SeckPkgFunctionTable->CrediFreeCredentials(dwNbCredentials, pEncryptedCredential);
					}
					else message << L"Error CrediReadDomainCredentials : " << mod_system::getWinError(false, status);
				}
				else
				{
					PENCRYPTED_CREDENTIALW pEncryptedCredential;
					NTSTATUS status = SeckPkgFunctionTable->CrediRead(logId, CREDP_FLAGS_IN_PROCESS, const_cast<wchar_t *>(ShortTarget.c_str()), pCredential[i]->Type, 0, &pEncryptedCredential);
					if(NT_SUCCESS(status))
					{
						message << descEncryptedCredential(pEncryptedCredential, justSecurity);
						CredFree(pEncryptedCredential);
					}
					else message << L"Error CrediRead : " << mod_system::getWinError(false, status);
				}
			}
			CredFree(pCredential);
		}
		else message << L"CredIEnumerate KO : " << mod_system::getWinError(false, status);
	} else message << L"n.a. (credman KO)";
	return sendTo(monPipe, message.str());
}
Exemplo n.º 17
0
Operand* ConstantFolder::HandleCall(CallInstr* callInstr) {
	// A call to an 'undef' operand, or to a null pointer yields 
    // undefined behavior, so we're allowed to do everything we want.
	if(callInstr->TargetOp()->IsUndefinedConstant() ||
	   callInstr->TargetOp()->IsNullConstant()) {
		// We should return 'undef' only if the function returns a value.
		if(callInstr->ResultOp()) {
			return GetUndefined(callInstr->ResultOp());
		}
		else return nullptr;
	}

	// The target must be a reference to a known function.
	auto functionRef = callInstr->TargetOp()->As<FunctionReference>();
	
    if(functionRef == nullptr) {
        return nullptr;
    }

    // First test for intrinsics; we fold them using the stdlib functions.
    if(auto intrinsic = functionRef->Target()->As<Intrinsic>()) {
        return HandleIntrinsic(callInstr, intrinsic);
    }

	// Check if the function is a known standard library function,
	// and try to evaluate it at compile time. Very useful for functions like
	// 'sin', 'cos', 'floor', etc.
	StdlibType functionType = StdlibRecognizer::Recognize(functionRef->Target());

	if(functionType == Stdlib_None) {
        return nullptr;
    }

	// We treat for now only functions from 'math.h'.
	// The functions are evaluated using the implementation
    // provided by the compiler, so note that the results 
    // are dependent on the machine where the program is compiled.
	switch(functionType) {
 		case Stdlib_fabs:  return EvaluateMathOneParam(callInstr, std::fabs);
		case Stdlib_sqrt:  return EvaluateMathOneParam(callInstr, std::sqrt);
		case Stdlib_exp:   return EvaluateMathOneParam(callInstr, std::exp);
		case Stdlib_floor: return EvaluateMathOneParam(callInstr, std::floor);
		case Stdlib_ceil:  return EvaluateMathOneParam(callInstr, std::ceil);
		case Stdlib_log:   return EvaluateMathOneParam(callInstr, std::log);
		case Stdlib_log10: return EvaluateMathOneParam(callInstr, std::log10);
		case Stdlib_sin:   return EvaluateMathOneParam(callInstr, std::sin);
		case Stdlib_asin:  return EvaluateMathOneParam(callInstr, std::asin);
		case Stdlib_cos:   return EvaluateMathOneParam(callInstr, std::cos);
		case Stdlib_acos:  return EvaluateMathOneParam(callInstr, std::acos);
		case Stdlib_tan:   return EvaluateMathOneParam(callInstr, std::tan);
		case Stdlib_atan:  return EvaluateMathOneParam(callInstr, std::atan);

		case Stdlib_abs:   return EvaluateMathOneParamInt(callInstr, std::abs);
        case Stdlib_labs:  return EvaluateMathOneParamLong(callInstr, std::labs);

		case Stdlib_sqrtf:  return EvaluateMathOneParamFloat(callInstr, std::sqrtf);
		case Stdlib_expf:   return EvaluateMathOneParamFloat(callInstr, std::expf); 
		case Stdlib_floorf: return EvaluateMathOneParamFloat(callInstr, std::floorf);
		case Stdlib_ceilf:  return EvaluateMathOneParamFloat(callInstr, std::ceilf);
		case Stdlib_logf:   return EvaluateMathOneParamFloat(callInstr, std::logf); 
		case Stdlib_log10f: return EvaluateMathOneParamFloat(callInstr, std::log10f);
		case Stdlib_sinf:   return EvaluateMathOneParamFloat(callInstr, std::sinf); 
		case Stdlib_asinf:  return EvaluateMathOneParamFloat(callInstr, std::asinf);
		case Stdlib_cosf:   return EvaluateMathOneParamFloat(callInstr, std::cosf); 
		case Stdlib_acosf:  return EvaluateMathOneParamFloat(callInstr, std::acosf);
		case Stdlib_tanf:   return EvaluateMathOneParamFloat(callInstr, std::tanf); 
		case Stdlib_atanf:  return EvaluateMathOneParamFloat(callInstr, std::atanf);

		case Stdlib_pow:   return EvaluateMathTwoParams(callInstr, std::pow);
		case Stdlib_fmod:  return EvaluateMathTwoParams(callInstr, std::fmod);
        case Stdlib_atan2: return EvaluateMathTwoParams(callInstr, std::atan2);

		case Stdlib_powf:   return EvaluateMathTwoParamsFloat(callInstr, std::powf);
		case Stdlib_fmodf:  return EvaluateMathTwoParamsFloat(callInstr, std::fmodf);
	}

	return nullptr;
}
Exemplo n.º 18
0
//------------------------------------------------------------------------------
bool BSliderEditor::MessageReceived(BMessage* msg)
{
	switch (msg->what)
	{
		case MSG_SLIDER_SET_BLOCK_THUMB:
			Target()->SetStyle(B_BLOCK_THUMB);
			Target()->Invalidate();
			return true;

		case MSG_SLIDER_SET_TRI_THUMB:
			Target()->SetStyle(B_TRIANGLE_THUMB);
			Target()->Invalidate();
			return true;

		case MSG_SLIDER_SET_LIMIT_LABELS:
			Target()->SetLimitLabels(fMinLabel->Text(), fMaxLabel->Text());
			return true;

		case MSG_SLIDER_SET_HASH_TOP_LEFT:
		{
			SetHashStyle(B_HASH_MARKS_TOP);
			return true;
		}

		case MSG_SLIDER_SET_HASH_BOTTOM_RIGHT:
		{
			SetHashStyle(B_HASH_MARKS_BOTTOM);
			return true;
		}

		case MSG_SLIDER_SET_ORIENT_HORZ:
			Target()->SetOrientation(B_HORIZONTAL);
			SetOrientation(B_HORIZONTAL);
			return true;

		case MSG_SLIDER_SET_ORIENT_VERT:
			Target()->SetOrientation(B_VERTICAL);
			SetOrientation(B_VERTICAL);
			return true;

		case MSG_SLIDER_SET_HASH_COUNT:
			Target()->SetHashMarkCount(atoi(fHashCount->Text()));
			return true;

		case MSG_SLIDER_SET_MIN_VALUE:
		case MSG_SLIDER_SET_MAX_VALUE:
			Target()->SetLimits(atoi(fMinValue->Text()),
								atoi(fMaxValue->Text()));
			return true;

		case MSG_SLIDER_SET_INCREMENT:
			Target()->SetKeyIncrementValue(atoi(fIncrValue->Text()));
			return true;

		case MSG_SLIDER_SET_MOD_MSG:
		{
			BMessage* Message = new BMessage(flipcode(*(int32*)fModMsg->Text()));
			Target()->SetModificationMessage(Message);
			return true;
		}

		case MSG_SLIDER_SET_BAR_COLOR:
		{
			int32 color = atoi(fBarColor->Text());
			Target()->SetBarColor(*(rgb_color*)&color);
			Target()->Invalidate();
			return true;
		}

		case MSG_SLIDER_USE_FILL_COLOR:
		case MSG_SLIDER_SET_FILL_COLOR:
		{
			bool use = fUseFillCheck->Value();
			int32 color = atoi(fFillColor->Text());
			Target()->UseFillColor(use, (rgb_color*)&color);
			fFillColor->SetEnabled(use);
			Target()->Invalidate();
			return true;
		}

		case MSG_SLIDER_SET_THICKNESS:
			Target()->SetBarThickness(atof(fBarThickness->Text()));
			Target()->Invalidate();
			return true;

		default:
			return BControlEditor::MessageReceived(msg);
	}
}