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

C++ duk_push_this函数代码示例

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

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



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

示例1: File_ReadText

static int File_ReadText(duk_context* ctx)
{
    duk_push_this(ctx);
    File* file = js_to_class_instance<File>(ctx, -1, 0);

    String text;
    file->ReadText(text);

    duk_push_string(ctx, text.CString());

    return 1;
}
开发者ID:AliAkbarMontazeri,项目名称:AtomicGameEngine,代码行数:12,代码来源:JSIO.cpp


示例2: duk_bi_logger_constructor

/* Constructor */
DUK_INTERNAL duk_ret_t duk_bi_logger_constructor(duk_context *ctx) {
	duk_hthread *thr = (duk_hthread *) ctx;
	duk_idx_t nargs;

	/* Calling as a non-constructor is not meaningful. */
	if (!duk_is_constructor_call(ctx)) {
		return DUK_RET_TYPE_ERROR;
	}

	nargs = duk_get_top(ctx);
	duk_set_top(ctx, 1);

	duk_push_this(ctx);

	/* [ name this ] */

	if (nargs == 0) {
		/* Automatic defaulting of logger name from caller.  This would
		 * work poorly with tail calls, but constructor calls are currently
		 * never tail calls, so tail calls are not an issue now.
		 */

		if (thr->callstack_top >= 2) {
			duk_activation *act_caller = thr->callstack + thr->callstack_top - 2;
			duk_hobject *func_caller;

			func_caller = DUK_ACT_GET_FUNC(act_caller);
			if (func_caller) {
				/* Stripping the filename might be a good idea
				 * ("/foo/bar/quux.js" -> logger name "quux"),
				 * but now used verbatim.
				 */
				duk_push_hobject(ctx, func_caller);
				duk_get_prop_stridx(ctx, -1, DUK_STRIDX_FILE_NAME);
				duk_replace(ctx, 0);
			}
		}
	}
	/* the stack is unbalanced here on purpose; we only rely on the
	 * initial two values: [ name this ].
	 */

	if (duk_is_string(ctx, 0)) {
		duk_dup(ctx, 0);
		duk_put_prop_stridx(ctx, 1, DUK_STRIDX_LC_N);
	} else {
		/* don't set 'n' at all, inherited value is used as name */
	}

	duk_compact(ctx, 1);

	return 0;  /* keep default instance */
}
开发者ID:3009420,项目名称:civetweb,代码行数:54,代码来源:duk_bi_logger.c


示例3: js_Font_clone

static duk_ret_t
js_Font_clone(duk_context* ctx)
{
	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);
	// TODO: actually clone font in Font:clone()
	duk_push_sphere_font(ctx, font);
	return 1;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:12,代码来源:font.c


示例4: gumjs_stalker_from_args

static GumDukStalker *
gumjs_stalker_from_args (const GumDukArgs * args)
{
  duk_context * ctx = args->ctx;
  GumDukStalker * self;

  duk_push_this (ctx);
  self = _gum_duk_require_data (ctx, -1);
  duk_pop (ctx);

  return self;
}
开发者ID:Fitblip,项目名称:frida-gum,代码行数:12,代码来源:gumdukstalker.c


示例5: NativeGetAllProps

static int NativeGetAllProps(duk_context* ctx)
{
    if (!duk_is_string(ctx, 0)) {
        duk_error(ctx, DUK_ERR_TYPE_ERROR, "First argument must be the interface name");
    }
    duk_push_c_lightfunc(ctx, AJS_MarshalMethodCall, 1, 0, 0);
    duk_push_this(ctx);
    MessageSetup(ctx, &AJ_PropertiesIface[0][1], "GetAll", NULL, AJ_MSG_METHOD_CALL);
    duk_dup(ctx, 0);
    duk_call_method(ctx, 1);
    return 1;
}
开发者ID:anthony-ngu,项目名称:core-alljoyn-js,代码行数:12,代码来源:ajs_sessions.c


示例6: js_Logger_write

static duk_ret_t
js_Logger_write(duk_context* ctx)
{
	const char* text = duk_to_string(ctx, 0);
	
	logger_t* logger;

	duk_push_this(ctx);
	logger = duk_require_sphere_obj(ctx, -1, "Logger");
	write_log_line(logger, NULL, text);
	return 0;
}
开发者ID:caivega,项目名称:minisphere,代码行数:12,代码来源:logger.c


示例7: js_Sound_reset

static duk_ret_t
js_Sound_reset(duk_context* ctx)
{
	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, 0);
	play_sound(sound);
	return 0;
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:12,代码来源:sound.c


示例8: Light_SetShadowBias

static int Light_SetShadowBias(duk_context* ctx)
{
    float constantBias = (float) duk_to_number(ctx, 0);
    float slopeScaledBias = (float) duk_to_number(ctx, 1);

    BiasParameters bparms(constantBias, slopeScaledBias);

    duk_push_this(ctx);
    Light* light = js_to_class_instance<Light>(ctx, -1, 0);
    light->SetShadowBias(bparms);
    return 0;
}
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:12,代码来源:JSGraphics.cpp


示例9: duk_bi_error_prototype_to_string

int duk_bi_error_prototype_to_string(duk_context *ctx) {
	/* FIXME: optimize with more direct internal access */

	duk_push_this(ctx);
	if (!duk_is_object(ctx, -1)) {
		goto type_error;
	}

	/* [ ... this ] */

	duk_get_prop_stridx(ctx, -1, DUK_STRIDX_NAME);
	if (duk_is_undefined(ctx, -1)) {
		duk_pop(ctx);
		duk_push_string(ctx, "Error");
	} else {
		duk_to_string(ctx, -1);
	}

	/* [ ... this name ] */

	/* FIXME: Are steps 6 and 7 in E5 Section 15.11.4.4 duplicated by
	 * accident or are they actually needed?  The first ToString()
	 * could conceivably return 'undefined'.
	 */
	duk_get_prop_stridx(ctx, -2, DUK_STRIDX_MESSAGE);
	if (duk_is_undefined(ctx, -1)) {
		duk_pop(ctx);
		duk_push_string(ctx, "");
	} else {
		duk_to_string(ctx, -1);
	}

	/* [ ... this name message ] */

	if (duk_get_length(ctx, -2) == 0) {
		/* name is empty -> return message */
		return 1;
	}
	if (duk_get_length(ctx, -1) == 0) {
		/* message is empty -> return name */
		duk_pop(ctx);
		return 1;
	}
	duk_push_string(ctx, ": ");
	duk_insert(ctx, -2);  /* ... name ': ' message */
	duk_concat(ctx, 3);

	return 1;

 type_error:
	return DUK_RET_TYPE_ERROR;
}
开发者ID:alwayrun,项目名称:duktape,代码行数:52,代码来源:duk_bi_error.c


示例10: 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);
	font = duk_require_sphere_obj(ctx, -1, "Font");
	duk_pop(ctx);
	duk_push_int(ctx, get_text_width(font, text));
	return 1;
}
开发者ID:svaarala,项目名称:minisphere,代码行数:13,代码来源:font.c


示例11: 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


示例12: 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


示例13: 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);
	font = duk_require_sphere_obj(ctx, -1, "Font");
	duk_pop(ctx);
	duk_push_sphere_image(ctx, get_glyph_image(font, cp));
	return 1;
}
开发者ID:svaarala,项目名称:minisphere,代码行数:13,代码来源:font.c


示例14: 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


示例15: js_Logger_beginBlock

static duk_ret_t
js_Logger_beginBlock(duk_context* ctx)
{
	const char* title = duk_to_string(ctx, 0);
	
	logger_t* logger;

	duk_push_this(ctx);
	logger = duk_require_sphere_obj(ctx, -1, "Logger");
	if (!begin_log_block(logger, title))
		duk_error_ni(ctx, -1, DUK_ERR_ERROR, "Log:beginBlock(): Failed to create new log block");
	return 0;
}
开发者ID:caivega,项目名称:minisphere,代码行数:13,代码来源:logger.c


示例16: 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


示例17: js_RawFile_get_position

static duk_ret_t
js_RawFile_get_position(duk_context* ctx)
{
	FILE* file;

	duk_push_this(ctx);
	file = duk_require_sphere_obj(ctx, -1, "RawFile");
	duk_pop(ctx);
	if (file == NULL)
		duk_error_ni(ctx, -1, DUK_ERR_ERROR, "RawFile:position - File has been closed");
	duk_push_int(ctx, ftell(file));
	return 1;
}
开发者ID:caivega,项目名称:minisphere,代码行数:13,代码来源:rawfile.c


示例18: w_LocalStorage_constructor

    // Binding
    int w_LocalStorage_constructor(duk_context *ctx)
    {
        LocalStorage *inst = new LocalStorage();
        setNativePointer(ctx, inst);

        // Create an object property to save data
        duk_push_this(ctx); /* this */
        duk_push_object(ctx); /* this, emptyObj */
        duk_put_prop_string(ctx, -2, "__MURAL_DATA__"); /* this */
        duk_pop(ctx);

        return 1;
    }
开发者ID:caivega,项目名称:Mural,代码行数:14,代码来源:LocalStorage.cpp


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ duk_put_prop_string函数代码示例发布时间:2022-05-30
下一篇:
C++ duk_push_string函数代码示例发布时间: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