Exemple #1
0
/*
 * Add a UTF8 string as a 4-byte length followed by a non-NULL-terminated
 * string.
 *
 * Because these strings are coming out of the VM, it's safe to assume that
 * they can be null-terminated (either they don't have null bytes or they
 * have stored null bytes in a multi-byte encoding).
 */
void expandBufAddUtf8String(ExpandBuf *pBuf, const u1 *str) {
    int strLen = strlen((const char *) str);

    ensureSpace(pBuf, sizeof(u4) + strLen);
    setUtf8String(pBuf->storage + pBuf->curLen, str);
    pBuf->curLen += sizeof(u4) + strLen;
}
Exemple #2
0
int SP_NKStringBuffer :: append( char c )
{
	ensureSpace( 1 );
	mImpl->mBuffer[ mImpl->mSize++ ] = c;
	mImpl->mBuffer[ mImpl->mSize ] = '\0';

	return 0;
}
int SP_JsonStringBuffer :: append( char c )
{
	ensureSpace( 1 );
	mBuffer[ mSize++ ] = c;
	mBuffer[ mSize ] = '\0';

	return 0;
}
Exemple #4
0
quint8 IOBuffer::readByte()
{
	quint8 num =0;
	if (ensureSpace(sizeof(quint8)))
	{
		num = m_ba.at(m_nCurrentPos);
		m_nCurrentPos++;
	}
	return num;
}
Exemple #5
0
QByteArray IOBuffer::readByteArray(quint32 size)
{
	QByteArray ba;
    if (ensureSpace(size))
	{
        ba = m_ba.mid(m_nCurrentPos, size);
        m_nCurrentPos += size;
	}
	return ba;
}
Exemple #6
0
/*
 * Allocate some space in the buffer.
 */
u1 *expandBufAddSpace(ExpandBuf *pBuf, int gapSize) {
    u1 *gapStart;

    ensureSpace(pBuf, gapSize);
    gapStart = pBuf->storage + pBuf->curLen;
    /* do we want to garbage-fill the gap for debugging? */
    pBuf->curLen += gapSize;

    return gapStart;
}
void QTextEngine::shape( int item ) const
{
    assert( item < items.size() );
    QScriptItem &si = items[item];

    if ( si.num_glyphs )
	return;

    QFont::Script script = (QFont::Script)si.analysis.script;
    si.glyph_data_offset = used;

    if ( !si.fontEngine )
	si.fontEngine = fnt->engineForScript( script );
    si.fontEngine->ref();

	si.ascent = si.fontEngine->ascent();
	si.descent = si.fontEngine->descent();
    si.num_glyphs = 0;

    if ( si.fontEngine && si.fontEngine != (QFontEngine*)-1 ) {
        QShaperItem shaper_item;
        shaper_item.script = si.analysis.script;
        shaper_item.string = &string;
        shaper_item.from = si.position;
        shaper_item.length = length(item);
        shaper_item.font = si.fontEngine;
        shaper_item.num_glyphs = QMAX(int(num_glyphs - used), shaper_item.length);
        shaper_item.flags = si.analysis.bidiLevel % 2 ? RightToLeft : 0;

        while (1) {
//         qDebug("    . num_glyphs=%d, used=%d, item.num_glyphs=%d", num_glyphs, used, shaper_item.num_glyphs);
            ensureSpace(shaper_item.num_glyphs);
            shaper_item.num_glyphs = num_glyphs - used;
//          qDebug("    .. num_glyphs=%d, used=%d, item.num_glyphs=%d", num_glyphs, used, shaper_item.num_glyphs);
            shaper_item.glyphs = glyphs(&si);
            shaper_item.advances = advances(&si);
            shaper_item.offsets = offsets(&si);
            shaper_item.attributes = glyphAttributes(&si);
            shaper_item.log_clusters = logClusters(&si);
            if (scriptEngines[shaper_item.script].shape(&shaper_item))
                break;
        }

        si.num_glyphs = shaper_item.num_glyphs;
    }
    ((QTextEngine *)this)->used += si.num_glyphs;

    si.width = 0;
    advance_t *advances = this->advances( &si );
    advance_t *end = advances + si.num_glyphs;
    while ( advances < end )
	si.width += *(advances++);

    return;
}
Exemple #8
0
quint16 IOBuffer::readUInt16()
{
    quint16 n =0;
	if (ensureSpace(sizeof(quint16)))
	{
        n = *((quint16*) m_ba.mid(m_nCurrentPos, sizeof(quint16)).data());
		m_nCurrentPos += sizeof(quint16);
	}

    return n;
}
Exemple #9
0
quint64 IOBuffer::readUInt64()
{
    quint64 num = 0;
    if (ensureSpace(sizeof(quint64)))
    {
        num = *((quint64*) m_ba.mid(m_nCurrentPos, sizeof(quint64)).data());
        m_nCurrentPos += sizeof(quint64);
    }

    return num;
}
/**
 * The init method for this class.  This does delayed
 * initialization of this object until a INIT message is
 * received during initialization.
 *
 * @param initialSize
 *               The initial list size (optional)
 *
 * @return Always returns nothing
 */
RexxObject *QueueClass::initRexx(RexxObject *initialSize)
{
    // It would be nice to do this expansion in the new method, but it sort
    // of messes up subclasses (e.g. CircularQueue) if we steal the first new
    // argument.  We will set the capacity here, even if it means an immediate expansion

    // the capacity is optional, but must be a positive numeric value
    size_t capacity = optionalLengthArgument(initialSize, DefaultArraySize, ARG_ONE);
    ensureSpace(capacity);
    return OREF_NULL;
}
Exemple #11
0
int SP_NKStringBuffer :: append( const char * value, int size )
{
	if( NULL == value ) return -1;

	size = ( size <= 0 ? strlen( value ) : size );
	if( size <= 0 ) return -1;

	ensureSpace( size );
	memcpy( mImpl->mBuffer + mImpl->mSize, value, size );
	mImpl->mSize += size;
	mImpl->mBuffer[ mImpl->mSize ] = '\0';

	return 0;
}
void QTextEngine::shapeTextMac(int item) const
{
    QScriptItem &si = layoutData->items[item];

    si.glyph_data_offset = layoutData->used;

    QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
    if (font->type() != QFontEngine::Multi) {
        shapeTextWithHarfbuzz(item);
        return;
    }
    
#ifndef QT_MAC_USE_COCOA
    QFontEngineMacMulti *fe = static_cast<QFontEngineMacMulti *>(font);
#else
    QCoreTextFontEngineMulti *fe = static_cast<QCoreTextFontEngineMulti *>(font);
#endif
    QTextEngine::ShaperFlags flags;
    if (si.analysis.bidiLevel % 2)
        flags |= RightToLeft;
    if (option.useDesignMetrics())
	flags |= DesignMetrics;

    attributes(); // pre-initialize char attributes

    const int len = length(item);
    int num_glyphs = length(item);
    const QChar *str = layoutData->string.unicode() + si.position;
    ushort upperCased[256];
    if (si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase
            || si.analysis.flags == QScriptAnalysis::Lowercase) {
        ushort *uc = upperCased;
        if (len > 256)
            uc = new ushort[len];
        for (int i = 0; i < len; ++i) {
            if(si.analysis.flags == QScriptAnalysis::Lowercase)
                uc[i] = str[i].toLower().unicode();
            else
                uc[i] = str[i].toUpper().unicode();
        }
        str = reinterpret_cast<const QChar *>(uc);
    }

    ensureSpace(num_glyphs);
    num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used;

    QGlyphLayout g = availableGlyphs(&si);
    g.numGlyphs = num_glyphs;
    unsigned short *log_clusters = logClusters(&si);

    bool stringToCMapFailed = false;
    if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes())) {
        ensureSpace(num_glyphs);
        stringToCMapFailed = fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters,
                                              attributes());
    }

    if (!stringToCMapFailed) {
        heuristicSetGlyphAttributes(str, len, &g, log_clusters, num_glyphs);

        si.num_glyphs = num_glyphs;

        layoutData->used += si.num_glyphs;

        QGlyphLayout g = shapedGlyphs(&si);

        if (si.analysis.script == QUnicodeTables::Arabic) {
            QVarLengthArray<QArabicProperties> props(len + 2);
            QArabicProperties *properties = props.data();
            int f = si.position;
            int l = len;
            if (f > 0) {
                --f;
                ++l;
                ++properties;
            }
            if (f + l < layoutData->string.length()) {
                ++l;
            }
            qt_getArabicProperties((const unsigned short *)(layoutData->string.unicode()+f), l, props.data());

            unsigned short *log_clusters = logClusters(&si);

            for (int i = 0; i < len; ++i) {
                int gpos = log_clusters[i];
                g.attributes[gpos].justification = properties[i].justification;
            }
        }
    }

    const ushort *uc = reinterpret_cast<const ushort *>(str);

    if ((si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase
         || si.analysis.flags == QScriptAnalysis::Lowercase)
        && uc != upperCased)
        delete [] uc;
}
Exemple #13
0
 void push( const FormulaToken& token )
 {
     ensureSpace();
     insert( topIndex++, token );
 }
Exemple #14
0
 FormulaTokenStack()
     : QVector<FormulaToken>(), topIndex( 0 )
 {
     ensureSpace();
 }
Exemple #15
0
/*
 * Append eight big-endian bytes.
 */
void expandBufAdd8BE(ExpandBuf *pBuf, u8 val) {
    ensureSpace(pBuf, sizeof(val));
    set8BE(pBuf->storage + pBuf->curLen, val);
    pBuf->curLen += sizeof(val);
}
Exemple #16
0
/*
 * Append a byte.
 */
void expandBufAdd1(ExpandBuf *pBuf, u1 val) {
    ensureSpace(pBuf, sizeof(val));
    *(pBuf->storage + pBuf->curLen) = val;
    pBuf->curLen++;
}