void NamePrettyPrinter::visit(NameId *name)
{
    Identifier *id = name->identifier();
    if (id)
        _name = QString::fromLatin1(id->chars(), id->size());
    else
        _name = QLatin1String("anonymous");
}
Exemple #2
0
String::String(const Identifier& str)
{
    if (str.isNull())
        return;
    
    if (str.isEmpty())
        m_impl = StringImpl::empty();
    else 
        m_impl = new StringImpl(reinterpret_cast<const UChar*>(str.data()), str.size());
}
// Check for a CSS prefix.
// Passed prefix is all lowercase.
// First character of the prefix within the property name may be upper or lowercase.
// Other characters in the prefix within the property name must be lowercase.
// The prefix within the property name must be followed by a capital letter.
static bool hasCSSPropertyNamePrefix(const Identifier& propertyName, const char* prefix)
{
#ifndef NDEBUG
    ASSERT(*prefix);
    for (const char* p = prefix; *p; ++p)
        ASSERT(isASCIILower(*p));
    ASSERT(propertyName.size());
#endif

    if (toASCIILower(propertyName.data()[0]) != prefix[0])
        return false;

    unsigned length = propertyName.size();
    for (unsigned i = 1; i < length; ++i) {
        if (!prefix[i])
            return isASCIIUpper(propertyName.data()[i]);
        if (propertyName.data()[i] != prefix[i])
            return false;
    }
    return false;
}
Loader::Loader(const std::string& fileName, const Identifier& acceptedIdentifier):
	fileContents(fileName)
{
	constexpr auto minimalSize = sizeof(Identifier) + sizeof(Node::START) + sizeof(Node::type) + sizeof(Node::END);
	if (fileContents.size() <= minimalSize) {
		throw InvalidOTBFormat{};
	}

	Identifier fileIdentifier;
	std::copy(fileContents.begin(), fileContents.begin() + fileIdentifier.size(), fileIdentifier.begin());
	if (fileIdentifier != acceptedIdentifier && fileIdentifier != wildcard) {
		throw InvalidOTBFormat{};
	}
}
void NamePrettyPrinter::visit(SelectorNameId *name)
{
    for (unsigned i = 0; i < name->nameCount(); ++i) {
        Name *n = name->nameAt(i);
        if (!n)
            continue;

        Identifier *id = n->identifier();
        if (id) {
            _name += QString::fromLatin1(id->chars(), id->size());

            if (name->hasArguments() || name->nameCount() > 1)
                _name += ':';
        }
    }
}
static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0)
{
    if (hadPixelOrPosPrefix)
        *hadPixelOrPosPrefix = false;

    unsigned length = propertyName.size();
    if (!length)
        return String();

    Vector<UChar> name;
    name.reserveInitialCapacity(length);

    unsigned i = 0;

    if (hasCSSPropertyNamePrefix(propertyName, "css"))
        i += 3;
    else if (hasCSSPropertyNamePrefix(propertyName, "pixel")) {
        i += 5;
        if (hadPixelOrPosPrefix)
            *hadPixelOrPosPrefix = true;
    } else if (hasCSSPropertyNamePrefix(propertyName, "pos")) {
        i += 3;
        if (hadPixelOrPosPrefix)
            *hadPixelOrPosPrefix = true;
    } else if (hasCSSPropertyNamePrefix(propertyName, "webkit")
            || hasCSSPropertyNamePrefix(propertyName, "khtml")
            || hasCSSPropertyNamePrefix(propertyName, "apple"))
        name.append('-');
    else {
        if (isASCIIUpper(propertyName.data()[0]))
            return String();
    }

    name.append(toASCIILower(propertyName.data()[i++]));

    for (; i < length; ++i) {
        UChar c = propertyName.data()[i];
        if (!isASCIIUpper(c))
            name.append(c);
        else {
            name.append('-');
            name.append(toASCIILower(c));
        }
    }

    return String::adopt(name);
}
void NamePrettyPrinter::visit(TemplateNameId *name)
{
    Identifier *id = name->identifier();
    if (id)
        _name = QString::fromLatin1(id->chars(), id->size());
    else
        _name = QLatin1String("anonymous");
    _name += QLatin1Char('<');
    for (unsigned index = 0; index < name->templateArgumentCount(); ++index) {
        if (index != 0)
            _name += QLatin1String(", ");

        FullySpecifiedType argTy = name->templateArgumentAt(index);
        QString arg = overview()->prettyType(argTy);
        if (arg.isEmpty())
            _name += QString::fromLatin1("_Tp%1").arg(index + 1);
        else
            _name += arg;
    }
    if (! _name.isEmpty() && _name.at(_name.length() - 1) == '>')
        _name += QLatin1Char(' ');
    _name += QLatin1Char('>');
}
void NamePrettyPrinter::visit(DestructorNameId *name)
{
    Identifier *id = name->identifier();
    _name += QLatin1Char('~');
    _name += QString::fromLatin1(id->chars(), id->size());
}
Exemple #9
0
int Lookup::find(const struct HashTable *table, const Identifier &s)
{
  const HashEntry *entry = KJS::findEntry(table, s.ustring().rep()->hash(), s.data(), s.size());
  if (entry)
    return entry->value;
  return -1;
}
Exemple #10
0
int Lookup::find(const struct HashTable *table, const Identifier &s)
{
  return find(table, s.data(), s.size());
}
Exemple #11
0
unsigned int Lookup::hash(const Identifier &key)
{
  return hash(key.data(), key.size());
}
Exemple #12
0
String::String(const Identifier& str)
{
    if (str.isNull())
        return;
    m_impl = StringImpl::create(str.data(), str.size());
}