示例#1
0
static JSBool JSB_Product_getProperty(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp)
{
    IOSProduct *product = (IOSProduct *)JS_GetPrivate(obj);
    jsval property;
    JS_IdToValue(cx, id, &property);
    switch (JSVAL_TO_INT(property))
    {
        case PROPERTY_PRODUCT_IDENTIFIER:
            vp.setString(JS_InternString(cx, product->productIdentifier.c_str()));
            break;
        case PROPERTY_PRODUCT_TITLE:
            vp.setString(JS_InternString(cx, product->localizedTitle.c_str()));
            break;
        case PROPERTY_PRODUCT_DESCRIPTION:
            vp.setString(JS_InternString(cx, product->localizedDescription.c_str()));
            break;
        case PROPERTY_PRODUCT_PRICE:
            vp.setString(JS_InternString(cx, product->localizedPrice.c_str()));
            break;
        case PROPERTY_PRODUCT_ISVALID:
            vp.setBoolean(product->isValid);
            break;
    }
    return JS_TRUE;
}
示例#2
0
NS_IMETHODIMP
SmsFilter::GetRead(JSContext* aCx, JS::MutableHandle<JS::Value> aRead)
{
  if (mData.read() == eReadState_Unknown) {
    aRead.setNull();
    return NS_OK;
  }

  aRead.setBoolean(mData.read());
  return NS_OK;
}
  virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue)
  {
    aValue.setUndefined();

    const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
    if (v.type() != BluetoothValue::Tbool) {
      BT_WARNING("Not a boolean!");
      SetError(NS_LITERAL_STRING("BluetoothReplyTypeError"));
      return false;
    }

    aValue.setBoolean(v.get_bool());
    return true;
  }