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


C++ Isolate::GetDukContext方法代码示例

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


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

示例1: AddObject

void ObjectList::AddObject(void *val) {
    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    duk_push_heapptr(ctx, list_ptr_);
    duk_push_heapptr(ctx, val);
    duk_size_t len = duk_get_length(ctx, -1);
    duk_put_prop_index(ctx, -2, (duk_uarridx_t) len);
    duk_pop(ctx);
}
开发者ID:caivega,项目名称:dukv8,代码行数:10,代码来源:ObjectList.cpp

示例2: removeList

void GCObjectPool::removeList() {
    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    // Get the "refs" array in the heap stash
    duk_push_global_stash(ctx);
    duk_get_prop_string(ctx, -1, "__object_list");
    duk_remove(ctx, -2);

    // scopeList[scopeIndex] = scopeList[0]
    duk_get_prop_index(ctx, -1, 0);                                // <scopeList> <scopeList[0]>
    duk_put_prop_index(ctx, -2, (duk_uarridx_t) list_idx_);

    // scopeList[0] = scopeIndex
    duk_push_int(ctx, list_idx_);                                  // <scopeList> <scopeIndex>
    duk_put_prop_index(ctx, -2, 0);                                // <scopeList>

    duk_pop(ctx);                                                  //
}
开发者ID:caivega,项目名称:dukv8,代码行数:19,代码来源:GCObjectPool.cpp

示例3: RemoveObject

void GlobalStash::RemoveObject(int index) {
    if (!index) return;

    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    // Get the "refs" array in the heap stash
    duk_push_global_stash(ctx);
    duk_get_prop_string(ctx, -1, name_);
    duk_remove(ctx, -2);

    // scopeList[scopeIndex] = scopeList[0]
    duk_get_prop_index(ctx, -1, 0);                                // <scopeList> <scopeList[0]>
    duk_put_prop_index(ctx, -2, (duk_uarridx_t) index);

    // scopeList[0] = scopeIndex
    duk_push_int(ctx, index);                                      // <scopeList> <scopeIndex>
    duk_put_prop_index(ctx, -2, 0);                                // <scopeList>

    duk_pop(ctx);                                                  //
}
开发者ID:caivega,项目名称:dukv8,代码行数:21,代码来源:GlobalStash.cpp

示例4: addNewList

void GCObjectPool::addNewList() {
    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    // Get the "refs" array in the heap stash
    duk_push_global_stash(ctx);
    duk_get_prop_string(ctx, -1, "__object_list");
    duk_remove(ctx, -2);

    int type = duk_get_type(ctx, -1);

    int freeSlot;

    // freeSlot = scopeList[0]
    duk_get_prop_index(ctx, -1, 0);                                // <scopeList> <scopeList[0]>
    freeSlot = duk_get_int(ctx, -1);
    duk_pop(ctx);                                                  // <scopeList>

    if (freeSlot != 0) {
        // scopeList[0] = scopeList[freeSlot]
        duk_get_prop_index(ctx, -1, (duk_uarridx_t) freeSlot);    // <scopeList> <scopeList[freeSlot]>
        duk_put_prop_index(ctx, -2, 0);                            // <scopeList>
    } else {
        // freeSlot = scopeList.length;
        freeSlot = (int) duk_get_length(ctx, -1);
    }

    duk_push_array(ctx);
    list_ptr_ = duk_get_heapptr(ctx, -1);                         // <scopeList> <scope>

    // scopeList[freeSlot] = scope
    duk_put_prop_index(ctx, -2, (duk_uarridx_t) freeSlot);        // <scopeList>

    // Remove the refs array from the stack.
    duk_pop(ctx);                                                  //

    list_idx_ = freeSlot;
}
开发者ID:caivega,项目名称:dukv8,代码行数:38,代码来源:GCObjectPool.cpp

示例5: AddObject

int GlobalStash::AddObject(void *ptr) {
    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    // Get the "refs" array in the heap stash
    duk_push_global_stash(ctx);
    duk_get_prop_string(ctx, -1, name_);
    duk_remove(ctx, -2);

    int type = duk_get_type(ctx, -1);

    int freeSlot;

    // freeSlot = scopeList[0]
    duk_get_prop_index(ctx, -1, 0);                                // <scopeList> <scopeList[0]>
    freeSlot = duk_get_int(ctx, -1);
    duk_pop(ctx);                                                  // <scopeList>

    if (freeSlot != 0) {
        // scopeList[0] = scopeList[freeSlot]
        duk_get_prop_index(ctx, -1, (duk_uarridx_t) freeSlot);    // <scopeList> <scopeList[freeSlot]>
        duk_put_prop_index(ctx, -2, 0);                            // <scopeList>
    } else {
        // freeSlot = scopeList.length;
        freeSlot = (int) duk_get_length(ctx, -1);
    }

    duk_push_heapptr(ctx, ptr);                                   // <scopeList> <scope>

    // scopeList[freeSlot] = scope
    duk_put_prop_index(ctx, -2, (duk_uarridx_t) freeSlot);        // <scopeList>

    // Remove the refs array from the stack.
    duk_pop(ctx);                                                  //

    return freeSlot;
}
开发者ID:caivega,项目名称:dukv8,代码行数:37,代码来源:GlobalStash.cpp

示例6: EnsureObjectList

void GCObjectPool::EnsureObjectList() {
    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    // 每个 global 对象对应一个 stash 对象
    duk_push_global_stash(ctx);
    duk_get_prop_string(ctx, -1, "__object_list");

    if (duk_is_undefined(ctx, -1)) {
        duk_pop(ctx);

        // Create a new array with one `0` at index `0`.
        duk_push_array(ctx);
        duk_push_int(ctx, 0);
        duk_put_prop_index(ctx, -2, 0);

        duk_dup_top(ctx);

        // Store it as "name_" in the heap stash
        duk_put_prop_string(ctx, -3, "__object_list");
    }

    duk_pop_2(ctx);
}
开发者ID:caivega,项目名称:dukv8,代码行数:24,代码来源:GCObjectPool.cpp

示例7:

GlobalStash::GlobalStash(const char *name) : name_(name) {
    Isolate *isolate = Isolate::GetCurrent();
    duk_context *ctx = isolate->GetDukContext();

    // 每个 global 对象对应一个 stash 对象
    duk_push_global_stash(ctx);
    duk_get_prop_string(ctx, -1, name_);

    if (duk_is_undefined(ctx, -1)) {
        duk_pop(ctx);

        // Create a new array with one `0` at index `0`.
        duk_push_array(ctx);
        duk_push_int(ctx, 0);
        duk_put_prop_index(ctx, -2, 0);

        // Store it as "name_" in the heap stash
        duk_put_prop_string(ctx, -2, name_);
    } else {
        duk_pop(ctx);
    }

    duk_pop(ctx);
}
开发者ID:caivega,项目名称:dukv8,代码行数:24,代码来源:GlobalStash.cpp


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