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


C++ ValueArray::nth方法代码示例

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


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

示例1: while

    void test_writeBarrier_2(void)
    {
        GC::initialize();

        Bytecode* myBytecode = gCodeManager.readBytecode("test.hyb");
        myBytecode->setInitialized();

        Context* context = gCodeManager.createContext();
        Thread* pThread = gThreadManager.createTmpThread();
        context->pushClass(myBytecode->mainClass());
        context->methodCall(HSym_gc_test_writeBarrier_2, 0);
        pThread->initialize(context);
        pThread->start();

        GC::unmark();
        while (gThreadManager.isThreadRunning()) {
            gThreadManager.exec1tick();
            GC::incremental();
        }

        GC::full();
        Value* ga = gGlobalVar.getVarAddr_notCreate(HSym_a);
        CPPUNIT_ASSERT(ga != NULL);
        ValueArray* arr = ga->toCppObj<ValueArray>(HSym_Array);
        for (int i = 0; i < 50; ++i) {
            Value v = arr->nth(i);
            Object* obj = v.toObj();
            CPPUNIT_ASSERT_EQUAL(HC_Array, obj->type());
            CPPUNIT_ASSERT(obj->isMarked());
            ValueArray* a2 = obj->cppObj<ValueArray>();
            obj = a2->nth(0).toObj();
            CPPUNIT_ASSERT_EQUAL(HC_StringBuffer, obj->type());
            CPPUNIT_ASSERT(obj->isMarked());
            obj = a2->nth(1).toObj();
            CPPUNIT_ASSERT_EQUAL(HC_StringBuffer, obj->type());
            CPPUNIT_ASSERT(obj->isMarked());
        }

        GC::finalize();
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:40,代码来源:Test_hyGC.cpp

示例2: test_writeBarrier

    void test_writeBarrier(void)
    {
        GC::initialize();

        Bytecode* myBytecode = gCodeManager.readBytecode("test.hyb");
        myBytecode->setInitialized();

        Context* context = gCodeManager.createContext();
        Thread* pThread = gThreadManager.createTmpThread();
        context->pushClass(myBytecode->mainClass());
        context->methodCall(HSym_gc_test_writeBarrier, 0);
        pThread->initialize(context);
        pThread->start();

        gThreadManager.exec1tick();
        GC::unmark();

        for (int i = 0; i < 300; ++i) {
            gThreadManager.exec1tick();
            GC::incremental();
        }

        GC::full();
        Value* ga = gGlobalVar.getVarAddr_notCreate(HSym_a);
        CPPUNIT_ASSERT(ga != NULL);
        ValueArray* arr = ga->toCppObj<ValueArray>(HSym_Array);
        for (int i = 0; i < 100; ++i) {
            Value v = arr->nth(i);
            Object* obj = v.toObj();
            CPPUNIT_ASSERT_EQUAL(HC_StringBuffer, obj->type());
            //StringBuffer* sb = obj->cppObj<StringBuffer>();
            //HMD_PRINTF("%d:%x %x type=%x(SB=%x)",i,obj,sb,obj->type(),HC_StringBuffer);
            //HMD_PRINTF(" bufSize=%d,length=%d,buf=%x\n",sb->bufSize(),sb->length(),sb->top());
            CPPUNIT_ASSERT(obj->isMarked());
        }

        GC::finalize();
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:38,代码来源:Test_hyGC.cpp


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