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


C++ JS_ValueToString函数代码示例

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


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

示例1: xgg_pluginhelper_add

static JSBool xgg_pluginhelper_add(JSContext *pcxa, JSObject *pobja, uintN argc, jsval *pva1, jsval *rval)
{
	char	*psz1 = JS_GetStringBytes(JS_ValueToString(pcxa, pva1[1]));
	XJSE_TRACE("xgg_pluginhelper_add (%s)", psz1);

	XJSE_XGG_PLUGINHELPER_PRIV	*pv0 = 0;
	pv0 = JS_GetPrivate(pcxa, pobja);
	//XJSE_SAFENNP(pv0->pszurl, free);
	//pv0->pszurl = (char*)xjse_malloc(0, strlen(pszurl) + 1);
	//strcpy(pv0->pszurl, pszurl);

	return  JS_TRUE;
}
开发者ID:odistagon,项目名称:cyeonna,代码行数:13,代码来源:xgg_pluginhelper.c

示例2: smjs_load_uri

static JSBool
smjs_load_uri(JSContext *ctx, uintN argc, jsval *rval)
{
	jsval *argv = JS_ARGV(ctx, rval);
	struct smjs_load_uri_hop *hop;
	struct download *download;
	JSString *jsstr;
	unsigned char *uri_string;
	struct uri *uri;

	if (argc < 2) return JS_FALSE;

	jsstr = JS_ValueToString(smjs_ctx, argv[0]);
	uri_string = JS_EncodeString(smjs_ctx, jsstr);

	uri = get_uri(uri_string, 0);
	if (!uri) return JS_FALSE;

	download = mem_alloc(sizeof(*download));
	if (!download) {
		done_uri(uri);
		return JS_FALSE;
	}

	hop = mem_alloc(sizeof(*hop));
	if (!hop) {
		mem_free(download);
		done_uri(uri);
		return JS_FALSE;
	}

	hop->callback = argv[1];
	hop->ses = smjs_ses;
	if (!JS_AddNamedValueRoot(smjs_ctx, &hop->callback,
			     "smjs_load_uri_hop.callback")) {
		mem_free(hop);
		mem_free(download);
		done_uri(uri);
		return JS_FALSE;
	}

	download->data = hop;
	download->callback = (download_callback_T *) smjs_loading_callback;

	load_uri(uri, NULL, download, PRI_MAIN, CACHE_MODE_NORMAL, -1);

	done_uri(uri);

	return JS_TRUE;
}
开发者ID:ezc,项目名称:elinks,代码行数:50,代码来源:load_uri.c

示例3: win32_setdlldirectory

JSBool win32_setdlldirectory(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
	JS_BeginRequest(cx);
	if(argc < 1)
	{
		JS_ReportError(cx, "Must pass a path to SetDllDirectory.");
		JS_EndRequest(cx);
		return JS_FALSE;
	}
	JSString * str = JS_ValueToString(cx, *argv);
	*rval = SetDllDirectory((LPWSTR)JS_GetStringChars(str)) ? JSVAL_TRUE : JSVAL_FALSE;
	JS_EndRequest(cx);
	return JS_TRUE;
}
开发者ID:z4y4,项目名称:njord,代码行数:14,代码来源:win32s.cpp

示例4: JS_EvaluateScript

int cScriptEngine::Start()
{
   JSBool ok = 0;
   m_rval = 0;

   ok = JS_EvaluateScript(m_cx, m_gObj, m_script_code, m_script_length, "", 0, &m_rval);
	if(ok == JS_TRUE)
	{
      JSString *str;
		str = JS_ValueToString(m_cx, m_rval);
		char *s = JS_GetStringBytes(str);
		
	} else {
      JSString *str;
		str = JS_ValueToString(m_cx, m_rval);
		char *s = JS_GetStringBytes(str);

		// error
      return 2;
	}

   return 0;
}
开发者ID:jstty,项目名称:OlderProjects,代码行数:23,代码来源:cScriptEngine.cpp

示例5: go_obj_func_callback

/* The object function callback. */
JSBool go_obj_func_callback(JSContext *cx, uintN argc, jsval *vp) {
	JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));

	jsval name;
	JS_GetProperty(cx, callee, "name", &name);

	char* cname = JS_EncodeString(cx, JS_ValueToString(cx, name));

	JSBool result = call_go_obj_func(JS_GetPrivate(cx, JS_THIS_OBJECT(cx, vp)), cname, argc, vp);

	JS_free(cx, (void*)cname);

	return result;
}
开发者ID:MrXiaoZ,项目名称:monkey,代码行数:15,代码来源:monkey.c

示例6: vm_dumpGCStats

static JSBool vm_dumpGCStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
  const char 	*filename = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
  FILE		*file;
  
  depth = JS_SuspendRequest(cx);
  file = fopen(filename, "w");
  flock(file, LOCK_EX);
  JS_ResumeRequest(cx);

  js_DumpGCStats();

  fclose(file);
}
开发者ID:wesgarland,项目名称:gpsee,代码行数:14,代码来源:vm.c

示例7: elixir_object_get_str

Eina_Bool
elixir_object_get_str(JSContext *cx, JSObject *obj, const char *name, const char **value)
{
   JSString *str;
   jsval propertie;

   if (!JS_GetProperty(cx, obj, name, &propertie))
     return EINA_FALSE;

   str = JS_ValueToString(cx, propertie);
   *value = elixir_get_string_bytes(str, NULL);

   return EINA_TRUE;
}
开发者ID:Limsik,项目名称:e17,代码行数:14,代码来源:elixir_object.c

示例8: syck_resolve

static JSBool
syck_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
	JSObject **objp)
{
if (_debug)
fprintf(stderr, "==> %s(%p,%p,0x%lx[%u],0x%x,%p) property %s flags 0x%x{%s,%s,%s,%s,%s}\n", __FUNCTION__, cx, obj, (unsigned long)id, (unsigned)JSVAL_TAG(id), (unsigned)flags, objp,
		JS_GetStringBytes(JS_ValueToString(cx, id)), flags,
		(flags & JSRESOLVE_QUALIFIED) ? "qualified" : "",
		(flags & JSRESOLVE_ASSIGNING) ? "assigning" : "",
		(flags & JSRESOLVE_DETECTING) ? "detecting" : "",
		(flags & JSRESOLVE_DECLARING) ? "declaring" : "",
		(flags & JSRESOLVE_CLASSNAME) ? "classname" : "");
    return JS_TRUE;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:14,代码来源:syck-js.c

示例9: JS_STATIC_DLL_CALLBACK

JS_STATIC_DLL_CALLBACK(JSBool) js__print(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
    uintN i, n;
    JSString * str;

    for (i = n = 0; i < argc; i++) {
        str = JS_ValueToString(cx, argv[i]);
        if (!str) return JS_FALSE;
        fprintf(stdout, "%s%s", i ? " " : "", JS_GetStringBytes(str));
    }
    n++;
    if (n) fputc('\n', stdout);
    return JS_TRUE;
}
开发者ID:mariokonrad,项目名称:embedded-language,代码行数:14,代码来源:simple.cpp

示例10: teletone_add_tone

static JSBool teletone_add_tone(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
	struct teletone_obj *tto = JS_GetPrivate(cx, obj);
	if (argc > 2) {
		int x;
        int nmax = argc;
		char *fval;
		char *map_str;
		map_str = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));

		if ( TELETONE_MAX_TONES < nmax ) {
			nmax = TELETONE_MAX_TONES;
		}

		for (x = 1; x < nmax; x++) {
			fval = JS_GetStringBytes(JS_ValueToString(cx, argv[x]));
			tto->ts.TONES[(int) *map_str].freqs[x - 1] = strtod(fval, NULL);
		}
		return JS_TRUE;
	}

	return JS_FALSE;
}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:23,代码来源:mod_spidermonkey_teletone.c

示例11: Dump

Dump(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
    JSString *str;
    if (!argc)
        return JS_TRUE;
    
    str = JS_ValueToString(cx, argv[0]);
    if (!str)
        return JS_FALSE;

    char *bytes = JS_GetStringBytes(str);
    fputs(bytes, stderr);
    return JS_TRUE;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:14,代码来源:mozJSComponentLoader.cpp

示例12: Load

static JSBool
Load(JSContext *cx, uintN argc, jsval *vp)
{
    SG_context *pCtx = NULL;
    JSObject *thisobj = JS_THIS_OBJECT(cx, vp);
    jsval *argv = JS_ARGV(cx, vp);
    uintN i;
    if (!thisobj)
        return JS_FALSE;

	SG_context__alloc(&pCtx);
	if (pCtx==NULL)
		return JS_FALSE;

    for (i = 0; i < argc; i++) {
        JSString *str = JS_ValueToString(cx, argv[i]);
        char *filename = NULL;
    	uint32 oldopts;
    	JSObject *scriptObj;
        if (!str) {
        	SG_CONTEXT_NULLFREE(pCtx);
            return JS_FALSE;
        }
        argv[i] = STRING_TO_JSVAL(str);
        sg_jsglue__jsstring_to_sz(pCtx, cx, str, &filename);
        if (SG_context__has_err(pCtx)) {
        	SG_CONTEXT_NULLFREE(pCtx);
            return JS_FALSE;
        }
        errno = 0;
        oldopts = JS_GetOptions(cx);
        JS_SetOptions(cx, oldopts | JSOPTION_COMPILE_N_GO | JSOPTION_NO_SCRIPT_RVAL);
        scriptObj = JS_CompileFile(cx, thisobj, filename);
        SG_NULLFREE(pCtx, filename);
        JS_SetOptions(cx, oldopts);
        if (!scriptObj) {
        	SG_CONTEXT_NULLFREE(pCtx);
            return JS_FALSE;
        }

        if (!compileOnly && !JS_ExecuteScript(cx, thisobj, scriptObj, NULL)) {
        	SG_CONTEXT_NULLFREE(pCtx);
            return JS_FALSE;
        }
    }

	SG_CONTEXT_NULLFREE(pCtx);
    return JS_TRUE;
}
开发者ID:refaqtor,项目名称:sourcegear_veracity_clone,代码行数:49,代码来源:vscript.c

示例13: jwindow_alert

JSBool jwindow_alert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
#define WEBC_JSCRIPT_USER_ALERT 1
#if (WEBC_JSCRIPT_USER_ALERT)
	if (argc >= 1)
	{
		char *str = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
		webc_user_alert_box((char *)str);

	}
	return JS_TRUE;
#else
    return jwindow_dialog(cx, obj, argc, argv, rval, WHICH_DIALOGUE_ALERT);
#endif
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:15,代码来源:wjdialogs.cpp

示例14: win32_setcurrentdirectory

JSBool win32_setcurrentdirectory(JSContext * cx, JSObject * obj, uintN argc, jsval *argv, jsval * rval)
{
	JS_BeginRequest(cx);
	if(argc < 1 || !JSVAL_IS_STRING(*argv))
	{
		JS_ReportError(cx, "Must provide directory name to setcurrentdirectory.");
		JS_EndRequest(cx);
		return JS_FALSE;
	}

	JSString * pathName = JS_ValueToString(cx, *argv);
	*rval = SetCurrentDirectory((LPWSTR)JS_GetStringChars(pathName)) ? JSVAL_TRUE : JSVAL_FALSE;
	JS_EndRequest(cx);
	return JS_TRUE;
}
开发者ID:z4y4,项目名称:njord,代码行数:15,代码来源:win32s.cpp

示例15: jsGoto

static JSBool
jsGoto( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval )
{
   if( ( 1 <= argc )
       &&
       JSVAL_IS_STRING( argv[0] ) )
   {
      gotoCalled_ = true ;
      abortCodeQueue();
      absoluteURL( JS_GetStringBytes( JS_ValueToString( cx, argv[0] ) ), gotoURL_ );
   }

   *rval = JSVAL_TRUE ;
   return JS_TRUE ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:15,代码来源:jsHyperlink.cpp


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