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

C++ JS_ARGV函数代码示例

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

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



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

示例1: MessageCommon

static JSBool
MessageCommon(JSContext* cx, uintN argc, jsval* vp,
              MessageResult* result)
{
  if (argc < 1) {
    JS_ReportError(cx, "Message requires a name, at least");
    return JS_FALSE;
  }

  jsval* argv = JS_ARGV(cx, vp);

  JSString* msgNameStr = JS_ValueToString(cx, argv[0]);
  if (!msgNameStr) {
    JS_ReportError(cx, "Could not convert value to string");
    return JS_FALSE;
  }

  size_t length;
  const jschar* chars = JS_GetStringCharsAndLength(cx, msgNameStr, &length);
  if (!chars)
      return JS_FALSE;

  result->msgName.Assign(chars, length);

  result->data.Clear();

  if (!result->data.SetCapacity(argc)) {
    JS_ReportOutOfMemory(cx);
    return JS_FALSE;
  }

  for (uintN i = 1; i < argc; ++i) {
    Variant* vp = result->data.AppendElement();
    if (!JetpackActorCommon::jsval_to_Variant(cx, argv[i], vp)) {
      JS_ReportError(cx, "Invalid message argument at position %d", i);
      return JS_FALSE;
    }
  }

  return JS_TRUE;
}
开发者ID:krad-radio,项目名称:mozilla-krad,代码行数:41,代码来源:JetpackChild.cpp


示例2: js_cocos2dx_CCMenuItemImage_create

JSBool js_cocos2dx_CCMenuItemImage_create(JSContext *cx, uint32_t argc, jsval *vp)
{
	if (argc >= 2) {
		jsval *argv = JS_ARGV(cx, vp);
		const char *arg0; do { JSString *tmp = JS_ValueToString(cx, argv[0]); arg0 = JS_EncodeString(cx, tmp); } while (0);
		const char *arg1; do { JSString *tmp = JS_ValueToString(cx, argv[1]); arg1 = JS_EncodeString(cx, tmp); } while (0);
		const char *arg2 = NULL;
		int last = 2;
		if (JSVAL_IS_STRING(argv[2])) {
			do { JSString *tmp = JS_ValueToString(cx, argv[2]); arg2 = JS_EncodeString(cx, tmp); } while (0);
			last = 3;
		}
		cocos2d::CCMenuItemImage* ret = cocos2d::CCMenuItemImage::create(arg0, arg1, arg2);
		jsval thisObj = argv[last++];
		jsval callback = argv[last];
		JSObject *obj = bind_menu_item<cocos2d::CCMenuItemImage>(cx, ret, callback, thisObj);
		JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
		return JS_TRUE;
	}
	return JS_FALSE;
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:21,代码来源:cocos2d_specifics.cpp


示例3: js_conio_cputs

static JSBool
js_conio_cputs(JSContext *cx, uintN argc, jsval *arglist)
{
	jsval *argv=JS_ARGV(cx, arglist);
	char *	str;
	jsrefcount	rc;

	if(argc==1) {
		JSVALUE_TO_MSTRING(cx, argv[0], str, NULL);
		HANDLE_PENDING(cx);
		if(str != NULL) {
			rc=JS_SUSPENDREQUEST(cx);
			JS_SET_RVAL(cx, arglist,INT_TO_JSVAL(cputs(str)));
			free(str);
			JS_RESUMEREQUEST(cx, rc);
			return(JS_TRUE);
		}
	}

	return(JS_FALSE);
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:21,代码来源:js_conio.c


示例4: js_cocos2dx_postMessage

static JSBool js_cocos2dx_postMessage(JSContext *cx, uint32_t argc, jsval *vp)
{
	jsval *argv = JS_ARGV(cx, vp);
	if (argc >= 1) {
		std::string* msg = new std::string();

		do {
			JSBool ok = jsval_to_std_string(cx, argv[0], msg);
			JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments");
		} while (0);

		extension::MessageDelegate::sharedMessageDelegate()->postMessage("message", msg->c_str());

		CC_SAFE_DELETE(msg);

		JS_SET_RVAL(cx, vp, JSVAL_VOID);
		return JS_TRUE;	
	}
	JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
	return JS_FALSE;
}
开发者ID:akira-cn,项目名称:flappy_bird,代码行数:21,代码来源:cqwrap_misc_manual.cpp


示例5: Sys_loadModule

static JSBool Sys_loadModule(JSContext *cx, unsigned argc, jsval *vp)
{
	jsval module;
	JSString *module_str;
	char *module_name;

	module = JS_ARGV(cx, vp)[0];

	if (!JSVAL_IS_STRING(module))
		return JS_FALSE;

	module_str = JSVAL_TO_STRING(module);
	module_name = JS_EncodeString(cx, module_str);
	if (!module_name)
		return JS_FALSE;

	JS_Log(JS_LOG_INFO, "[STUB] Loading module \"%s\".\n", module_name);

	JS_free(cx, module_name);
	return JS_TRUE;
}
开发者ID:mindbit,项目名称:mailfilter,代码行数:21,代码来源:js_sys.c


示例6: JSLoadScripts

/**
 * The function used as importScript from the JavaScript environment (ZOO-API)
 * 
 * @param cx the JavaScript context
 * @param argc the number of parameters
 * @param argv1 the parameter values
 * @return true
 */
JSBool 
JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1)
{
  JS_MaybeGC(cx);

  jsval *argv = JS_ARGV(cx,argv1);
  int i=0;
  JS_MaybeGC(cx);
  for(i=0;i<argc;i++){
    char *filename = JSValToChar(cx,&argv[i]);
#ifdef JS_DEBUG
    fprintf(stderr,"Trying to load %s\n",api0);
    fflush(stderr);
#endif
    JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),filename);
  }
  JS_MaybeGC(cx);
  JS_SET_RVAL(cx, argv1, JSVAL_VOID);
  
  return JS_TRUE;
}
开发者ID:OSGeo,项目名称:zoo-project,代码行数:29,代码来源:service_internal_js.c


示例7: rpmfc_ctor

static JSBool
rpmfc_ctor(JSContext *cx, uintN argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSObject *obj = JS_NewObjectForConstructor(cx, vp);
    JSBool ok = JS_FALSE;

_CTOR_DEBUG_ENTRY(_debug);

    if (JS_IsConstructing(cx, vp)) {
	(void) rpmfc_init(cx, obj);
    } else {
	if ((obj = JS_NewObject(cx, &rpmfcClass, NULL, NULL)) == NULL)
	    goto exit;
	*vp = OBJECT_TO_JSVAL(obj);
    }
    ok = JS_TRUE;

exit:
    return ok;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:21,代码来源:rpmfc-js.c


示例8: JS_ConvertArguments

JSBool S_CCFileUtils::jsfullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp) {
    if (argc == 2) {
        JSString *arg0;
        JSString *arg1;
        JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
        char *narg0 = JS_EncodeString(cx, arg0);
        char *narg1 = JS_EncodeString(cx, arg1);
        const char *ret = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(narg0, narg1);
        if (ret == NULL) {
            JS_SET_RVAL(cx, vp, JSVAL_NULL);
            return JS_TRUE;
        }
        JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret));
        JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));        
        return JS_TRUE;
        
        return JS_TRUE;
    }
    JS_SET_RVAL(cx, vp, JSVAL_TRUE);
    return JS_TRUE;
}
开发者ID:136446529,项目名称:book-code,代码行数:21,代码来源:cocos2d_manual_bindings.cpp


示例9: seal

static JSBool
seal(JSContext* cx, uintN argc, jsval* vp)
{
    jsval* argv = JS_ARGV(cx, vp);
    JSObject *target;
    JSBool deep = JS_FALSE;

    if(!JS_ConvertArguments(cx, argc, argv, "o/b", &target, &deep))
        return JS_FALSE;

    if(!target) {
        JS_SET_RVAL(cx, vp, JSVAL_VOID);
        return JS_TRUE;
    }

    if(JS_SealObject(cx, target, deep) != JS_TRUE)
        return JS_FALSE;

    JS_SET_RVAL(cx, vp, JSVAL_VOID);
    return JS_TRUE;
}
开发者ID:draco2003,项目名称:bigcouch,代码行数:21,代码来源:sm180.c


示例10: js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logTiming

JSBool js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_logTiming(JSContext *cx, uint32_t argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSBool ok = JS_TRUE;
    if (argc == 4) {
        std::string arg0;
        int arg1;
        std::string arg2;
        std::string arg3;
        ok &= jsval_to_std_string(cx, argv[0], &arg0);
        ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
        ok &= jsval_to_std_string(cx, argv[2], &arg2);
        ok &= jsval_to_std_string(cx, argv[3], &arg3);
        JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
        sdkbox::PluginGoogleAnalytics::logTiming(arg0, arg1, arg2, arg3);
        JS_SET_RVAL(cx, vp, JSVAL_VOID);
        return JS_TRUE;
    }
    JS_ReportError(cx, "wrong number of arguments");
    return JS_FALSE;
}
开发者ID:sdkbox,项目名称:sdkbox-sample-ga,代码行数:21,代码来源:PluginGoogleAnalyticsJS.cpp


示例11: rpmbf_del

static JSBool
rpmbf_del(JSContext *cx, uintN argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSObject *obj = JS_THIS_OBJECT(cx, vp);
    void * ptr = JS_GetInstancePrivate(cx, obj, &rpmbfClass, NULL);
    rpmbf bf = ptr;
    JSBool ok = JS_FALSE;
    const char * _s = NULL;

_METHOD_DEBUG_ENTRY(_debug);

    *vp = JSVAL_FALSE;
    if (!(ok = JS_ConvertArguments(cx, argc, argv, "s", &_s)))
        goto exit;

    *vp = (rpmbfDel(bf, _s, 0) == 0 ? JSVAL_TRUE : JSVAL_FALSE);
    ok = JS_TRUE;
exit:
    return ok;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:21,代码来源:rpmbf-js.c


示例12: elixir_border_evas_object_params

static JSBool
elixir_border_evas_object_params(void (*func)(const Evas_Object *obj, int *l, int *r, int *t, int *b),
                                 const elixir_parameter_t *params[],
                                 JSContext *cx, uintN argc, jsval *vp)
{
   Evas_Object *know;
   int l;
   int r;
   int t;
   int b;
   elixir_value_t val[1];

   if (!elixir_params_check(cx, params, val, argc, JS_ARGV(cx, vp)))
     return JS_FALSE;

   GET_PRIVATE(cx, val[0].v.obj, know);

   func(know, &l, &r, &t, &b);

   return elixir_new_evas_border(cx, l, r, t, b, &(JS_RVAL(cx, vp)));
}
开发者ID:gzorin,项目名称:e17,代码行数:21,代码来源:evas-object-params.c


示例13: UnwrapNW

static bool
UnwrapNW(JSContext *cx, unsigned argc, jsval *vp)
{
  if (argc != 1) {
    return ThrowException(NS_ERROR_XPC_NOT_ENOUGH_ARGS, cx);
  }

  JS::RootedValue v(cx, JS_ARGV(cx, vp)[0]);
  if (!v.isObject() || !js::IsWrapper(&v.toObject())) {
    JS_SET_RVAL(cx, vp, v);
    return true;
  }

  if (AccessCheck::wrapperSubsumes(&v.toObject())) {
    bool ok = xpc::WrapperFactory::WaiveXrayAndWrap(cx, v.address());
    NS_ENSURE_TRUE(ok, false);
  }

  JS_SET_RVAL(cx, vp, v);
  return true;
}
开发者ID:bakulf,项目名称:mozilla-central,代码行数:21,代码来源:XPCWrapper.cpp


示例14: js_cocos2dx_swap_native_object

JSBool js_cocos2dx_swap_native_object(JSContext *cx, uint32_t argc, jsval *vp)
{
	if (argc == 2) {
		// get the native object from the second object to the first object
		jsval *argv = JS_ARGV(cx, vp);
		JSObject *one = JSVAL_TO_OBJECT(argv[0]);
		JSObject *two = JSVAL_TO_OBJECT(argv[1]);
		js_proxy_t *nproxy;
		JS_GET_NATIVE_PROXY(nproxy, two);
		void *ptrTwo = (nproxy ? nproxy->ptr : NULL);
		if (nproxy) {
			js_proxy_t *jsproxy;
			JS_GET_PROXY(jsproxy, ptrTwo);
			if (jsproxy) {
				JS_REMOVE_PROXY(jsproxy, nproxy);
				JS_NEW_PROXY(nproxy, ptrTwo, one);
			}
		}
	}
	return JS_TRUE;
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:21,代码来源:cocos2d_specifics.cpp


示例15: elixir_evas_object_line_xy_get

static JSBool
elixir_evas_object_line_xy_get(JSContext *cx, uintN argc, jsval *vp)
{
   Evas_Object *evas_line;
   JSObject *js_obj;
   JSClass *evas_line_coord_class;
   jsval propertie;
   int x1;
   int y1;
   int x2;
   int y2;
   elixir_value_t val[1];

   if (!elixir_params_check(cx, _evas_object_line_params, val, argc, JS_ARGV(cx, vp)))
     return JS_FALSE;

   GET_PRIVATE(cx, val[0].v.obj, evas_line);

   evas_object_line_xy_get(evas_line, &x1, &y1, &x2, &y2);
   evas_line_coord_class = elixir_class_request("evas_line_coord", NULL);

   js_obj = JS_NewObject(cx, evas_line_coord_class, NULL, NULL);
   if (!js_obj)
     return JS_FALSE;
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(js_obj));

   propertie = INT_TO_JSVAL(x1);
   JS_SetProperty(cx, js_obj, "x1", &propertie);

   propertie = INT_TO_JSVAL(y1);
   JS_SetProperty(cx, js_obj, "y1", &propertie);

   propertie = INT_TO_JSVAL(x2);
   JS_SetProperty(cx, js_obj, "x2", &propertie);

   propertie = INT_TO_JSVAL(y2);
   JS_SetProperty(cx, js_obj, "y2", &propertie);

   return JS_TRUE;
}
开发者ID:gzorin,项目名称:e17,代码行数:40,代码来源:evas-object-params.c


示例16: rpmmpf_Open

static JSBool
rpmmpf_Open(JSContext *cx, uintN argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSObject *obj = JS_THIS_OBJECT(cx, vp);
    void * ptr = JS_GetInstancePrivate(cx, obj, &rpmmpfClass, NULL);
    DB_MPOOLFILE * mpf = ptr;
    char * _file = NULL;
    uint32_t _flags = DB_CREATE;
    int _mode = 0640;
    uint32_t _pagesize = _RPMMPF_PAGESIZE;

    JSBool ok = JS_FALSE;

_METHOD_DEBUG_ENTRY(_debug);

    if (mpf == NULL) goto exit;
    *vp = JSVAL_FALSE;

    if (!(ok = JS_ConvertArguments(cx, argc, argv, "/suiu", &_file, &_flags, &_mode, &_pagesize)))
	goto exit;

    {	size_t pagesize = _pagesize;
	int ret = mpf->open(mpf, _file, _flags, _mode, pagesize);
	switch (ret) {
	default:
	    fprintf(stderr, "DB_MPOOLFILE->open: %s\n", db_strerror(ret));
	    goto exit;
	    break;
	case 0:
	    *vp = JSVAL_TRUE;
	    break;
	}
    }

    ok = JS_TRUE;

exit:
    return ok;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:40,代码来源:rpmmpf-js.c


示例17: gjs_address_of

static JSBool
gjs_address_of(JSContext *context,
               unsigned   argc,
               jsval     *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSObject *target_obj;
    JSBool ret;
    char *pointer_string;
    jsval retval;

    if (!gjs_parse_args(context, "addressOf", "o", argc, argv, "object", &target_obj))
        return JS_FALSE;

    pointer_string = g_strdup_printf("%p", target_obj);

    ret = gjs_string_from_utf8(context, pointer_string, -1, &retval);
    if (ret)
        JS_SET_RVAL(context, vp, retval);

    return ret;
}
开发者ID:darkxst,项目名称:gjs-js188,代码行数:22,代码来源:system.c


示例18: js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_init

JSBool js_PluginGoogleAnalyticsJS_PluginGoogleAnalytics_init(JSContext *cx, uint32_t argc, jsval *vp)
{
    jsval *argv = JS_ARGV(cx, vp);
    JSBool ok = JS_TRUE;
    if (argc == 0) {
        sdkbox::PluginGoogleAnalytics::init();
        JS_SET_RVAL(cx, vp, JSVAL_VOID);
        return JS_TRUE;
    }
    if (argc == 1) {
        const char* arg0;
        std::string arg0_tmp;
        ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp);
        arg0 = arg0_tmp.c_str();
        JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
        sdkbox::PluginGoogleAnalytics::init(arg0);
        JS_SET_RVAL(cx, vp, JSVAL_VOID);
        return JS_TRUE;
    }
    JS_ReportError(cx, "wrong number of arguments");
    return JS_FALSE;
}
开发者ID:sdkbox,项目名称:sdkbox-sample-ga,代码行数:22,代码来源:PluginGoogleAnalyticsJS.cpp


示例19: elixir_string_const_evas_object_params

static JSBool
elixir_string_const_evas_object_params(const char* (*func)(const Evas_Object *obj),
				       const elixir_parameter_t *params[],
				       JSContext *cx, uintN argc, jsval *vp)
{
   Evas_Object *know = NULL;
   const char *str;
   elixir_value_t val[1];

   if (!elixir_params_check(cx, params, val, argc, JS_ARGV(cx, vp)))
     return JS_FALSE;

   GET_PRIVATE(cx, val[0].v.obj, know);

   str = func(know);

   if (strncmp(str, "elixir/", 7) == 0)
     str = strdupa(str + 7);

   elixir_return_str(cx, vp, str);
   return JS_TRUE;
}
开发者ID:gzorin,项目名称:e17,代码行数:22,代码来源:evas-object-params.c


示例20: gjs_bindtextdomain

static JSBool
gjs_bindtextdomain(JSContext *context,
                   unsigned   argc,
                   jsval     *vp)
{
    jsval *argv = JS_ARGV(context, vp);
    char *domain;
    char *location;

    if (!gjs_parse_args (context, "bindtextdomain", "sF", argc, argv,
                         "domain", &domain,
                         "location", &location))
        return JS_FALSE;

    bindtextdomain(domain, location);
    /* Always use UTF-8; we assume it internally here */
    bind_textdomain_codeset(domain, "UTF-8");
    g_free (domain);
    g_free (location);
    JS_SET_RVAL(context, vp, JSVAL_VOID);
    return JS_TRUE;
}
开发者ID:Katyunechka,项目名称:gjs,代码行数:22,代码来源:gettext-native.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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