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

C++ duk_get_prop_string函数代码示例

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

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



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

示例1: dump_error

void dump_error(duk_context *ctx) {
	duk_dup(ctx, -1);
	printf("ToString(error): %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "name");
	printf("name: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "message");
	printf("message: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	/* 'code' is no longer set, test that it reads back as 'undefined' */
	duk_get_prop_string(ctx, -1, "code");
	printf("code: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "fileName");
	printf("fileName is a string: %d\n", (int) duk_is_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "lineNumber");
	printf("lineNumber: %ld\n", (long) duk_get_int(ctx, -1));
	duk_pop(ctx);

	/* 'isNative' has also been removed, check that it reads back as 'undefined' */
	duk_get_prop_string(ctx, -1, "isNative");
	printf("isNative: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);
}
开发者ID:BrandonTheHamm,项目名称:duktape,代码行数:31,代码来源:test-error.c


示例2: nsp_texture_draw_line

// ====== Xtase drawing routines ======
duk_ret_t nsp_texture_draw_line(duk_context *ctx) {
    int x1 = duk_require_int(ctx, 0);
    int y1 = duk_require_int(ctx, 1);

    int x2 = duk_require_int(ctx, 2);
    int y2 = duk_require_int(ctx, 3);

    uint16_t color = duk_require_int(ctx, 4);


    duk_push_this(ctx);
    duk_get_prop_string(ctx, -1, "width");
    int w = duk_require_int(ctx, -1);
    duk_pop(ctx);
    duk_get_prop_string(ctx, -1, "height");
    int h = duk_require_int(ctx, -1);
    duk_pop(ctx);

    if (w <= 0 || h <= 0) {
			duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "width and height must be positive");
			duk_throw(ctx);
    }

    duk_get_prop_string(ctx, -1, "bitmap");
    size_t size;
    uint16_t *bitmap = duk_get_buffer(ctx, -1, &size);
    if (bitmap == NULL) {
			duk_push_error_object(ctx, DUK_ERR_ERROR, "bitmap pointer is NULL");
			duk_throw(ctx);
    }

		FbDev* fb = (FbDev*)malloc( 1 * sizeof(FbDev) );
		  fb->width = w;
		  fb->height = h;
		  fb->fb_size = w * h;
		  fb->fb = bitmap;
		  drawLine(x1,y1,x2,y2,color,fb);
		free(fb);
    return 0;
}
开发者ID:fgalliat,项目名称:duktape-nspire,代码行数:41,代码来源:nsp_texture.c


示例3: dump_error

void dump_error(duk_context *ctx) {
	duk_dup(ctx, -1);
	printf("ToString(error): %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "name");
	printf("name: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "message");
	printf("message: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "code");
	printf("code: %d\n", duk_get_int(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "fileName");
	printf("fileName: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "lineNumber");
	printf("lineNumber: %d\n", duk_get_int(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "isNative");
	printf("isNative: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);
}
开发者ID:JoshEngebretson,项目名称:duktape,代码行数:29,代码来源:test-error.c


示例4: js_Font_drawTextBox

static duk_ret_t
js_Font_drawTextBox(duk_context* ctx)
{
	int x = duk_require_int(ctx, 0);
	int y = duk_require_int(ctx, 1);
	int w = duk_require_int(ctx, 2);
	int h = duk_require_int(ctx, 3);
	int offset = duk_require_int(ctx, 4);
	const char* text = duk_to_string(ctx, 5);

	font_t*     font;
	int         line_height;
	const char* line_text;
	color_t     mask;
	int         num_lines;

	int i;

	duk_push_this(ctx);
	font = duk_require_sphere_obj(ctx, -1, "Font");
	duk_get_prop_string(ctx, -1, "\xFF" "color_mask"); mask = duk_require_sphere_color(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	if (!screen_is_skipframe(g_screen)) {
		duk_push_c_function(ctx, js_Font_wordWrapString, DUK_VARARGS);
		duk_push_this(ctx);
		duk_push_string(ctx, text);
		duk_push_int(ctx, w);
		duk_call_method(ctx, 2);
		duk_get_prop_string(ctx, -1, "length"); num_lines = duk_get_int(ctx, -1); duk_pop(ctx);
		line_height = get_font_line_height(font);
		for (i = 0; i < num_lines; ++i) {
			duk_get_prop_index(ctx, -1, i); line_text = duk_get_string(ctx, -1); duk_pop(ctx);
			draw_text(font, mask, x + offset, y, TEXT_ALIGN_LEFT, line_text);
			y += line_height;
		}
		duk_pop(ctx);
	}
	return 0;
}
开发者ID:svaarala,项目名称:minisphere,代码行数:39,代码来源:font.c


示例5: js_Font_getStringWidth

static duk_ret_t
js_Font_getStringWidth(duk_context* ctx)
{
	const char* text = duk_to_string(ctx, 0);
	
	font_t* font;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_int(ctx, get_text_width(font, text));
	return 1;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:13,代码来源:font.c


示例6: js_Font_getStringHeight

static duk_ret_t
js_Font_getStringHeight(duk_context* ctx)
{
	const char* text = duk_to_string(ctx, 0);
	int width = duk_require_int(ctx, 1);
	
	font_t* font;
	int     num_lines;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_c_function(ctx, js_Font_wordWrapString, DUK_VARARGS);
	duk_push_this(ctx);
	duk_push_string(ctx, text);
	duk_push_int(ctx, width);
	duk_call_method(ctx, 2);
	duk_get_prop_string(ctx, -1, "length"); num_lines = duk_get_int(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_int(ctx, get_font_line_height(font) * num_lines);
	return 1;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:22,代码来源:font.c


示例7: js_Font_getCharacterImage

static duk_ret_t
js_Font_getCharacterImage(duk_context* ctx)
{
	int cp = duk_require_int(ctx, 0);

	font_t* font;
	
	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_sphere_image(ctx, get_glyph_image(font, cp));
	return 1;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:13,代码来源:font.c


示例8: duk_module_node_init

void duk_module_node_init(duk_context *ctx) {
	/*
	 *  Stack: [ ... options ] => [ ... ]
	 */

	duk_idx_t options_idx;

	duk_require_object_coercible(ctx, -1);  /* error before setting up requireCache */
	options_idx = duk_require_normalize_index(ctx, -1);

	/* Initialize the require cache to a fresh object. */
	duk_push_global_stash(ctx);
	duk_push_object(ctx);
	duk_put_prop_string(ctx, -2, "\xff" "requireCache");
	duk_pop(ctx);

	/* Stash callbacks for later use.  User code can overwrite them later
	 * on directly by accessing the global stash.
	 */
	duk_push_global_stash(ctx);
	duk_get_prop_string(ctx, options_idx, "resolve");
	duk_require_function(ctx, -1);
	duk_put_prop_string(ctx, -2, "\xff" "modResolve");
	duk_get_prop_string(ctx, options_idx, "load");
	duk_require_function(ctx, -1);
	duk_put_prop_string(ctx, -2, "\xff" "modLoad");
	duk_pop(ctx);

	/* register `require` as a global function */
	duk_push_global_object(ctx);
	duk_push_string(ctx, "require");
	duk__push_require_function(ctx, "");
	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE |
	                      DUK_DEFPROP_SET_WRITABLE |
	                      DUK_DEFPROP_SET_CONFIGURABLE);
	duk_pop(ctx);

	duk_pop(ctx);  /* pop argument */
}
开发者ID:eliteYang,项目名称:duktape-js-cpp,代码行数:39,代码来源:duk_module_node.c


示例9: PushServiceCallback

/*
 * If there is a callback registered for this interface pushes the function onto the stack
 */
static int PushServiceCallback(duk_context* ctx, const char* iface)
{
    AJS_GetGlobalStashObject(ctx, "serviceCB");

    duk_get_prop_string(ctx, -1, iface);
    duk_remove(ctx, -2);
    if (duk_is_callable(ctx, -1)) {
        return 1;
    } else {
        duk_pop(ctx);
        return 0;
    }
}
开发者ID:anthony-ngu,项目名称:core-alljoyn-js,代码行数:16,代码来源:ajs_sessions.c


示例10: js_Sound_setVolume

static duk_ret_t
js_Sound_setVolume(duk_context* ctx)
{
	float new_gain = duk_require_int(ctx, 0);
	
	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	set_sound_gain(sound, (float)new_gain / 255);
	return 0;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:13,代码来源:sound.c


示例11: js_Sound_setRepeat

static duk_ret_t
js_Sound_setRepeat(duk_context* ctx)
{
	bool is_looped = duk_require_boolean(ctx, 0);
	
	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	set_sound_looping(sound, is_looped);
	return 0;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:13,代码来源:sound.c


示例12: dukzip_require_unz

static unzFile dukzip_require_unz(duk_context *ctx, int index) {
	unzFile result;

	duk_get_prop_string(ctx, index, ZIPHANDLE_PROP);
	result = duk_get_pointer(ctx, -1);
	duk_pop(ctx);
	if (!result) {
		duk_error(ctx, DUK_ERR_TYPE_ERROR, "Expected dukzip archive at index %d", index);
		return NULL;
	}

	return result;
}
开发者ID:armornick,项目名称:duktape-misc,代码行数:13,代码来源:zip.c


示例13: js_Sound_setPitch

static duk_ret_t
js_Sound_setPitch(duk_context* ctx)
{
	float new_pitch = duk_require_number(ctx, 0);

	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	set_sound_pitch(sound, new_pitch);
	return 0;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:13,代码来源:sound.c


示例14: duk__console_log_helper

static duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_name) {
	duk_uint_t flags = (duk_uint_t) duk_get_current_magic(ctx);
	FILE *output = (flags & DUK_CONSOLE_STDOUT_ONLY) ? stdout : stderr;
	duk_idx_t n = duk_get_top(ctx);
	duk_idx_t i;

	duk_get_global_string(ctx, "console");
	duk_get_prop_string(ctx, -1, "format");

	for (i = 0; i < n; i++) {
		if (duk_check_type_mask(ctx, i, DUK_TYPE_MASK_OBJECT)) {
			/* Slow path formatting. */
			duk_dup(ctx, -1);  /* console.format */
			duk_dup(ctx, i);
			duk_call(ctx, 1);
			duk_replace(ctx, i);  /* arg[i] = console.format(arg[i]); */
		}
	}

	duk_pop_2(ctx);

	duk_push_string(ctx, " ");
	duk_insert(ctx, 0);
	duk_join(ctx, n);

	if (error_name) {
		duk_push_error_object(ctx, DUK_ERR_ERROR, "%s", duk_require_string(ctx, -1));
		duk_push_string(ctx, "name");
		duk_push_string(ctx, error_name);
		duk_def_prop(ctx, -3, DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE);  /* to get e.g. 'Trace: 1 2 3' */
		duk_get_prop_string(ctx, -1, "stack");
	}

	fprintf(output, "%s\n", duk_to_string(ctx, -1));
	if (flags & DUK_CONSOLE_FLUSH) {
		fflush(output);
	}
	return 0;
}
开发者ID:svaarala,项目名称:duktape,代码行数:39,代码来源:duk_console.c


示例15: GetBinding

        static BindingInfo * GetBinding( duk_context * ctx )
        {
            duk_push_global_stash( ctx );
            duk_get_prop_string( ctx, -1, DUKBIND_BINDING_NAME );

            duk_size_t buffer_size;
            void * buffer = duk_to_buffer( ctx, -1, &buffer_size);
            dukbind_assert( buffer_size == sizeof( BindingInfo * ), "Invalid buffer size" );

            duk_pop_2( ctx );

            return *reinterpret_cast<BindingInfo**>( buffer );
        }
开发者ID:crazyjul,项目名称:dukbind,代码行数:13,代码来源:dukbind_proxy_function.cpp


示例16: _gum_duk_is_arg0_equal_to_prototype

gboolean
_gum_duk_is_arg0_equal_to_prototype (duk_context * ctx,
                                     const gchar * class_name)
{
  gboolean result;

  duk_get_global_string (ctx, class_name);
  duk_get_prop_string (ctx, -1, "prototype");
  result = duk_equals (ctx, 0, -1);
  duk_pop_2 (ctx);

  return result;
}
开发者ID:TechLord-Forever,项目名称:frida-gum,代码行数:13,代码来源:gumdukvalue.c


示例17: js_Sound_setPosition

static duk_ret_t
js_Sound_setPosition(duk_context* ctx)
{
	int new_pos = duk_require_int(ctx, 0);

	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	seek_sound(sound, new_pos);
	return 0;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:13,代码来源:sound.c


示例18: test_getprop

static duk_ret_t test_getprop(duk_context *ctx, void *udata) {
	(void) udata;

	prep(ctx);

	/* Property exists, own property */
	duk_get_prop_string(ctx, 0, "foo");
	printf("getprop foo: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	/* Property exists, inherited property */
	duk_get_prop_string(ctx, 0, "bar");
	printf("getprop bar: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	/* Property doesn't exist, terminate with error */
	duk_get_prop_string(ctx, 0, "quux");
	printf("getprop quux: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	return 0;
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:22,代码来源:test-dev-prototype-loop.c


示例19: GetWeakPtr

WeakPtr<Object>* GetWeakPtr(duk_context* ctx, duk_idx_t stackIndex)
{
    if (!duk_is_object(ctx, stackIndex))
        return nullptr;

    WeakPtr<Object>* ptr = nullptr;
    duk_get_prop_string(ctx, stackIndex, "\xff""weak");
    if (duk_is_pointer(ctx, -1))
        ptr = static_cast<WeakPtr<Object>*>(duk_to_pointer(ctx, -1));
    duk_pop(ctx);

    return ptr;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:13,代码来源:BindingsHelpers.cpp


示例20: _worker_dispatch_cb

static int _worker_dispatch_cb (evHandle *handle){
    comoWorker *worker = handle->data;
    duk_context *ctx = worker->Mainctx;

    mtx_lock(&worker->mtx);
    QUEUE *q;
    while ( !QUEUE_EMPTY(&worker->queueOut) ){

        q = QUEUE_HEAD(&(worker)->queueOut);
        QUEUE_REMOVE(q);
        comoQueue *queue = QUEUE_DATA(q, comoQueue, queue);

        if (worker->destroy != 0){
            goto FREE;
        }

        duk_push_heapptr(ctx, worker->self);
        
        if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT){
            dump_stack(ctx, "DUK");
            assert(0);
        }

        como_push_worker_value(ctx, queue);

        duk_call(ctx, 1);
        duk_pop(ctx);

        FREE :
        /* free except in case of pointers */
        if (queue->data != NULL && queue->type != DUK_TYPE_POINTER){
            free(queue->data);
        }

        free(queue);
    }
    mtx_unlock(&worker->mtx);

    if (worker->destroy == 2){
        
        duk_push_global_stash(ctx);
        duk_get_prop_string(ctx, -1, "comoWorkersCallBack");
        duk_push_number(ctx, (double) handle->id);
        duk_del_prop(ctx, -2);

        handle_close(handle);
        free(worker);
    }

    return 0;
}
开发者ID:catoc,项目名称:Comojs,代码行数:51,代码来源:worker.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ duk_get_top函数代码示例发布时间:2022-05-30
下一篇:
C++ duk_get_prop_index函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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