void set(const std::string &string) {
     if (string.empty()) {
         m_value.SetEmptyString();
     }
     else {
         m_value.Set(Nan::New(string).ToLocalChecked());
     }
 }
Beispiel #2
0
void StringCache::setReturnValueFromStringSlow(v8::ReturnValue<v8::Value> returnValue, StringImpl* stringImpl)
{
    if (!stringImpl->length()) {
        returnValue.SetEmptyString();
        return;
    }

    UnsafePersistent<v8::String> cachedV8String = m_stringCache.get(stringImpl);
    if (!cachedV8String.isEmpty()) {
        m_lastStringImpl = stringImpl;
        m_lastV8String = cachedV8String;
        returnValue.Set(*cachedV8String.persistent());
        return;
    }

    returnValue.Set(createStringAndInsertIntoCache(stringImpl, returnValue.GetIsolate()));
}
void StringCache::setReturnValueFromStringSlow(v8::ReturnValue<v8::Value> returnValue, StringImpl* stringImpl)
{
    if (!stringImpl->length()) {
        returnValue.SetEmptyString();
        return;
    }

    StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_stringCache.GetReference(stringImpl);
    if (!cachedV8String.IsEmpty()) {
        m_lastStringImpl = stringImpl;
        m_lastV8String = cachedV8String;
        m_lastV8String.SetReturnValue(returnValue);
        return;
    }

    returnValue.Set(createStringAndInsertIntoCache(returnValue.GetIsolate(), stringImpl));
}
 void set(uint32_t number) {
     m_value.Set(number);
 }
 void set(double number) {
     m_value.Set(number);
 }
 void set(bool boolean) {
     m_value.Set(boolean);
 }
 void set(const v8::Local<v8::Value> &value) {
     m_value.Set(value);
 }