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


C++ duk_get_prop_string函数代码示例

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


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


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