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


C++ JSVAL_IS_INT函数代码示例

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


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

示例1: Window_printString

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

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

    JS_BeginRequest(cx);
    JS_EnterLocalRootScope(cx);

    if (argc == 1){
        wprintw(win, JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
    }
    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);
        }

        __Window_options(cx, win, options, JS_TRUE);
        if (!JSVAL_IS_INT(x) && !JSVAL_IS_INT(y)) {
            wprintw(win, JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
        }
        else {
            mvwprintw(win,
                JSVAL_IS_INT(y) ? JSVAL_TO_INT(y) : 0,
                JSVAL_IS_INT(x) ? JSVAL_TO_INT(x) : 0,
                JS_GetStringBytes(JS_ValueToString(cx, argv[0]))
            );
        }
        __Window_options(cx, win, options, JS_FALSE);
    }

    JS_LeaveLocalRootScope(cx);
    JS_EndRequest(cx);

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

示例2: su_versionCompareTo

/**
 *  implementation of InstallVersion.compareTo()
 */
static JSBool PR_CALLBACK su_versionCompareTo(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
    int     compval;
    VERSION thisver, v;

    if ( argc == 0 )
        return JS_FALSE;

    if ( JSVAL_IS_STRING(argv[0]) ) {
        su_strToVersion( JS_GetStringBytes(JSVAL_TO_STRING(argv[0])), &v );
    }
    else if (JSVAL_IS_OBJECT(argv[0]) ) {
        /* check to make sure it's an InstallVersion */
        JSObject *argobj;
        JSClass *argclass;

        argobj = JSVAL_TO_OBJECT(argv[0]);
        argclass = JS_GetClass(cx, argobj);

        if ( argclass != &su_version_class ) {
            /* XXX report error here */
            return JS_FALSE;
        }

        su_objToVers( cx, argobj, &v );
    }
    else {
        v.major = v.minor = v.release = v.build = 0;

        if ( argc > 0 && JSVAL_IS_INT(argv[0]) )
            v.major = JSVAL_TO_INT(argv[0]);

        if ( argc > 1 && JSVAL_IS_INT(argv[1]) )
            v.minor = JSVAL_TO_INT(argv[1]);

        if ( argc > 2 && JSVAL_IS_INT(argv[2]) )
            v.release = JSVAL_TO_INT(argv[2]);

        if ( argc > 3 && JSVAL_IS_INT(argv[3]) )
            v.build = JSVAL_TO_INT(argv[3]);
    }

    su_objToVers( cx, obj, &thisver );

    compval = su_compareVersions( &thisver, &v );
    *rval = INT_TO_JSVAL(compval);

    return JS_TRUE;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:52,代码来源:su_version.c

示例3: GoToTime

JSBool ADM_JSAvidemux::GoToTime(JSContext *cx, JSObject *obj, uintN argc, 
                                       jsval *argv, jsval *rval)
{// begin GoToTime
	ADM_JSAvidemux *p = (ADM_JSAvidemux *)JS_GetPrivate(cx, obj);
	// default return value
	*rval = BOOLEAN_TO_JSVAL(false);
	if(argc != 3)
		return JS_FALSE;
	if(JSVAL_IS_INT(argv[0]) == false || JSVAL_IS_INT(argv[1]) == false || JSVAL_IS_INT(argv[2]) == false)
		return JS_FALSE;
        enterLock();
	*rval = INT_TO_JSVAL(A_jumpToTime(JSVAL_TO_INT(argv[0]),JSVAL_TO_INT(argv[1]),JSVAL_TO_INT(argv[2]), 0));
	leaveLock();
	return JS_TRUE;
}// end GoToTime
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:15,代码来源:ADM_JSAvidemux.cpp

示例4: GoToTime

JSBool ADM_JSAvidemux::GoToTime(JSContext *cx, JSObject *obj, uintN argc, 
                                       jsval *argv, jsval *rval)
{// begin GoToTime
	ADM_JSAvidemux *p = (ADM_JSAvidemux *)JS_GetPrivate(cx, obj);
	// default return value
	*rval = BOOLEAN_TO_JSVAL(false);
	if(argc != 3)
		return JS_FALSE;
	if(JSVAL_IS_INT(argv[0]) == false || JSVAL_IS_INT(argv[1]) == false || JSVAL_IS_INT(argv[2]) == false)
		return JS_FALSE;
	jsrefcount nRefCount = JS_SuspendRequest(cx);
	*rval = INT_TO_JSVAL(A_jumpToTime(JSVAL_TO_INT(argv[0]),JSVAL_TO_INT(argv[1]),JSVAL_TO_INT(argv[2])));
	JS_ResumeRequest(cx,nRefCount);
	return JS_TRUE;
}// end GoToTime
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:15,代码来源:ADM_JSAvidemux.cpp

示例5: jsSetBits

static JSBool
jsSetBits( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval )
{
   *rval = JSVAL_FALSE ;
   
   jsPort_t *port = (jsPort_t *)JS_GetInstancePrivate( cx, obj, &jsSerialPortClass_, NULL );
   if( port )
   {
      if( ( 1 == argc ) && JSVAL_IS_INT( argv[0] ) )
      {
         int const bits = JSVAL_TO_INT( argv[0] );
         if( ( 5 <= bits ) && ( 8 >= bits ) )
         {
            struct termios termState;
            tcgetattr(port->getFd(),&termState);
            
            termState.c_cflag &= ~CSIZE ;
            termState.c_cflag |= csLengthMasks_[bits-5];
         
            int result = tcsetattr( port->getFd(), TCSANOW, &termState );
            if( 0 == result )
            {
               *rval = JSVAL_TRUE ;
            }
            else
               perror( "setBits" );
         }
         else
            JS_ReportError( cx, "unsupported character length" );
      }
      else
         JS_ReportError( cx, "Usage: scanner.setBits( 7|8 );" );
   }
   return JS_TRUE ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:35,代码来源:jsSerial.cpp

示例6: GetInstallVersionProperty

GetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
  nsIDOMInstallVersion *a = (nsIDOMInstallVersion*)JS_GetPrivate(cx, obj);

  // If there's no private data, this must be the prototype, so ignore
  if (nsnull == a) {
    return JS_TRUE;
  }

  if (JSVAL_IS_INT(id)) {
    switch(JSVAL_TO_INT(id)) {
      case INSTALLVERSION_MAJOR:
      {
        PRInt32 prop;
        if (NS_OK == a->GetMajor(&prop)) {
          *vp = INT_TO_JSVAL(prop);
        }
        else {
          return JS_FALSE;
        }
        break;
      }
      case INSTALLVERSION_MINOR:
      {
        PRInt32 prop;
        if (NS_OK == a->GetMinor(&prop)) {
          *vp = INT_TO_JSVAL(prop);
        }
        else {
          return JS_FALSE;
        }
        break;
      }
      case INSTALLVERSION_RELEASE:
      {
        PRInt32 prop;
        if (NS_OK == a->GetRelease(&prop)) {
          *vp = INT_TO_JSVAL(prop);
        }
        else {
          return JS_FALSE;
        }
        break;
      }
      case INSTALLVERSION_BUILD:
      {
        PRInt32 prop;
        if (NS_OK == a->GetBuild(&prop)) {
          *vp = INT_TO_JSVAL(prop);
        }
        else {
          return JS_FALSE;
        }
        break;
      }
    }
  }

  return JS_TRUE;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:60,代码来源:nsJSInstallVersion.cpp

示例7: unit_cancel

INT unit_cancel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{	
	CDebug cDbg("unit cancel");

	if(!GameReady())
		return JS_TRUE;

	if(argc == 1 && JSVAL_IS_INT(argv[0]))
	{
		jsint nType = JSVAL_TO_INT(argv[0]);

		if(nType == 0)
			D2CLIENT_CloseInteract();
		else if(nType == 1)
			D2CLIENT_CloseNPCInteract();
	}
	else if(D2CLIENT_GetCursorItem())
	{
		// Diablo drops an Item by using the Walk function.
		// Just perform a clickMap "click" and we drop it
		D2CLIENT_clickMap(0, 10, 10, 0x08);
	}

	return JS_TRUE;
}
开发者ID:ds-hwang,项目名称:d2bs,代码行数:25,代码来源:JSUnit.cpp

示例8: js_json_emit_jsval

static void
js_json_emit_jsval(JSContext *cx, jsval value, htsbuf_queue_t *out)
{
  char buf[100];
  if(JSVAL_IS_BOOLEAN(value)) {
    if(JSVAL_TO_BOOLEAN(value))
      htsbuf_append(out, "true", 4);
    else
      htsbuf_append(out, "false", 5);
  } else if(JSVAL_IS_INT(value)) {
    snprintf(buf, sizeof(buf), "%d", JSVAL_TO_INT(value));
    htsbuf_append(out, buf, strlen(buf));
  } else if(JSVAL_IS_DOUBLE(value)) {
    double dbl;
    if(JS_ValueToNumber(cx, value, &dbl) &&
       !my_double2str(buf, sizeof(buf), dbl))
      htsbuf_append(out, buf, strlen(buf));
    else
      htsbuf_append(out, "null", 4);
  } else if(JSVAL_IS_NULL(value)) {
    htsbuf_append(out, "null", 4);
  } else if(JSVAL_IS_STRING(value)) {
    js_json_emit_str(cx, value, out);
  } else if(JSVAL_IS_OBJECT(value)) {
    JSObject *obj = JSVAL_TO_OBJECT(value);
    JSClass *c = JS_GetClass(cx, obj);

    if(!strcmp(c->name, "XML"))   // Treat some classes special
      js_json_emit_str(cx, value, out);
    else {
      if(json_encode_from_object(cx, obj, out))
	htsbuf_append(out, "null", 4);
    }
  }
}
开发者ID:Rautz,项目名称:showtime,代码行数:35,代码来源:js_json.c

示例9: JSB_IOSiAP_paymentWithProduct

static JSBool JSB_IOSiAP_paymentWithProduct(JSContext *cx, uint32_t argc, jsval *vp)
{
    JSB_PRECONDITION2(argc > 0, cx, JS_FALSE, "Invalid number of arguments");
    jsval *argv = JS_ARGV(cx,vp);
    
    JSObject *obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
    IOSiAP_Bridge *bridge = (IOSiAP_Bridge *)JS_GetPrivate(obj);
    
    // safety check for type
    JSObject *productObj = JSVAL_TO_OBJECT(argv[0]);
    if (NULL == productObj) {
        JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(JS_FALSE));
        return JS_TRUE;
    }
    if (JS_FALSE == JS_InstanceOf(cx, productObj, JSB_Product_class, NULL)) {
        JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(JS_FALSE));
        return JS_TRUE;
    }
    IOSProduct *product = (IOSProduct *)JS_GetPrivate(productObj);
    
    int quantity = 1;
    if (argc > 1 && JSVAL_IS_INT(argv[1])) {
        quantity = JSVAL_TO_INT(argv[1]);
    }
    
    bridge->iap->paymentWithProduct(product, quantity);
    
    JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(JS_TRUE));
    return JS_TRUE;
}
开发者ID:1007650105,项目名称:cocos-docs,代码行数:30,代码来源:IOSiAP_JSB.cpp

示例10: PyUnicode_FromString

static PyObject *to_python_object(JSContext *context, jsval value) {
    if (JSVAL_IS_PRIMITIVE(value)) {
        if (JSVAL_IS_STRING(value)) {
            return PyUnicode_FromString(JS_EncodeString(context, JSVAL_TO_STRING(value)));
        } else if (JSVAL_IS_BOOLEAN(value)) {
            return PyBool_FromLong(JSVAL_TO_BOOLEAN(value));
        } else if (JSVAL_IS_INT(value)) {
            return PyLong_FromLong(JSVAL_TO_INT(value));
        } else if (JSVAL_IS_DOUBLE(value)) {
            return PyFloat_FromDouble(JSVAL_TO_DOUBLE(value));
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    } else {
        JSObject *obj = JSVAL_TO_OBJECT(value);
        if (JS_ObjectIsDate(context, obj)) {
            return to_python_datetime(context, obj);
        } else if (JS_IsArrayObject(context, obj)) {
            return to_python_list(context, obj);
        } else {
            return to_python_dict(context, obj);
        }
    }
}
开发者ID:jordanm,项目名称:spindly,代码行数:25,代码来源:spindly.c

示例11: node_setProperty

  static JSBool
  node_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
  {
    EJS_CHECK_CLASS(cx, obj, node_class);
    
    if (!JSVAL_IS_INT(id)) return JS_TRUE;
    jsint slot=JSVAL_TO_INT(id);

    dom::Node* nthis=(dom::Node *)JS_GetPrivate(cx,obj);
    if (!nthis) return JS_TRUE;
    
    switch (slot) {
    case NODE_VALUE:
      {
	dom::String* value=NULL;
	if (!jsToDomString(cx,*vp,value)) return JS_FALSE;
	try{
	  nthis->setNodeValue(value);
	}catch(const dom::DOMException &e){
	  EJS_THROW_ERROR(cx, obj, e.what());
	}
	break;
      }
    default:
      break;
    }
    return JS_TRUE;
  }
开发者ID:BackupTheBerlios,项目名称:egachine,代码行数:28,代码来源:ejsnode.cpp

示例12: NPT_COMPILER_UNUSED

NPT_Result
GPAC_GenericDevice::OnAction(PLT_ActionReference&          action,
                             const PLT_HttpRequestContext& context)
{
	NPT_COMPILER_UNUSED(context);

#ifdef GPAC_HAS_SPIDERMONKEY
	gf_mx_p(m_pMutex);
#endif
	PLT_ActionDesc &act_desc = action->GetActionDesc();
	NPT_String name = act_desc.GetName();
#ifdef GPAC_HAS_SPIDERMONKEY
	assert(!m_pSema);
#endif
	GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Action %s called (thread %d)\n", (char *) name, gf_th_id() ));

#ifdef GPAC_HAS_SPIDERMONKEY
	if (JSVAL_IS_NULL(act_proc)) {
		gf_mx_v(m_pMutex);
		return NPT_SUCCESS;
	}

	jsval argv[2];

	m_pUPnP->LockJavascript(GF_TRUE);

	JSObject *js_action = JS_NewObject(m_pUPnP->m_pJSCtx, &m_pUPnP->upnpDeviceClass._class, 0, 0);
	argv[0] = OBJECT_TO_JSVAL(js_action);
	SMJS_SET_PRIVATE(m_pUPnP->m_pJSCtx, js_action, this);

	act_ref = action;

	JS_DefineProperty(m_pUPnP->m_pJSCtx, js_action, "Name", STRING_TO_JSVAL( JS_NewStringCopyZ(m_pUPnP->m_pJSCtx, name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
	GPAC_Service *service = (GPAC_Service *) act_desc.GetService();
	JS_DefineProperty(m_pUPnP->m_pJSCtx, js_action, "Service", service->m_pObj ? OBJECT_TO_JSVAL( service->m_pObj) : JSVAL_NULL, 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
	JS_DefineFunction(m_pUPnP->m_pJSCtx, js_action, "GetArgument", upnp_action_get_argument, 1, 0);
	JS_DefineFunction(m_pUPnP->m_pJSCtx, js_action, "SendReply", upnp_action_send_reply, 1, 0);

	/*create a semaphore*/
	m_pSema = gf_sema_new(1, 0);

	jsval rval;
	JS_CallFunctionValue(m_pUPnP->m_pJSCtx, obj, act_proc, 1, argv, &rval);
	SMJS_SET_PRIVATE(m_pUPnP->m_pJSCtx, js_action, NULL);
	m_pUPnP->LockJavascript(GF_FALSE);

	if (JSVAL_IS_INT(rval) && (JSVAL_TO_INT(rval) != 0)) {
		action->SetError(JSVAL_TO_INT(rval), "Action Failed");
	}
	/*wait on the semaphore*/
	if (!gf_sema_wait_for(m_pSema, 10000)) {
		GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[UPnP] Reply processing to action %s timeout - sending incomplete reply)\n", (char *) name));
	}
	gf_sema_del(m_pSema);
	m_pSema = NULL;

	gf_mx_v(m_pMutex);
#endif
	return NPT_SUCCESS;
}
开发者ID:ARSekkat,项目名称:gpac,代码行数:60,代码来源:GenericDevice.cpp

示例13: perlarray_set

static JSBool
perlarray_set(
    JSContext *cx,
    JSObject *obj,
    jsval id,
    jsval *vp
) {
    dTHX;
    SV *ref = (SV *)JS_GetPrivate(cx, obj);
    AV *av = (AV *)SvRV(ref);

    PJS_ARRAY_CHECK

    if(JSVAL_IS_INT(id)) {
        IV ix = JSVAL_TO_INT(id);
        SV *sv;
        if(!PJS_ReflectJS2Perl(aTHX_ cx, *vp, &sv, 1)) {
            JS_ReportError(cx, "Failed to convert argument to Perl");
            return JS_FALSE;
        }
        if(!av_store(av, ix, sv)) {
	    if(SvRMAGICAL(av)) mg_set(sv);
	    sv_free(sv);
	}
    }
    
    return JS_TRUE;
}
开发者ID:gitpan,项目名称:JSP,代码行数:28,代码来源:PJS_PerlArray.c

示例14: perlarray_resolve

static JSBool
perlarray_resolve(
    JSContext *cx,
    JSObject *obj,
    jsval id,
    uintN flags,
    JSObject **objp
) {
    dTHX;
    SV *ref = (SV *)JS_GetPrivate(cx, obj);
    AV *av = (AV *)SvRV(ref);
    SV **v;
    int index;

    PJS_ARRAY_CHECK

    if(JSVAL_IS_STRING(id))
	return JS_TRUE;

    if(JSVAL_IS_INT(id)) {
	index = JSVAL_TO_INT(id);
	v = av_fetch(av, index, 0);
	if(v) {
	    JSString *str = JS_ValueToString(cx,id);
	    if(!JS_DefineProperty(cx, obj, JS_GetStringBytes(str),
	                          JSVAL_VOID, NULL, NULL, 0))
		return JS_FALSE;
	    *objp = obj;
	}
    }
    return JS_TRUE;
}
开发者ID:gitpan,项目名称:JSP,代码行数:32,代码来源:PJS_PerlArray.c

示例15: perlarray_get

static JSBool
perlarray_get(
    JSContext *cx,
    JSObject *obj,
    jsval id,
    jsval *vp
) {
    dTHX;
    SV *ref = (SV *)JS_GetPrivate(cx, obj);
    AV *av = (AV *)SvRV(ref);
    JSBool ok = JS_TRUE;

    PJS_ARRAY_CHECK

    if(JSVAL_IS_INT(id)) {
        I32 ix = JSVAL_TO_INT(id);
        SV **v;
	ENTER; SAVETMPS;
        v = av_fetch(av, ix, 0);
        if(v) {
	    if(SvGMAGICAL(*v)) mg_get(*v);
            ok = PJS_ReflectPerl2JS(aTHX_ cx, obj, sv_mortalcopy(*v), vp);
        }
        else {
            JS_ReportError(cx, "Failed to retrieve element at index: %d", ix);
            ok = JS_FALSE;
        }
	FREETMPS; LEAVE;
    }
    
    return ok;
}
开发者ID:gitpan,项目名称:JSP,代码行数:32,代码来源:PJS_PerlArray.c


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