本文整理汇总了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);
}
示例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); //
}
示例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); //
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}