예제 #1
0
Comment CommentStore::takeComment( int line ) {
    CommentSet::iterator it = m_comments.find( Comment( 0, line ) );
    if( it != m_comments.end() ) {
        Comment ret = *it;
        m_comments.erase( it );
/*        kDebug() << "Took comment in line" << line << "new count:" << m_comments.size();*/
        return ret;
    } else {
        return Comment();
    }
}
예제 #2
0
void TAP::SuiteHeader(	const String &  name
                      , unsigned        first
                      , int             testsInSuite)
{
  suiteName= name;

  Comment( name );

  if ( testsInSuite > 0 )
    output << first << ".." << first + testsInSuite - 1 << std::endl;
  else
    Comment( "doesn't contain any tests" );
}
예제 #3
0
// Generate enum declarations.
static void GenEnum(const EnumDef &enum_def, std::string *code_ptr) {
  if (enum_def.generated) return;

  Comment(enum_def.doc_comment, code_ptr);
  BeginEnum(code_ptr);
  for (auto it = enum_def.vals.vec.begin();
       it != enum_def.vals.vec.end();
       ++it) {
    auto &ev = **it;
    Comment(ev.doc_comment, code_ptr, "  ");
    EnumMember(enum_def, ev, code_ptr);
  }
  EndEnum(code_ptr);
}
예제 #4
0
// Generate struct or table methods.
static void GenStruct(const StructDef &struct_def,
                      std::string *code_ptr,
                      StructDef *root_struct_def) {
  if (struct_def.generated) return;

  Comment(struct_def.doc_comment, code_ptr);
  BeginClass(struct_def, code_ptr);
  if (&struct_def == root_struct_def) {
    // Generate a special accessor for the table that has been declared as
    // the root type.
    NewRootTypeFromBuffer(struct_def, code_ptr);
  }
  // Generate the Init method that sets the field in a pre-existing
  // accessor object. This is to allow object reuse.
  InitializeExisting(struct_def, code_ptr);
  for (auto it = struct_def.fields.vec.begin();
       it != struct_def.fields.vec.end();
       ++it) {
    auto &field = **it;
    if (field.deprecated) continue;

    GenStructAccessor(struct_def, field, code_ptr);
  }

  if (struct_def.fixed) {
    // create a struct constructor function
    GenStructBuilder(struct_def, code_ptr);
  } else {
    // Create a set of functions that allow table construction.
    GenTableBuilders(struct_def, code_ptr);
  }
}
예제 #5
0
void MCACommentConsumer::HandleComment(SMLoc Loc, StringRef CommentText) {
  // Skip empty comments.
  StringRef Comment(CommentText);
  if (Comment.empty())
    return;

  // Skip spaces and tabs.
  unsigned Position = Comment.find_first_not_of(" \t");
  if (Position >= Comment.size())
    // We reached the end of the comment. Bail out.
    return;

  Comment = Comment.drop_front(Position);
  if (Comment.consume_front("LLVM-MCA-END")) {
    Regions.endRegion(Loc);
    return;
  }

  // Try to parse the LLVM-MCA-BEGIN comment.
  if (!Comment.consume_front("LLVM-MCA-BEGIN"))
    return;

  // Skip spaces and tabs.
  Position = Comment.find_first_not_of(" \t");
  if (Position < Comment.size())
    Comment = Comment.drop_front(Position);
  // Use the rest of the string as a descriptor for this code snippet.
  Regions.beginRegion(Comment, Loc);
}
예제 #6
0
void
Consumer::sendPrecedingComment(	Comment const& comment,
											Annotation const& annotation,
											MarkSet const& marks)
{
	writeComment(Comment(), comment, annotation, marks);
}
예제 #7
0
bool CEC_Category_Tag::Apply()
{
	bool ret = theApp->glob_prefs->UpdateCategory(GetInt(), Name(), CPath(Path()), Comment(), Color(), Prio());
	if (!ret) {
		GetTagByName(EC_TAG_CATEGORY_PATH)->SetStringData(theApp->glob_prefs->GetCatPath(GetInt()).GetRaw());
	}
	return ret;
}
예제 #8
0
//---------------------------------------------------------------------------
void File_Speex::Data_Parse()
{
    //Parsing
    if (Identification_Done)
        Comment();
    else
        Identification();
}
예제 #9
0
Comment CommentStore::takeCommentInRange( int end, int start ) {
    CommentSet::iterator it = m_comments.lower_bound( Comment( 0, end ) );


    while( it != m_comments.begin() && (*it).line() > end ) {
        --it;
    }

    if( it != m_comments.end() && (*it).line() >= start && (*it).line() <= end ) {
        Comment ret = *it;
        m_comments.erase( it );
/*        kDebug() << "Took comment in line" << (*it).line() << "new count:" << m_comments.size();*/
        return ret;
    } else {
        return Comment();
    }
}
예제 #10
0
Comment CommentStore::takeFirstComment() {
    CommentSet::iterator it = m_comments.begin();
    if( it == m_comments.end() ) return Comment();
    Comment ret = *it;
    m_comments.erase(it);
/*    kDebug() << "taken first comment in line" << (*it).line() << "new count:" << m_comments.size();*/
    return ret;
}
예제 #11
0
  void SeriesList::drawInFrame(Frame& innerFrame, double minX, double maxX, double minY, double maxY)
  {
    double multX = innerFrame.getWidth()/(maxX-minX);
    double multY = innerFrame.getHeight()/(maxY-minY);

    // Draw lines
    for(int i=0;i<getNumSeries();i++)
    {
      innerFrame.push_state();

      StrokeStyle s = getStyle(i);          
      Marker m = getMarker(i);

      if(m.getColor().isClear() && s.getColor().isClear())
      {
        innerFrame << Comment("Plot contained data with clear stroke and marker.  Skipping.");
        continue;
      }

      vector< pair<double,double> >& vec = getPointList(i);
      Path curve(vec,innerFrame.lx(), innerFrame.ly());

      // What I'd give for a line of haskell...
      // map (\(x,y) -> (multX*(x-minX), multY*(y-minY))) vector
      map_object map_instance(multX,minX,multY,minY);

      innerFrame.setMarker(m);
      innerFrame.setLineStyle(s);

      if(s.getColor().isClear())
      {
        // crop
        auto_ptr< Path > cropX = Splitter::cropToBox(minX,maxX,minY,maxY,curve);

        // Fit it to the box.
        std::for_each(cropX->begin(), cropX->end(), map_instance);

        // Draw the line
        innerFrame.line(*cropX);
      }
      else 
      {
        // interpolate
        auto_ptr< std::list<Path> > interpX = Splitter::interpToBox(minX,maxX,minY,maxY,curve);

        for(std::list<Path>::iterator i=interpX->begin();i!=interpX->end();i++)
        {
          // Fit it to the box
          std::for_each(i->begin(), i->end(), map_instance);

          // Draw the line
          innerFrame.line(*i);
        }
      }
      innerFrame.pop_state();
    }
  }
예제 #12
0
bool CEC_Category_Tag::Create()
{
	Category_Struct * category = NULL;
	bool ret = theApp->glob_prefs->CreateCategory(category, Name(), CPath(Path()), Comment(), Color(), Prio());
	if (!ret) {
		GetTagByName(EC_TAG_CATEGORY_PATH)->SetStringData(theApp->glob_prefs->GetCatPath(
			theApp->glob_prefs->GetCatCount() - 1).GetRaw());
	}
	return ret;
}
예제 #13
0
void TAP::Assert(const String & expected, const String & result
                 , const String & file, int line)
{
  std::ostringstream tmp("Assertion Failed in file ");

  tmp << file << " Line " << line;

  Comment(tmp.str());

  tmp.flush();
  tmp << "Expected: " << expected;

  Comment(tmp.str());

  tmp.flush();
  tmp << "Received: " << result;

  Comment(tmp.str());
}
예제 #14
0
void XmlElement::add_comment(size_t pos, const std::string& text)
{
    // binary search
    int left = -1, right = (int) _comments.size();
    while (left + 1 < right)
    {
        const int mid = (left + right) / 2;
        if (_comments.at(mid).pos <= pos)
            left = mid;
        else
            right = mid;
    }
    _comments.insert(_comments.begin() + right, Comment(pos, text));
}
예제 #15
0
void Resource::Comment()
{
	Match(';');

	while (!Is('\n') && !Is(EOF))
	{
		Lex();
	}

	if (Is(';'))
	{
		Comment();
	}
}
예제 #16
0
// Teradata HELP STATISTICS statement
bool SqlParser::ParseTeradataHelpStatistics(Token *help, Token *statistics)
{
	if(help == NULL || statistics == NULL)
		return false;

	// Table name
	Token *table_name = GetNextIdentToken(SQL_IDENT_OBJECT);

	// Comment for other databases
	if(_target != SQL_TERADATA)
		Comment(help, Nvl(GetNext(';', L';'), GetLastToken()));

	return true;
}
예제 #17
0
 std::vector<Comment> Patch::getComments() const noexcept
 {
     std::vector<Comment> objects;
     if(isValid())
     {
         t_canvas* cnv = reinterpret_cast<t_canvas*>(m_ptr);
         t_symbol* txt = gensym("text");
         
         for(t_gobj *y = cnv->gl_list; y; y = y->g_next)
         {
             if(y->g_pd->c_name == txt)
             {
                 objects.push_back(Comment(*this, reinterpret_cast<void *>(y)));
             }
         }
     }
     return objects;
 }
예제 #18
0
파일: scanner.cpp 프로젝트: it3ration/opcpp
// parses the next token
// returns false if done
void opScanner::ScanTokens(const inputtype& Input) {
    // if we've reached the end of the Input stream,
    // add an EOF token and return false

    int size = Input.Size();
    int current = 0;

    // TODO: the input list of chars is really a bad idea
    //		Input should be a vector, and we should not alter it,
    //		instead we should iterate over it (maybe w/ an iterator we pass
    //		around.

    while (current != size) {
        // scan for the next token
        // (with the correct precedence)
        if (current != size && Newline(Input, current))
            ;
        else if (current != size && CComment(Input, current))
            ;
        else if (current != size && Comment(Input, current))
            ;
        else if (current != size && String(Input, current))
            ;
        else if (current != size && WhiteSpace(Input, current))
            ;
        else if (current != size && Operator(Input, current))
            ;
        else if (current != size && Hexadecimals(Input, current))
            ;
        else if (current != size && Number(Input, current))
            ;
        else if (current != size && GetId(Input, current))
            ;
        else if (current != size) {
            opToken newToken(T_ANYCHAR, Input[current], CurrentLine);

            Tokens.PushBack(newToken);
            ++current;
        }
    }

    Tokens.PushBack(opToken(T_EOF, "", CurrentLine));
}
예제 #19
0
// Generate a struct field, conditioned on its child type(s).
static void GenStructAccessor(const StructDef &struct_def,
                              const FieldDef &field,
                              std::string *code_ptr) {
  Comment(field.doc_comment, code_ptr, "");
  if (IsScalar(field.value.type.base_type)) {
    if (struct_def.fixed) {
      GetScalarFieldOfStruct(struct_def, field, code_ptr);
    } else {
      GetScalarFieldOfTable(struct_def, field, code_ptr);
    }
  } else {
    switch (field.value.type.base_type) {
      case BASE_TYPE_STRUCT:
        if (struct_def.fixed) {
          GetStructFieldOfStruct(struct_def, field, code_ptr);
        } else {
          GetStructFieldOfTable(struct_def, field, code_ptr);
        }
        break;
      case BASE_TYPE_STRING:
        GetStringField(struct_def, field, code_ptr);
        break;
      case BASE_TYPE_VECTOR: {
        auto vectortype = field.value.type.VectorType();
        if (vectortype.base_type == BASE_TYPE_STRUCT) {
          GetMemberOfVectorOfStruct(struct_def, field, code_ptr);
        } else {
          GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr);
        }
        break;
      }
      case BASE_TYPE_UNION:
        GetUnionField(struct_def, field, code_ptr);
        break;
      default:
        assert(0);
    }
  }
  if (field.value.type.base_type == BASE_TYPE_VECTOR) {
    GetVectorLen(struct_def, field, code_ptr);
  }
}
예제 #20
0
void Resource::Lex()
{
  if (_top < _buffer_len)
  {
	  _top++;
	  _look = _buffer[_top];

#ifdef DEBUG_RESOURCE_LEX
	  printf("%c", _look);
	  fflush(stdout);
#endif

	  if (_look == ';' && !_string)
	  {
		  Comment();
	  }
  }
  else
  {
	  _look = EOF;
  }
}
void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
  const NamespaceDecl *ND = Result.Nodes.getNodeAs<NamespaceDecl>("namespace");
  const SourceManager &Sources = *Result.SourceManager;

  if (!locationsInSameFile(Sources, ND->getLocStart(), ND->getRBraceLoc()))
    return;

  // Don't require closing comments for namespaces spanning less than certain
  // number of lines.
  unsigned StartLine = Sources.getSpellingLineNumber(ND->getLocStart());
  unsigned EndLine = Sources.getSpellingLineNumber(ND->getRBraceLoc());
  if (EndLine - StartLine + 1 <= ShortNamespaceLines)
    return;

  // Find next token after the namespace closing brace.
  SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
  SourceLocation Loc = AfterRBrace;
  Token Tok;
  // Skip whitespace until we find the next token.
  while (Lexer::getRawToken(Loc, Tok, Sources, Result.Context->getLangOpts()) ||
         Tok.is(tok::semi)) {
    Loc = Loc.getLocWithOffset(1);
  }
  if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc))
    return;

  bool NextTokenIsOnSameLine = Sources.getSpellingLineNumber(Loc) == EndLine;
  // If we insert a line comment before the token in the same line, we need
  // to insert a line break.
  bool NeedLineBreak = NextTokenIsOnSameLine && Tok.isNot(tok::eof);

  SourceRange OldCommentRange(AfterRBrace, AfterRBrace);
  std::string Message = "%0 not terminated with a closing comment";

  // Try to find existing namespace closing comment on the same line.
  if (Tok.is(tok::comment) && NextTokenIsOnSameLine) {
    StringRef Comment(Sources.getCharacterData(Loc), Tok.getLength());
    SmallVector<StringRef, 7> Groups;
    if (NamespaceCommentPattern.match(Comment, &Groups)) {
      StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] : "";
      StringRef Anonymous = Groups.size() > 3 ? Groups[3] : "";

      // Check if the namespace in the comment is the same.
      if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) ||
          (ND->getNameAsString() == NamespaceNameInComment &&
           Anonymous.empty())) {
        // FIXME: Maybe we need a strict mode, where we always fix namespace
        // comments with different format.
        return;
      }

      // Otherwise we need to fix the comment.
      NeedLineBreak = Comment.startswith("/*");
      OldCommentRange =
          SourceRange(AfterRBrace, Loc.getLocWithOffset(Tok.getLength()));
      Message =
          (llvm::Twine(
               "%0 ends with a comment that refers to a wrong namespace '") +
           NamespaceNameInComment + "'").str();
    } else if (Comment.startswith("//")) {
      // Assume that this is an unrecognized form of a namespace closing line
      // comment. Replace it.
      NeedLineBreak = false;
      OldCommentRange =
          SourceRange(AfterRBrace, Loc.getLocWithOffset(Tok.getLength()));
      Message = "%0 ends with an unrecognized comment";
    }
    // If it's a block comment, just move it to the next line, as it can be
    // multi-line or there may be other tokens behind it.
  }

  std::string NamespaceName =
      ND->isAnonymousNamespace()
          ? "anonymous namespace"
          : ("namespace '" + ND->getNameAsString() + "'");

  diag(AfterRBrace, Message)
      << NamespaceName << FixItHint::CreateReplacement(
                              CharSourceRange::getCharRange(OldCommentRange),
                              std::string(SpacesBeforeComments, ' ') +
                                  getNamespaceComment(ND, NeedLineBreak));
  diag(ND->getLocation(), "%0 starts here", DiagnosticIDs::Note)
      << NamespaceName;
}
예제 #22
0
// Temporary table options
bool SqlParser::ParseTempTableOptions(Token *table_name, Token **start_out, Token **end_out, bool *no_data)
{
	bool exists = false;

	Token *start = NULL;

	while(true)
	{
		Token *next = GetNextToken();

		if(next == NULL)
			break;

		if(start == NULL)
			start = next;

		// ON COMMIT PRESERVE | DELETE ROWS in Oracle, DB2; ON ROLLBACK PRESERVE | DELETE ROWS in DB2   
		if(next->Compare("ON", L"ON", 2) == true)
		{
			Token *commit = GetNextWordToken("COMMIT", L"COMMIT", 6);
			Token *rollback = NULL;

			if(commit == NULL)
				rollback = GetNextWordToken("ROLLBACK", L"ROLLBACK", 8);

			if(commit == NULL && rollback == NULL)
				break;

			Token *delete_ = GetNextWordToken("DELETE", L"DELETE", 6);
			Token *preserve = NULL;

			if(delete_ == NULL)
				preserve = GetNextWordToken("PRESERVE", L"PRESERVE", 8);

			Token *rows = GetNextWordToken("ROWS", L"ROWS", 4);

			if(_target == SQL_SQL_SERVER)
				Token::Remove(next, rows);
			else
			// Oracle does not support ON ROLLBACK, but DELETE ROWS in default on rollback
			if(_target == SQL_ORACLE && rollback != NULL) 
			{
				if(delete_ != NULL)
					Token::Remove(next, rows);
				else
					Comment(next, rows);
			}
			
			exists = true;
			continue;
		}
		else
		// NOT LOGGED in DB2   
		if(next->Compare("NOT", L"NOT", 3) == true)
		{
			Token *logged = GetNextWordToken("LOGGED", L"LOGGED", 6);

			if(logged != NULL)
			{
				if(_target == SQL_ORACLE) 
					Token::Remove(next, logged);

				exists = true;
				continue;
			}
		}
		else
		// WITH REPLACE, WITH NO DATA in DB2   
		if(next->Compare("WITH", L"WITH", 4) == true)
		{
			Token *replace = GetNextWordToken("REPLACE", L"REPLACE", 7);
			Token *no = NULL;

			if(replace == NULL)
				no = GetNextWordToken("NO", L"NO", 2);

			// WITH REPLACE in DB2
			if(replace != NULL)
			{
				if(Target(SQL_DB2) == false) 
					Token::Remove(next, replace);

				_spl_declared_tables_with_replace.Add(table_name);

				exists = true;
				continue;
			}
			else
			// WITH NO DATA in DB2
			if(no != NULL)
			{
				Token *data = GetNextWordToken("DATA", L"DATA", 4);

				if(data != NULL)
				{
					if(_target == SQL_ORACLE) 
						Token::Remove(next, data);

					if(no_data != NULL)
						*no_data = true;

					exists = true;
					continue;
				}
			}
		}
		else
		// DEFINITION ONLY in DB2   
		if(next->Compare("DEFINITION", L"DEFINITION", 10) == true)
		{
			Token *only = GetNextWordToken("ONLY", L"ONLY", 4);

			if(only != NULL)
			{
				if(_target == SQL_ORACLE) 
					Token::Remove(next, only);

				if(no_data != NULL)
					*no_data = true;

				exists = true;
				continue;
			}
		}
		else
		// IN tablespace in DB2   
		if(next->Compare("IN", L"IN", 2) == true)
		{
			Token *tablespace_name = GetNextToken();

			if(tablespace_name != NULL)
			{
				if(_target == SQL_ORACLE) 
					Token::Remove(next, tablespace_name);

				exists = true;
				continue;
			}
		}
				
		// Not a temporary table clause
		PushBack(next);
		break;
	}

	if(exists == true)
	{
		if(start_out != NULL)
			*start_out = start;

		if(end_out != NULL)
			*end_out = GetLastToken();
	}

	return exists;
}
예제 #23
0
int directive( int i, long direct )
/* Handle all directives */
{
    int         ret;

    /* no expansion on the following */
    switch( direct ) {
    case T_MASM:
        Options.mode &= ~MODE_IDEAL;
        return( NOT_ERROR );
    case T_IDEAL:
        Options.mode |= MODE_IDEAL;
        return( NOT_ERROR );
    case T_DOT_286C:
        direct = T_DOT_286;
    case T_DOT_8086:
    case T_DOT_186:
    case T_DOT_286:
    case T_DOT_286P:
    case T_DOT_386:
    case T_DOT_386P:
    case T_DOT_486:
    case T_DOT_486P:
    case T_DOT_586:
    case T_DOT_586P:
    case T_DOT_686:
    case T_DOT_686P:
    case T_DOT_8087:
    case T_DOT_287:
    case T_DOT_387:
    case T_DOT_NO87:
    case T_DOT_K3D:
    case T_DOT_MMX:
    case T_DOT_XMM:
    case T_DOT_XMM2:
    case T_DOT_XMM3:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        } else {
            ret = cpu_directive(direct);
            if( Parse_Pass != PASS_1 )
                ret = NOT_ERROR;
            return( ret );
        }
    case T_P286N:
        direct = T_P286;
    case T_P8086:
    case T_P186:
    case T_P286:
    case T_P286P:
    case T_P386:
    case T_P386P:
    case T_P486:
    case T_P486P:
    case T_P586:
    case T_P586P:
    case T_P686:
    case T_P686P:
    case T_P8087:
    case T_P287:
    case T_P387:
    case T_PK3D:
    case T_PMMX:
    case T_PXMM:
    case T_PXMM2:
    case T_PXMM3:
        ret = cpu_directive(direct);
        if( Parse_Pass != PASS_1 )
            ret = NOT_ERROR;
        return( ret );
    case T_DOT_DOSSEG:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_DOSSEG:
        Globals.dosseg = TRUE;
        return( NOT_ERROR );
    case T_PUBLIC:
        /* special case - expanded inside iff it is an EQU to a symbol */
        return( Parse_Pass == PASS_1 ? PubDef(i+1) : NOT_ERROR );
    case T_ELSE:
    case T_ELSEIF:
    case T_ELSEIF1:
    case T_ELSEIF2:
    case T_ELSEIFB:
    case T_ELSEIFDEF:
    case T_ELSEIFE:
    case T_ELSEIFNB:
    case T_ELSEIFNDEF:
    case T_ELSEIFDIF:
    case T_ELSEIFDIFI:
    case T_ELSEIFIDN:
    case T_ELSEIFIDNI:
    case T_ENDIF:
    case T_IF:
    case T_IF1:
    case T_IF2:
    case T_IFB:
    case T_IFDEF:
    case T_IFE:
    case T_IFNB:
    case T_IFNDEF:
    case T_IFDIF:
    case T_IFDIFI:
    case T_IFIDN:
    case T_IFIDNI:
        return( conditional_assembly_directive( i ) );
    case T_DOT_ERR:
    case T_DOT_ERRB:
    case T_DOT_ERRDEF:
    case T_DOT_ERRDIF:
    case T_DOT_ERRDIFI:
    case T_DOT_ERRE:
    case T_DOT_ERRIDN:
    case T_DOT_ERRIDNI:
    case T_DOT_ERRNB:
    case T_DOT_ERRNDEF:
    case T_DOT_ERRNZ:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_ERR:
    case T_ERRIFB:
    case T_ERRIFDEF:
    case T_ERRIFDIF:
    case T_ERRIFDIFI:
    case T_ERRIFE:
    case T_ERRIFIDN:
    case T_ERRIFIDNI:
    case T_ERRIFNDEF:
        return( conditional_error_directive( i ) );
    case T_ENDS:
        if( Definition.struct_depth != 0 )
            return( StructDef( i ) );
        // else fall through to T_SEGMENT
    case T_SEGMENT:
        return( Parse_Pass == PASS_1 ? SegDef(i) : SetCurrSeg(i) );
    case T_GROUP:
        return( Parse_Pass == PASS_1 ? GrpDef(i) : NOT_ERROR );
    case T_PROC:
        return( ProcDef( i, TRUE ) );
    case T_ENDP:
        return( ProcEnd(i) );
    case T_ENUM:
        return( EnumDef( i ) );
    case T_DOT_CODE:
    case T_DOT_STACK:
    case T_DOT_DATA:
    case T_DOT_DATA_UN:
    case T_DOT_FARDATA:
    case T_DOT_FARDATA_UN:
    case T_DOT_CONST:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_CODESEG:
    case T_STACK:
    case T_DATASEG:
    case T_UDATASEG:
    case T_FARDATA:
    case T_UFARDATA:
    case T_CONST:
        return( SimSeg(i) );
    case T_WARN:
    case T_NOWARN:
        return( NOT_ERROR ); /* Not implemented yet */
    case T_DOT_ALPHA:
    case T_DOT_SEQ:
    case T_DOT_LIST:
    case T_DOT_LISTALL:
    case T_DOT_LISTIF:
    case T_DOT_LISTMACRO:
    case T_DOT_LISTMACROALL:
    case T_DOT_NOLIST:
    case T_DOT_XLIST:
    case T_DOT_TFCOND:
    case T_DOT_SFCOND:
    case T_DOT_LFCOND:
    case T_DOT_CREF:
    case T_DOT_XCREF:
    case T_DOT_NOCREF:
    case T_DOT_SALL:
    case T_PAGE:
    case T_TITLE:
    case T_SUBTITLE:
    case T_SUBTTL:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
        AsmWarn( 4, IGNORING_DIRECTIVE );
        return( NOT_ERROR );
    case T_DOT_BREAK:
    case T_DOT_CONTINUE:
    case T_DOT_ELSE:
    case T_DOT_ENDIF:
    case T_DOT_ENDW:
    case T_DOT_IF:
    case T_DOT_RADIX:
    case T_DOT_REPEAT:
    case T_DOT_UNTIL:
    case T_DOT_WHILE:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_ECHO:
    case T_HIGH:
    case T_HIGHWORD:
    case T_LOW:
    case T_LOWWORD:
    case T_ADDR:
    case T_BOUND:
    case T_CASEMAP:
    case T_INVOKE:
    case T_LROFFSET:
    case T_OPATTR:
    case T_OPTION:
    case T_POPCONTEXT:
    case T_PUSHCONTEXT:
    case T_PROTO:
    case T_THIS:
    case T_WIDTH:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_CATSTR:
    case T_MASK:
    case T_PURGE:
    case T_RECORD:
    case T_TYPEDEF:
    case T_UNION:
        AsmError( NOT_SUPPORTED );
        return( ERROR );
    case T_ORG:
        ExpandTheWorld( 0, FALSE, TRUE );
        break;
    case T_TEXTEQU:     /* TEXTEQU */
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_EQU2:        /* = */
    case T_EQU:         /* EQU */
        /* expand any constants and simplify any expressions */
        ExpandTheConstant( 0, FALSE, TRUE );
        break;
    case T_NAME:        /* no expand parameters */
        break;
    case T_DOT_STARTUP:
    case T_DOT_EXIT:
        if( Options.mode & MODE_IDEAL ) {
            AsmError( UNKNOWN_DIRECTIVE );
            return( ERROR );
        }
    case T_STARTUPCODE:
    case T_EXITCODE:
    default:
        /* expand any constants in all other directives */
        ExpandAllConsts( 0, FALSE );
        break;
    }

    switch( direct ) {
    case T_ALIAS:
        if( Parse_Pass == PASS_1 )
            return( AddAlias( i ) );
        return( NOT_ERROR );
    case T_EXTERN:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_EXTRN:
        return( Parse_Pass == PASS_1 ? ExtDef( i+1, FALSE ) : NOT_ERROR );
    case T_COMM:
        return( Parse_Pass == PASS_1 ? CommDef(i+1) : NOT_ERROR );
    case T_EXTERNDEF:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_GLOBAL:
        return( Parse_Pass == PASS_1 ? ExtDef( i+1, TRUE ) : NOT_ERROR );
    case T_DOT_MODEL:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_MODEL:
        return( Model(i) );
    case T_INCLUDE:
        return( Include(i+1) );
    case T_INCLUDELIB:
        return( Parse_Pass == PASS_1 ? IncludeLib(i+1) : NOT_ERROR );
    case T_ASSUME:
        return( SetAssume(i) );
    case T_END:
        return( ModuleEnd(Token_Count) );
    case T_EQU:
        return( DefineConstant( i-1, FALSE, FALSE ) );
    case T_EQU2:
        return( DefineConstant( i-1, TRUE, FALSE ) );
    case T_TEXTEQU:
        return( DefineConstant( i-1, TRUE, TRUE ) );
    case T_MACRO:
        return( MacroDef(i, FALSE ) );
    case T_ENDM:
        return( MacroEnd( FALSE ) );
    case T_EXITM:
        return( MacroEnd( TRUE ) );
    case T_ARG:
        return( Parse_Pass == PASS_1 ? ArgDef(i) : NOT_ERROR );
    case T_USES:
        return( Parse_Pass == PASS_1 ? UsesDef(i) : NOT_ERROR );
    case T_LOCAL:
        return( Parse_Pass == PASS_1 ? LocalDef(i) : NOT_ERROR );
    case T_COMMENT:
        if( Options.mode & MODE_IDEAL )
            break;
        return( Comment( START_COMMENT, i ) );
    case T_STRUCT:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_STRUC:
        return( StructDef( i ) );
    case T_NAME:
        return( Parse_Pass == PASS_1 ? NameDirective(i) : NOT_ERROR );
    case T_LABEL:
        return( LabelDirective( i ) );
    case T_ORG:
        return( OrgDirective( i ) );
    case T_ALIGN:
    case T_EVEN:
        return( AlignDirective( direct, i ) );
    case T_FOR:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_IRP:
        return( ForDirective ( i+1, IRP_WORD ) );
    case T_FORC:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_IRPC:
        return( ForDirective ( i+1, IRP_CHAR ) );
    case T_REPEAT:
        if( Options.mode & MODE_IDEAL ) {
            break;
        }
    case T_REPT:
        return( ForDirective ( i+1, IRP_REPEAT ) );
    case T_DOT_STARTUP:
    case T_DOT_EXIT:
    case T_STARTUPCODE:
    case T_EXITCODE:
        return( Startup ( i ) );
    case T_LOCALS:
    case T_NOLOCALS:
        return( Locals( i ) );
    }
    AsmError( UNKNOWN_DIRECTIVE );
    return( ERROR );
}
void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
  const NamespaceDecl *ND = Result.Nodes.getNodeAs<NamespaceDecl>("namespace");
  const SourceManager &Sources = *Result.SourceManager;

  if (!locationsInSameFile(Sources, ND->getLocStart(), ND->getRBraceLoc()))
    return;

  // Don't require closing comments for namespaces spanning less than certain
  // number of lines.
  unsigned StartLine = Sources.getSpellingLineNumber(ND->getLocStart());
  unsigned EndLine = Sources.getSpellingLineNumber(ND->getRBraceLoc());
  if (EndLine - StartLine + 1 <= ShortNamespaceLines)
    return;

  // Find next token after the namespace closing brace.
  SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
  SourceLocation Loc = AfterRBrace;
  Token Tok;
  // Skip whitespace until we find the next token.
  while (Lexer::getRawToken(Loc, Tok, Sources, Result.Context->getLangOpts())) {
    Loc = Loc.getLocWithOffset(1);
  }
  if (!locationsInSameFile(Sources, ND->getRBraceLoc(), Loc))
    return;

  bool NextTokenIsOnSameLine = Sources.getSpellingLineNumber(Loc) == EndLine;
  // If we insert a line comment before the token in the same line, we need
  // to insert a line break.
  bool NeedLineBreak = NextTokenIsOnSameLine && Tok.isNot(tok::eof);

  // Try to find existing namespace closing comment on the same line.
  if (Tok.is(tok::comment) && NextTokenIsOnSameLine) {
    StringRef Comment(Sources.getCharacterData(Loc), Tok.getLength());
    SmallVector<StringRef, 6> Groups;
    if (NamespaceCommentPattern.match(Comment, &Groups)) {
      StringRef NamespaceNameInComment = Groups.size() >= 6 ? Groups[5] : "";

      // Check if the namespace in the comment is the same.
      if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) ||
          ND->getNameAsString() == NamespaceNameInComment) {
        // FIXME: Maybe we need a strict mode, where we always fix namespace
        // comments with different format.
        return;
      }

      // Otherwise we need to fix the comment.
      NeedLineBreak = Comment.startswith("/*");
      CharSourceRange OldCommentRange = CharSourceRange::getCharRange(
          SourceRange(Loc, Loc.getLocWithOffset(Tok.getLength())));
      diag(Loc, "namespace closing comment refers to a wrong namespace '%0'")
          << NamespaceNameInComment
          << FixItHint::CreateReplacement(
                 OldCommentRange, getNamespaceComment(ND, NeedLineBreak));
      return;
    }

    // This is not a recognized form of a namespace closing comment.
    // Leave line comment on the same line. Move block comment to the next line,
    // as it can be multi-line or there may be other tokens behind it.
    if (Comment.startswith("//"))
      NeedLineBreak = false;
  }

  diag(ND->getLocation(), "namespace not terminated with a closing comment")
      << FixItHint::CreateInsertion(AfterRBrace,
                                    std::string(SpacesBeforeComments, ' ') +
                                        getNamespaceComment(ND, NeedLineBreak));
}
예제 #25
0
// DB2 CREATE DATABASE statement
bool SqlParser::Db2CreateDatabase(Token *create, Token * /*database*/, Token * /*name*/)
{
	bool exists = false;

	// CREATE DATABASE options
	while(true)
	{
		Token *next = GetNextToken();

		if(next == NULL)
			break;

		// BUFFERPOOL name
		if(next->Compare("BUFFERPOOL", L"BUFFERPOOL", 10) == true)
		{
			Token *name = GetNextToken();

			if(Target(SQL_DB2, SQL_ORACLE) == false)
				Token::Remove(next, name);

			exists = true;
			continue;
		}
		else
		// INDEXBP name
		if(next->Compare("INDEXBP", L"INDEXBP", 7) == true)
		{
			Token *name = GetNextToken();

			if(Target(SQL_DB2, SQL_ORACLE) == false)
				Token::Remove(next, name);

			exists = true;
			continue;
		}
		else
		// STOGROUP name
		if(next->Compare("STOGROUP", L"STOGROUP", 8) == true)
		{
			Token *name = GetNextToken();

			if(Target(SQL_DB2, SQL_ORACLE) == false)
				Token::Remove(next, name);

			exists = true;
			continue;
		}
		else
		// CCSID ASCII | EBCDIC | UNICODE
		if(next->Compare("CCSID", L"CCSID", 5) == true)
		{
			Token *code = GetNextToken();

			if(Target(SQL_DB2, SQL_ORACLE) == false)
				Token::Remove(next, code);

			exists = true;
			continue;
		}
	
		PushBack(next);
		break;
	}

	// Comment the entire statement for Oracle
	if(_target == SQL_ORACLE)
	{
		Token *end = GetLastToken(GetNextCharToken(';', L';'));
		Comment(create, end);
	}

	return exists;
}
예제 #26
0
void ComRead( void )
{
    char        *cursor;
    uint        column;
    char        ch;
    byte        chtype;
    uint        stmt_type;
    unsigned_32 stmt_no;
    bool        stno_found;
    byte        cont_type;
    bool        done_scan;
    ftnoption   save_options;

    // Comment processor sets "Options" so that
    //          c$warn
    //          c$notime=5
    // is diagnosed if /nowarn is specified
    // "Options" must be saved so that we don't get an unreferenced warning
    // message in the following case.
    //          c$noreference
    //                  integer*4 sam
    //          c$reference
    //                  end
    save_options = Options;
    stmt_type = STMT_COMMENT;
    cont_type = 0;
    cursor = 0;
    column = FIRST_COL - 1;
    stmt_no = 0;
    stno_found = FALSE;
    done_scan = FALSE;
    for(;;) {
        ReadSrc();
        if( ProgSw & PS_SOURCE_EOF ) break;
        if( CurrFile->flags & CONC_PENDING ) break;
        // column starts off before current column
        column = FIRST_COL - 1;
        cursor = SrcBuff;
        ch = *cursor;
        if( ( ch != 'C' ) && ( ch != 'c' ) && ( ch != '*' ) ) {
            if( ProgSw & PS_SKIP_SOURCE ) continue;
            if( ( ch == 'D' ) || ( ch == 'd' ) ) {
                if( !(ExtnSw & XS_D_IN_COLUMN_1) ) {
                    Extension( CC_D_IN_COLUMN_1 );
                    ExtnSw |= XS_D_IN_COLUMN_1;
                }
                if( !CompileDebugStmts() ) continue;
                ch = ' ';
            }
            // not a comment (but it might be a blank line)
            // try for a statement number
            stmt_no = 0;
            stno_found = FALSE;
            for(;;) {
                chtype = CharSetInfo.character_set[ (unsigned char)ch ];
                if( chtype == C_EL ) break;
                if( ( chtype == C_CM ) && ( column != CONT_COL - 1 ) ) {
                    if( ( ExtnSw & XS_EOL_COMMENT ) == 0 ) {
                        Extension( CC_EOL_COMMENT );
                        ExtnSw |= XS_EOL_COMMENT;
                    }
                    break;
                }
                if( chtype == C_SP ) {
                    ++column;
                } else if( chtype == C_TC ) {
                    column += 8 - column % 8;
                } else if( CharSetInfo.is_double_byte_blank( cursor ) ) {
                    cursor++;
                    column += 2;
                } else {
                    // a digit in the statement number field
                    ++column;
                    if( ( chtype == C_DI ) && ( column != CONT_COL ) ) {
                        stmt_type = STMT_START;
                        if( column > CONT_COL ) {
                            done_scan = TRUE;
                            break;
                        }
                        stmt_no = 10 * stmt_no + ch - '0';
                        stno_found = TRUE;
                    } else {
                        stmt_type = STMT_START;
                        if( column != CONT_COL ) {
                            done_scan = TRUE;
                            break;
                        }
                        // its in the continuation column
                        if( ch != '0' ) {
                            // we have a genuine continuation line
                            // but save the type for later diagnosis
                            cont_type = chtype;
                            stmt_type = STMT_CONT;
                            // position to column 7
                            ++column;
                            ++cursor;
                            done_scan = TRUE;
                            break;
                        }
                    }
                }
                ++cursor;
                ch = *cursor;
                if( column >= LastColumn ) {
                    // Consider:                             Column 73
                    //     1                                     |
                    //     0123                                  2001
                    *cursor = NULLCHAR;
                    break;
                }
            }
            if( done_scan ) break;
            if( stmt_type != STMT_COMMENT ) break;
        }
        Comment();
        // quit if the comment simulates EOF (i.e. C$DATA)
        if( ProgSw & PS_SOURCE_EOF ) break;
        // quit if c$include encountered
        if( CurrFile->flags & INC_PENDING ) break;
    }
    Cursor = cursor;
    Column = column - 1;
    NextStmtNo = stmt_no;
    StmtNoFound = stno_found;
    StmtType = stmt_type;
    ContType = cont_type;
    Options = save_options;
}
예제 #27
0
void prep_line_for_conditional_assembly( char *line )
/***************************************************/
{
    char        *ptr;
    char        *end;
    int         count;
    char        delim;
    char        fix;

    if( Comment( QUERY_COMMENT, 0 ) ) {
        delim = (char)Comment( QUERY_COMMENT_DELIM, 0 );
        if( strchr( line, delim ) != NULL ) {
            Comment( END_COMMENT, 0 );
        }
        *line = '\0';
        return;
    }

    if( *line == '\0' ) return;

    /* fixme */
    /* get rid of # signs */
    ptr = line + strspn( line, " \t" );
    for( end = ptr; isalnum( *end ) || *end == '#' ; ++end )
        /* nothing to do */ ;
    fix = *end;
    *end = '\0';

    if( *ptr == '#' ) {
        /* treat #if as if, remove # sign */
        *ptr =' ';
        ptr++;
    }

    count = get_instruction_position( ptr );
    *end = fix;
    if( count == EMPTY ) {
        /* if it is not in the table */
        if( CurState == LOOKING_FOR_TRUE_COND || CurState == DONE || MacroExitState ) {
            *line = '\0';
        }
        return;
    }

    /* otherwise, see if it is a conditional assembly directive */

    switch( AsmOpTable[count].token) {
    case T_ELSE:
    case T_ELSEIF:
    case T_ELSEIF1:
    case T_ELSEIF2:
    case T_ELSEIFB:
    case T_ELSEIFDEF:
    case T_ELSEIFE:
    case T_ELSEIFDIF:
    case T_ELSEIFDIFI:
    case T_ELSEIFIDN:
    case T_ELSEIFIDNI:
    case T_ELSEIFNB:
    case T_ELSEIFNDEF:
    case T_ENDIF:
    case T_IF:
    case T_IF1:
    case T_IF2:
    case T_IFB:
    case T_IFDEF:
    case T_IFE:
    case T_IFDIF:
    case T_IFDIFI:
    case T_IFIDN:
    case T_IFIDNI:
    case T_IFNB:
    case T_IFNDEF:
        break;
    default:
        if( CurState == LOOKING_FOR_TRUE_COND || CurState == DONE || MacroExitState ) {
            *line = '\0';
        }
    }
    return;
}
예제 #28
0
void CBSumCaret::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags, CView* pView)
{

	UINT txi = m_xi * nRepCnt;   
	UINT txs = m_xs * nRepCnt;
	DWORD tyi = m_yi * nRepCnt;
	DWORD tys = m_ys * nRepCnt;
	UINT OldXPos = m_XPosition;
	DWORD OldYPos = m_YPosition;
	int nomove = 0, comment = 0;
	UINT smaxx = m_maxx;
	DWORD smaxy = m_maxy;
	UINT sminx = m_minx;
	DWORD sminy = m_miny;
	char tChar;

	// Arange for clipping function	
	if ( m_Clipping ) {
		/*
		m_maxx = m_ClipRect.BottomRight().x;
		m_maxy = m_ClipRect.BottomRight().y - m_CaretHeight;
		m_minx = m_ClipRect.TopLeft().x - 2;
		m_miny = m_ClipRect.TopLeft().y;
		*/
		m_maxx = m_ClipXPosition + m_ClipXSize;
		m_maxy = m_ClipYPosition + m_ClipYSize - m_CaretHeight;
//		m_minx = m_ClipXPosition - 2;
		m_minx = m_ClipXPosition;
		m_miny = m_ClipYPosition;
	}

	// Move m_Position based on char and max's
	switch ( nChar ) {
	case VK_UP:
		if ( (m_miny + tyi) <= m_YPosition ) {
			m_YPosition -= tyi;
		}
		break;
	case VK_DOWN:
		if ( (m_YPosition + tyi) < m_maxy ) {
			m_YPosition += tyi;
		}
		break;
	case VK_LEFT:
		if ( m_ControlOn ) {
			if ( (m_minx + txs) <= m_XPosition ) {
				m_XPosition -= txs;
			} else {
				while ( (m_minx + txi) <= m_XPosition ) {
					m_XPosition -= txi;
				}
			}				
		} else {
			if ( (m_minx + txi) <= m_XPosition ) {
				m_XPosition -= txi;
			}
		}
		break;
	case VK_RIGHT:
		if ( m_ControlOn ) {
			if ( (m_XPosition + txs) < m_maxx ) {
				m_XPosition += txs;
			} else {
				while ( (m_XPosition + txi) < m_maxx ) {
					m_XPosition += txi;
				}
			}				
		} else {
			if ( (m_XPosition + txi) < m_maxx ) {
				m_XPosition += txi;
			}
		}
		break;
	case VK_CONTROL:
		m_ControlOn = 1;
		nomove = 1;
		break;
	case VK_SHIFT:
		m_ShiftOn = 1;
		if ( !(nFlags & 0x4000) ) {
			LeftDown( m_XPosition, m_YPosition, pView );
		}
		nomove = 1;
		break;
	case VK_END:
		if ( m_ControlOn ) {
			m_YPosition = m_maxy;
		} else {
			while ( (m_XPosition + txi) < m_maxx ) {
				m_XPosition += txi;
			}
		}
		break;
	case VK_HOME:
		if ( m_ControlOn ) {
			m_YPosition = m_miny;
		} else {
			while ( (m_minx + txi) <= m_XPosition ) {
				m_XPosition -= txi;
			}
		}
		break;
	case VK_NEXT:
		if ( (m_YPosition + tys) < m_maxy ) {
			m_YPosition += tys;
		} else {
			while ( (m_YPosition + tyi) < m_maxy ) {
				m_YPosition += tyi;
			}
		}				
		break;
	case VK_PRIOR:
		if ( (m_miny + tys) <= m_YPosition ) {
			m_YPosition -= tys;
		} else {
			while ( (m_miny + tyi) <= m_YPosition ) {
				m_YPosition -= tyi;
			}
		}				
		break;
	case VK_RETURN:
		if ( !m_ShiftOn ) {
			// Simulate Mouse double click calls.
			LeftDown( m_XPosition, m_YPosition, pView );
			LeftUp( m_XPosition, m_YPosition, pView );
			Select( m_XPosition, m_YPosition, pView );
			LeftUp( m_XPosition, m_YPosition, pView );
		}
		nomove = 1;
		break;
	default:		// Here we going to test for alpha ...
		if ( isprint ( (tChar = MakeAscii(nChar, nFlags)) ) ) {
			comment = 1;
		}
		if ( tChar == 8 ) {
			if ( (m_minx + txi) < m_XPosition ) {
				m_XPosition -= txi;
			}
		}			
		break;
	}

	// Undo clipping function
	if ( m_Clipping ) {
		m_maxx = smaxx;
		m_maxy = smaxy;
		m_minx = sminx;
		m_miny = sminy;
	}

	// Comment processing	
	if ( comment ) {
		if ( Comment( tChar, m_XPosition, m_YPosition, pView ) ) {
			// Advance caret only if char taken
			if ( (m_XPosition + txi) < m_maxx ) {
				m_XPosition += txi;
			}
		}

//		return;
	}

	// Check if keystroke resulted in movement
	if ( !nomove ) {

		// If selecting, then call move virtual function
		if ( m_ShiftOn ) {
			Move ( m_XPosition, m_YPosition, pView );
		}
		
		// Check for screen scroll bars positions
	    // CPoint tPos = m_Position;

	    if ( 
			(m_YPosition - m_ScrollYPosition + m_CaretHeight) >= m_ViewYSize 
			&& m_YPosition >= m_ScrollYPosition 
		) {
	
			if ( (m_YPosition + m_CaretHeight) > m_maxy ) {
	    		m_YPosition -= m_CaretHeight;
		    	m_ScrollYPosition = m_maxy - m_ViewYSize;
	    	} else {
		    	m_ScrollYPosition += m_YPosition - OldYPos;
		    }
		    	
	    	((CSummaryView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition );
	    	((CSummaryView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition);

		} else if ( m_YPosition < m_ScrollYPosition  ) {

// Changed because of end at second to last line, then page up till error ..
//			if ( m_YPosition < (DWORD)m_CaretHeight ) {
			if ( OldYPos - m_YPosition > m_ScrollYPosition ) {
		    	m_ScrollYPosition = 0;
	    	} else {
		    	m_ScrollYPosition -= OldYPos - m_YPosition;
		    }
	    	
	    	((CSummaryView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition );
	    	((CSummaryView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition);
	    
		} else if ( m_XPosition - m_ScrollXPosition >= m_ViewXSize && m_XPosition >= m_ScrollXPosition ) {
	    	m_ScrollXPosition += m_XPosition - OldXPos;
			if ( m_XPosition + m_xi == m_maxx ) {
				m_ScrollXPosition += m_xi;
			}
	    	
	    	((CSummaryView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition );
	    	((CSummaryView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition);
		
		} else if ( m_XPosition < m_ScrollXPosition ) {
			if ( OldXPos - m_XPosition > m_ScrollXPosition ) {
				m_ScrollXPosition = 0;
			} else {
		    	m_ScrollXPosition -= OldXPos - m_XPosition;
			}
	    	
	    	((CSummaryView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition );
	    	((CSummaryView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition);
		}
	}
		

	// Check if Scroll Call need to be made.
	// CRect tRect ( m_ScrollPos, m_ViewSize );


	if ( !((m_XPosition >= m_ScrollXPosition && m_XPosition < (m_ScrollXPosition + m_ViewXSize)) 
		&&
		(m_YPosition >= m_ScrollYPosition && m_YPosition < (m_ScrollYPosition + m_ViewYSize)))
	) {

		// CPoint tPos = m_ScrollPos;
		UINT tXPos = m_ScrollXPosition;
		DWORD tYPos = m_ScrollYPosition;
		UINT tX = 0;
		if ( m_maxx > m_ViewXSize ) tX = m_maxx - m_ViewXSize;
		DWORD tY = 0;
		if ( m_maxy > m_ViewYSize ) tY = m_maxy - m_ViewYSize;
		tYPos = m_YPosition < tY ? m_YPosition: tY;
		tXPos = m_XPosition < tX ? m_XPosition: tX;
    	((CSummaryView*)pView)->ScrollToPosition ( tXPos, tYPos );
    	((CSummaryView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition);
	}


	// Set the caret to the current position
	CaretPos ();
{
	POSITION tPos = ((CSummaryView*)pView)->m_RowViewList.GetHeadPosition();
	CGPRowView *tGP;

	while ( tPos != NULL ) {
		tGP = (CGPRowView *)((CSummaryView*)pView)->m_RowViewList.GetNext(tPos);
		if ( tGP->IsPointWithin( m_XPosition, m_YPosition ) ) {
			tGP->SetStatusBar(nFlags, m_XPosition, m_YPosition );
			break;
		}
	}
}
}
예제 #29
0
///Does not delete the comment
Comment CommentStore::latestComment() const {
    CommentSet::const_iterator it = m_comments.end();
    if( it == m_comments.begin() ) return Comment();
    --it;
    return *it;
}
예제 #30
0
파일: mediainfo.c 프로젝트: Erikhht/TCPMP
static int Init(win* p)
{
	tchar_t s[256];
	packetformat Format;
	int No;
	node* VOutput = NULL;
	node* Reader = NULL;
	node* Input = NULL;
	node* Player = Context()->Player;
	winunit y;

	Player->Get(Player,PLAYER_FORMAT,&Reader,sizeof(Reader));
	Player->Get(Player,PLAYER_INPUT,&Input,sizeof(Input));
	Player->Get(Player,PLAYER_VOUTPUT,&VOutput,sizeof(VOutput));

	y = 4;

	if (Input)
		Info(p,Input,&y,0);

	if (Reader)
	{
		pin Pin;

		Info(p,Reader,&y,MEDIAINFO_FORMAT);
		Comment(p,(player*)Player,&y,-1);

		for (No=0;Reader->Get(Reader,FORMAT_STREAM+No,&Pin,sizeof(Pin))==ERR_NONE;++No)
			if (PlayerGetStream((player*)Player,No,&Format,NULL,0,NULL))
			{
				y += 6;

				if (Format.Type != PACKET_NONE)
				{
					if (!PacketFormatName(&Format,s,TSIZEOF(s))) s[0] =0;
					WinPropLabel(p,&y,LangStr(PLAYER_ID,STREAM_NAME+Format.Type),s);
				}

				switch (Format.Type)
				{
				case PACKET_NONE:
					break;

				case PACKET_VIDEO:
					if (Pin.Node && Compressed(&Format.Format.Video.Pixel))
						Info(p,Pin.Node,&y,MEDIAINFO_CODEC);

					if (Format.Format.Video.Width && Format.Format.Video.Height)
					{
						stprintf_s(s,TSIZEOF(s),T("%d x %d"),Format.Format.Video.Width,Format.Format.Video.Height);
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_SIZE),s);
					}
					if (Format.PacketRate.Num)
					{
						FractionToString(s,TSIZEOF(s),&Format.PacketRate,0,3);
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_FPS),s);
					}
					if (Format.ByteRate)
					{
						IntToString(s,TSIZEOF(s),(Format.ByteRate+62)/125,0);
						tcscat_s(s,TSIZEOF(s),T(" kbit/s")); // 1000byte/sec
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_BITRATE),s);
					}

					break;

				case PACKET_AUDIO:

					if (Pin.Node && Format.Format.Audio.Format != AUDIOFMT_PCM)
						Info(p,Pin.Node,&y,MEDIAINFO_CODEC);

					s[0] = 0;
					if (Format.Format.Audio.SampleRate)
					{
						IntToString(s+tcslen(s),TSIZEOF(s)-tcslen(s),Format.Format.Audio.SampleRate,0);
						tcscat_s(s,TSIZEOF(s),T(" Hz "));
					}
					switch (Format.Format.Audio.Channels)
					{
					case 0: break;
					case 1: tcscat_s(s,TSIZEOF(s),LangStr(MEDIAINFO_ID,MEDIAINFO_AUDIO_MONO)); break;
					case 2: tcscat_s(s,TSIZEOF(s),LangStr(MEDIAINFO_ID,MEDIAINFO_AUDIO_STEREO)); break;
					default: stcatprintf_s(s,TSIZEOF(s),T("%d Ch"),Format.Format.Audio.Channels); break;
					}
					if (s[0])
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_FORMAT),s);

					if (Format.ByteRate)
					{
						IntToString(s,TSIZEOF(s),(Format.ByteRate+62)/125,0);
						tcscat_s(s,TSIZEOF(s),T(" kbit/s")); // 1000bit/sec
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_BITRATE),s);
					}

					break;

				case PACKET_SUBTITLE:
					if (Pin.Node)
						Info(p,Pin.Node,&y,MEDIAINFO_CODEC);
					break;
				}

				Comment(p,(player*)Player,&y,No);
			}

		if (VOutput)
		{
			int Total = 0;
			int Dropped = 0;

			VOutput->Get(VOutput,OUT_TOTAL,&Total,sizeof(int));
			VOutput->Get(VOutput,OUT_DROPPED,&Dropped,sizeof(int));

			Total += Dropped;
			if (Total)
			{
				y += 6;

				IntToString(s,TSIZEOF(s),Total,0);
				WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_VIDEO_TOTAL),s);

				IntToString(s,TSIZEOF(s),Dropped,0);
				WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_VIDEO_DROPPED),s);

				Player->Get(Player,PLAYER_VSTREAM,&No,sizeof(No));
				if (No>=0 && Reader->Get(Reader,(FORMAT_STREAM+No)|PIN_FORMAT,&Format,sizeof(Format))==ERR_NONE &&
					Format.Type == PACKET_VIDEO && Format.PacketRate.Num)
				{
					Simplify(&Format.PacketRate,(1<<30)/Total,(1<<30)/Total);
					Format.PacketRate.Num *= Total - Dropped;
					Format.PacketRate.Den *= Total;
					FractionToString(s,TSIZEOF(s),&Format.PacketRate,0,3);
					WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_AVG_FPS),s);
				}
			}
		}
	}

	return ERR_NONE;
}