• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Traits类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getSlotObject

    ScriptObject* ScriptObject::getSlotObject(uint32_t slot)
    {
        Traits* traits = this->traits();
        const TraitsBindingsp td = traits->getTraitsBindings();
        void* p;
        const SlotStorageType sst = td->calcSlotAddrAndSST(slot, (void*)this, p);

        // based on profiling of Flex apps, it's *much* more common for the slot in this case
        // to have a type (vs "atom"), so check for that first...
        if (sst == SST_scriptobject)
        {
            return *((ScriptObject**)p);
        }
        else if (sst == SST_atom)
        {
            Atom const a = *((const Atom*)p);

            // don't call AvmCore::isObject(); it checks for null, which we don't care about here
            if (atomKind(a) == kObjectType)
                return (ScriptObject*)atomPtr(a);

            // else fall thru and return null
        }

        return NULL;
    }
开发者ID:bsdf,项目名称:trx,代码行数:26,代码来源:ScriptObject.cpp


示例2: implToString

 Stringp ClassClosure::implToString() const
 {
     AvmCore* core = this->core();
     Traits* t = this->traits()->itraits;
     Stringp s = core->concatStrings(core->newConstantStringLatin1("[class "), t->name());
     return core->concatStrings(s, core->newConstantStringLatin1("]"));
 }
开发者ID:AdiKo,项目名称:avmplus,代码行数:7,代码来源:ClassClosure.cpp


示例3:

    /*static*/ CreateInstanceProc FASTCALL ClassClosure::checkForRestrictedInheritance(VTable* ivtable, CreateInstanceProc p)
    {
        if (ivtable)
        {
            Traits* itraits = ivtable->traits;
            if (p == ArrayClass::createInstanceProc && !itraits->needsHashtable())
            {
                // If we are a sealed subclass of Array, we want to check BugCompatibility
                // to see if instances of this class should behave as "semisealed" instead.
                if (!itraits->core->currentBugCompatibility()->bugzilla654807)
                {
                    return SemiSealedArrayObject::createInstanceProc;
                }
            }

            // Bugzilla 688486: if this is unsubclassed array, let it be simple.
            if (itraits == itraits->core->traits.array_itraits)
            {
                return ArrayClass::createUnsubclassedInstanceProc;
            }

            Traits* base = itraits->base;
            if (base != NULL && base->isRestrictedInheritance && base->pool != itraits->pool)
            {
                return ClassClosure::cantInstantiateCreateInstanceProc;
            }
        }
        return p;
    }
开发者ID:AdiKo,项目名称:avmplus,代码行数:29,代码来源:ClassClosure.cpp


示例4: implToString

 Stringp ScriptObject::implToString() const
 {
     AvmCore* core = this->core();
     Traits* t = this->traits();
     Stringp s = core->concatStrings(core->newConstantStringLatin1("[object "), t->name());
     return core->concatStrings(s, core->newConstantStringLatin1("]"));
 }
开发者ID:bsdf,项目名称:trx,代码行数:7,代码来源:ScriptObject.cpp


示例5: verifyQueue2

// After loading an ABC and inserting scripts into the verify queue,
// process the work queues until they are empty.
void BaseExecMgr::verifyEarly(Toplevel* toplevel, AbcEnv* abc_env)
{
    GCList<MethodInfo> verifyQueue2(core->GetGC(), kListInitialCapacity);
    int verified;
    do {
        verified = 0;
        while (!verifyTraitsQueue.isEmpty()) {
            Traits* t = verifyTraitsQueue.removeFirst();
            t->resolveSignatures(toplevel);
            TraitsBindingsp td = t->getTraitsBindings();
            enqFunction(t->init);
            for (int i=0, n=td->methodCount; i < n; i++)
                enqFunction(td->getMethod(i));
        }
        while (!verifyFunctionQueue.isEmpty()) {
            MethodInfo* f = verifyFunctionQueue.removeLast();
            if (!isVerified(f)) {
                if (f->declaringTraits()->init != f && f->declaringScope() == NULL) {
                    verifyQueue2.add(f);
                    continue;
                }
                verified++;
                //console << "pre verify " << f << "\n";
                verifyMethod(f, toplevel, abc_env);
                setVerified(f);
                if (config.verifyonly)
                    f->_invoker = verifyOnlyInvoker;
            }
        }
        while (!verifyQueue2.isEmpty())
            verifyFunctionQueue.add(verifyQueue2.removeLast());
    } while (verified > 0);
}
开发者ID:bsdf,项目名称:trx,代码行数:35,代码来源:exec-verifyall.cpp


示例6: find_

    // case-sensitive Boyer-Moore search
    BidiIter find_(BidiIter begin, BidiIter end, Traits const &traits) const
    {
        typedef typename boost::iterator_difference<BidiIter>::type diff_type;
        diff_type const endpos = std::distance(begin, end);
        diff_type offset = static_cast<diff_type>(this->length_);

        for(diff_type curpos = offset; curpos < endpos; curpos += offset)
        {
            std::advance(begin, offset);

            char_type const *pat_tmp = this->last_;
            BidiIter str_tmp = begin;

            for(; traits.translate(*str_tmp) == *pat_tmp; --pat_tmp, --str_tmp)
            {
                if(pat_tmp == this->begin_)
                {
                    return str_tmp;
                }
            }

            offset = this->offsets_[traits.hash(traits.translate(*begin))];
        }

        return end;
    }
开发者ID:rogerclark,项目名称:grumble,代码行数:27,代码来源:boyer_moore.hpp


示例7: _newVT

 static VTable* _newVT(Toplevel* toplevel, PoolObject* pool, uint16_t sz)
 {
     Traits* t = Traits::newTraits(pool, NULL, sz, 0, 0, TRAITSTYPE_RT);
     t->verifyBindings(toplevel);
     t->resolveSignatures(toplevel);
     return toplevel->core()->newVTable(t, NULL, toplevel);
 }
开发者ID:DaZhu,项目名称:crossbridge,代码行数:7,代码来源:SamplerScript.cpp


示例8: AvmAssert

    VTable* VTable::newParameterizedVTable(Traits* param_traits, Stringp fullname)
    {
        Toplevel* toplevel = this->toplevel();
        AvmCore* core = toplevel->core();
        Namespacep traitsNs = this->traits->ns();

        GCRef<builtinClassManifest> builtinClasses = toplevel->builtinClasses();
        GCRef<ObjectVectorClass> vectorobj_cls = builtinClasses->get_Vector_objectClass();
        GCRef<ScopeChain> vectorobj_cscope = vectorobj_cls->vtable->init->scope();
        GCRef<ScopeChain> vectorobj_iscope = vectorobj_cls->ivtable()->init->scope();
        VTable* objVecVTable = vectorobj_cls->vtable;
        AbcEnv* objVecAbcEnv = vectorobj_cscope->abcEnv();
        Toplevel* objVecToplevel = objVecVTable->toplevel();
        VTable* objVecIVTable = objVecVTable->ivtable;

        // these cases should all be filtered out by the caller;
        // we only want to handle Vector<SomeObject> here
        AvmAssert(param_traits != NULL &&
                    param_traits != toplevel->intClass()->vtable->traits->itraits &&
                    param_traits != toplevel->uintClass()->vtable->traits->itraits &&
                    param_traits != toplevel->numberClass()->vtable->traits->itraits);

        PoolObject* traitsPool = this->traits->pool;

        Stringp classname = core->internString(fullname->appendLatin1("$"));
        Traits* ctraits = core->domainMgr()->findTraitsInPoolByNameAndNS(traitsPool, classname, traitsNs);
        Traits* itraits;
        if (!ctraits)
        {
            // important: base the new ctraits on objVecVTable->traits, *not* this->traits;
            // we want the result to be based off ObjectVectorClass, not VectorClass
            // (otherwise sizeofInstance would be too small and we'd be crashy)
            ctraits = objVecVTable->traits->newParameterizedCTraits(classname, traitsNs);
            ctraits->verifyBindings(toplevel);

            itraits = traitsPool->resolveParameterizedType(toplevel, this->ivtable->traits, param_traits);
            ctraits->itraits = itraits;
        }
        else
        {
            itraits = ctraits->itraits;
        }

        AvmAssert(itraits != NULL);

        VTable* class_ivtable = builtinClasses->get_ClassClass()->ivtable();

        VTable* cvtab = core->newVTable(ctraits, class_ivtable, objVecToplevel);
        ScopeChain* cvtab_cscope = vectorobj_cscope->cloneWithNewVTable(core->GetGC(), cvtab, objVecAbcEnv);

        VTable* ivtab = core->newVTable(itraits, objVecIVTable, objVecToplevel);
        ScopeChain* ivtab_iscope = vectorobj_iscope->cloneWithNewVTable(core->GetGC(), ivtab, objVecAbcEnv);
        cvtab->ivtable = ivtab;
        ivtab->init = objVecIVTable->init;

        cvtab->resolveSignatures(cvtab_cscope);
        ivtab->resolveSignatures(ivtab_iscope);

        return cvtab;
    }
开发者ID:bsdf,项目名称:trx,代码行数:60,代码来源:VTable.cpp


示例9: getTraits

 bool DomainObject::isDynamic (Atom a)
 {
     Traits *traits = getTraits(a);
     if (traits->itraits != NULL) {
         traits = traits->itraits;
     }
     return traits->needsHashtable();
 }
开发者ID:FlowShift,项目名称:thane,代码行数:8,代码来源:DomainClass.cpp


示例10: set_char

 void set_char(char_type ch, bool icase, Traits const &traits)
 {
     if(this->test_icase_(icase))
     {
         ch = icase ? traits.translate_nocase(ch) : traits.translate(ch);
         this->bset_.set(traits.hash(ch));
     }
 }
开发者ID:venkatarajasekhar,项目名称:viper,代码行数:8,代码来源:hash_peek_bitset.hpp


示例11: shortest_path_regular_tetrahedron

void shortest_path_regular_tetrahedron()
{
  typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
  typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron_3;
  typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Polyhedron_3> Traits;
  typedef Traits::Barycentric_coordinate Barycentric_coordinate;
  typedef Traits::FT FT;
  typedef boost::graph_traits<Polyhedron_3> Graph_traits;
  typedef Graph_traits::vertex_iterator vertex_iterator;
  typedef Graph_traits::face_descriptor face_descriptor;
  typedef Graph_traits::face_iterator face_iterator;
  typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;

  Traits traits;

  Traits::Construct_barycentric_coordinate construct_barycentric_coordinate(traits.construct_barycentric_coordinate_object());

  Polyhedron_3 P;

  CGAL::test::make_regular_tetrahedron(P);

  CGAL::set_halfedgeds_items_id(P);

  Barycentric_coordinate b = construct_barycentric_coordinate(FT(1.0) / FT(3.0), FT(1.0) / FT(3.0), FT(1.0) / FT(3.0));

  face_iterator startFace;
  face_iterator endFace;

  boost::tie(startFace,endFace) = CGAL::faces(P);

  face_descriptor firstFace = *startFace;

  Surface_mesh_shortest_path shortestPaths(P, traits);
  //shortestPaths.m_debugOutput = true;
  shortestPaths.add_source_point(firstFace, b);
  shortestPaths.build_sequence_tree();

  vertex_iterator currentVertex;
  vertex_iterator endVertex;

  Kernel::FT sideLength = Kernel::FT(2.0);
  Kernel::FT halfSideLength = sideLength / Kernel::FT(2.0);
  Kernel::FT triangleHeight = CGAL::sqrt((sideLength*sideLength) - (halfSideLength*halfSideLength));

  for (boost::tie(currentVertex, endVertex) = CGAL::vertices(P); currentVertex != endVertex; ++currentVertex)
  {
    if ((*currentVertex)->point().y()==-1)
    {
      CHECK_CLOSE(shortestPaths.shortest_distance_to_source_points(*currentVertex).first, Kernel::FT((triangleHeight * Kernel::FT(4.0)) / Kernel::FT(3.0)), Kernel::FT(0.000001));
    }
    else
    {
      CHECK_CLOSE(shortestPaths.shortest_distance_to_source_points(*currentVertex).first, Kernel::FT((triangleHeight * Kernel::FT(2.0)) / Kernel::FT(3.0)), Kernel::FT(0.000001));
    }
  }
}
开发者ID:Asuzer,项目名称:cgal,代码行数:56,代码来源:Surface_mesh_shortest_path_test_1.cpp


示例12: lookup_classname

inline typename Traits::char_class_type
lookup_classname(Traits const &traits, char const (&cname)[N], bool icase)
{
    typename Traits::char_type name[N] = {0};
    for(std::size_t j = 0; j < N-1; ++j)
    {
        name[j] = traits.widen(cname[j]);
    }
    return traits.lookup_classname(name, name + N - 1, icase);
}
开发者ID:rogerclark,项目名称:grumble,代码行数:10,代码来源:regex_traits.hpp


示例13: Add

	/**
	 *  @pre !Finished()
	 */
	AttributeList& Add(AttribKind attrib, bool value)
	{
		assert(!Finished());
		typedef typename Traits::template EnumBaseType<
			AttribKind
		>::Type Enum;
		_attribs.push_back(Int(Enum(attrib)));
		_attribs.push_back(
			value?
			_traits.TrueValue():
			_traits.FalseValue()
		);
		return *this;
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:17,代码来源:attrib_list.hpp


示例14: init_

 void init_(Traits const &traits, mpl::true_)
 {
     this->fold_.reserve(this->length_ + 1);
     for(unsigned char offset = this->length_; offset; --offset, ++this->last_)
     {
         this->fold_.push_back(traits.fold_case(*this->last_));
         for(typename string_type::const_iterator beg = this->fold_.back().begin(), end = this->fold_.back().end();
             beg != end; ++beg)
         {
             this->offsets_[traits.hash(*beg)] = offset;
         }
     }
     this->fold_.push_back(traits.fold_case(*this->last_));
 }
开发者ID:rogerclark,项目名称:grumble,代码行数:14,代码来源:boyer_moore.hpp


示例15: makeVerticalLine

X_monotone_curve_2 makeVerticalLine( Bound x )
{
    Traits traits;
    Traits::Construct_point_2 constructPoint =
        traits.construct_point_2_object( );
    Traits::Construct_x_monotone_segment_2 constructSegment = 
        traits.construct_x_monotone_segment_2_object( );

    std::vector< X_monotone_curve_2 > curves;
    Point_2 p1 = constructPoint( Algebraic_real_1(x), Algebraic_real_1(Bound( -10000 )) );
    Point_2 p2 = constructPoint( x, Bound( +10000 ) );
    constructSegment( p1, p2, std::back_inserter( curves ) );
    return curves[ 0 ];
}
开发者ID:2php,项目名称:cgal,代码行数:14,代码来源:TestAlgebraic.cpp


示例16: find_nocase_fold_

    // case-insensitive Boyer-Moore search with case-folding
    BidiIter find_nocase_fold_(BidiIter begin, BidiIter end, Traits const &traits) const
    {
        typedef typename boost::iterator_difference<BidiIter>::type diff_type;
        diff_type const endpos = std::distance(begin, end);
        diff_type offset = static_cast<diff_type>(this->length_);

        for(diff_type curpos = offset; curpos < endpos; curpos += offset)
        {
            std::advance(begin, offset);

            string_type const *pat_tmp = &this->fold_.back();
            BidiIter str_tmp = begin;

            for(; pat_tmp->end() != std::find(pat_tmp->begin(), pat_tmp->end(), *str_tmp);
                --pat_tmp, --str_tmp)
            {
                if(pat_tmp == &this->fold_.front())
                {
                    return str_tmp;
                }
            }

            offset = this->offsets_[traits.hash(*begin)];
        }

        return end;
    }
开发者ID:rogerclark,项目名称:grumble,代码行数:28,代码来源:boyer_moore.hpp


示例17: getScopeTraitsAt

	Stringp ScopeTypeChain::format(AvmCore* core) const
	{
		Stringp r = core->kEmptyString;
		r = r->appendLatin1("STC:[");
		for (int i = 0; i < fullsize; i++)
		{
			if (i > 0)
				r = r->appendLatin1(",");
			Traits* t = getScopeTraitsAt(i);
			bool b = getScopeIsWithAt(i);
			r = r->append(t->format(core));
			r = r->appendLatin1(b?":1":":0");
		}
		r = r->appendLatin1("]");
		return r;
	}
开发者ID:weimingtom,项目名称:mod-actionscript,代码行数:16,代码来源:ScopeChain.cpp


示例18: switch

inline sequence<BidiIter> make_any_xpression
(
    regex_constants::syntax_option_type flags
  , Traits const &tr
)
{
    using namespace regex_constants;
    typedef typename iterator_value<BidiIter>::type char_type;
    typedef detail::set_matcher<Traits, mpl::int_<2> > set_matcher;
    typedef literal_matcher<Traits, mpl::false_, mpl::true_> literal_matcher;

    char_type const newline = tr.widen('\n');
    set_matcher s;
    s.set_[0] = newline;
    s.set_[1] = 0;
    s.inverse();

    switch(((int)not_dot_newline | not_dot_null) & flags)
    {
    case not_dot_null:
        return make_dynamic<BidiIter>(literal_matcher(char_type(0), tr));

    case not_dot_newline:
        return make_dynamic<BidiIter>(literal_matcher(newline, tr));

    case (int)not_dot_newline | not_dot_null:
        return make_dynamic<BidiIter>(s);

    default:
        return make_dynamic<BidiIter>(any_matcher());
    }
}
开发者ID:AlexMioMio,项目名称:boost,代码行数:32,代码来源:parser.hpp


示例19: line_start_finder

 line_start_finder(Traits const &traits)
 {
     char_class_type newline = lookup_classname(traits, "newline");
     for(int j = 0; j < 256; ++j)
     {
         this->bits_[j] = traits.isctype(static_cast<char_type>(static_cast<unsigned char>(j)), newline);
     }
 }
开发者ID:Axitonium,项目名称:sourcesdkpython,代码行数:8,代码来源:finder.hpp


示例20: nocase

    void nocase(Traits const &traits)
    {
        this->icase_ = true;

        for(int i = 0; i < Size; ++i)
        {
            this->set_[i] = traits.translate_nocase(this->set_[i]);
        }
    }
开发者ID:rogerclark,项目名称:grumble,代码行数:9,代码来源:set_matcher.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TrajClient类代码示例发布时间:2022-05-31
下一篇:
C++ TrainingSet类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap