当前位置: 首页>>代码示例>>C++>>正文


C++ Vector::append方法代码示例

本文整理汇总了C++中wtf::Vector::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector::append方法的具体用法?C++ Vector::append怎么用?C++ Vector::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wtf::Vector的用法示例。


在下文中一共展示了Vector::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: call

EncodedJSValue JSC_HOST_CALL COMMethodCall::call(ExecState* execState) {
    COMMethodCall* callee = jsCast<COMMethodCall*>(execState->callee());
    if (execState->argumentCount() != callee->_parameterCells.size()) {
        // TODO: error
        CRASH();
    }

    COMInterop* interop = jsCast<GlobalObject*>(execState->lexicalGlobalObject())->interop();

    size_t numberOfABIParameters = callee->_parameterCells.size() + (callee->_isVoid ? 1 : 2);

    HRESULT hr;

    Microsoft::WRL::ComPtr<IUnknown> self;
    hr = interop->wrap(execState->thisValue(), callee->_methodInterface, self.GetAddressOf());

    void** vtable = *reinterpret_cast<void***>(self.Get());
    void* fn = vtable[callee->_methodIndex];

    WTF::Vector<void*> arguments;
    arguments.reserveCapacity(numberOfABIParameters);

    IUnknown* thisValue = self.Get();
    arguments.append(&thisValue);

    for (int i = 0; i < callee->_parameterCells.size(); i++) {
        JSCell* type = callee->_parameterCells[i].get();
        void* buffer = _alloca(std::max(sizeof(ffi_arg), callee->_parameterTypes[i + 1]->size));
        getFFIMethodTable(type)->marshalJSToNative(type, execState, execState->uncheckedArgument(i), buffer);
        arguments.append(buffer);
    }

    void* returnBuffer = nullptr;
    if (!callee->_isVoid) {
        returnBuffer = _alloca(std::max(sizeof(ffi_arg), callee->_parameterTypes[numberOfABIParameters - 1]->size));
        arguments.append(&returnBuffer);
    }

    ffi_call(&callee->_cif, FFI_FN(fn), &hr, arguments.data());

    JSValue jsResult;
    if (!SUCCEEDED(hr)) {
        _com_error error(hr, nullptr);
        jsResult = execState->vm().throwException(execState, createError(execState, error.ErrorMessage()));
    } else if (!callee->_isVoid) {
        JSCell* returnType = callee->_returnType.get();
        jsResult = getFFIMethodTable(returnType)->marshalNativeToJS(returnType, execState, returnBuffer);
    } else {
        jsResult = jsUndefined();
    }

    return JSValue::encode(jsResult);
}
开发者ID:Happy-Ferret,项目名称:windows-runtime,代码行数:53,代码来源:COMMethodCall.cpp

示例2: write_string

static void write_string(WTF::Vector<char>& v, const WebCore::String& str)
{
    unsigned strLen = str.length();
    // Only do work if the string has data.
    if (strLen) {
        // Determine how much to grow the vector. Use the worst case for utf8 to
        // avoid reading the string twice. Add sizeof(unsigned) to hold the
        // string length in utf8.
        unsigned vectorLen = v.size() + sizeof(unsigned);
        unsigned length = (strLen << 2) + vectorLen;
        // Grow the vector. This will change the value of v.size() but we
        // remember the original size above.
        v.grow(length);
        // Grab the position to write to.
        char* data = v.begin() + vectorLen;
        // Write the actual string
        int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
        LOGV("Writing string       %d %.*s", l, l, data);
        // Go back and write the utf8 length. Subtract sizeof(unsigned) from
        // data to get the position to write the length.
        memcpy(data - sizeof(unsigned), (char*)&l, sizeof(unsigned));
        // Shrink the internal state of the vector so we match what was
        // actually written.
        v.shrink(vectorLen + l);
    } else
        v.append((char*)&strLen, sizeof(unsigned));
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:27,代码来源:WebHistory.cpp

示例3: checkGrammarOfString

void SpellCheckerClientImpl::checkGrammarOfString(const String& text, WTF::Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
{
    if (badGrammarLocation)
        *badGrammarLocation = -1;
    if (badGrammarLength)
        *badGrammarLength = 0;

    if (!m_webView->spellCheckClient())
        return;
    WebVector<WebTextCheckingResult> webResults;
    m_webView->spellCheckClient()->checkTextOfParagraph(text, WebTextCheckingTypeGrammar, &webResults);
    if (!webResults.size())
        return;

    // Convert a list of WebTextCheckingResults to a list of GrammarDetails. If
    // the converted vector of GrammarDetails has grammar errors, we set
    // badGrammarLocation and badGrammarLength to tell WebKit that the input
    // text has grammar errors.
    for (size_t i = 0; i < webResults.size(); ++i) {
        if (webResults[i].decoration == WebTextDecorationTypeGrammar) {
            GrammarDetail detail;
            detail.location = webResults[i].location;
            detail.length = webResults[i].length;
            detail.userDescription = webResults[i].replacement;
            details.append(detail);
        }
    }
    if (!details.size())
        return;
    if (badGrammarLocation)
        *badGrammarLocation = 0;
    if (badGrammarLength)
        *badGrammarLength = text.length();
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例4: parseSuboriginHeader

bool parseSuboriginHeader(const String& header, Suborigin* suborigin, WTF::Vector<String>& messages)
{
    Vector<String> headers;
    header.split(',', true, headers);

    if (headers.size() > 1)
        messages.append("Multiple Suborigin headers found. Ignoring all but the first.");

    Vector<UChar> characters;
    headers[0].appendTo(characters);

    const UChar* position = characters.data();
    const UChar* end = position + characters.size();

    skipWhile<UChar, isASCIISpace>(position, end);

    String name;
    position = parseSuboriginName(position, end, name, messages);
    if (!position)
        return false;

    suborigin->setName(name);

    while (position < end) {
        skipWhile<UChar, isASCIISpace>(position, end);
        if (position == end)
            return true;

        String optionName;
        position = parseSuboriginPolicyOption(position, end, optionName, messages);

        if (!position) {
            suborigin->clear();
            return false;
        }

        Suborigin::SuboriginPolicyOptions option = getSuboriginPolicyOptionFromString(optionName);
        if (option == Suborigin::SuboriginPolicyOptions::None)
            messages.append("Ignoring unknown suborigin policy option " + optionName + ".");
        else
            suborigin->addPolicyOption(option);
    }

    return true;
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:45,代码来源:HTTPParsers.cpp

示例5:

void
FileChooserPrivate::chooseFiles(const String* str, int items)
{
    WTF::Vector<WebCore::String> ws;

    for (int i=0; i<items; i++) {
        ws.append(str[i]);
    }
    m_webcore->chooseFiles(ws);
}
开发者ID:flying-dutchmen,项目名称:3DS_w3Browser,代码行数:10,代码来源:WKCFileChooser.cpp

示例6:

TEST(FontDescriptionTest, TestHashCollision)
{
    FontWeight weights[] = {
        FontWeight100,
        FontWeight200,
        FontWeight300,
        FontWeight400,
        FontWeight500,
        FontWeight600,
        FontWeight700,
        FontWeight800,
        FontWeight900,
    };
    FontStretch stretches[] {
        FontStretchUltraCondensed,
        FontStretchExtraCondensed,
        FontStretchCondensed,
        FontStretchSemiCondensed,
        FontStretchNormal,
        FontStretchSemiExpanded,
        FontStretchExpanded,
        FontStretchExtraExpanded,
        FontStretchUltraExpanded
    };
    FontStyle styles[] = {
        FontStyleNormal,
        FontStyleOblique,
        FontStyleItalic
    };
    FontVariant variants[] = {
        FontVariantNormal,
        FontVariantSmallCaps
    };

    FontDescription source;
    WTF::Vector<unsigned> hashes;
    for (size_t i = 0; i < WTF_ARRAY_LENGTH(weights); i++) {
        source.setWeight(weights[i]);
        for (size_t j = 0; j < WTF_ARRAY_LENGTH(stretches); j++) {
            source.setStretch(stretches[j]);
            for (size_t k = 0; k < WTF_ARRAY_LENGTH(styles); k++) {
                source.setStyle(styles[k]);
                for (size_t m = 0; m < WTF_ARRAY_LENGTH(variants); m++) {
                    source.setVariant(variants[m]);
                    unsigned hash = source.styleHashWithoutFamilyList();
                    ASSERT_FALSE(hashes.contains(hash));
                    hashes.append(hash);
                }
            }
        }
    }

}
开发者ID:azureplus,项目名称:chromium,代码行数:53,代码来源:FontDescriptionTest.cpp

示例7:

WTF::Vector <BackingStoreClient*> BackingStoreClient::children() const
{
    WTF::Vector<BackingStoreClient*> children;
    for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
        BlackBerry::WebKit::BackingStoreClient* client =
            m_webPage->d->backingStoreClientForFrame(child);

        if (client)
            children.append(client);
    }

    return children;
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例8: write_item

static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item)
{
    // Original url
    write_string(v, item->originalURLString());

    // Url
    write_string(v, item->urlString());

    // Title
    write_string(v, item->title());

    // Form content type
    write_string(v, item->formContentType());

    // Form data
    const WebCore::FormData* formData = item->formData();
    if (formData) {
        write_string(v, formData->flattenToString());
        // save the identifier as it is not included in the flatten data
        int64_t id = formData->identifier();
        v.append((char*)&id, sizeof(int64_t));
    } else
        write_string(v, WebCore::String()); // Empty constructor does not allocate a buffer.

    // Target
    write_string(v, item->target());

    AndroidWebHistoryBridge* bridge = item->bridge();
    LOG_ASSERT(bridge, "We should have a bridge here!");
    // Screen scale
    const int scale = bridge->scale();
    LOGV("Writing scale %d", scale);
    v.append((char*)&scale, sizeof(int));
    const int screenWidthScale = bridge->screenWidthScale();
    LOGV("Writing screen width scale %d", screenWidthScale);
    v.append((char*)&screenWidthScale, sizeof(int));

    // Document state
    const WTF::Vector<WebCore::String>& docState = item->documentState();
    WTF::Vector<WebCore::String>::const_iterator end = docState.end();
    unsigned stateSize = docState.size();
    LOGV("Writing docState     %d", stateSize);
    v.append((char*)&stateSize, sizeof(unsigned));
    for (WTF::Vector<WebCore::String>::const_iterator i = docState.begin(); i != end; ++i) {
        write_string(v, *i);
    }

    // Is target item
    LOGV("Writing isTargetItem %d", item->isTargetItem());
    v.append((char)item->isTargetItem());

    // Children count
    unsigned childCount = item->children().size();
    LOGV("Writing childCount   %d", childCount);
    v.append((char*)&childCount, sizeof(unsigned));
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:56,代码来源:WebHistory.cpp

示例9: UpdatePluginDirectories

void JavaBridge::UpdatePluginDirectories(JNIEnv* env, jobject obj,
        jobjectArray array, jboolean reload) {
    WTF::Vector<WTF::String> directories;
    int count = env->GetArrayLength(array);
    for (int i = 0; i < count; i++) {
        jstring dir = (jstring) env->GetObjectArrayElement(array, i);
        directories.append(jstringToWtfString(env, dir));
        env->DeleteLocalRef(dir);
    }
    checkException(env);
    WebCore::PluginDatabase *pluginDatabase =
            WebCore::PluginDatabase::installedPlugins();
    pluginDatabase->setPluginDirectories(directories);
    // refreshPlugins() should refresh both PluginDatabase and Page's PluginData
    WebCore::Page::refreshPlugins(reload);
}
开发者ID:OmarBizreh,项目名称:Sliding_XZ,代码行数:16,代码来源:JavaBridge.cpp

示例10: getRealObject

WTF::Vector<WebCore::String>JavaBridge::getSupportedKeyStrengthList() {
    WTF::Vector<WebCore::String> list;
    JNIEnv* env = JSC::Bindings::getJNIEnv();
    AutoJObject obj = getRealObject(env, mJavaObject);
    jobjectArray array = (jobjectArray) env->CallObjectMethod(obj.get(),
                         mGetKeyStrengthList);
    int count = env->GetArrayLength(array);
    for (int i = 0; i < count; ++i) {
        jstring keyStrength = (jstring) env->GetObjectArrayElement(array, i);
        list.append(to_string(env, keyStrength));
        env->DeleteLocalRef(keyStrength);
    }
    env->DeleteLocalRef(array);
    checkException(env);
    return list;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例11: ReverseBidi

// ReverseBidi is a trimmed-down version of GraphicsContext::drawBidiText()
void ReverseBidi(UChar* chars, int len) {
    using namespace WTF::Unicode;
    WTF::Vector<UChar> result;
    result.reserveCapacity(len);
    TextRun run(chars, len);
    BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
    BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs();
    bidiResolver.setStatus(BidiStatus(LeftToRight, LeftToRight, LeftToRight,
        BidiContext::create(0, LeftToRight, false)));
    bidiResolver.setPosition(TextRunIterator(&run, 0));
    bidiResolver.createBidiRunsForLine(TextRunIterator(&run, len));
    if (!bidiRuns.runCount())
        return;
    BidiCharacterRun* bidiRun = bidiRuns.firstRun();
    while (bidiRun) {
        int bidiStart = bidiRun->start();
        int bidiStop = bidiRun->stop();
        int size = result.size();
        int bidiCount = bidiStop - bidiStart;
        result.append(chars + bidiStart, bidiCount);
        if (bidiRun->level() % 2) {
            UChar* start = &result[size];
            UChar* end = start + bidiCount;
            // reverse the order of any RTL substrings
            while (start < end) {
                UChar temp = *start;
                *start++ = *--end;
                *end = temp;
            }
            start = &result[size];
            end = start + bidiCount - 1;
            // if the RTL substring had a surrogate pair, restore its order
            while (start < end) {
                UChar trail = *start++;
                if (!U16_IS_SURROGATE(trail))
                    continue;
                start[-1] = *start; // lead
                *start++ = trail;
            }
        }
        bidiRun = bidiRun->next();
    }
    bidiRuns.deleteRuns();
    memcpy(chars, &result[0], len * sizeof(UChar));
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:46,代码来源:SelectText.cpp

示例12: getGuessesForWord

void EditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& guesses)
{
    GSList* langs = webkit_web_settings_get_spell_languages(m_webView);
    guesses.clear();

    for (; langs; langs = langs->next) {
        size_t numberOfSuggestions;
        size_t i;

        SpellLanguage* lang = static_cast<SpellLanguage*>(langs->data);
        gchar** suggestions = enchant_dict_suggest(lang->speller, word.utf8().data(), -1, &numberOfSuggestions);

        for (i = 0; i < numberOfSuggestions && i < 10; i++)
            guesses.append(String::fromUTF8(suggestions[i]));

        if (numberOfSuggestions > 0)
            enchant_dict_free_suggestions(lang->speller, suggestions);
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:19,代码来源:EditorClientGtk.cpp

示例13: paintedSurfacesCleanup

void TilesManager::paintedSurfacesCleanup(GLWebViewState* state)
{
    // PaintedSurfaces are created by LayerAndroid with a refcount of 1,
    // and just transferred to new (corresponding) layers when a new layer tree
    // is received.
    // PaintedSurface also keep a reference on the Layer it currently has, so
    // when we unref the tree of layer, those layers with a PaintedSurface will
    // still be around if we do nothing.
    // Here, if the surface does not have any associated layer, it means that we
    // received a new layer tree without a corresponding layer (i.e. a layer
    // using a texture has been removed by webkit).
    // In that case, we remove the PaintedSurface from our list, and unref it.
    // If the surface does have a layer, but the GLWebViewState associated to
    // that layer is different from the one passed in parameter, it means we can
    // also remove the surface (and we also remove/unref any layer that surface
    // has). We do this when we deallocate GLWebViewState (i.e. the webview has
    // been destroyed) and also when we switch to a page without
    // composited layers.

    WTF::Vector<PaintedSurface*> collect;
    for (unsigned int i = 0; i < m_paintedSurfaces.size(); i++) {
        PaintedSurface* surface = m_paintedSurfaces[i];

        Layer* drawing = surface->drawingLayer();
        Layer* painting = surface->paintingLayer();

        XLOG("considering PS %p, drawing %p, painting %p", surface, drawing, painting);

        bool drawingMatchesState = state && drawing && (drawing->state() == state);
        bool paintingMatchesState = state && painting && (painting->state() == state);

        if ((!painting && !drawing) || drawingMatchesState || paintingMatchesState) {
            XLOG("trying to remove PS %p, painting %p, drawing %p, DMS %d, PMS %d",
                 surface, painting, drawing, drawingMatchesState, paintingMatchesState);
            collect.append(surface);
        }
    }
    for (unsigned int i = 0; i < collect.size(); i++) {
        PaintedSurface* surface = collect[i];
        m_paintedSurfaces.remove(m_paintedSurfaces.find(surface));
        SkSafeUnref(surface);
    }
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:43,代码来源:TilesManager.cpp

示例14: getGuessesForWord

void EditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& guesses)
{
    GSList* dicts = webkit_web_settings_get_enchant_dicts(m_webView);
    guesses.clear();

    for (; dicts; dicts = dicts->next) {
        size_t numberOfSuggestions;
        size_t i;

        EnchantDict* dict = static_cast<EnchantDict*>(dicts->data);
        gchar** suggestions = enchant_dict_suggest(dict, word.utf8().data(), -1, &numberOfSuggestions);

        for (i = 0; i < numberOfSuggestions && i < 10; i++)
            guesses.append(String::fromUTF8(suggestions[i]));

        if (numberOfSuggestions > 0)
            enchant_dict_free_suggestions(dict, suggestions);
    }
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:19,代码来源:EditorClientGtk.cpp

示例15: discardTexturesVector

void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount,
                                         WTF::Vector<TileTexture*>& textures,
                                         bool deallocateGLTextures)
{
    const unsigned int max = textures.size();
    int dealloc = 0;
    WTF::Vector<int> discardedIndex;
    for (unsigned int i = 0; i < max; i++) {
        TextureOwner* owner = textures[i]->owner();
        if (!owner || owner->drawCount() < sparedDrawCount) {
            if (deallocateGLTextures) {
                // deallocate textures' gl memory
                textures[i]->discardGLTexture();
                discardedIndex.append(i);
            } else if (owner) {
                // simply detach textures from owner
                static_cast<Tile*>(owner)->discardTextures();
            }
            dealloc++;
        }
    }

    bool base = textures == m_textures;
    // Clean up the vector of TileTextures and reset the max texture count.
    if (discardedIndex.size()) {
        android::Mutex::Autolock lock(m_texturesLock);
        for (int i = discardedIndex.size() - 1; i >= 0; i--)
            textures.remove(discardedIndex[i]);

        int remainedTextureNumber = textures.size();
        int* countPtr = base ? &m_currentTextureCount : &m_currentLayerTextureCount;
        if (remainedTextureNumber < *countPtr) {
            ALOGV("reset currentTextureCount for %s tiles from %d to %d",
                  base ? "base" : "layer", *countPtr, remainedTextureNumber);
            *countPtr = remainedTextureNumber;
        }

    }

    ALOGV("Discarded %d %s textures (out of %d %s tiles)",
          dealloc, (deallocateGLTextures ? "gl" : ""),
          max, base ? "base" : "layer");
}
开发者ID:3filiatd,项目名称:google_cache_invalidation_repo,代码行数:43,代码来源:TilesManager.cpp


注:本文中的wtf::Vector::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。