本文整理汇总了C++中duk_pop_2函数的典型用法代码示例。如果您正苦于以下问题:C++ duk_pop_2函数的具体用法?C++ duk_pop_2怎么用?C++ duk_pop_2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了duk_pop_2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dukky_application_cache_onobsolete_setter
static duk_ret_t dukky_application_cache_onobsolete_setter(duk_context *ctx)
{
/* Get private data for method */
application_cache_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例2: test
void test(duk_context *ctx) {
int rc;
duk_eval_string(ctx, "this.testFunc = eval.bind(this, 'print(\\'hello from eval\\')');");
duk_pop(ctx);
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, "testFunc");
rc = duk_pcall(ctx, 0);
printf("rc=%d\n", rc);
duk_pop_2(ctx);
printf("final top: %d\n", duk_get_top(ctx));
}
示例3: dukky_audio_track_kind_getter
static duk_ret_t dukky_audio_track_kind_getter(duk_context *ctx)
{
/* Get private data for method */
audio_track_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例4: dukky_validity_state_typeMismatch_getter
static duk_ret_t dukky_validity_state_typeMismatch_getter(duk_context *ctx)
{
/* Get private data for method */
validity_state_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例5: dukky_drag_event_dataTransfer_getter
static duk_ret_t dukky_drag_event_dataTransfer_getter(duk_context *ctx)
{
/* Get private data for method */
drag_event_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例6: dukky_html_anchor_element_protocol_getter
static duk_ret_t dukky_html_anchor_element_protocol_getter(duk_context *ctx)
{
/* Get private data for method */
html_anchor_element_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例7: dukky_mutation_record_oldValue_getter
static duk_ret_t dukky_mutation_record_oldValue_getter(duk_context *ctx)
{
/* Get private data for method */
mutation_record_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例8: dukky_document_fragment_childElementCount_getter
static duk_ret_t dukky_document_fragment_childElementCount_getter(duk_context *ctx)
{
/* Get private data for method */
document_fragment_private_t *priv = NULL;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, dukky_magic_string_private);
priv = duk_get_pointer(ctx, -1);
duk_pop_2(ctx);
if (priv == NULL) {
return 0; /* can do? No can do. */
}
return 0;
}
示例9: test
void test(duk_context *ctx) {
duk_ret_t rc;
duk_set_top(ctx, 0);
duk_push_string(ctx, "foo"); /* dummy */
/* success case */
duk_push_int(ctx, 10);
duk_push_int(ctx, 11);
duk_push_int(ctx, 12);
rc = duk_safe_call(ctx, test_1, 3 /*nargs*/, 2 /*nrets*/);
if (rc == DUK_EXEC_SUCCESS) {
printf("1st return value: %s\n", duk_to_string(ctx, -2)); /* 21 */
printf("2nd return value: %s\n", duk_to_string(ctx, -1)); /* undefined */
} else {
printf("error: %s\n", duk_to_string(ctx, -2));
}
duk_pop_2(ctx);
/* error case */
duk_push_int(ctx, 10);
duk_push_int(ctx, 11);
duk_push_int(ctx, 12);
rc = duk_safe_call(ctx, test_2, 3 /*nargs*/, 2 /*nrets*/);
if (rc == DUK_EXEC_SUCCESS) {
printf("1st return value: %s\n", duk_to_string(ctx, -2)); /* 21 */
printf("2nd return value: %s\n", duk_to_string(ctx, -1)); /* undefined */
} else {
printf("error: %s\n", duk_to_string(ctx, -2));
}
duk_pop_2(ctx);
/* XXX: also test invalid input stack shapes (like not enough args) */
printf("final top: %ld\n", (long) duk_get_top(ctx));
}
示例10: NativeSignal
static int NativeSignal(duk_context* ctx)
{
const char* dest;
uint32_t session;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, "dest");
dest = duk_get_string(ctx, -1);
duk_pop(ctx);
duk_get_prop_string(ctx, -1, "session");
session = duk_get_int(ctx, -1);
duk_pop_2(ctx);
InitSignal(ctx, dest, session);
return 1;
}
示例11: js_register_LocalStorage
duk_ret_t js_register_LocalStorage(duk_context *ctx)
{
duk_push_global_object(ctx); /* global */
duk_get_prop_string(ctx, -1, MURAL_JS_NAMESPACE); /* global, __MURAL__ */
duk_push_c_function(ctx, w_LocalStorage_constructor, 0); /* global, __MURAL__, constructor */
duk_push_object(ctx); /* global, __MURAL__, constructor, prototype */
duk_put_function_list(ctx, -1, methods_of_LocalStorage);
duk_put_prop_string(ctx, -2, "prototype"); /* global, __MURAL__, constructor */
duk_put_prop_string(ctx, -2, "LocalStorage"); /* global, __MURAL__ */
duk_pop_2(ctx);
return 0;
}
示例12: w_LocalStorage_prototype_removeItem
int w_LocalStorage_prototype_removeItem(duk_context *ctx)
{
const char *key = duk_require_string(ctx, 0);
duk_push_this(ctx); /* this */
duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */
duk_del_prop_string(ctx, -1, key); /* this, __MURAL_DATA__ */
LocalStorage *inst = getNativePointer<LocalStorage>(ctx);
duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */
inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */
duk_pop_2(ctx);
return 0;
}
示例13: _gum_duk_require_uint64
guint64
_gum_duk_require_uint64 (duk_context * ctx,
duk_idx_t index,
GumDukCore * core)
{
GumDukUInt64 * object;
duk_dup (ctx, index);
duk_push_heapptr (ctx, core->uint64);
if (!duk_instanceof (ctx, -2, -1))
_gum_duk_throw (ctx, "expected UInt64");
duk_pop_2 (ctx);
object = _gum_duk_require_data (ctx, index);
return object->value;
}
示例14: module_search
// Duktape.modSearch function, needed for loading modules with require()
duk_ret_t module_search(duk_context *ctx) {
const char *id = duk_require_string(ctx, 0);
// C modules: add functions to exports variable (3rd argument) and return undefined
for (int i = 0; i < c_module_count; i++) {
if (!strcmp(c_module_list[i].name, id)) {
duk_push_c_function(ctx, c_module_list[i].init_func, 0);
duk_call(ctx, 0);
duk_enum(ctx, -1, 0);
while(duk_next(ctx, -1, 1)) {
duk_put_prop(ctx, 2);
}
duk_pop_2(ctx);
return 0;
}
}
// JS modules: return source code as a string
// Read from file "modname.js.tns"
int module_filename_len = strlen(id) + strlen(".js.tns") + 1;
char *module_filename = malloc(module_filename_len);
if (!module_filename) goto error;
snprintf(module_filename, module_filename_len, "%s.js.tns", id);
FILE *module_file = fopen(module_filename, "r");
free(module_filename);
if (!module_file) goto error;
if (fseek(module_file, 0, SEEK_END) != 0) goto error;
long module_file_size = ftell(module_file);
if (module_file_size == -1) goto error;
rewind(module_file);
char *src = malloc(module_file_size);
if (!src) goto error;
fread(src, 1, module_file_size, module_file);
if (ferror(module_file)) goto error;
fclose(module_file);
duk_push_lstring(ctx, src, module_file_size);
free(src);
return 1;
error:
duk_push_error_object(ctx, DUK_ERR_ERROR, "module %s not found: %s", id, strerror(errno));
duk_throw(ctx);
}
示例15: kbjs_PinId_str
/*----------------------------------------------------------------------------*/
static duk_ret_t
kbjs_PinId_str(duk_context *context)
{
/* STACK: [this] */
duk_push_this(context);
/* STACK: [this, void*] */
duk_get_prop_string(context, (duk_idx_t)-1, KBJS_INSTANCE_PTR);
kbjs_PinId *pin_id = duk_get_pointer(context, (duk_idx_t)-1);
/* STACK: [] */
duk_pop_2(context);
/* STACK: ["PIN*"] */
duk_push_string(context, pin_id->str);
/* Return string */
return (duk_ret_t)1;
}