Beispiel #1
2
bool WFormModel::validateField(Field field)
{
  if (!isVisible(field))
    return true;

  FieldMap::iterator i = fields_.find(field);

  if (i != fields_.end()) {
    FieldData& d = i->second;

    if (d.validator)
      setValidation(field, d.validator->validate(asString(valueText(field))));
    else
      setValidation(field, Valid);

    return d.validation.state() == WValidator::Valid;
  } else
    return true;
}
Beispiel #2
0
void SetFieldValueAST::typeCheck(TypeChecker& checker) {
	mObjectRefExpression->typeCheck(checker);

	std::shared_ptr<Type> objRefType;

	if (auto varRef = std::dynamic_pointer_cast<VariableReferenceExpressionAST>(mObjectRefExpression)) {
		auto varSymbol = std::dynamic_pointer_cast<VariableSymbol>(mSymbolTable->find(varRef->name()));
		objRefType = checker.findType(varSymbol->variableType());
	} else if (auto arrayRef = std::dynamic_pointer_cast<ArrayAccessAST>(mObjectRefExpression)) {
		objRefType = arrayRef->expressionType(checker);
	} else {
		checker.typeError("Not implemented");
	}

	auto memberName = getMemberName();
	std::string objName = objRefType->name();

	if (!checker.objectExists(objName)) {
		checker.typeError(objRefType->name() + " is not an object type.");
	}

	auto& object = checker.getObject(objName);

	if (!object.fieldExists(memberName)) {
		checker.typeError("There exists no field '" + memberName + "' in the type '" + objRefType->name() + "'.");
	}

	mRightHandSide->typeCheck(checker);

	//Check rhs
	std::shared_ptr<Type> fieldType;

	if (std::dynamic_pointer_cast<ArrayAccessAST>(mMemberExpression)) {
		fieldType = std::dynamic_pointer_cast<ArrayType>(object.getField(memberName).type())->elementType();
	} else {
		fieldType = object.getField(memberName).type();
	}

	checker.assertSameType(
		*fieldType,
		*mRightHandSide->expressionType(checker),
		asString());
}
Beispiel #3
0
 string RinexMetHeader::convertObsType(const RinexMetHeader::RinexMetType& oneObs)
    throw(FFStreamError)
 {
    if      (oneObs == PR) return "PR";
    else if (oneObs == TD) return "TD";
    else if (oneObs == HR) return "HR";
    else if (oneObs == ZW) return "ZW";
    else if (oneObs == ZD) return "ZD";
    else if (oneObs == ZT) return "ZT";
    else if (oneObs == WD) return "WD";
    else if (oneObs == WS) return "WS";
    else if (oneObs == RI) return "RI";
    else if (oneObs == HI) return "HI";
    else
    {
       FFStreamError e("Bad obs type:" + asString(oneObs));
       GPSTK_THROW(e);
    } 
 }
Beispiel #4
0
void TextureItem::draw(const Rect& area, WidgetState state) const
{
  Drawer& drawer = m_layer.drawer();

  if (state == STATE_SELECTED)
  {
    const vec3 color = drawer.theme().textColors[STATE_SELECTED];
    drawer.fillRectangle(area, vec4(color, 1.f));
  }

  const float em = drawer.currentEM();

  const Rect textureArea(area.position, vec2(em * 3.f));
  drawer.blitTexture(textureArea, *m_texture);

  const Rect textArea(area.position + vec2(em * 3.5f, 0.f),
                      area.size - vec2(em, 0.f));
  drawer.drawText(textArea, asString().c_str(), LEFT_ALIGNED, state);
}
Beispiel #5
0
EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState* exec, JSCell* base, EncodedJSValue encodedProperty)
{
    JSValue property = JSValue::decode(encodedProperty);

    if (property.isUInt32())
        return getByVal(exec, base, property.asUInt32());
    if (property.isDouble()) {
        double propertyAsDouble = property.asDouble();
        uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble);
        if (propertyAsUInt32 == propertyAsDouble)
            return getByVal(exec, base, propertyAsUInt32);
    } else if (property.isString()) {
        if (JSValue result = base->fastGetOwnProperty(exec, asString(property)->value(exec)))
            return JSValue::encode(result);
    }

    Identifier ident(exec, property.toString(exec));
    return JSValue::encode(JSValue(base).get(exec, ident));
}
Beispiel #6
0
void Logger::write(Level level, const std::string& message) {
    if(level < level_) return;
    char buf[20];
    time_t t = time(0);
    struct tm tm;
    strftime(&buf[0], sizeof(buf), "%F %T", localtime_r(&t, &tm));

    std::stringstream s;
    s << asString(level) << " " << buf << " " << prefix_
      << "[" << getpid() << ":" << boost::this_thread::get_id() << "]: "
      << message << std::endl;

    if(log_.get() != -1) {
        while(log_.write(s.str().c_str(), s.str().size()) == -1);
    }
    if(isatty(2) == 1) { 
        ::write(2, s.str().c_str(), s.str().size()); 
    }
}
Beispiel #7
0
SEXP
RGDAL_GetDriver(SEXP sxpDriverName) {

  const char *pDriverName = asString(sxpDriverName);

  installErrorHandler();
  GDALDriver *pDriver = (GDALDriver *) GDALGetDriverByName(pDriverName);
  uninstallErrorHandlerAndTriggerError();

  if (pDriver == NULL)
    error("No driver registered with name: %s\n", pDriverName);
  
  SEXP sxpHandle = R_MakeExternalPtr((void *) pDriver,
				     mkChar("GDAL Driver"),
				     R_NilValue);

  return(sxpHandle);

}
Beispiel #8
0
/**
    \fn makeCouples
    \brief convert couples into char *first and *couples c, c can be null
*/
bool    TinyParams::makeCouples(CONFcouple **c)
{
	int nb = nbParamsLeft();

	if (!nb)
	{
		*c = NULL;
		return true;
	}

	const char **s;
  s=(const char **)admAlloca(sizeof(char *)*nb);

	for (int i = 0; i < nb; i++)
	{
		s[i] = asString();
	}

	return stringsToConfCouple(nb, c, s);
}
Beispiel #9
0
      /// Converts the CommonTime \a dt into a Rinex3 Clock time
      /// string for the header
   string Rinex3ClockHeader::writeTime(const CommonTime& dt) const
   {

      if (dt == CommonTime::BEGINNING_OF_TIME)
      {
         return string(36, ' ');
      }

      string line;
      CivilTime civTime(dt);
      line  = rightJustify(asString<short>(civTime.year), 4);
      line += rightJustify(asString<short>(civTime.month), 3);
      line += rightJustify(asString<short>(civTime.day), 3);
      line += rightJustify(asString<short>(civTime.hour), 3);
      line += rightJustify(asString<short>(civTime.minute), 3);
      line += rightJustify(asString(civTime.second, 6), 10);

      return line;

   }  // End of method 'Rinex3ClockHeader::writeTime(const CommonTime& dt)'
Beispiel #10
0
MapData::Entry* MapData::find(CallFrame* callFrame, KeyType key)
{
    if (key.value.isString()) {
        auto iter = m_stringKeyedTable.find(asString(key.value)->value(callFrame).impl());
        if (iter == m_stringKeyedTable.end())
            return 0;
        return &m_entries[iter->value];
    }
    if (key.value.isCell()) {
        auto iter = m_cellKeyedTable.find(key.value.asCell());
        if (iter == m_cellKeyedTable.end())
            return 0;
        return &m_entries[iter->value];
    }

    auto iter = m_valueKeyedTable.find(JSValue::encode(key.value));
    if (iter == m_valueKeyedTable.end())
        return 0;
    return &m_entries[iter->value];
}
Beispiel #11
0
JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue initiator)
{
    auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject);
    auto& jsPromise = *JSC::JSInternalPromiseDeferred::create(exec, &globalObject);
    auto deferred = DeferredPromise::create(globalObject, jsPromise);
    if (moduleKeyValue.isSymbol()) {
        deferred->reject(TypeError, ASCIILiteral("Symbol module key should be already fulfilled with the inlined resource."));
        return jsPromise.promise();
    }

    if (!moduleKeyValue.isString()) {
        deferred->reject(TypeError, ASCIILiteral("Module key is not Symbol or String."));
        return jsPromise.promise();
    }

    // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script

    URL completedURL(URL(), asString(moduleKeyValue)->value(exec));
    if (!completedURL.isValid()) {
        deferred->reject(TypeError, ASCIILiteral("Module key is a valid URL."));
        return jsPromise.promise();
    }

    ASSERT_WITH_MESSAGE(JSC::jsDynamicCast<JSElement*>(initiator), "Initiator should be an JSElement");
    auto* scriptElement = toScriptElementIfPossible(&JSC::jsCast<JSElement*>(initiator)->wrapped());
    ASSERT_WITH_MESSAGE(scriptElement, "Initiator should be ScriptElement.");

    if (auto* frame = m_document.frame()) {
        auto loader = CachedModuleScriptLoader::create(*this, deferred.get());
        m_loaders.add(loader.copyRef());
        if (!loader->load(*scriptElement, completedURL)) {
            loader->clearClient();
            m_loaders.remove(WTFMove(loader));

            deferred->reject(frame->script().moduleLoaderAlreadyReportedErrorSymbol());
            return jsPromise.promise();
        }
    }

    return jsPromise.promise();
}
Beispiel #12
0
SEXP
RGDAL_GetMetadata(SEXP sxpObj, SEXP sxpDomain) {

  void *pGDALObj = getGDALObjPtr(sxpObj);

  const char *domain = asString(sxpDomain);

  char **metadata = ((GDALMajorObject *)pGDALObj)->GetMetadata(domain);

  if (metadata == NULL) return(R_NilValue);

  metadata = CSLDuplicate(metadata);

  SEXP sxpMetadata, sxpNames;

  PROTECT(sxpMetadata = allocVector(VECSXP, CSLCount(metadata)));

  PROTECT(sxpNames = allocVector(STRSXP, CSLCount(metadata)));
  
  int i;
  for (i = 0; i < CSLCount(metadata); ++i) {

    const char *field = CSLGetField(metadata, i);

    char *tag = NULL;

    const char *value = CPLParseNameValue(field, &tag);

    SET_VECTOR_ELT(sxpMetadata, i, value ? mkChar(value) : mkChar(""));

    SET_STRING_ELT(sxpNames, i, tag ? mkChar(tag) : mkChar(""));

  }

  setAttrib(sxpMetadata, R_NamesSymbol, sxpNames);

  UNPROTECT(2);

  return(sxpMetadata);

}
bool Value::equals(Value& value)
{
	if (isNull() && value.isNull())
		return true;

	switch (_type)
	{
	case type_int:
		return (asInteger() == value.asInteger());
	case type_text:
		return (asString().compare(value.asString()) == 0);
	case type_float:
		return (asDouble() == value.asDouble());
	case type_bool:
		return (asBool() == value.asBool());
	case type_time:
		return (asTime() == value.asTime());
	}

	return false;
}
Beispiel #14
0
    virtual void fire()
    {
        boost::python::handle<> aHandle(
            PyEval_EvalCode(
                reinterpret_cast< PyCodeObject* >( theCompiledExpression.get() ),
                theGlobalNamespace.ptr(), theLocalNamespace.ptr() ) );

        boost::python::object aResultObject( aHandle );
        
        // do not use extract<double> for efficiency
        if( ! PyFloat_Check( aResultObject.ptr() ) )
        {
            THROW_EXCEPTION_INSIDE( SimulationError, 
                             asString() + ": "
                             "The expression gave a non-float object." );
        }

        const Real aFlux( PyFloat_AS_DOUBLE( aResultObject.ptr() ) );

        setFlux( aFlux );
    }
Beispiel #15
0
  std::string TypeInfo::asDemangledString() const
  {
#ifdef __GNUC__
    if (stdInfo) {
      std::string tmp;
      int status;
      char *demangled = abi::__cxa_demangle(stdInfo->name(), NULL, NULL, &status);
      if (status == 0) {
        tmp = demangled;
        free(demangled);
        return tmp;
      } else {
        return stdInfo->name();
      }
    } else {
      return customInfo;
    }
#else
    return asString();
#endif
  }
bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier)
{
    // typedef (Algorithm or DOMString) AlgorithmIdentifier;

    String algorithmName;

    if (value.isString())
        algorithmName = value.toString(exec)->value(exec);
    else if (value.isObject()) {
        if (value.getObject()->inherits(StringObject::info()))
            algorithmName = asString(asStringObject(value)->internalValue())->value(exec);
        else {
            // FIXME: This doesn't perform some checks mandated by WebIDL for dictionaries:
            // - null and undefined input should be treated as if all elements in the dictionary were undefined;
            // - undefined elements should be treated as having a default value, or as not present if there isn't such;
            // - RegExp and Date objects cannot be converted to dictionaries.
            //
            // This is partially because we don't implement it elsewhere in WebCore yet, and partially because
            // WebCrypto doesn't yet clearly specify what to do with non-present values in most cases anyway.

            JSDictionary dictionary(exec, value.getObject());
            dictionary.get("name", algorithmName);
        }
    }

    if (exec->hadException())
        return false;

    if (!algorithmName.containsOnlyASCII()) {
        throwSyntaxError(exec);
        return false;
    }

    if (!CryptoAlgorithmRegistry::singleton().getIdentifierForName(algorithmName, algorithmIdentifier)) {
        setDOMException(exec, NOT_SUPPORTED_ERR);
        return false;
    }

    return true;
}
Beispiel #17
0
void JSValue::dumpForBacktrace(PrintStream& out) const
{
    if (!*this)
        out.print("<JSValue()>");
    else if (isInt32())
        out.printf("%d", asInt32());
    else if (isDouble())
        out.printf("%lf", asDouble());
    else if (isCell()) {
        if (asCell()->inherits(*asCell()->vm(), JSString::info())) {
            JSString* string = asString(asCell());
            const StringImpl* impl = string->tryGetValueImpl();
            if (impl)
                out.print("\"", impl, "\"");
            else
                out.print("(unresolved string)");
        } else if (asCell()->inherits(*asCell()->vm(), Structure::info())) {
            out.print("Structure[ ", asCell()->structure()->classInfo()->className);
#if USE(JSVALUE64)
            out.print(" ID: ", asCell()->structureID());
#endif
            out.print("]: ", RawPointer(asCell()));
        } else {
            out.print("Cell[", asCell()->structure()->classInfo()->className);
#if USE(JSVALUE64)
            out.print(" ID: ", asCell()->structureID());
#endif
            out.print("]: ", RawPointer(asCell()));
        }
    } else if (isTrue())
        out.print("True");
    else if (isFalse())
        out.print("False");
    else if (isNull())
        out.print("Null");
    else if (isUndefined())
        out.print("Undefined");
    else
        out.print("INVALID");
}
Beispiel #18
0
bool VirtualValue::operator>=(const VirtualValue& that) const
{
   ASSERT(!isArray() && !isObject() && !isBoolean());
   ASSERT(mKind == that.mKind);

   switch ( mKind )
   {
      case eNumber:
         return asNumber() >= that.asNumber();

      case eReal:
         return asReal() >= that.asReal();

      case eChar:
         return asChar() >= that.asChar();

      case eString:
         return asString() >= that.asString();
   }

   return false;
}
Beispiel #19
0
numeric Item::forceNumeric() const
{
   switch( type() ) {
      case FLC_ITEM_INT:
         return (numeric) asInteger();

      case FLC_ITEM_NUM:
         return asNumeric();

      case FLC_ITEM_RANGE:
         return (numeric) asRangeStart();

      case FLC_ITEM_STRING:
      {
         double tgt;
         if ( asString()->parseDouble( tgt ) )
            return tgt;
         return 0.0;
      }
   }
   return 0.0;
}
Beispiel #20
0
Variable const* System::findSizeVariable() const
{
    try
    {
        return getVariable( "SIZE" );
    }
    catch( NotFound const& )
    {
        System const* const aSuperSystem( getSuperSystem() );

        // Prevent infinite looping.    But this shouldn't happen.
        if( aSuperSystem == this )
        {
            THROW_EXCEPTION_INSIDE( UnexpectedError, 
                                    asString() + ": while trying get a SIZE "
                                    "variable, supersystem == this. "
                                    "Probably a bug." );
        }

        return aSuperSystem->findSizeVariable();
    }
}
Beispiel #21
0
	int operator()()
	{
		js::mValue v;
		string s = asString(contents("../../tests/rlptest.json"));
		js::read_string(s, v);
		bool passed = true;
		for (auto& i: v.get_obj())
		{
			js::mObject& o = i.second.get_obj();
			cnote << i.first;
			RLPStream s;
			buildRLP(o["in"], s);
			if (!o["out"].is_null() && o["out"].get_str() != toHex(s.out()))
			{
				cwarn << "Test failed.";
				cwarn << "Test says:" << o["out"].get_str();
				cwarn << "Impl says:" << toHex(s.out());
				passed = false;
			}
		}
		return passed ? 0 : 1;
	}
Beispiel #22
0
int64 Item::forceInteger() const
{
   switch( type() ) {
      case FLC_ITEM_INT:
         return asInteger();

      case FLC_ITEM_NUM:
         return (int64) asNumeric();

      case FLC_ITEM_RANGE:
         return (int64)asRangeStart();

      case FLC_ITEM_STRING:
      {
         int64 tgt;
         if ( asString()->parseInt( tgt ) )
            return tgt;
         return 0;
      }
   }
   return 0;
}
Beispiel #23
0
SEXP
RGDAL_SetCategoryNames(SEXP sxpRasterBand, SEXP sxpNames) {

  GDALRasterBand *pRasterBand = getGDALRasterPtr(sxpRasterBand);

  char **nameList = NULL;

  int i;
  installErrorHandler();
  for (i = 0; i < length(sxpNames); ++i)
    nameList = CSLAddString(nameList, asString(sxpNames, i));
  uninstallErrorHandlerAndTriggerError();

  installErrorHandler();
  CPLErr err = pRasterBand->SetCategoryNames(nameList);

  if (err == CE_Failure) warning("Failed to set category names");
  uninstallErrorHandlerAndTriggerError();

  return(sxpRasterBand);

}
Beispiel #24
0
SEXP
RGDAL_CloseDataset(SEXP sxpDataset) {


  SEXP sxpHandle = getObjHandle(sxpDataset);

  if (sxpHandle == NULL) return(R_NilValue);

  const char *classname = asString(getAttrib(sxpDataset, R_ClassSymbol));

  if (strcmp(classname, "GDALTransientDataset") == 0) {
    
    RGDAL_DeleteHandle(sxpHandle);

  } else {

    RGDAL_CloseHandle(sxpHandle);
  }

  return(R_NilValue);

}
   // - LuaValue::operator== ---------------------------------------------------
   bool LuaValue::operator== (const LuaValue& rhs) const
   {
      std::string lhsTypeName = typeName();
      std::string rhsTypeName = rhs.typeName();

      if (typeName() != rhs.typeName())
         return false;
      else switch (type())
      {
         case LUA_TNIL:
            return true;

         case LUA_TBOOLEAN:
            return asBoolean() == rhs.asBoolean();

         case LUA_TNUMBER:
            return asNumber() == rhs.asNumber();

         case LUA_TSTRING:
            return asString() == rhs.asString();

         case LUA_TTABLE:
            return asTable() == rhs.asTable();

         case LUA_TFUNCTION:
            return asFunction() == rhs.asFunction();

         case LUA_TUSERDATA:
            return asUserData() == rhs.asUserData();

         default:
         {
            assert(
               false
               && "Invalid type found in a call to 'LuaValue::operator==()'.");
            return 0; // make compilers happy
         }
      }
   }
Beispiel #26
0
   string FileSpec::convertFileSpecType(const FileSpecType fst)
      throw(FileSpecException)
   {
      if (fst == station)          return string("n");
      else if (fst == receiver)    return string("r");
      else if (fst == prn)         return string("p");
      else if (fst == selected)    return string("t");
      else if (fst == sequence)    return string("I");
      else if (fst == version)     return string("v");
      else if (fst == fixed)       return string("");
      else if (fst == clock)       return string("k");
      else if (fst == text)        return string("x");

      else if (fst == year)        return string("y");
      else if (fst == month)       return string("m");
      else if (fst == dayofmonth)  return string("d");
      else if (fst == hour)        return string("H");
      else if (fst == minute)      return string("M");
      else if (fst == second)      return string("S");
      else if (fst == fsecond)     return string("f");
      else if (fst == gpsweek)     return string("G");
      else if (fst == fullgpsweek) return string("F");
      else if (fst == gpssecond)   return string("g");
      else if (fst == mjd)         return string("Q");
      else if (fst == dayofweek)   return string("w");
      else if (fst == day)         return string("j");
      else if (fst == doysecond)   return string("s");
      else if (fst == zcount)      return string("Z");
      else if (fst == zcountfloor) return string("z");
      else if (fst == unixsec)     return string("U");
      else if (fst == unixusec)    return string("u");
      else if (fst == fullzcount)  return string("C");
      else
      {
         FileSpecException fse("Unknown FileSpecType: " + asString(fst));
         GPSTK_THROW(fse);
      }
   }
Animation AnimationLoader::loadFromResources(const Resources::ResourcePack& resourcePack)
	{
	auto atlasResource = resourcePack.resource("atlas");
	Texture atlas(atlasResource);
	auto configResource = resourcePack.resource("config");
	ConfigReader reader(configResource.asString());
	unsigned frames = reader.getInt("Frames");
	if (frames == 1)
		return Animation(atlas);

	int frameDuration = reader.getInt("FrameDuration");
	std::vector<Rectangle> frameRects;
	frameRects.reserve(frames);
	for (unsigned i = 0; i < frames; ++i)
		{
		String rectName = String("Rect") + String::fromInt(i + 1);
		std::vector<String> rectCoords = reader.getArray(rectName);
		int x = rectCoords[0].toInt(), y = rectCoords[1].toInt();
		unsigned w = rectCoords[2].toInt(), h = rectCoords[3].toInt();
		frameRects.emplace_back(x, y, w, h);
		}
	return Animation(atlas, frameRects, std::chrono::milliseconds(frameDuration));
	}
Beispiel #28
0
bool Item::isTrue() const
{
   switch( dereference()->type() )
   {
      case FLC_ITEM_BOOL:
         return asBoolean() != 0;

      case FLC_ITEM_INT:
         return asInteger() != 0;

      case FLC_ITEM_NUM:
         return asNumeric() != 0.0;

      case FLC_ITEM_RANGE:
         return asRangeStart() != asRangeEnd() || asRangeIsOpen();

      case FLC_ITEM_STRING:
         return asString()->size() != 0;

      case FLC_ITEM_ARRAY:
         return asArray()->length() != 0;

      case FLC_ITEM_DICT:
         return asDict()->length() != 0;

      case FLC_ITEM_FUNC:
      case FLC_ITEM_OBJECT:
      case FLC_ITEM_CLASS:
      case FLC_ITEM_METHOD:
      case FLC_ITEM_MEMBUF:
      case FLC_ITEM_LBIND:
         // methods are always filled, so they are always true.
         return true;
   }

   return false;
}
Beispiel #29
0
EncodedJSValue JIT_OPERATION operationGetByVal(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty)
{
    VM& vm = exec->vm();
    NativeCallFrameTracer tracer(&vm, exec);
    
    JSValue baseValue = JSValue::decode(encodedBase);
    JSValue property = JSValue::decode(encodedProperty);

    if (LIKELY(baseValue.isCell())) {
        JSCell* base = baseValue.asCell();

        if (property.isUInt32()) {
            return getByVal(exec, base, property.asUInt32());
        } else if (property.isDouble()) {
            double propertyAsDouble = property.asDouble();
            uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble);
            if (propertyAsUInt32 == propertyAsDouble && isIndex(propertyAsUInt32))
                return getByVal(exec, base, propertyAsUInt32);
        } else if (property.isString()) {
            Structure& structure = *base->structure(vm);
            if (JSCell::canUseFastGetOwnProperty(structure)) {
                if (AtomicStringImpl* existingAtomicString = asString(property)->toExistingAtomicString(exec)) {
                    if (JSValue result = base->fastGetOwnProperty(vm, structure, existingAtomicString))
                        return JSValue::encode(result);
                }
            }
        }
    }

    baseValue.requireObjectCoercible(exec);
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    auto propertyName = property.toPropertyKey(exec);
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    return JSValue::encode(baseValue.get(exec, propertyName));
}
Beispiel #30
0
zmqpp::message reader::Json::read() {
    zmqpp::message msg;
    msg << target;
    ::Json::Value value;
    ::Json::Reader reader;
    if (!reader.parse(Plain::read_input_str(), value)) {
        throw std::runtime_error(reader.getFormatedErrorMessages());
    }
    if (!value.isArray()) {
        throw std::runtime_error("Must be array");
    }
    for (size_t i = 0; i < value.size(); ++i) {
        auto val = value.get(i, "");
        std::string param = (val.isString() ? val.asString() : val.toStyledString());
        if (!val.isString()) {
            if (verbose) {
                std::cerr << "Item #" << i << " is not string!" << std::endl;
            }
            param = trim_newline(param);
        }
        msg << param;
    }
    return msg;
}