/**
			 * Checks whether a resource already exists and returns it or if no
			 * resource was found creates one.
			 * @param type Resource type name.
			 * @param name Resource name.
			 * @return Resource with the given name or 0 if no resource could be
			 * created.
			 * @note This function only does a static check of the pointer, so
			 * take care that the factory produces instances of the correct
			 * class.
			 */
			template<class T> typename T::Ptr getOrCreate(const std::string &type,
			                                              const std::string &name)
			{
				// TODO: Dynamic checks in debug version?
				Resource::Ptr res = getOrCreate(type, name);
				typename T::Ptr derived = (T*)res.get();
				return derived;
			}
PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::nextInlineTextBox() const
{
    ASSERT(!m_inlineTextBox || !m_inlineTextBox->layoutObject().needsLayout());
    if (!m_inlineTextBox)
        return nullptr;

    return getOrCreate(m_layoutText, m_inlineTextBox->nextTextBox());
}
Example #3
0
void Variables::setGlobalVisible(const Symbol& _key, bool _bVisible, int _iLevel)
{
    Variable* pVar = getOrCreate(_key);
    pVar->setGlobalVisible(_iLevel, _bVisible);
    if (_bVisible)
    {
        pVar->setGlobal(true);
    }
}
Example #4
0
void Variables::removeGlobal(const Symbol& _key, int _iLevel)
{
    Variable* pVar = getOrCreate(_key);
    if (pVar->isGlobal())
    {
        pVar->setGlobal(false);
        pVar->setGlobalValue(NULL);
    }

    remove(pVar, _iLevel);
}
PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::previousOnLine() const
{
    ASSERT(!m_inlineTextBox || !m_inlineTextBox->layoutObject().needsLayout());
    if (!m_inlineTextBox)
        return nullptr;

    InlineBox* previous = m_inlineTextBox->prevOnLine();
    if (previous && previous->isInlineTextBox())
        return getOrCreate(&toInlineTextBox(previous)->layoutObject(), toInlineTextBox(previous));

    return nullptr;
}
PassRefPtr<AbstractInlineTextBox> AbstractInlineTextBox::nextOnLine() const
{
    ASSERT(!m_inlineTextBox || !m_inlineTextBox->layoutObject().needsLayout());
    if (!m_inlineTextBox)
        return nullptr;

    InlineBox* next = m_inlineTextBox->nextOnLine();
    if (next && next->isInlineTextBox())
        return getOrCreate(&toInlineTextBox(next)->layoutObject(), toInlineTextBox(next));

    return nullptr;
}
Example #7
0
void ProfilerUIImpl::addToTree(Lumix::Debug::Allocator::AllocationInfo* info)
{
	Lumix::Debug::StackNode* nodes[1024];
	int count = Lumix::Debug::StackTree::getPath(info->m_stack_leaf, nodes, Lumix::lengthOf(nodes));

	auto node = m_allocation_root;
	for (int i = count - 1; i >= 0; --i)
	{
		node = getOrCreate(node, nodes[i], info->m_size);
	}
	node->m_allocations.push(info);
}
MediaDownload * MediaDownloadManager::acquireMediaDownload(const QUrl &url)
{
    if (!url.isValid())
        return 0;

    QMutexLocker mapMutexLocker(&m_mapMutex);
    Q_UNUSED(mapMutexLocker);

    MediaDownload *mediaDownload = getOrCreate(url);
    mediaDownload->ref();

    return mediaDownload;
}
Example #9
0
bool Libraries::putInPreviousScope(const Symbol& _keyLib, types::Library* _pLib, int _iLevel)
{
    Library* lib = getOrCreate(_keyLib);

    if (lib->empty())
    {
        lib->put(_pLib, _iLevel);
    }
    else if (lib->top()->m_iLevel > _iLevel)
    {
        ScopedLibrary* pLib = lib->top();
        lib->pop();
        putInPreviousScope(_keyLib, _pLib, _iLevel);
        lib->put(pLib);
    }
    else
    {
        lib->put(_pLib, _iLevel);
    }

    return true;
}
Example #10
0
types::InternalType* Variables::getGlobalValue(const Symbol& _key)
{
    return getOrCreate(_key)->getGlobalValue();
}
Example #11
0
bool Variables::isGlobal(const Symbol& _key, int /*_iLevel*/)
{
    return getOrCreate(_key)->isGlobal();
}
Example #12
0
bool Variables::isGlobalVisible(const Symbol& _key, int _iLevel)
{
    return getOrCreate(_key)->isGlobalVisible(_iLevel);
}
Example #13
0
void Libraries::put(const Symbol& _keyLib, types::Library* _pLib, int _iLevel)
{
    Library* lib = getOrCreate(_keyLib);
    lib->put(_pLib, _iLevel);
}
Example #14
0
void Variables::setGlobal(const Symbol& _key)
{
    getOrCreate(_key)->setGlobal(true);
}
Example #15
0
void Variables::put(const Symbol& _key, types::InternalType* _pIT, int _iLevel)
{
    Variable* var = getOrCreate(_key);
    var->put(_pIT, _iLevel);
}
ServiceWorker* ServiceWorker::from(ExecutionContext* executionContext, WebServiceWorker* worker)
{
    return getOrCreate(executionContext, worker);
}
PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(JSContextRef, JSObjectRef object)
{
    Node* node = toNode(toJS(object));
    return getOrCreate(node);
}
Example #18
0
 void mark(const Id& chunkId, std::size_t chunkNum)
 {
     getOrCreate(chunkId, chunkNum).exists = true;
 }
RefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(JSContextRef, JSObjectRef object)
{
    Node* node = JSNode::toWrapped(toJS(object));
    return getOrCreate(node);
}
Ref<InjectedBundleNodeHandle> InjectedBundleNodeHandle::document()
{
    return getOrCreate(m_node->document());
}
MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString>
SharedImmutableStringsCache::getOrCreate(const char16_t* chars, size_t length)
{
    return getOrCreate(chars, length, [&]() { return DuplicateString(chars, length); });
}
PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(JSContextRef, JSObjectRef object)
{
    Range* range = JSRange::toWrapped(toJS(object));
    return getOrCreate(range);
}