コード例 #1
0
ファイル: Parser.cpp プロジェクト: looncraz/haiku
bool
Token::operator==(Token &ref) const {
	// Compare types, then data if necessary
	if (Type() == ref.Type()) {
		switch (Type()) {
			case CharacterString:
//				printf(" str1 == '%s'\n", String());
//				printf(" str2 == '%s'\n", ref.String());
//				printf(" strcmp() == %d\n", strcmp(String(), ref.String()));
			{
				return String() == ref.String();				
				
/*				
				// strcmp() seems to choke on certain, non-normal ASCII chars
				// (i.e. chars outside the usual alphabets, but still valid
				// as far as ASCII is concerned), so we'll just compare the
				// strings by hand to be safe.
				const char *str1 = String();
				const char *str2 = ref.String();				
				int len1 = strlen(str1);
				int len2 = strlen(str2);
//				printf("len1 == %d\n", len1);
//				printf("len2 == %d\n", len2);
				if (len1 == len2) {
					for (int i = 0; i < len1; i++) {
//						printf("i == %d, str1[%d] == %x, str2[%d] == %x\n", i, i, str1[i], i, str2[i]);
						if (str1[i] != str2[i])
							return false;
					}
				}
				return true;
*/
			}
//				return strcmp(String(), ref.String()) == 0;
			
			case Integer:
				return Int() == ref.Int();
				
			case FloatingPoint:
				return Float() == ref.Float();		
			
			default:
				return true;	
		}	
	} else
		return false;
}
コード例 #2
0
 // ColorMask 0 | RGBA
 NodePtr Parser::ColorMask(std::unique_ptr<ParserNode> left, const Token & tok)
 {
     ngfx::BlendState* BS = ExtractBlend(left.get());
     if (LookAhead(Token::TOK_INTEGER)) {
         Token mask = Consume();
         BS->renderTargets[0].colorWriteMask = mask.Int();
     } else if (LookAhead(Token::TOK_IDENTIFIER)) {
         auto cmTok = Consume().Str();
         if(!ParseColorMask(cmTok, BS->renderTargets[0])) {
             SpawnError("Failed to parse ColorMask value", "Any of 'RGBA' here");
             return left;
         }
     } else {
         SpawnError("Failed to parse ColorMask", "Expected Integer or Any of 'RGBA' here");
         return left;
     }
     return left;
 }