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

C++ JS_ValueToInt32函数代码示例

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

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



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

示例1: js_cocos2dx_CCMenuItemAtlasFont_create

JSBool js_cocos2dx_CCMenuItemAtlasFont_create(JSContext *cx, uint32_t argc, jsval *vp)
{
    const char *arg0 = NULL;
    const char *arg1 = NULL;
    do {
        if (argc >= 5) {
            jsval *argv = JS_ARGV(cx, vp);
            do { JSString *tmp = JS_ValueToString(cx, argv[0]); arg0 = JS_EncodeString(cx, tmp); } while (0);
            do { JSString *tmp = JS_ValueToString(cx, argv[1]); arg1 = JS_EncodeString(cx, tmp); } while (0);
            int arg2; if (!JS_ValueToInt32(cx, argv[2], &arg2)) break;
            int arg3; if (!JS_ValueToInt32(cx, argv[3], &arg3)) break;
            int arg4; if (!JS_ValueToInt32(cx, argv[4], &arg4)) break;
            cocos2d::CCMenuItemAtlasFont* ret = cocos2d::CCMenuItemAtlasFont::create(arg0, arg1, arg2, arg3, arg4);

            JS_free(cx, (void*)arg0);
            JS_free(cx, (void*)arg1);
            
            JSObject *obj = bind_menu_item<cocos2d::CCMenuItemAtlasFont>(cx, ret, (argc == 7 ? argv[6] : JSVAL_VOID), (argc >= 6 ? argv[5] : JSVAL_VOID));
            JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
            return JS_TRUE;
        }
    } while(0);
    
    JS_free(cx, (void*)arg0);
    JS_free(cx, (void*)arg1);
    
	return JS_FALSE;
}
开发者ID:dumganhar,项目名称:HelloExtensionJS,代码行数:28,代码来源:cocos2d_specifics.cpp


示例2: js_inkey

static JSBool
js_inkey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	char		key[2];
	int32		mode=0;
	int32		timeout=0;
	sbbs_t*		sbbs;
    JSString*	js_str;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if(argc)
		JS_ValueToInt32(cx,argv[0],&mode);
	if(argc>1)
		JS_ValueToInt32(cx,argv[1],&timeout);
	key[0]=sbbs->inkey(mode,timeout);
	key[1]=0;

	if((js_str = JS_NewStringCopyZ(cx, key))==NULL)
		return(JS_FALSE);

	*rval = STRING_TO_JSVAL(js_str);
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:25,代码来源:js_console.cpp


示例3: js_printtail

static JSBool
js_printtail(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	int			lines=0;
	long		mode=0;
	uintN		i;
	sbbs_t*		sbbs;
    JSString*	js_str=NULL;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	for(i=0;i<argc;i++) {
		if(JSVAL_IS_NUMBER(argv[i])) {
			if(!lines)
				JS_ValueToInt32(cx,argv[i],(int32*)&lines);
			else
				JS_ValueToInt32(cx,argv[i],(int32*)&mode);
		} else if(JSVAL_IS_STRING(argv[i]))
			js_str = JS_ValueToString(cx, argv[i]);
	}

	if(js_str==NULL)
		return(JS_FALSE);

	if(!lines) 
		lines=5;

	sbbs->printtail(JS_GetStringBytes(js_str),lines,mode);
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:31,代码来源:js_console.cpp


示例4: jhtml_textarea_setProperty

/**
 * This method is called when setting a Property in HTMLTextArea
 */
static JSBool jhtml_textarea_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
	HTMLElement *pElem = (HTMLElement *) jhutil_GetPrivate(cx, obj);
	HTMLTextArea *pText = (pElem)? (HTMLTextArea *) pElem : 0;

	if (!pText)
		return JS_TRUE;

	switch (JSVAL_TO_INT(id))
	{
		case HTMLTEXTAREAELEMENT_COLS:
			if (JSVAL_IS_INT(*vp))
			{
				int32 cols;
				JS_ValueToInt32(cx, *vp, &cols);
				pText->SetCols(cols);
				pText->Update(0,0);
				return JS_TRUE;
			}
			break;
		case HTMLTEXTAREAELEMENT_ROWS:
			if (JSVAL_IS_INT(*vp))
			{
				int32 rows;
				JS_ValueToInt32(cx, *vp, &rows);
				pText->SetRows(rows);
				pText->Update(0,0);
				return JS_TRUE;
			}
			break;
		default:
			break;
	}//end switch
	return JS_TRUE;
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:38,代码来源:jhtarea.cpp


示例5: fill_rectangle

static JSBool
fill_rectangle(JSContext *context, JSObject *obj,
               cairo_rectangle_int_t *rect)
{
    jsval val;

    if (!gjs_object_get_property_const(context, obj, GJS_STRING_X, &val))
        return JS_FALSE;
    if (!JS_ValueToInt32(context, val, &rect->x))
        return JS_FALSE;

    if (!gjs_object_get_property_const(context, obj, GJS_STRING_Y, &val))
        return JS_FALSE;
    if (!JS_ValueToInt32(context, val, &rect->y))
        return JS_FALSE;

    if (!gjs_object_get_property_const(context, obj, GJS_STRING_WIDTH, &val))
        return JS_FALSE;
    if (!JS_ValueToInt32(context, val, &rect->width))
        return JS_FALSE;

    if (!gjs_object_get_property_const(context, obj, GJS_STRING_HEIGHT, &val))
        return JS_FALSE;
    if (!JS_ValueToInt32(context, val, &rect->height))
        return JS_FALSE;

    return JS_TRUE;
}
开发者ID:victoryang,项目名称:gjs,代码行数:28,代码来源:cairo-region.cpp


示例6: Window_redraw

JSBool
Window_redraw (JSContext* cx, JSObject* object, uintN argc, jsval* argv, jsval* rval)
{
    if (argc != 2 && argc != 0) {
        JS_ReportError(cx, "Not enough parameters.");
        return JS_FALSE;
    }

    WINDOW* win = ((WindowInformation*)JS_GetPrivate(cx, object))->win;

    JS_BeginRequest(cx);
    JS_EnterLocalRootScope(cx);
    switch (argc) {
        case 0: {
            wrefresh(win);
        } break;

        case 2: {
            jsint beg; JS_ValueToInt32(cx, argv[0], &beg);
            jsint num; JS_ValueToInt32(cx, argv[1], &num);

            wredrawln(win, beg, num);
        } break;
    }
    JS_LeaveLocalRootScope(cx);
    JS_EndRequest(cx);

    return JS_TRUE;

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


示例7: js_uploaded_file

static JSBool
js_uploaded_file(JSContext *cx, uintN argc, jsval *arglist)
{
	JSObject *obj=JS_THIS_OBJECT(cx, arglist);
	jsval *argv=JS_ARGV(cx, arglist);
	private_t*	p;
	int32	files=1;
	int32	bytes=0;
	jsrefcount	rc;
	scfg_t*		scfg;

	scfg=JS_GetRuntimePrivate(JS_GetRuntime(cx));

	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL)
		return JS_FALSE;

	if(argc) {
		if(!JS_ValueToInt32(cx, argv[0], &bytes))
			return JS_FALSE;
	}
	if(argc>1) {
		if(!JS_ValueToInt32(cx, argv[1], &files))
			return JS_FALSE;
	}

	rc=JS_SUSPENDREQUEST(cx);
	js_getuserdat(scfg,p);

	JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(user_uploaded(scfg, p->user, files, bytes)));
	JS_RESUMEREQUEST(cx, rc);

	return JS_TRUE;
}
开发者ID:mattzorzin,项目名称:synchronet,代码行数:35,代码来源:js_user.c


示例8: js_conio_window

static JSBool
js_conio_window(JSContext *cx, uintN argc, jsval *arglist)
{
	jsval *argv=JS_ARGV(cx, arglist);
	int32 left=1;
	int32 top=1;
	int32 right=cio_textinfo.screenwidth;
	int32 bottom=cio_textinfo.screenheight;
	jsrefcount	rc;

	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if(argc > 4)
		return(JS_FALSE);

	if(argc > 0) {
		if(!JSVAL_IS_NUMBER(argv[0]))
			return(JS_FALSE);
		if(!JS_ValueToInt32(cx, argv[0], &left))
			return(JS_FALSE);
	}
	if(argc > 1) {
		if(!JSVAL_IS_NUMBER(argv[1]))
			return(JS_FALSE);
		if(!JS_ValueToInt32(cx, argv[1], &top))
			return(JS_FALSE);
	}
	if(argc > 2) {
		if(!JSVAL_IS_NUMBER(argv[2]))
			return(JS_FALSE);
		if(!JS_ValueToInt32(cx, argv[2], &right))
			return(JS_FALSE);
	}
	if(argc > 3) {
		if(!JSVAL_IS_NUMBER(argv[3]))
			return(JS_FALSE);
		if(!JS_ValueToInt32(cx, argv[3], &bottom))
			return(JS_FALSE);
	}

	rc=JS_SUSPENDREQUEST(cx);
	window(left, top, right, bottom);
	JS_RESUMEREQUEST(cx, rc);
	if(cio_textinfo.winleft == left
			&& cio_textinfo.winright==right
			&& cio_textinfo.wintop==top
			&& cio_textinfo.winbottom==bottom) {
		JS_SET_RVAL(cx, arglist,JSVAL_TRUE);
	}
	else {
		JS_SET_RVAL(cx, arglist,JSVAL_FALSE);
	}
	return(JS_TRUE);
}
开发者ID:kindy,项目名称:synchronet-bbs-1,代码行数:54,代码来源:js_conio.c


示例9: xgg_pbar_propop_xn_set

/** set numeric property (xn).
 */
JSBool xgg_pbar_propop_xn_set(JSContext *pcxa, JSObject *pobja, jsval id, jsval *vp)
{
	XGGPRIVHDR*		phdr = JS_GetPrivate(pcxa, pobja);
	XGG_PBAR_PRIV*	pv0 = JS_GetPrivate(pcxa, pobja);
	XJSEXADGELEM*	pelem0 = phdr->pxadgelem;
	XJSECTX*		pjsectx = (XJSECTX*)JS_GetContextPrivate(pcxa);
	XJSE_ASSERT(pelem0 != 0);	// basicelement inheritances must have this

	xjse_result_t	xr1;
	xjse_int_t		nid = 0;//, nvalue = 0;//, n1;
	char*			psz0;
	JS_ValueToInt32(pcxa, id, &nid);
	//JS_ValueToInt32(pcxa, vp[0], &nvalue);
	//XJSE_TRACE("xgg_pbar_propop_xn_set. [%d](%d)", nid, nvalue);

	switch(nid) {
	case PBAR_TID_EMPTYIMAGE:
		psz0 = JS_GetStringBytes(JS_ValueToString(pcxa, vp[0]));
		xr1 = xgg_xadget_reload_img(pjsectx, &(pv0->ppbempty), psz0, 0, 0);
		if(xr1 != XJSE_SUCCESS)
			goto	failed;
		if(pelem0->fcx == 0.0f)
			pelem0->fcx = (xjse_float_t)(pv0->ppbempty->nimgwidth);
		if(pelem0->fcy == 0.0f)
			pelem0->fcy = (xjse_float_t)(pv0->ppbempty->nimgheight);
		break;
	case PBAR_TID_FULLIMAGE:
		psz0 = JS_GetStringBytes(JS_ValueToString(pcxa, vp[0]));
		xr1 = xgg_xadget_reload_img(pjsectx, &(pv0->ppbfull), psz0, 0, 0);
		if(xr1 != XJSE_SUCCESS)
			goto	failed;
		break;
	case PBAR_TID_MAX:
		JS_ValueToInt32(pcxa, vp[0], &(pv0->nmax));
		break;
	case PBAR_TID_MIN:
		JS_ValueToInt32(pcxa, vp[0], &(pv0->nmin));
		break;
	case PBAR_TID_VALUE:
		JS_ValueToInt32(pcxa, vp[0], &(pv0->nvalue));
		break;
	default:
		XJSE_TRACE("(E) unknown xn prop [property id: %d]", nid);
	}

	return	JS_TRUE;

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


示例10: js_getstr

static JSBool
js_getstr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	char		*p;
	long		mode=0;
	uintN		i;
	size_t		maxlen=0;
	sbbs_t*		sbbs;
    JSString*	js_str=NULL;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	for(i=0;i<argc;i++) {
		if(JSVAL_IS_NUMBER(argv[i])) {
			if(!maxlen)
				JS_ValueToInt32(cx,argv[i],(int32*)&maxlen);
			else
				JS_ValueToInt32(cx,argv[i],(int32*)&mode);
			continue;
		}
		if(JSVAL_IS_STRING(argv[i])) {
			js_str = JS_ValueToString(cx, argv[i]);
			if (!js_str)
			    return(JS_FALSE);
		}
	}

	if(!maxlen) maxlen=128;

	if((p=(char *)calloc(1,maxlen+1))==NULL)
		return(JS_FALSE);

	if(js_str!=NULL)
		sprintf(p,"%.*s",(int)maxlen,JS_GetStringBytes(js_str));

	sbbs->getstr(p,maxlen,mode);

	js_str = JS_NewStringCopyZ(cx, p);

	free(p);

	if(js_str==NULL)
		return(JS_FALSE);

	*rval = STRING_TO_JSVAL(js_str);
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:48,代码来源:js_console.cpp


示例11: JSUpdateStatus

/**
 * The function used as ZOOUpdateStatus from the JavaScript environment
 * (ZOO-API).
 *
 * @param cx the JavaScript context
 * @param argc the number of parameters
 * @param argv1 the parameter values
 * @return true
 * @see setHeader,_updateStatus
 */
JSBool
JSUpdateStatus(JSContext *cx, uintN argc, jsval *argv1)
{
  jsval *argv = JS_ARGV(cx,argv1);
  JS_MaybeGC(cx);
  int istatus=0;
  char *status=NULL;
  maps *conf;
  if(argc>2){
#ifdef JS_DEBUG
    fprintf(stderr,"Number of arguments used to call the function : %i",argc);
#endif
    return JS_FALSE;
  }
  conf=mapsFromJSObject(cx,argv[0]);
  if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){
    char tmpStatus[4];
    sprintf(tmpStatus,"%i",istatus);
    tmpStatus[3]=0;
    status=strdup(tmpStatus);
  }
  if(getMapFromMaps(conf,"lenv","status")!=NULL){
    if(status!=NULL){
      setMapInMaps(conf,"lenv","status",status);
      free(status);
    }
    else
      setMapInMaps(conf,"lenv","status","15");
    _updateStatus(conf);
  }
  freeMaps(&conf);
  free(conf);
  JS_MaybeGC(cx);
  return JS_TRUE;
}
开发者ID:OSGeo,项目名称:zoo-project,代码行数:45,代码来源:service_internal_js.c


示例12: JS_ValueToInt32

template<> bool ScriptInterface::FromJSVal<unsigned long>(JSContext* cx, jsval v, unsigned long& out)
{
	int32 tmp;
	JSBool ok = JS_ValueToInt32(cx, v, &tmp);
	out = (unsigned long)tmp;
	return ok == JS_TRUE;
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:7,代码来源:ScriptConversions.cpp


示例13: TCP_connect

JSBool
TCP_connect (JSContext* cx, JSObject* object, uintN argc, jsval* argv, jsval* rval)
{
    char*    host;
    int      port    = -1;
    jsdouble timeout = 30;

    JS_BeginRequest(cx);

    if (argc < 1) {
        JS_ReportError(cx, "Not enough parameters.");
        JS_EndRequest(cx);
        return JS_FALSE;
    }

    jsval jsConnected;
    JS_GetProperty(cx, object, "connected", &jsConnected);

    if (jsConnected == JSVAL_TRUE) {
        JS_ReportError(cx, "The socket is already connected.");
        JS_EndRequest(cx);
        return JS_FALSE;
    }

    switch (argc) {
        case 3: JS_ValueToNumber(cx, argv[2], &timeout);
        case 2: JS_ValueToInt32(cx, argv[1], &port);
        case 1: host = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
    }

    TCPInformation* data = (TCPInformation*) JS_GetPrivate(cx, object);
    PRNetAddr addr; 

    if (__Sockets_initAddr(&addr, host, port) == PR_FAILURE) {
        *rval = JSVAL_FALSE;
        JS_EndRequest(cx);
        return JS_TRUE;
    }

    if (PR_Connect(data->socket, &addr, (timeout == -1)
        ? PR_INTERVAL_NO_TIMEOUT
        : PR_MicrosecondsToInterval(timeout*1000000)) == PR_FAILURE)
    {
        if (PR_GetError() == PR_CONNECT_RESET_ERROR) {
            JS_ReportError(cx, "Connection reset by peer.");
        }

        jsConnected = JSVAL_FALSE;
        JS_SetProperty(cx, object, "connected", &jsConnected);

        JS_EndRequest(cx);
        return JS_FALSE;
    }

    jsConnected = JSVAL_TRUE;
    JS_SetProperty(cx, object, "connected", &jsConnected);

    JS_EndRequest(cx);
    return JS_TRUE;
}
开发者ID:mandrake,项目名称:lulzjs,代码行数:60,代码来源:TCP.cpp


示例14: to_erl_int

int
to_erl_int(emonk_buf_t* buf, JSContext* cx, jsval val)
{
    int32_t rval;
    
    if(!JS_ValueToInt32(cx, val, &rval)) return ERROR;
    
    if((unsigned int) rval < 255)
    {
        REQUEST(2);
        BUFPTR[0] = SMALL_INTEGER;
        BUFPTR[1] = (char) rval;
        buf->used += 2;
    }
    else
    {
        REQUEST(5);
        BUFPTR[0] = INTEGER;
        rval = htonl(rval);
        memcpy(BUFPTR+1, &rval, 4);
        buf->used += 5;
    }

    return OK;    
}
开发者ID:kocolosk,项目名称:emonk,代码行数:25,代码来源:emonk_to_erl.c


示例15: js_handle_ctrlkey

static JSBool
js_handle_ctrlkey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
	char		key;
	int32		mode=0;
	sbbs_t*		sbbs;
    JSString*	js_str;

	*rval = JSVAL_FALSE;

	if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
		return(JS_FALSE);

	if(JSVAL_IS_INT(argv[0]))
		key=(char)JSVAL_TO_INT(argv[0]);
	else {
		if((js_str=JS_ValueToString(cx, argv[0]))==NULL)
			return(JS_FALSE);
		key=*JS_GetStringBytes(js_str);
	}

	if(argc>1)
		JS_ValueToInt32(cx, argv[1], &mode);

	*rval = BOOLEAN_TO_JSVAL(sbbs->handle_ctrlkey(key,mode)==0);
    return(JS_TRUE);
}
开发者ID:ftnapps,项目名称:pkg-sbbs,代码行数:27,代码来源:js_console.cpp


示例16: jhtml_tablerow_insertCell

/**
 * InsertCell - insert a cell into this row
 *
 * params - int index - this index tells where to put the new cell.
 * return - HTMLElement - the newly added Cell
 */
JSBool jhtml_tablerow_insertCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
  #if (WEBC_SUPPORT_TABLES)
	HTMLElement *pElem = (HTMLElement *) jhutil_GetPrivate(cx, obj);
	HTMLTableRow *ptrow = (pElem)? (HTMLTableRow *) pElem : 0;
	if (ptrow && (argc > 0 && JSVAL_IS_INT(argv[0])))
	{
		int32 index = 0;
		JS_ValueToInt32(cx, argv[0], &index);

		HTMLElement *pElem = ptrow->InsertCell(index);
		ptrow->Update(0,0);
		if (pElem)
		{
			*rval = OBJECT_TO_JSVAL(pElem->CreateJSObject());
		}
		else
		{
			*rval = JSVAL_NULL;
		}
	}
	return JS_TRUE;
  #else // WEBC_SUPPORT_TABLES
    return JS_FALSE;
  #endif // WEBC_SUPPORT_TABLES
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:32,代码来源:jhtblrow.cpp


示例17: GetVibrationDurationFromJsval

/**
 * Converts a jsval into a vibration duration, checking that the duration is in
 * bounds (non-negative and not larger than sMaxVibrateMS).
 *
 * Returns true on success, false on failure.
 */
bool
GetVibrationDurationFromJsval(const jsval& aJSVal, JSContext* cx,
                              int32_t* aOut)
{
  return JS_ValueToInt32(cx, aJSVal, aOut) &&
         *aOut >= 0 && static_cast<uint32_t>(*aOut) <= sMaxVibrateMS;
}
开发者ID:bebef1987,项目名称:mozilla-central,代码行数:13,代码来源:Navigator.cpp


示例18: rpmhdr_setprop

static JSBool
rpmhdr_setprop(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
{
    void * ptr = JS_GetInstancePrivate(cx, obj, &rpmhdrClass, NULL);
    jsval idval;
    JS_IdToValue(cx, id, &idval);
    jsint tiny = JSVAL_TO_INT(idval);

_PROP_DEBUG_ENTRY(_debug < 0);

    /* XXX the class has ptr == NULL, instances have ptr != NULL. */
    if (ptr == NULL)
	return JS_TRUE;

    switch (tiny) {
    case _DEBUG:
	if (!JS_ValueToInt32(cx, *vp, &_debug))
	    break;
	break;
    default:
	break;
    }

    return JS_TRUE;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:25,代码来源:rpmhdr-js.c


示例19: js_conio_cgets

static JSBool
js_conio_cgets(JSContext *cx, uintN argc, jsval *arglist)
{
	jsval *argv=JS_ARGV(cx, arglist);
	char	buf[258];
	int32	maxlen=255;
	char	*ret;
	jsrefcount	rc;

	JS_SET_RVAL(cx, arglist, JSVAL_VOID);

	if(argc > 1)
		return(JS_FALSE);
	if(argc > 0) {
		if(!JSVAL_IS_NUMBER(argv[0]))
			return(JS_FALSE);
		if(!JS_ValueToInt32(cx, argv[0], &maxlen))
			return(JS_FALSE);
		if(maxlen > 255)
			return(JS_FALSE);
	}
	buf[0]=(char)maxlen;
	rc=JS_SUSPENDREQUEST(cx);
	ret=cgets(buf);
	JS_RESUMEREQUEST(cx, rc);
	if(ret==NULL)
		JS_SET_RVAL(cx, arglist,JSVAL_NULL);
	else {
		buf[257]=0;
		JS_SET_RVAL(cx, arglist,STRING_TO_JSVAL(JS_NewStringCopyZ(cx,ret)));
	}

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


示例20: elixir_object_get_int

Eina_Bool
elixir_object_get_int(JSContext *cx, JSObject *obj, const char *name, int *value)
{
   jsval propertie;
   jsdouble localdbl;

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

   if (JSVAL_IS_INT(propertie)
       || JSVAL_IS_STRING(propertie))
     {
        if (!JS_ValueToInt32(cx, propertie, value))
          return EINA_FALSE;
     }
   else
     if (JSVAL_IS_DOUBLE(propertie))
       {
          if (!JS_ValueToNumber(cx, propertie, &localdbl))
            return EINA_FALSE;
          *value = localdbl;
       }
     else
       if (JSVAL_IS_BOOLEAN(propertie))
         {
            *value = JSVAL_TO_BOOLEAN(propertie);
         }
       else
         return EINA_FALSE;

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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