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


C++ MutableHandleString类代码示例

本文整理汇总了C++中MutableHandleString的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleString类的具体用法?C++ MutableHandleString怎么用?C++ MutableHandleString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: key

bool
JSCompartment::wrap(JSContext* cx, MutableHandleString strp)
{
    MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(this));
    MOZ_ASSERT(cx->compartment() == this);

    /* If the string is already in this compartment, we are done. */
    JSString* str = strp;
    if (str->zoneFromAnyThread() == zone())
        return true;

    /* If the string is an atom, we don't have to copy. */
    if (str->isAtom()) {
        MOZ_ASSERT(str->isPermanentAtom() || str->zone()->isAtomsZone());
        return true;
    }

    /* Check the cache. */
    RootedValue key(cx, StringValue(str));
    if (WrapperMap::Ptr p = crossCompartmentWrappers.lookup(CrossCompartmentKey(key))) {
        strp.set(p->value().get().toString());
        return true;
    }

    /* No dice. Make a copy, and cache it. */
    JSString* copy = CopyStringPure(cx, str);
    if (!copy)
        return false;
    if (!putWrapper(cx, CrossCompartmentKey(key), StringValue(copy)))
        return false;

    strp.set(copy);
    return true;
}
开发者ID:ollie314,项目名称:gecko-dev,代码行数:34,代码来源:jscompartment.cpp

示例2: d

bool
DebugState::getSourceMappingURL(JSContext* cx, MutableHandleString result) const
{
    result.set(nullptr);
    if (!maybeBytecode_)
        return true;

    for (const CustomSection& customSection : metadata().customSections) {
        const NameInBytecode& sectionName = customSection.name;
        if (strlen(SourceMappingURLSectionName) != sectionName.length ||
            memcmp(SourceMappingURLSectionName, maybeBytecode_->begin() + sectionName.offset,
                   sectionName.length) != 0)
        {
            continue;
        }

        // Parse found "SourceMappingURL" custom section.
        Decoder d(maybeBytecode_->begin() + customSection.offset,
                  maybeBytecode_->begin() + customSection.offset + customSection.length,
                  customSection.offset,
                  /* error = */ nullptr);
        uint32_t nchars;
        if (!d.readVarU32(&nchars))
            return true; // ignoring invalid section data
        const uint8_t* chars;
        if (!d.readBytes(nchars, &chars) || d.currentPosition() != d.end())
            return true; // ignoring invalid section data

        UTF8Chars utf8Chars(reinterpret_cast<const char*>(chars), nchars);
        JSString* str = JS_NewStringCopyUTF8N(cx, utf8Chars);
        if (!str)
            return false;
        result.set(str);
        return true;
    }

    // Check presence of "SourceMap:" HTTP response header.
    char* sourceMapURL = metadata().sourceMapURL.get();
    if (sourceMapURL && strlen(sourceMapURL)) {
        UTF8Chars utf8Chars(sourceMapURL, strlen(sourceMapURL));
        JSString* str = JS_NewStringCopyUTF8N(cx, utf8Chars);
        if (!str)
            return false;
        result.set(str);
    }
    return true;
}
开发者ID:mongodb,项目名称:mongo,代码行数:47,代码来源:WasmDebug.cpp

示例3:

ParallelResult
jit::IntToStringPar(ForkJoinSlice *slice, int i, MutableHandleString out)
{
    JSFlatString *str = Int32ToString<NoGC>(slice, i);
    if (!str)
        return TP_RETRY_SEQUENTIALLY;
    out.set(str);
    return TP_SUCCESS;
}
开发者ID:matyapiro31,项目名称:instantbird-1.5,代码行数:9,代码来源:ParallelFunctions.cpp


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