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

C++ JS_ValueToObject函数代码示例

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

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



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

示例1: jsval_to_animationInfo

bool jsval_to_animationInfo(JSContext* cx, JS::HandleValue vp, cocostudio::timeline::AnimationInfo* ret)
{
    JS::RootedObject tmp(cx);
    JS::RootedValue jsName(cx);
    JS::RootedValue jsStartId(cx);
    JS::RootedValue jsEndId(cx);
    std::string name;
    double startIndex, endIndex;
    
    bool ok = vp.isObject() &&
    JS_ValueToObject(cx, vp, &tmp) &&
    JS_GetProperty(cx, tmp, "name", &jsName) &&
    JS_GetProperty(cx, tmp, "startIndex", &jsStartId) &&
    JS_GetProperty(cx, tmp, "endIndex", &jsEndId) &&
    JS::ToNumber(cx, jsStartId, &startIndex) &&
    JS::ToNumber(cx, jsEndId, &endIndex) &&
    jsval_to_std_string(cx, jsName, &name) &&
    !std::isnan(startIndex) && !std::isnan(endIndex);
    
    JSB_PRECONDITION3(ok, cx, false, "Error processing arguments");
    
    ret->name = name;
    ret->startIndex = (int)startIndex;
    ret->endIndex = (int)endIndex;
    return true;
}
开发者ID:FenneX,项目名称:FenneXEmptyProject,代码行数:26,代码来源:jsb_cocos2dx_studio_conversions.cpp


示例2: xgg_xdom_getelementsbytagname

static JSBool xgg_xdom_getelementsbytagname(JSContext *pcxa, JSObject *pobja, uintN argc, jsval *pva1, jsval *rval)
{
	JSBool				b1 = JS_TRUE;
	XJSECTX*			pjsectx = (XJSECTX*)JS_GetContextPrivate(pcxa);
	XJSE_XDOMPRIV*		pv1 = (XJSE_XDOMPRIV*)JS_GetPrivate(pcxa, pobja);
	jsval				vrootelem;

	b1 = JS_GetElement(pjsectx->pctx, pv1->ponodelist, 0, &vrootelem);
	if(b1 != JS_TRUE) {
		XJSE_TRACE("(E) JS_GetElement() failed!");
		goto	failed;
	}

	JSObject	*porootelem = 0;
	b1 = JS_ValueToObject(pcxa, vrootelem, &porootelem);
	if(b1 != JS_TRUE || porootelem == 0) {
		XJSE_TRACE("(E) JS_ValueToObject() failed!");
		goto	failed;
	}

	return	xgg_element_getelementsbytagname(
		pcxa, porootelem, argc, pva1, rval);

failed:
	return	JS_FALSE;
}
开发者ID:odistagon,项目名称:cyeonna,代码行数:26,代码来源:xgg_dom.c


示例3: getJsObjOrCreat

    jsval getJsObjOrCreat(JSContext* cx, JSObject* jsObj, const char* name, JSObject** retObj) {
        JSObject* parent = NULL;
        JSObject* tempObj = jsObj;
        jsval tempVal;

        std::stringstream ss(name);
        std::string sub;
        const char* subChar;

        while(getline(ss, sub, '.')) {
            if(sub.empty())continue;

            subChar = sub.c_str();
            parent = tempObj;
            JS_GetProperty(cx, parent, subChar, &tempVal);
            if (tempVal == JSVAL_VOID) {
                tempObj = JS_NewObject(cx, NULL, NULL, NULL);
                tempVal = OBJECT_TO_JSVAL(tempObj);
                JS_SetProperty(cx, parent, subChar, &tempVal);
            } else {
                JS_ValueToObject(cx, tempVal, &tempObj);
            }
        }

        *retObj = tempObj;
        return tempVal;
    }
开发者ID:sdkbox,项目名称:sdkbox-sample-appnext,代码行数:27,代码来源:SDKBoxJSHelper.cpp


示例4: register_pluginx_js_extensions

void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
{
    // first, try to get the ns
    jsval nsval;
    JSObject *ns;
    JS_GetProperty(cx, global, "plugin", &nsval);
    if (nsval == JSVAL_VOID) {
        ns = JS_NewObject(cx, NULL, NULL, NULL);
        nsval = OBJECT_TO_JSVAL(ns);
        JS_SetProperty(cx, global, "plugin", &nsval);
    } else {
        JS_ValueToObject(cx, nsval, &ns);
    }

    JS_DefineFunction(cx, jsb_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_ProtocolShare_prototype, "setResultListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);

    global = ns;
    js_register_pluginx_protocols_PluginParam(cx, global);
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:26,代码来源:jsb_pluginx_extension_registration.cpp


示例5: SetContextObj

static JSBool
SetContextObj(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
  nsJSSh* shell;
  if (!GetJSShGlobal(cx, obj, &shell)) return JS_FALSE;

  JSAutoRequest ar(cx);

  if (argc!=1) return JS_FALSE;

  JSObject *arg_obj;
  if (!JS_ValueToObject(cx, argv[0], &arg_obj)) {
    return JS_FALSE;
  }

  if (shell->mContextObj != shell->mGlobal)
    JS_RemoveRoot(cx, &(shell->mContextObj));
  
  shell->mContextObj = arg_obj;
  
  if (shell->mContextObj != shell->mGlobal)
    JS_AddRoot(cx, &(shell->mContextObj));
  
  return JS_TRUE;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:25,代码来源:nsJSSh.cpp


示例6: jsval_to_opaque

JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **r)
{
#ifdef __LP64__
	JSObject *tmp_arg;
	if( ! JS_ValueToObject( cx, vp, &tmp_arg ) )
		return JS_FALSE;

	JSB_PRECONDITION( js_IsTypedArray( tmp_arg ), "jsb: Not a TypedArray object");

	JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(void*), "jsb: Invalid Typed Array lenght");
	
	int32_t* arg_array = (int32_t*)JS_GetTypedArrayData( tmp_arg );
	uint64 ret =  arg_array[0];
	ret = ret << 32;
	ret |= arg_array[1];
	
#else
	assert( sizeof(int)==4);
	int32_t ret;
	if( ! JS_ValueToInt32(cx, vp, &ret ) )
	  return JS_FALSE;
#endif
	*r = (void*)ret;
	return JS_TRUE;
}
开发者ID:dumganhar,项目名称:cocos2dx-watermelon-ios,代码行数:25,代码来源:js_manual_conversions.cpp


示例7: jsval_to_long

// XXX: sizeof(long) == 8 in 64 bits on OS X... apparently on Windows it is 32 bits (???)
JSBool jsval_to_long( JSContext *cx, jsval vp, long *r )
{
#ifdef __LP64__
	// compatibility check
	assert( sizeof(long)==8);
	JSObject *tmp_arg;
	if( ! JS_ValueToObject( cx, vp, &tmp_arg ) )
		return JS_FALSE;

	JSB_PRECONDITION( js_IsTypedArray( tmp_arg ), "jsb: Not a TypedArray object");

	JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long), "jsb: Invalid Typed Array lenght");
	
	int32_t* arg_array = (int32_t*)JS_GetTypedArrayData( tmp_arg );
	long ret =  arg_array[0];
	ret = ret << 32;
	ret |= arg_array[1];
	
#else
	// compatibility check
	assert( sizeof(int)==4);
	long ret = JSVAL_TO_INT(vp);
#endif
	
	*r = ret;
	return JS_TRUE;
}
开发者ID:dumganhar,项目名称:cocos2dx-watermelon-ios,代码行数:28,代码来源:js_manual_conversions.cpp


示例8: jsval_array_to_string

bool jsval_array_to_string(JSContext *cx, jsval v, std::string* ret)
{
	JS::RootedObject jsobj(cx);
	bool ok = v.isObject() && JS_ValueToObject( cx, JS::RootedValue(cx, v), &jsobj );
	JSB_PRECONDITION2( ok, cx, false, "Error converting value to object");
	JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array");

	uint32_t len;
	JS_GetArrayLength(cx, jsobj, &len);

	for( uint32_t i=0; i< len;i++ ) {
		JS::RootedValue valarg(cx);
		JS_GetElement(cx, jsobj, i, &valarg);

		std::string temp;
		ok = jsval_to_std_string(cx, valarg, &temp);
		JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
		if(i != len -1)
			ret->append(temp + ",");
		else
			ret->append(temp);
	}

	return true;
}
开发者ID:TheWindShan,项目名称:HYFish,代码行数:25,代码来源:jsb_pluginx_basic_conversions.cpp


示例9: respond_to_p

/*
 * call-seq:
 *   respond_to?(symbol)
 *
 * Returns <code>true</code> if this JavaScript object responds to the
 * named method.
 */
static VALUE
respond_to_p(int argc, const VALUE* argv, VALUE self)
{
  VALUE sym, priv;

  rb_scan_args(argc, argv, "11", &sym, &priv);

  RubyLandProxy* proxy;
  Data_Get_Struct(self, RubyLandProxy, proxy);

  JSContext * context = johnson_get_current_context(proxy->runtime);
  PREPARE_RUBY_JROOTS(context, 2);
  
  VALUE stringval = rb_funcall(sym, rb_intern("to_s"), 0);
  char* name = StringValuePtr(stringval);
  
  // assignment is always okay
  if (name[strlen(name) - 1] == '=')
    JRETURN_RUBY(Qtrue);
  
  jsval proxy_value;
  JCHECK(get_jsval_for_proxy(proxy, &proxy_value));
  JROOT(proxy_value);

  JSObject *obj;
  JSBool found;
  
  JCHECK(JS_ValueToObject(context, proxy_value, &obj));
  JROOT(obj);

  JCHECK(JS_HasProperty(context, obj, name, &found));

  JRETURN_RUBY(found ? Qtrue : CALL_RUBY_WRAPPER(rb_call_super, argc, argv));
}
开发者ID:aasmith,项目名称:johnson,代码行数:41,代码来源:ruby_land_proxy.c


示例10: fromjs_isTimerValid

JSBool JSJSGlobalObject::fromjs_isTimerValid(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
  // get instance
  JSGlobalObject *object = static_cast<JSGlobalObject *>(reinterpret_cast<JSScriptable *>(JS_GetPrivate(cx, obj)));
  if (!object) {
    JSScriptable::js_throwNullCallException(JSJSGlobalObject::classDescriptor.name, JSJSGlobalObject::functionTable[4].name);
    return JS_FALSE;
  }
  // record context
  object->js_setCurrentContext(cx);
  // JSTimer *timer
  JSObject *p0;
  if (!JS_ValueToObject(cx, argv[0], &p0))
    return JS_FALSE;
  argv[0] = OBJECT_TO_JSVAL(p0);
  JSTimer *p0o = NULL;
  if (p0) {
    JSScriptable *pobj = reinterpret_cast<JSScriptable*>(JS_GetPrivate(cx, p0));
    if (!pobj) {
      object->js_throwNullParamException(0, JSJSGlobalObject::functionTable[4].name, JSJSGlobalObject::classDescriptor.name);
      return JS_FALSE;
    }
    p0o = static_cast<JSTimer *>(pobj->js_getInterface(JS_JSTimer_GUID));
    if (!p0o) {
      object->js_throwParamTypeException(0, JSJSTimer::classDescriptor.name, JSJSGlobalObject::functionTable[4].name, JSJSGlobalObject::classDescriptor.name);
      return JS_FALSE;
    }
  }
  // call method
  ASSERT(object != NULL);
  bool rv = object->isTimerValid(p0o);
  // handle return value
  *rval = BOOLEAN_TO_JSVAL(rv);
  // success
  return JS_TRUE;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:35,代码来源:JSJSGlobalObject.cpp


示例11: AfxGlImage_writeBitmap

static JSBool
AfxGlImage_writeBitmap(JSContext *cx, unsigned argc, JS::Value *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
	if(1 > args.length())
		return JS_FALSE;

	JSObject * jsObj;
	if(!JS_ValueToObject(cx, args.thisv(), &jsObj))
		return JS_FALSE;

	AfxGlImage *afxGlImage = (AfxGlImage *)JS_GetPrivate(jsObj);

    JSString *str = JS_ValueToString(cx, args[0]);
    if (!str)
        return JS_FALSE;

    char *c_str = JS_EncodeString(cx, str);
	if(!c_str)
		return JS_FALSE;

	std::wstring wFileName;

	bool bOk = AnsiStringToWideString(c_str, wFileName);

	JS_free(cx, c_str);

	if(!(bOk
		&& AfxImageUtils::WriteBitmap(afxGlImage, wFileName.c_str())))
		return JS_FALSE;

	args.rval().set(JSVAL_VOID);
    return JS_TRUE;
}
开发者ID:YaLTeR,项目名称:advancedfx,代码行数:34,代码来源:scripting.cpp


示例12: AfxGlImage_sliceFloatDepthBuffer

static JSBool
AfxGlImage_sliceFloatDepthBuffer(JSContext *cx, unsigned argc, JS::Value *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
	if(2 > args.length())
		return JS_FALSE;

	JSObject * jsObj;
	if(!JS_ValueToObject(cx, args.thisv(), &jsObj))
		return JS_FALSE;

	AfxGlImage *afxGlImage = (AfxGlImage *)JS_GetPrivate(jsObj);

	GLdouble sliceLo;
	GLdouble sliceHi;
	
	if(!(
		JS::ToNumber(cx, args[0], &sliceLo)
		&& JS::ToNumber(cx, args[1], &sliceHi)
	))
		return JS_FALSE;

	if(!AfxImageUtils::SliceFloatDepthBuffer(afxGlImage, sliceLo, sliceHi))
		return JS_FALSE;

	args.rval().set(JSVAL_VOID);
    return JS_TRUE;
}
开发者ID:YaLTeR,项目名称:advancedfx,代码行数:28,代码来源:scripting.cpp


示例13: Window_printChar

JSBool
Window_printChar (JSContext* cx, JSObject* object, uintN argc, jsval* argv, jsval* rval)
{
    if (argc < 1) {
        JS_ReportError(cx, "Not enough parameters.");
        return JS_FALSE;
    }

    JS_BeginRequest(cx);
    JS_EnterLocalRootScope(cx);

    WINDOW* win = (WINDOW*) JS_GetPrivate(cx, object);

    jsint ch; JS_ValueToInt32(cx, argv[0], &ch);

    if (argc == 1){
        waddch(win, ch);
    }
    else if (argc == 2) {
        JSObject* options; JS_ValueToObject(cx, argv[1], &options);

        jsval x, y;

        JS_GetProperty(cx, options, "x", &x);
        if (JSVAL_IS_VOID(x) || JSVAL_IS_NULL(x)) {
            JS_GetProperty(cx, options, "X", &x);
        }

        JS_GetProperty(cx, options, "y", &y);
        if (JSVAL_IS_VOID(y) || JSVAL_IS_NULL(y)) {
            JS_GetProperty(cx, options, "Y", &y);
        }

        jsval jsEcho; JS_GetProperty(cx, options, "echo", &jsEcho);
        JSBool echo; JS_ValueToBoolean(cx, jsEcho, &echo);

        __Window_options(cx, win, options, JS_TRUE);
        if (echo) {
            wechochar(win, ch);
        }
        else if (!JSVAL_IS_INT(x) && !JSVAL_IS_INT(y)) {
            waddch(win, ch);
        }
        else {
            mvwaddch(win,
                JSVAL_IS_INT(y) ? JSVAL_TO_INT(y) : 0,
                JSVAL_IS_INT(x) ? JSVAL_TO_INT(x) : 0,
                ch
            );
        }
        __Window_options(cx, win, options, JS_FALSE);
    }

    JS_LeaveLocalRootScope(cx);
    JS_EndRequest(cx);

    return JS_TRUE;
}
开发者ID:meh,项目名称:lulzjs-ncurses,代码行数:58,代码来源:Window.cpp


示例14: jsval_to_CGPoint

JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, CGPoint *ret )
{
#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES
    
	JSObject *jsobj;
	if( ! JS_ValueToObject( cx, vp, &jsobj ) )
		return JS_FALSE;
	
	JSB_PRECONDITION( jsobj, "Not a valid JS object");
    
	jsval valx, valy;
	JSBool ok = JS_TRUE;
	ok &= JS_GetProperty(cx, jsobj, "x", &valx);
	ok &= JS_GetProperty(cx, jsobj, "y", &valy);
    
	if( ! ok )
		return JS_FALSE;
	
	double x, y;
	ok &= JS_ValueToNumber(cx, valx, &x);
	ok &= JS_ValueToNumber(cx, valy, &y);
	
	if( ! ok )
		return JS_FALSE;
	
	ret->x = x;
	ret->y = y;
    
	return JS_TRUE;
    
#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES
    
	JSObject *tmp_arg;
	if( ! JS_ValueToObject( cx, vp, &tmp_arg ) )
		return JS_FALSE;
	
	JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object");
	
	JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(CGPoint), "Invalid length");
	
	*ret = *(CGPoint*)JS_GetArrayBufferViewData( tmp_arg, cx );
	
	return JS_TRUE;
#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES
}
开发者ID:dumganhar,项目名称:cocos2dx-watermelon-ios,代码行数:45,代码来源:js_manual_conversions.cpp


示例15: File_constructor

//////////////////////////////////////////////////////////////////////////
// constructor
JSBool File_constructor(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{
	File_data * data = (File_data *)malloc(sizeof(File_data));
	memset(data, 0, sizeof(File_data));

	JSObject * propertyMap = 0;
	if(argc==1)	// File(path)   or  File(propertyMap)
	{
		if(!JSVAL_IS_STRING(argv[0]) && !JSVAL_IS_OBJECT(argv[0]))
		{
			JS_ReportError(cx, "File constructor argument #1 has an unexpected type. Expected string or object, got: %s", JS_GetTypeName(cx, JS_TypeOfValue(cx, argv[0])));
			return JS_FALSE;
		}

		if(JSVAL_IS_OBJECT(argv[0]))
			JS_ValueToObject(cx, argv[0], &propertyMap);
		else if(JSVAL_IS_STRING(argv[0]))
			JS_SetProperty(cx, obj, "path", &argv[0]);
	}
	else if(argc==2)	// File(path, propertyMap)
	{
		if(!JSVAL_IS_STRING(argv[0]))
		{
			JS_ReportError(cx, "File constructor argument #1 has an unexpected type. Expected string, got: %s", JS_GetTypeName(cx, JS_TypeOfValue(cx, argv[0])));
			return JS_FALSE;
		}
		else if(!JSVAL_IS_OBJECT(argv[1]))
		{
			JS_ReportError(cx, "File constructor argument #2 has an unexpected type. Expected object, got: %s", JS_GetTypeName(cx, JS_TypeOfValue(cx, argv[1])));
			return JS_FALSE;
		}

		JS_SetProperty(cx, obj, "path", &argv[0]);

		JS_ValueToObject(cx, argv[1], &propertyMap);
	}

	if(propertyMap && !JS_CopyObjectProperties(cx, propertyMap, obj))
		return JS_FALSE;

	JS_SetPrivate(cx, obj, data);

	return JS_TRUE;
}
开发者ID:Alix29,项目名称:piston,代码行数:46,代码来源:File.cpp


示例16: GetObject

JSBool GetObject(JSContext* cx, JSObject* obj, int index, JSObject** value) {
    jsval element;
    if(JS_GetElement(cx, obj, index, &element) == JS_FALSE)
        return JS_FALSE;
    
    if(JS_ValueToObject(cx, element, value) == JS_FALSE)
        return JS_FALSE;
    
    return JS_TRUE;
}
开发者ID:devmario,项目名称:VBEngine,代码行数:10,代码来源:FlashCS5extension.c


示例17: elixir_get_obj

JSObject*
elixir_get_obj(JSContext *cx, jsval arg)
{
   JSObject *ret = NULL;

   if (JSVAL_IS_OBJECT(arg))
     JS_ValueToObject(cx, arg, &ret);

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


示例18: getObjectFromNamespace

JSObject* getObjectFromNamespace(JSContext* cx, JSObject *ns, const char *name) {
	jsval out;
	if (JS_GetProperty(cx, ns, name, &out) == JS_TRUE) {
		JSObject *obj;
		if (JS_ValueToObject(cx, out, &obj) == JS_TRUE) {
			
		}
	}
	return NULL;
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:10,代码来源:cocos2d_specifics.cpp


示例19: JS_GetEmptyStringValue

void FFSessionHandler::getStringObjectClass(JSContext* ctx) {
  jsval str = JS_GetEmptyStringValue(ctx);
  JSObject* obj = 0;
  if (!JS_ValueToObject(ctx, str, &obj)) {
    return;
  }
  if (!obj) {
    return;
  }
  stringObjectClass = JS_GET_CLASS(ctx, obj);
}
开发者ID:jnorthrup,项目名称:gwt-sandbox,代码行数:11,代码来源:FFSessionHandler.cpp


示例20: Core_print

JSBool
Core_print (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
    JS_BeginRequest(cx);
    JS_EnterLocalRootScope(cx);

    char*     separator = " ";
    char*     end       = "\n";
    int       fd        = fileno(stdout);
    FILE*     fp        = NULL;
    jsval     property;
    JSObject* options;

    if (argc > 1 && JS_TypeOfValue(cx, argv[argc-1]) == JSTYPE_OBJECT) {
        JS_ValueToObject(cx, argv[argc-1], &options);
        argc--;

        JS_GetProperty(cx, options, "separator", &property);
        if (JSVAL_IS_VOID(property) || JSVAL_IS_NULL(property)) {
            JS_GetProperty(cx, options, "sep", &property);
        }

        if (JSVAL_IS_STRING(property)) {
            separator = JS_GetStringBytes(JS_ValueToString(cx, property));
        }

        JS_GetProperty(cx, options, "end", &property);
        if (JSVAL_IS_STRING(property)) {
            end = JS_GetStringBytes(JS_ValueToString(cx, property));
        }

        JS_GetProperty(cx, options, "file", &property);
        if (JSVAL_IS_NUMBER(property)) {
            fd = JSVAL_TO_INT(property);
        }
    }

    fp = fdopen(fd, "a+");

    uintN i;
    for (i = 0; i < argc; i++) {
        fprintf(fp, "%s", JS_GetStringBytes(JS_ValueToString(cx, argv[i])));

        if (i != argc-1) {
            fprintf(fp, "%s", separator);
        }
    }
    fprintf(fp, "%s", end);

    JS_LeaveLocalRootScope(cx);
    JS_EndRequest(cx);

    return JS_TRUE;
}
开发者ID:mandrake,项目名称:lulzjs,代码行数:54,代码来源:Core.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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