Exemplo n.º 1
0
void HexEditorCtrl::OnMouseMove( wxMouseEvent& event ){
	if(event.m_leftDown){									//if left button is pressed
		int new_hex_location=0;								// initialize new_hex_location variable
		if( event.GetEventObject() == hex_ctrl ) 		// if this event from hex_ctrl area
			new_hex_location = hex_ctrl->PixelCoordToInternalPosition( event.GetPosition() ); //than take it's location on hex chars
		else if ( event.GetEventObject() == text_ctrl ){ //if we got this event from text area
			new_hex_location = GetCharToHexSize()*(text_ctrl->PixelCoordToInternalPosition( event.GetPosition() )); //Than we needed to multiply with 2 for take it's hex location.
			}

		int old_hex_location = GetLocalHexInsertionPoint();	//requesting old hex location
		if( new_hex_location != old_hex_location ){				//if hex selection addresses are different, start selection routine

			if( !select->GetState() )	//if this is new selection start
				if( Selector() == false )	//and  select without focus
					return;						//don't make anything.
			SetLocalHexInsertionPoint( new_hex_location );	//Moving cursor to new location.
			Selector();							//Making actual selection.
			PaintSelection();
			}
		}
	else{
		if( event.GetEventObject() == hex_ctrl ||
			event.GetEventObject() == text_ctrl ||
			event.GetEventObject() == offset_ctrl ){
			TagElement* tg = static_cast<wxHexCtrl*>(event.GetEventObject())->GetTagByPix( event.GetPosition() );
			if( (tg == NULL && TAGMutex==true) || 	 //If there is no Tag at under and tag mutex available
				(tg != NULL && !tg->visible) )		// or Changed to new tag
				TagHideAll();
			}
		event.Skip(); //enable tags but problems with paint?
		}
	}
Exemplo n.º 2
0
void
TopologyModule::SelectNodesByMask_L_a_MFunction::execute(
  SLIInterpreter* i ) const
{
  i->assert_stack_load( 3 );

  const index& layer_gid = getValue< long >( i->OStack.pick( 2 ) );
  std::vector< double > anchor =
    getValue< std::vector< double > >( i->OStack.pick( 1 ) );
  MaskDatum mask = getValue< MaskDatum >( i->OStack.pick( 0 ) );

  std::vector< index > mask_gids;

  const int dim = anchor.size();

  if ( dim != 2 and dim != 3 )
  {
    throw BadProperty( "Center must be 2- or 3-dimensional." );
  }

  if ( dim == 2 )
  {
    Layer< 2 >* layer = dynamic_cast< Layer< 2 >* >(
      kernel().node_manager.get_node( layer_gid ) );

    MaskedLayer< 2 > ml =
      MaskedLayer< 2 >( *layer, Selector(), mask, true, false );

    for ( Ntree< 2, index >::masked_iterator it =
            ml.begin( Position< 2 >( anchor[ 0 ], anchor[ 1 ] ) );
          it != ml.end();
          ++it )
    {
      mask_gids.push_back( it->second );
    }
  }
  else
  {
    Layer< 3 >* layer = dynamic_cast< Layer< 3 >* >(
      kernel().node_manager.get_node( layer_gid ) );

    MaskedLayer< 3 > ml =
      MaskedLayer< 3 >( *layer, Selector(), mask, true, false );

    for ( Ntree< 3, index >::masked_iterator it =
            ml.begin( Position< 3 >( anchor[ 0 ], anchor[ 1 ], anchor[ 2 ] ) );
          it != ml.end();
          ++it )
    {
      mask_gids.push_back( it->second );
    }
  }

  i->OStack.pop( 3 );
  i->OStack.push( mask_gids );
  i->EStack.pop();
}
Exemplo n.º 3
0
inline
Selector operator - ( const Selector & A, const Selector & B  )
{
  Selector S( A );
  S -= Selector(B);
  return S;
}
Exemplo n.º 4
0
inline
Selector operator | ( const Selector & A, const Part & B  )
{
  Selector S( A );
  S |= Selector(B);
  return S;
}
Exemplo n.º 5
0
inline
Selector operator & ( const Part & A , const Part & B )
{
  Selector S( A );
  S &= Selector( B );
  return S;
}
Exemplo n.º 6
0
SFMLMap::SFMLMap(RenderWindow* p_App, string p_mapName, pixPosition start, int p_space, bool showGrille) : Map(p_mapName.c_str(), start, p_space), App(p_App), showGrille(showGrille)
{
   loadTilesetImage();
   Select = Selector(App, start);
   grille = grider(p_App);
   grille.genGrid(start,mapDim.first,mapDim.second,1,Color::White);
   cutTileset();
}
Exemplo n.º 7
0
    double computeSVF(Selector selector = Selector(),
                      CorrelAlgo correlAlgo = CorrelAlgo())
    {
        selector.init(this->oracleTrace, this->sideChannelTrace);

        LazyMatrix<OracleType, OracleDist> oMatrix(oracleTrace);
        LazyMatrix<SideChannelType, SideChannelDist> scMatrix(sideChannelTrace);
        return correlAlgo(oMatrix, scMatrix, selector);
    }
Exemplo n.º 8
0
SFMLMap::SFMLMap(RenderWindow* p_App, string p_mapName, int p_space, bool showGrille) : Map(p_mapName.c_str(), pixPosition(), p_space), App(p_App), showGrille(showGrille)
{
   loadTilesetImage();
   start = pixPosition((GAME_W)/2-(mapDim.first*32)/2,(GAME_H-ACTION_H)/2-(mapDim.second*32)/2);
   Select = Selector(App, start);
   grille = grider(p_App);
   grille.genGrid(start,mapDim.first,mapDim.second,1,Color::White);
   cutTileset();
   Select.setActive(0);
}
Exemplo n.º 9
0
Selector selectField( const FieldBase& field )
{
  /*
  Selector selector;
  const FieldRestrictionVector& sel_rvec = field.restrictions();
  for(size_t i=0; i<sel_rvec.size(); ++i) {
    selector |= sel_rvec[i].selector();
  }
  return selector;
  */
  return Selector(field);
}
Exemplo n.º 10
0
QString DataBroadcastDescriptor::toString(void) const
{
    QString ret = QString("DataBroadcastDescriptor: "
                                "data_broadcast_id(%1) "
                                "component_tag(%1) ")
            .arg(DataBroadcastId(), 0, 10)
            .arg(DataComponentTag(), 0, 10);

    ret += QString("selector(0x ");
    for (uint i = 0; i < SelectorLength(); i++)
        ret += QString("%1 ").arg(Selector()[i], 0, 16);
    ret += ") ";

    ret += QString("ISO_639_language_code(%1) ")
        .arg(LanguageString());

    ret += QString("text(%1) ") + Text();

    return ret;
}
 void DynamicInterceptTestFramework::SimulateData(int time_dimension) {
   state_modules().SimulateData(time_dimension);
   Vector state = state_modules().StateContribution();
   data_.clear();
   for (int t = 0; t < time_dimension; ++t) {
     int nobs = 1 + rpois(poisson_rate_);
     Matrix predictors(nobs, true_beta_.size());
     predictors.randomize();
     Vector response = predictors * true_beta_;
     response += state[t];
     for (int j = 0; j < nobs; ++j) {
       response[j] += rnorm_mt(GlobalRng::rng, 0, observation_sd_);
     }
     NEW(StateSpace::TimeSeriesRegressionData, data_point)(
         response, predictors, Selector(response.size(), true));
     data_.push_back(data_point);
     xtx_ += predictors.inner();
     total_nobs_ += nobs;
   }
 }
Exemplo n.º 12
0
/** 载入CSS代码块,用于实现CSS代码的分块载入 */
static int LCUI_LoadCSSBlock( CSSParserContext ctx, const char *str )
{
	size_t size = 0;
	LCUI_Selector s;
	LinkedListNode *node;

	ctx->ptr = str;
	for( ; *ctx->ptr && size < ctx->buffer_size; ++ctx->ptr, ++size ) {
		switch( ctx->target ) {
		case TARGET_SELECTOR:
			switch( *ctx->ptr ) {
			case '/': goto proc_comment;
			case '{':
				ctx->target = TARGET_KEY;
				ctx->css = StyleSheet();
			case ',':
				ctx->buffer[ctx->pos] = 0;
				ctx->pos = 0;
				DEBUG_MSG("selector: %s\n", ctx->buffer);
				s = Selector( ctx->buffer );
				if( !s ) {
					// 解析出错 ...
					break;
				}
				LinkedList_Append( &ctx->selectors, s );
				break;
			default:
				ctx->buffer[ctx->pos++] = *ctx->ptr;
				break;
			}
			break;
		case TARGET_KEY:
			switch( *ctx->ptr ) {
			case '/': goto proc_comment;
			case ' ':
			case '\n':
			case '\r':
			case '\t':
			case ';':
				ctx->pos = 0;
				continue;
			case ':': break;
			case '}':
				ctx->target = TARGET_NONE;
				goto put_css;
			default:
				ctx->buffer[ctx->pos++] = *ctx->ptr;
				continue;
			}
			goto select_parser;
		case TARGET_VALUE:
			switch( *ctx->ptr ) {
			case '/': goto proc_comment;
			case '}':
			case ';':
				goto parse_value;
			case '\n':
			case '\r':
			case '\t':
			case ' ':
				if( ctx->pos == 0 ) {
					continue;
				}
			default:
				ctx->buffer[ctx->pos++] = *ctx->ptr;
				continue;
			}
			break;
		case TARGET_COMMENT:
			if( ctx->is_line_comment ) {
				if( *ctx->ptr == '\n' ) {
					ctx->target = ctx->target_bak;
				}
				break;
			}
			if( *ctx->ptr == '/' && *(ctx->ptr - 1) == '*' ) {
				ctx->target = ctx->target_bak;
			}
			break;
		case TARGET_NONE:
		default:
			switch( *ctx->ptr ) {
			case '/': goto proc_comment;
			case '\n':
			case '\t':
			case '\r':
			case ' ':
			case ',':
			case '{':
			case '\\':
			case '"':
			case '}': continue;
			default: break;
			}
			ctx->pos = 0;
			ctx->buffer[ctx->pos++] = *ctx->ptr;
			ctx->target = TARGET_SELECTOR;
			break;
		}
		continue;
proc_comment:
		switch( *(ctx->ptr + 1) ) {
		case '/': ctx->is_line_comment = TRUE; break;
		case '*': ctx->is_line_comment = FALSE; break;
		default:
			ctx->buffer[ctx->pos++] = *ctx->ptr;
			continue;
		}
		if( ctx->target_bak != TARGET_COMMENT ) {
			ctx->target_bak = ctx->target;
			ctx->target = TARGET_COMMENT;
		}
		continue;
put_css:
		DEBUG_MSG("put css\n");
		/* 将记录的样式表添加至匹配到的选择器中 */
		for( LinkedList_Each( node, &ctx->selectors ) ) {
			LCUI_PutStyleSheet( node->data, ctx->css, ctx->space );
		}
		LinkedList_Clear( &ctx->selectors, (FuncPtr)Selector_Delete );
		StyleSheet_Delete( ctx->css );
		continue;
select_parser:
		ctx->target = TARGET_VALUE;
		ctx->buffer[ctx->pos] = 0;
		ctx->pos = 0;
		ctx->parser = Dict_FetchValue( self.parsers, ctx->buffer );
		DEBUG_MSG("select style: %s, parser: %p\n",
			   ctx->buffer, ctx->parser);
		continue;
parse_value:
		if( *ctx->ptr == ';' ) {
			ctx->target = TARGET_KEY;
		}
		if( !ctx->parser ) {
			continue;
		}
		ctx->buffer[ctx->pos] = 0;
		ctx->pos = 0;
		ctx->parser->parse( ctx->css, ctx->parser->key, ctx->buffer );
		DEBUG_MSG("parse style value: %s, result: %d\n", ctx->buffer);
		if( *ctx->ptr == '}' ) {
			ctx->target = TARGET_NONE;
			goto put_css;
		}
	}
	return size;
}
Exemplo n.º 13
0
 SelectorMatrix(int nrow, int ncol, bool include_all = true) {
   for (int i = 0; i < ncol; ++i) {
     columns_.push_back(Selector(nrow, include_all));
   }
 }
Exemplo n.º 14
0
SFMLMap::SFMLMap(RenderWindow* p_App, dimension mapDim, pixPosition p_start, bool showGrille, bool activeSelector, bool tiledSelector, int p_space) : Map(mapDim, p_start, p_space), App(p_App), showGrille(showGrille)
{
   Select = Selector(App, start, activeSelector, tiledSelector);
   grille = grider(App);
   grille.genGrid(start,mapDim.first,mapDim.second,1,Color::White);
}
Exemplo n.º 15
0
/*
 * Create a new user context of given size
 */
static struct User_Context *Create_User_Context(ulong_t size) {
    struct User_Context *context;
    int index;

    /* Size must be a multiple of the page size */
    size = Round_Up_To_Page(size);
    if (userDebug)
        Print("Size of user memory == %lu (%lx) (%lu pages)\n", size, size,
              size / PAGE_SIZE);

    /* Allocate memory for the user context */
    Disable_Interrupts();
    context = (struct User_Context *)Malloc(sizeof(*context));
    if (context != 0)
        context->memory = Malloc(size);
    Enable_Interrupts();

    if (context == 0 || context->memory == 0)
        goto fail;

    /*
     * Fill user memory with zeroes;
     * leaving it uninitialized is a potential security flaw
     */
    memset(context->memory, '\0', size);

    context->size = size;

    /* Allocate an LDT descriptor for the user context */
    context->ldtDescriptor = Allocate_Segment_Descriptor();
    if (context->ldtDescriptor == 0)
        goto fail;
    if (userDebug)
        Print("Allocated descriptor %d for LDT\n",
              Get_Descriptor_Index(context->ldtDescriptor));
    Init_LDT_Descriptor(context->ldtDescriptor, context->ldt,
                        NUM_USER_LDT_ENTRIES);
    index = Get_Descriptor_Index(context->ldtDescriptor);
    context->ldtSelector = Selector(KERNEL_PRIVILEGE, true, index);

    /* Initialize code and data segments within the LDT */
    Init_Code_Segment_Descriptor(&context->ldt[0],
                                 (ulong_t) context->memory,
                                 size / PAGE_SIZE, USER_PRIVILEGE);
    Init_Data_Segment_Descriptor(&context->ldt[1],
                                 (ulong_t) context->memory,
                                 size / PAGE_SIZE, USER_PRIVILEGE);
    context->csSelector = Selector(USER_PRIVILEGE, false, 0);
    context->dsSelector = Selector(USER_PRIVILEGE, false, 1);

    /* Nobody is using this user context yet */
    context->refCount = 0;

    /* Initialize background flag */
    context->backgrounded = 0;

    /* Initialize all semaphore flags to 0 */
    int sem_ind;
    for (sem_ind = 0; sem_ind < MAX_SEM_SIZE; sem_ind++) {
        context->sem_flags[sem_ind] = 0;
    }

    /* Success! */
    return context;

  fail:
    /* We failed; release any allocated memory */
    Disable_Interrupts();
    if (context != 0) {
        if (context->memory != 0)
            Free(context->memory);
        Free(context);
    }
    Enable_Interrupts();

    return 0;
}
Exemplo n.º 16
0
 Selector & operator &= ( const Part& part)
 { return add_binary_op(SelectorNodeType::INTERSECTION, Selector(part)); }
Exemplo n.º 17
0
 Selector & operator |= ( const Part& part )
 { return operator|=(Selector(part)); }
Exemplo n.º 18
0
static int Spawn_Program(char *exeFileData, struct Exe_Format *exeFormat)
{
  struct Segment_Descriptor* desc;
  unsigned long virtSize;
  unsigned short codeSelector, dataSelector;

  int i;
  ulong_t maxva = 0;

  /* Find maximum virtual address */
  for (i = 0; i < exeFormat->numSegments; ++i) {
    struct Exe_Segment *segment = &exeFormat->segmentList[i];
    ulong_t topva = segment->startAddress + segment->sizeInMemory; 
    
    if (topva > maxva)
      maxva = topva;
  }

  /* setup some memory space for the program */

  virtSize = Round_Up_To_Page(maxva) + 4096; /* leave some slack for stack */
  virtSpace = Malloc(virtSize);
  memset((char *) virtSpace, '\0', virtSize);

  /* Load segment data into memory */
  for (i = 0; i < exeFormat->numSegments; ++i) {
    struct Exe_Segment *segment = &exeFormat->segmentList[i];

    memcpy(virtSpace + segment->startAddress,
	   exeFileData + segment->offsetInFile,
	   segment->lengthInFile);
  }

  /* allocate and init descriptors and selectors for code and data */

  // Kernel code segment.
  desc = Allocate_Segment_Descriptor();
  Init_Code_Segment_Descriptor(
			       desc,
			       (unsigned long)virtSpace, // base address
			       (virtSize/PAGE_SIZE)+10,	 // num pages
			       0		         // privilege level (0 == kernel)
			       );
  codeSelector = Selector( 0, true, Get_Descriptor_Index( desc ) );
  // Kernel data segment.
  desc = Allocate_Segment_Descriptor();
  Init_Data_Segment_Descriptor(
			       desc,
			       (unsigned long)virtSpace, // base address
			       (virtSize/PAGE_SIZE)+10,	 // num pages
			       0		         // privilege level (0 == kernel)
			       );
  dataSelector = Selector( 0, true, Get_Descriptor_Index( desc ) );

  Install_Interrupt_Handler( 0x90, &Printrap_Handler );

  if (lprogdebug)
    {
      Print("Spawn_Program(): all structures are set up\n");
      Print(" virtSpace    = %x\n", (unsigned int) virtSpace);
      Print(" virtSize     = %x\n", (unsigned int) virtSize);
      Print(" codeSelector = %x\n", codeSelector);
      Print(" dataSelector = %x\n", dataSelector);

      Print("Now calling Trampoline()... \n");
    }

  Trampoline(codeSelector, dataSelector, exeFormat->entryAddr); 
  return 0;
}
Exemplo n.º 19
0
/*
 * Load a user executable into memory by creating a User_Context
 * data structure.
 * Params:
 * exeFileData - a buffer containing the executable to load
 * exeFileLength - number of bytes in exeFileData
 * exeFormat - parsed ELF segment information describing how to
 *   load the executable's text and data segments, and the
 *   code entry point address
 * command - string containing the complete command to be executed:
 *   this should be used to create the argument block for the
 *   process
 * pUserContext - reference to the pointer where the User_Context
 *   should be stored
 *
 * Returns:
 *   0 if successful, or an error code (< 0) if unsuccessful
 */
int Load_User_Program(char *exeFileData, ulong_t exeFileLength,
    struct Exe_Format *exeFormat, const char *command,
    struct User_Context **pUserContext)
{
    /*
     * Hints:
     * ok - Determine where in memory each executable segment will be placed
     * ok - Determine size of argument block and where it memory it will
     *   be placed
     * - Copy each executable segment into memory
     * - Format argument block in memory
     * - In the created User_Context object, set code entry point
     *   address, argument block address, and initial kernel stack pointer
     *   address
     */
	int i;
	ulong_t size; 
	ulong_t maxva = 0;
	unsigned numArgs;
	ulong_t argBlockSize;

	/* calculates arg block length */	
	Get_Argument_Block_Size(command, &numArgs, &argBlockSize);

	/* Find maximum virtual address */
	for (i = 0; i < exeFormat->numSegments; ++i) {
		struct Exe_Segment *segment = &exeFormat->segmentList[i];
		ulong_t topva = segment->startAddress + segment->sizeInMemory; 

		if (topva > maxva)
			maxva = topva;
	}
	/* calculates memory size for the program, the stack and the args */
	size = Round_Up_To_Page(maxva) + Round_Up_To_Page(DEFAULT_USER_STACK_SIZE + argBlockSize); 
	
	/* creates the user context */
	if( (*pUserContext = Create_User_Context(size)) == 0 )
		return -1;

	/* Load segment data into memory */
	for (i = 0; i < exeFormat->numSegments; ++i) {
		struct Exe_Segment *segment = &exeFormat->segmentList[i];
		memcpy((*pUserContext)->memory + segment->startAddress,
				exeFileData + segment->offsetInFile,
				segment->lengthInFile);
	}
	
	/* copy the args just after the data segment */
	struct Exe_Segment *segment = &exeFormat->segmentList[1];
	int userAddress = segment->startAddress + segment->lengthInFile;
	Print("%.8x\n", userAddress);
	Format_Argument_Block( (*pUserContext)->memory + userAddress, numArgs, userAddress, command);
	
	/* to show some part of the code */
//	memDump((*pUserContext)->memory + userAddress, 0x6c + 0x20);

	/* allocate the LDT descriptor in the GDT */
	(*pUserContext)->ldtDescriptor = Allocate_Segment_Descriptor();
	Init_LDT_Descriptor(
			(*pUserContext)->ldtDescriptor,
			(*pUserContext)->ldt,
			NUM_USER_LDT_ENTRIES);

	/* the LDT selector  */
	(*pUserContext)->ldtSelector = Selector( 
			KERNEL_PRIVILEGE, 
			true,	/* in the GDT */ 
			Get_Descriptor_Index( (*pUserContext)->ldtDescriptor ));

	/* code descriptor */
	Init_Code_Segment_Descriptor(
			&(*pUserContext)->ldt[0],
			(ulong_t)(*pUserContext)->memory , 			// base address
			((*pUserContext)->size/PAGE_SIZE)+10,	 	// FIXME is ok??? num pages
			USER_PRIVILEGE	
			);

	(*pUserContext)->csSelector = Selector( 
			USER_PRIVILEGE, 
			false,										/* LDT */ 
			0 );										/* descriptor index */

	/* data descriptor */
	Init_Data_Segment_Descriptor(
			&(*pUserContext)->ldt[1],
			(ulong_t)(*pUserContext)->memory , 			// base address
			((*pUserContext)->size/PAGE_SIZE)+10,	 	// FIXME is ok??? num pages
			USER_PRIVILEGE	
			);

	(*pUserContext)->dsSelector = Selector( 
			USER_PRIVILEGE, 
			false,										/* LDT */ 
			1 );										/* descriptor index */

	/* entry point */	
	(*pUserContext)->entryAddr = exeFormat->entryAddr;

	/* Address of argument block in user memory */
    (*pUserContext)->argBlockAddr = userAddress;

	(*pUserContext)->stackPointerAddr = (*pUserContext)->size;
    /* Initial stack pointer */
    // TODO stackPointerAddr;

    /*
     * May use this in future to allow multiple threads
     * in the same user context
	 *	
	 *	int refCount;
	 *
     */

	/* for debuging */
	Print("virt Space: From %p to %p\n", (*pUserContext)->memory, (*pUserContext)->memory + (*pUserContext)->size);
	Print("%.8lX\n", (*pUserContext)->size);
	//Print("codeSelector=%08x,DataSelector=%08x\n", (*pUserContext)->csSelector,
	//		(*pUserContext)->dsSelector);

//j	memDump((*pUserContext)->memory+0x24f0,0x100);
//	memDump((void*)(*pUserContext),0x100);
	return 0;
}