wke升级vs2010,vs2013

转载请说明原出处,谢谢~~


首先感谢wke内核作者BlzFans和soui2作者flyhigh,使得基于webkit内核的浏览器控件小巧,易于使用。

wke的源码是基于vs2005和vs2008的工程,这对于现在公司的一些新项目而言,编译器版本太老了些,wke也就有了升级为高版本工程的需求。升级时,碰到了不少错误,查阅一些博客时候,发现也有不少寻找高版本工程的,不过升级的资料较少,看来大神们是不削于做这种工作的了,哈哈,开个玩笑。我就将自己升级时候碰到的一些问题,记录下来吧。

用vs2010或者vs2013直接升级时,从升级报告中可以看到很多错误,仔细查看都是“.vsprops”文件找不到这一类型错误,查看前面的路径可以知道,是该属性文件的路径有误。因此用记事本打开vs2008/vsprops/目录下面,名字中带有release和debug的文件,在其所有的路径前面增加“..\..\”,如图所示:

(为了方便,可以将这个vs2008文件夹复制2份出来,分别命名为vs2010,vs2013。)

直接用vs2010打开工程文件,可以看到升级报告里面已经没有错误了。接下来,就是处理丢失的各种工程属性和设置。在vs视图→属性管理器中展开各个项目的属性文件。依次处理每个属性页的 常规标签,用户宏标签,c/c++标签下面的常规、预处理器、预编译头、代码生成,高级,链接器标签下面的输入等。其中FeatureDefinesCairo用户宏比较多,可以从WebKitLibraries\win\tools\vsprops\FeatureDefinesCairo.vsprops中复制宏名。设置属性页时候,尽量先从list下方的属性页设置,上方的属性页选择从父级继承,有新的就添加。common属性页的WEBKITOUTPUTDIR按照自己工程设置输出目录,另外需要将ConfigurationBuiDir移动到最下面。

所有设置完成以后,vs2010工程就升级成功,可以编译通过了。

如果是vs2013,还会报大量模板语法错误,错误都指向了Source\JavaScriptCore\wtf\HashSet.h文件。如下修改HashSet.h文件。

/*
 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#ifndef WTF_HashSet_h
#define WTF_HashSet_h

#include "FastAllocBase.h"
#include "HashTable.h"

namespace WTF {

    template<typename Value, typename HashFunctions, typename Traits> class HashSet;
    template<typename Value, typename HashFunctions, typename Traits>
    void deleteAllValues(const HashSet<Value, HashFunctions, Traits>&);
    template<typename Value, typename HashFunctions, typename Traits>
    void fastDeleteAllValues(const HashSet<Value, HashFunctions, Traits>&);

    template<typename T> struct IdentityExtractor;

    template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash,
		typename TraitsArg = HashTraits<ValueArg> > class HashSet {
        WTF_MAKE_FAST_ALLOCATED;
    private:
        typedef HashArg HashFunctions;
        typedef TraitsArg ValueTraits;

    public:
        typedef typename ValueTraits::TraitType ValueType;

    private:
        typedef HashTable<ValueType, ValueType, IdentityExtractor<ValueType>,
            HashFunctions, ValueTraits, ValueTraits> HashTableType;

    public:
        typedef HashTableIteratorAdapter<HashTableType, ValueType> iterator;
        typedef HashTableConstIteratorAdapter<HashTableType, ValueType> const_iterator;

        void swap(HashSet&);

        int size() const;
        int capacity() const;
        bool isEmpty() const;

        iterator begin() ;
        iterator end() ;
	const_iterator begin() const;
	const_iterator end() const;

        iterator find(const ValueType&) ;
	const_iterator find(const ValueType&) const;
        bool contains(const ValueType&) const;

        // An alternate version of find() that finds the object by hashing and comparing
        // with some other type, to avoid the cost of type conversion. HashTranslator
        // must have the following function members:
        //   static unsigned hash(const T&);
        //   static bool equal(const ValueType&, const T&);
        template<typename T, typename HashTranslator> iterator find(const T&);
		template<typename T, typename HashTranslator> const_iterator find(const T&) const;
        template<typename T, typename HashTranslator> bool contains(const T&) const;

        // The return value is a pair of an interator to the new value's location, 
        // and a bool that is true if an new entry was added.
        pair<iterator, bool> add(const ValueType&);

        // An alternate version of add() that finds the object by hashing and comparing
        // with some other type, to avoid the cost of type conversion if the object is already
        // in the table. HashTranslator must have the following function members:
        //   static unsigned hash(const T&);
        //   static bool equal(const ValueType&, const T&);
        //   static translate(ValueType&, const T&, unsigned hashCode);
        template<typename T, typename HashTranslator> pair<iterator, bool> add(const T&);

        void remove(const ValueType&);
        void remove(iterator);
        void clear();

    private:
        friend void deleteAllValues<>(const HashSet&);
        friend void fastDeleteAllValues<>(const HashSet&);

        HashTableType m_impl;
    };

    template<typename T> struct IdentityExtractor {
        static const T& extract(const T& t) { return t; }
    };

    template<typename ValueType, typename ValueTraits, typename T, typename Translator>
    struct HashSetTranslatorAdapter {
        static unsigned hash(const T& key) { return Translator::hash(key); }
        static bool equal(const ValueType& a, const T& b) { return Translator::equal(a, b); }
        static void translate(ValueType& location, const T& key, const T&, unsigned hashCode)
        {
            Translator::translate(location, key, hashCode);
        }
    };

    template<typename T, typename U, typename V>
    inline void HashSet<T, U, V>::swap(HashSet& other)
    {
        m_impl.swap(other.m_impl); 
    }

    template<typename T, typename U, typename V>
    inline int HashSet<T, U, V>::size() const
    {
        return m_impl.size(); 
    }

    template<typename T, typename U, typename V>
    inline int HashSet<T, U, V>::capacity() const
    {
        return m_impl.capacity(); 
    }

    template<typename T, typename U, typename V>
    inline bool HashSet<T, U, V>::isEmpty() const
    {
        return m_impl.isEmpty(); 
    }

    template<typename T, typename U, typename V>
    inline typename HashSet<T, U, V>::iterator HashSet<T, U, V>::begin() 
    {
        return m_impl.begin(); 
    }

    template<typename T, typename U, typename V>
    inline typename HashSet<T, U, V>::iterator HashSet<T, U, V>::end() 
    {
        return m_impl.end(); 
    }

	template<typename T, typename U, typename V>
	inline typename HashSet<T, U, V>::const_iterator HashSet<T, U, V>::begin() const
	{
		return m_impl.begin();
	}

	template<typename T, typename U, typename V>
	inline typename HashSet<T, U, V>::const_iterator HashSet<T, U, V>::end() const
	{
		return m_impl.end();
	}

    template<typename T, typename U, typename V>
    inline typename HashSet<T, U, V>::iterator HashSet<T, U, V>::find(const ValueType& value)
    {
        return m_impl.find(value); 
    }

	template<typename T, typename U, typename V>
	inline typename HashSet<T, U, V>::const_iterator HashSet<T, U, V>::find(const ValueType& value) const
	{
		return m_impl.find(value);
	}

    template<typename T, typename U, typename V>
    inline bool HashSet<T, U, V>::contains(const ValueType& value) const
    {
        return m_impl.contains(value); 
    }

    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    typename HashSet<Value, HashFunctions, Traits>::iterator
    inline HashSet<Value, HashFunctions, Traits>::find(const T& value)
    {
        typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
        return m_impl.template find<T, Adapter>(value);
    }

	template<typename Value, typename HashFunctions, typename Traits>
	template<typename T, typename HashTranslator>
	typename HashSet<Value, HashFunctions, Traits>::const_iterator
		inline HashSet<Value, HashFunctions, Traits>::find(const T& value) const
	{
			typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
			return m_impl.template find<T, Adapter>(value);
		}

    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    inline bool HashSet<Value, HashFunctions, Traits>::contains(const T& value) const
    {
        typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
        return m_impl.template contains<T, Adapter>(value);
    }

    template<typename T, typename U, typename V>
    pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
    {
        return m_impl.add(value);
    }

    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
    HashSet<Value, HashFunctions, Traits>::add(const T& value)
    {
        typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
        return m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
    }

    template<typename T, typename U, typename V>
    inline void HashSet<T, U, V>::remove(iterator it)
    {
        if (it.m_impl == m_impl.end())
            return;
        m_impl.internalCheckTableConsistency();
        m_impl.removeWithoutEntryConsistencyCheck(it.m_impl);
    }

    template<typename T, typename U, typename V>
    inline void HashSet<T, U, V>::remove(const ValueType& value)
    {
        remove(find(value));
    }

    template<typename T, typename U, typename V>
    inline void HashSet<T, U, V>::clear()
    {
        m_impl.clear(); 
    }

    template<typename ValueType, typename HashTableType>
    void deleteAllValues(HashTableType& collection)
    {
        typedef typename HashTableType::const_iterator iterator;
        iterator end = collection.end();
        for (iterator it = collection.begin(); it != end; ++it)
            delete *it;
    }

    template<typename T, typename U, typename V>
    inline void deleteAllValues(const HashSet<T, U, V>& collection)
    {
        deleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
    }

    template<typename ValueType, typename HashTableType>
    void fastDeleteAllValues(HashTableType& collection)
    {
        typedef typename HashTableType::const_iterator iterator;
        iterator end = collection.end();
        for (iterator it = collection.begin(); it != end; ++it)
            fastDelete(*it);
    }

    template<typename T, typename U, typename V>
    inline void fastDeleteAllValues(const HashSet<T, U, V>& collection)
    {
        fastDeleteAllValues<typename HashSet<T, U, V>::ValueType>(collection.m_impl);
    }
    
    template<typename T, typename U, typename V, typename W>
    inline void copyToVector(const HashSet<T, U, V>& collection, W& vector)
    {
        typedef typename HashSet<T, U, V>::const_iterator iterator;
        
        vector.resize(collection.size());
        
        iterator it = collection.begin();
        iterator end = collection.end();
        for (unsigned i = 0; it != end; ++it, ++i)
            vector[i] = *it;
    }  

} // namespace WTF

using WTF::HashSet;

#endif /* WTF_HashSet_h */

头文件AllocationSpace.h如下地方

typedef HashSet<MarkedBlock*>::iterator BlockIterator;
修改为
typedef HashSet<MarkedBlock*>::const_iterator BlockIterator;
头文件ShadowInclusionSelector.h如下地方

inline ShadowInclusion* ShadowInclusionSet::find(Node* key) const
{
    PointerSet::iterator found = m_set.find<Node*, ShadowInclusionSet::Translator>(key);
    return found != m_set.end() ? *found : 0;
}
修改为

inline ShadowInclusion* ShadowInclusionSet::find(Node* key) const
{
    auto found = m_set.find<Node*, ShadowInclusionSet::Translator>(key);
    return found != m_set.end() ? *found : 0;
}
源文件JSParser.cpp如下地方
        void copyCapturedVariablesToVector(const IdentifierSet& capturedVariables, Vector<RefPtr<StringImpl> >& vector)
        {
            IdentifierSet::iterator end = capturedVariables.end();
            for (IdentifierSet::iterator it = capturedVariables.begin(); it != end; ++it) {
                if (m_declaredVariables.contains(*it))
                    continue;
                vector.append(*it);
            }
            vector.shrinkToFit();
        }
修改为

        void copyCapturedVariablesToVector(const IdentifierSet& capturedVariables, Vector<RefPtr<StringImpl> >& vector)
        {
	<span style="white-space:pre">	</span>auto end = (capturedVariables.end());
		for (auto it = (capturedVariables.begin()); it != end; ++it) {
		<span style="white-space:pre">	</span>if (m_declaredVariables.contains(*it))
		<span style="white-space:pre">		</span>continue;
		<span style="white-space:pre">		</span>vector.append(*it);
		}
		vector.shrinkToFit();
        }

其他HashSet模板的迭代器和const迭代器错误修改就不再列举。如上替换即可。

另外MathExtras.h里面还有一些函数有重定义,在MathExtras.h添加math.h,使用_INC_MATH宏添加判断即可。

至此,vs2013即可编译通过。






  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值