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

C++ duk_to_string函数代码示例

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

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



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

示例1: test

void test(duk_context *ctx) {
	int ret;

	printf("top: %d\n", (int) duk_get_top(ctx));
	ret = duk_get_global_string(ctx, "encodeURIComponent");
	printf("top: %d\n", (int) duk_get_top(ctx));
	printf("ret: %d\n", ret);
	duk_push_string(ctx, "foo bar");
	duk_call(ctx, 1);
	printf("encoded: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);
	printf("top: %d\n", (int) duk_get_top(ctx));

	ret = duk_get_global_string(ctx, "doesNotExist");
	printf("top: %d\n", (int) duk_get_top(ctx));
	printf("ret: %d\n", ret);
	printf("%s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);
	printf("top: %d\n", (int) duk_get_top(ctx));
}
开发者ID:remoe,项目名称:duktape,代码行数:20,代码来源:test-get-global-string.c


示例2: sys1_chmod

static int sys1_chmod(duk_context *ctx)
{
	const char *path = duk_to_string(ctx, 0);
	mode_t mode = duk_to_int(ctx, 1);
	int rc;

	rc = chmod(path, mode);

	duk_push_int(ctx, rc);
	return 1;
}
开发者ID:jelaas,项目名称:sys,代码行数:11,代码来源:sys1.c


示例3: es_gumbo_find_by_id

static int
es_gumbo_find_by_id(duk_context *ctx)
{
  es_gumbo_node_t *egn = es_get_native_obj(ctx, 0, &es_native_gumbo_node);
  const char *id = duk_to_string(ctx, 1);
  GumboNode *r = es_gumbo_find_by_id_r(egn->node, id);
  if(r == NULL)
    return 0;
  push_gumbo_node(ctx, r, egn->output);
  return 1;
}
开发者ID:Cy-4AH,项目名称:showtime,代码行数:11,代码来源:es_gumbo.c


示例4: test_getpropstring_a

/* duk_get_prop_string(), success cases */
static duk_ret_t test_getpropstring_a(duk_context *ctx, void *udata) {
	duk_ret_t rc;

	(void) udata;

	prep(ctx);

	rc = duk_get_prop_string(ctx, 0, "foo");
	printf("obj.foo -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 0, "foo" "\x00" "bar");  /* embedded NUL terminates key */
	printf("obj.foo -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 0, "nonexistent");
	printf("obj.nonexistent -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 0, "123");
	printf("obj['123'] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 1, "nonexistent");
	printf("arr.nonexistent -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 1, "2");
	printf("arr['2'] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 1, "length");
	printf("arr.length -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 2, "5");
	printf("'test_string'['5'] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	rc = duk_get_prop_string(ctx, 2, "length");
	printf("'test_string'.length -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:harold-b,项目名称:duktape,代码行数:47,代码来源:test-get-prop.c


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


示例6: test_2c

/* duk_get_prop_string(), DUK_INVALID_INDEX */
int test_2c(duk_context *ctx) {
	int rc;

	prep(ctx);

	rc = duk_get_prop_string(ctx, DUK_INVALID_INDEX, "foo");
	printf("obj.foo -> rc=%d, result='%s'\n", rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	printf("final top: %d\n", duk_get_top(ctx));
	return 0;
}
开发者ID:BpLife,项目名称:duktape,代码行数:13,代码来源:test-get-prop.c


示例7: handle_set

static duk_ret_t handle_set(duk_context *ctx) {
	/* 'this' binding: handler
	 * [0]: target
	 * [1]: key
	 * [2]: val
	 * [3]: receiver (proxy)
	 */

	const char *key = duk_to_string(ctx, 1);
	const char *val = duk_to_string(ctx, 2);

	printf("handle_set: key=%s, val=%s\n", key, val);

	if (key != NULL && key[0] == '_') {
		/* Indicate set failure for properties beginning with underscore. */
		duk_push_false(ctx);
	} else {
		duk_push_true(ctx);
	}
	return 1;
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:21,代码来源:test-proxy-basic.c


示例8: es_gumbo_find_by_class

static int
es_gumbo_find_by_class(duk_context *ctx)
{
  es_gumbo_node_t *egn = es_get_native_obj(ctx, 0, &es_native_gumbo_node);
  const char *cls = duk_to_string(ctx, 1);
  int idx = 0;
  duk_push_array(ctx);
  char **classlist = strvec_split(cls, ' ');
  es_gumbo_find_by_class_r(egn->node, classlist, ctx, &idx, egn->output);
  strvec_free(classlist);
  return 1;
}
开发者ID:Cy-4AH,项目名称:showtime,代码行数:12,代码来源:es_gumbo.c


示例9: r2cmd

static int r2cmd(duk_context *ctx) {
	char *ret;
	int n = duk_get_top (ctx);  /* #args */
	if (n>0) {
		const char *s = duk_to_string (ctx, 0);
		ret = r_core_cmd_str (Gcore, s);
		duk_push_string (ctx, ret);
		free (ret);
		return 1;
	}
	return 0;
}
开发者ID:pleonex,项目名称:radare2-bindings,代码行数:12,代码来源:duktape.c


示例10: test_3c

/* duk_get_prop_index(), DUK_INVALID_INDEX */
static duk_ret_t test_3c(duk_context *ctx) {
	duk_ret_t rc;

	prep(ctx);

	rc = duk_get_prop_index(ctx, DUK_INVALID_INDEX, 123);
	printf("obj[123] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:janneo,项目名称:duktape,代码行数:13,代码来源:test-get-prop.c


示例11: test_1

static duk_ret_t test_1(duk_context *ctx) {
    duk_idx_t i, n;

    prep(ctx);
    duk_remove(ctx, -2);          /* -> [ 123 345 ] */

    n = duk_get_top(ctx);
    for (i = 0; i < n; i++) {
        printf("%ld: %s\n", (long) i, duk_to_string(ctx, i));
    }
    return 0;
}
开发者ID:iotcafe,项目名称:duktape,代码行数:12,代码来源:test-remove.c


示例12: duk__push_string

DUK_LOCAL void duk__push_string(duk_context *ctx, duk_bitdecoder_ctx *bd) {
	duk_small_uint_t n;
	duk_small_uint_t i;
	duk_uint8_t *p;

	n = (duk_small_uint_t) duk_bd_decode(bd, DUK__STRING_LENGTH_BITS);
	p = (duk_uint8_t *) duk_push_fixed_buffer(ctx, n);
	for (i = 0; i < n; i++) {
		*p++ = (duk_uint8_t) duk_bd_decode(bd, DUK__STRING_CHAR_BITS);
	}
	duk_to_string(ctx, -1);
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:12,代码来源:duk_hthread_builtins.c


示例13: test_decode_invalid_char

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

	duk_set_top(ctx, 0);
	duk_push_string(ctx, "[email protected]=");
	duk_push_int(ctx, 321);  /* dummy */
	duk_base64_decode(ctx, -2);  /* buffer */
	printf("base64 decode: %s\n", duk_to_string(ctx, -2));
	printf("top after: %ld\n", (long) duk_get_top(ctx));  /* value + dummy */
	duk_set_top(ctx, 0);
	return 0;
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:12,代码来源:test-base64.c


示例14: sys1_stat

static int sys1_stat(duk_context *ctx)
{
	const char *path = duk_to_string(ctx, 0);
	struct stat buf;
	int rc;
	
	rc = stat(path, &buf);
	sys1_push_stat(ctx, &buf);
	duk_push_int(ctx, rc);
	duk_put_prop_string(ctx, -2, "rc");
	return 1;
}
开发者ID:jelaas,项目名称:sysjs,代码行数:12,代码来源:sys1.c


示例15: sys1_getenv

static int sys1_getenv(duk_context *ctx)
{
	const char *name = duk_to_string(ctx, 0);
	char *val;

	val = getenv(name);
	if(val)
		duk_push_string(ctx, val);
	else 
		duk_push_undefined(ctx);
	return 1;
}
开发者ID:jelaas,项目名称:sysjs,代码行数:12,代码来源:sys1.c


示例16: test_2b

/* duk_get_prop_string(), invalid index */
static duk_ret_t test_2b(duk_context *ctx) {
	duk_ret_t rc;

	prep(ctx);

	rc = duk_get_prop_string(ctx, 234, "foo");
	printf("obj.foo -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:janneo,项目名称:duktape,代码行数:13,代码来源:test-get-prop.c


示例17: test_3b

/* duk_get_prop_index(), invalid index */
int test_3b(duk_context *ctx) {
	int rc;

	prep(ctx);

	rc = duk_get_prop_index(ctx, 234, 123);
	printf("obj[123] -> rc=%d, result='%s'\n", rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	printf("final top: %d\n", duk_get_top(ctx));
	return 0;
}
开发者ID:BpLife,项目名称:duktape,代码行数:13,代码来源:test-get-prop.c


示例18: test_getprop_a

/* duk_get_prop(), success cases */
static duk_ret_t test_getprop_a(duk_context *ctx, void *udata) {
	duk_ret_t rc;

	(void) udata;

	prep(ctx);

	duk_push_string(ctx, "foo");
	rc = duk_get_prop(ctx, 0);
	printf("obj.foo -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_string(ctx, "nonexistent");
	rc = duk_get_prop(ctx, 0);
	printf("obj.nonexistent -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_int(ctx, 123);
	rc = duk_get_prop(ctx, 0);
	printf("obj[123] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_string(ctx, "nonexistent");
	rc = duk_get_prop(ctx, 1);
	printf("arr.nonexistent -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_int(ctx, 2);
	rc = duk_get_prop(ctx, 1);
	printf("arr[2] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_string(ctx, "length");
	rc = duk_get_prop(ctx, 1);
	printf("arr.length -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_int(ctx, 5);
	rc = duk_get_prop(ctx, 2);
	printf("'test_string'[5] -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_push_string(ctx, "length");
	rc = duk_get_prop(ctx, 2);
	printf("'test_string'.length -> rc=%d, result='%s'\n", (int) rc, duk_to_string(ctx, -1));
	duk_pop(ctx);

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:harold-b,项目名称:duktape,代码行数:51,代码来源:test-get-prop.c


示例19: test_delprop_a_safecall

/* duk_del_prop(), success cases */
static duk_ret_t test_delprop_a_safecall(duk_context *ctx, void *udata) {
	duk_ret_t rc;

	(void) udata;

	prep(ctx);

	/* existing, configurable */
	duk_push_string(ctx, "foo");
	rc = duk_del_prop(ctx, 0);
	printf("delete obj.foo -> rc=%d\n", (int) rc);

	/* nonexistent */
	duk_push_string(ctx, "nonexistent");
	rc = duk_del_prop(ctx, 0);
	printf("delete obj.nonexistent -> rc=%d\n", (int) rc);

	/* nonexistent */
	duk_push_int(ctx, 123);
	rc = duk_del_prop(ctx, 0);
	printf("delete obj[123] -> rc=%d\n", (int) rc);

	/* nonexistent, array */
	duk_push_string(ctx, "nonexistent");
	rc = duk_del_prop(ctx, 1);
	printf("delete arr.nonexistent -> rc=%d\n", (int) rc);

	/* existing, configurable, array */
	duk_push_int(ctx, 2);
	rc = duk_del_prop(ctx, 1);
	printf("delete arr[2] -> rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:jmptrader,项目名称:duktape,代码行数:41,代码来源:test-del-prop.c


示例20: sys1_open

static int sys1_open(duk_context *ctx)
{
	int fd;
	
	const char *path = duk_to_string(ctx, 0);
	uint32_t flags = duk_to_uint32(ctx, 1);
	int mode = duk_to_int(ctx, 2);

	fd = open(path, flags, mode);
	
	duk_push_number(ctx, fd);
	return 1;
}
开发者ID:jelaas,项目名称:sysjs,代码行数:13,代码来源:sys1.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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