Ejemplo n.º 1
0
 bool MutableMessage::addScalarField(const char *field, const uint8_t &value) {
     auto e = createScalarField(m_field_allocator, field, value);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (tf::likely(result.second)) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 2
0
 Stmt* Parser::useStatement()
 {
     uint32_t pos = position();
     eat(T_Use);
     if (!(hd() == T_Identifier && identValue() == compiler->SYM_namespace))
         compiler->syntaxError(pos, SYNTAXERR_ILLEGAL_USE);
     eat(T_Identifier);
     Str* ns = identifier();
     return ALLOC(UseNamespaceStmt, (pos, ns));
 }
CommandResult::SharedConst TotalBalancesCommand::resultOk(
    string &totalBalancesStr) const
{
    return CommandResult::SharedConst(
        new CommandResult(
            identifier(),
            UUID(),
            200,
            totalBalancesStr));
}
Ejemplo n.º 4
0
 Stmt* Parser::useStatement()
 {
     uint32_t pos = position();
     eat(T_Use);
     if (!match(T_Namespace))
         compiler->syntaxError(pos, SYNTAXERR_ILLEGAL_USE);
     Str* ns = identifier();
     addOpenNamespace(ALLOC(NamespaceRef, (ns)));
     return ALLOC(EmptyStmt, ());
 }
Ejemplo n.º 5
0
inline JSValue DialogHandler::returnValue() const
{
    JSDOMWindow* globalObject = toJSDOMWindow(m_frame.get(), normalWorld(m_exec->globalData()));
    if (!globalObject)
        return jsUndefined();
    Identifier identifier(m_exec, "returnValue");
    PropertySlot slot;
    if (!JSGlobalObject::getOwnPropertySlot(globalObject, m_exec, identifier, slot))
        return jsUndefined();
    return slot.getValue(m_exec, identifier);
}
void ThreadIdentifierData::initialize(ThreadIdentifier id)
{
    ASSERT(!identifier());

#if !ENABLE(SAMSUNG_WEBKIT_PERFORMANCE_PATCH)
    // SAMSUNG CHANGE : Webkit Performance Patch Merge + r92154
    initializeKeyOnce();
    // SAMSUNG CHANGE : Webkit Performance Patch Merge -
#endif
    pthread_setspecific(m_key, new ThreadIdentifierData(id));
}
Ejemplo n.º 7
0
 CatchClause* Parser::catchClause()
 {
     eat (T_LeftParen);
     Str* catchvar_name = identifier();
     Type* catchvar_type_name = NULL;
     if (match(T_Colon))
         catchvar_type_name = typeExpression();
     eat (T_RightParen);
     Seq<Stmt*>* catchblock = statementBlock();
     return ALLOC(CatchClause, (catchvar_name, catchvar_type_name, catchblock));
 }
Ejemplo n.º 8
0
void Scanner::scanToken()
{
	char c = advance();
	switch (c) {
	case '(': addToken(LEFT_PAREN); break;
	case ')': addToken(RIGHT_PAREN); break;
	case '{': addToken(LEFT_BRACE); break;
	case '}': addToken(RIGHT_BRACE); break;
	case ',': addToken(COMMA); break;
	case '.': addToken(DOT); break;
	case '-': addToken(MINUS); break;
	case '+': addToken(PLUS); break;
	case ';': addToken(SEMICOLON); break;
	case '*': addToken(STAR); break;
	case '!': addToken(match('=') ? BANG_EQUAL : BANG); break;
	case '=': addToken(match('=') ? EQUAL_EQUAL : EQUAL); break;
	case '<': addToken(match('=') ? LESS_EQUAL : LESS); break;
	case '>': addToken(match('=') ? GREATER_EQUAL : GREATER); break;
	case '/':
		if (match('/'))
		{
			while (peek() != '\n' && !isAtEnd()) advance();
		}
		else
		{
			addToken(SLASH);
		}
		break;
	case ' ':
	case '\r':
	case '\t':
		// Ignore whitespace.                      
		break;

	case '\n':
		line_++;
		break;
	case '"': string(); break;
	default:
		if (isDigit(c))
		{
			number();
		}
		else if (isAlpha(c))
		{
			identifier();
		}
		else
		{
			error(line_, "Unexpected character.");
		}
		break;
	}
}
Ejemplo n.º 9
0
void LineEdit::checkContent()
{
    if (text().length()>=2 && currentBegin!=text().mid(0,2).toLower()) {
        currentBegin = text().mid(0,2).toLower();
        networkManager->sendGetStationsRequest(currentBegin,identifier());
        //qDebug()<<"id  "<<identifier();
    }

    //QUrl decode cyrillic letters automatically
    //networkManager->sendGetStationsRequest(QUrl::toPercentEncoding(currentBegin),identifier());
}
Ejemplo n.º 10
0
AST *
PreProcessor::expression()
{
	List<Token> exps;
	while (!tokenit.eof() && !tokenit.is(_PP_END)) {
		const Token &t = tokenit.get(0);
		switch (t.id) {
		case _IDENT: {
			bool replaced = identifier();
			if (!replaced) {
				exps.push_back(t);
			}
			continue;
		}
			//'defined' expression is pre-evaluated here
		case _PP_DEFINED: {
			tokenit.next();
			bool lparen = tokenit.eat(_LPAREN);
			if (!tokenit.is(_IDENT)){
				ERROR("'defined' error");
			}
			bool defined = isDefined(tokenit.val()->toString());
			tokenit.next();
			if (lparen && !tokenit.eat(_RPAREN)) {
				ERROR("'defined' error");
				return false;
			}
			Token newt;
			newt.id = _DECIMAL_CONSTANT;
			if (defined) {
				newt.val = new TokenInt("<defined 1>", 1);
			} else {
				newt.val = new TokenInt("<defined 0>", 0);
			}
			exps.push_back(newt);
			continue;
		}
		case _SPC:
			//don't push spaces
			break;
		default:
			exps.push_back(t);
		}
		tokenit.next();
	}
	DBG("expression %d", exps.size());
	ptokens(exps);
	DBG("---------");
	if (tokenit.is(_PP_END)) {
		tokenit.next();
	}
	
	return parser.parseConstantExpression(exps);
}
Ejemplo n.º 11
0
void Brick::hit()
{
    if (identifier() == "HiddenBrick" && !isVisible()) {
        show();
        ++m_game->m_remainingBricks;
    } else if (identifier() == "MultipleBrick3") {
        setIdentifier("MultipleBrick2");
        // TODO: make a convenience function out of the following two
        m_game->addScore(qRound(m_game->m_dScore));
        m_game->m_dScore = BRICK_SCORE;
    } else if (identifier() == "MultipleBrick2") {
        setIdentifier("MultipleBrick1");
        m_game->addScore(qRound(m_game->m_dScore));
        m_game->m_dScore = BRICK_SCORE;
    } else if (identifier() == "ExplodingBrick") {
        explode();
    } else if (identifier() != "UnbreakableBrick") {
        forcedHit();
    }
}
Ejemplo n.º 12
0
void Brick::forcedHit()
{
    if (m_deleted) return;
    
    if (identifier() == "ExplodingBrick") {
        explode();
    } else {
        handleDeletion();
    }
    hide();
}
Ejemplo n.º 13
0
	/// Handle the completion of a timer operation.
	void handleTimeout( const boost::system::error_code& e )
	{
		if ( !e )	{
			m_connHandler->signalOccured( ConnectionHandler::TIMEOUT );
			LOG_DEBUG << "Timeout on connection to " << identifier();

			nextOperation();
		}
		else	{
			assert( e == boost::asio::error::operation_aborted );
		}
	}
Ejemplo n.º 14
0
void TCPConnection::send(ByteArray message, std::chrono::milliseconds timeout) const {
    try {
        socket_->SendData((const int8_t*)message.data(), message.size(), static_cast<uint32_t>(timeout.count()));
    } catch (const IVDA::SocketConnectionException& err) {
        throw ConnectionClosedError("Connection to peer " + socket_->GetPeerAddress() + " lost during send operation (internal error: " +
                                        err.what() + ")",
                                    identifier(), __FILE__, __LINE__);
    } catch (const IVDA::SocketException& err) {
        std::string internalError = mocca::joinString(err.what(), ", ", err.internalError());
        throw NetworkError("Network error in send operation (internal error: " + internalError + ")", __FILE__, __LINE__);
    }
}
Ejemplo n.º 15
0
JSValue JSSubtleCrypto::encrypt(ExecState* exec)
{
    if (exec->argumentCount() < 3)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));

    auto algorithm = createAlgorithmFromJSValue(exec, exec->uncheckedArgument(0));
    if (!algorithm) {
        ASSERT(exec->hadException());
        return jsUndefined();
    }

    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(exec, algorithm->identifier(), exec->uncheckedArgument(0));
    if (!parameters) {
        ASSERT(exec->hadException());
        return jsUndefined();
    }

    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(exec->uncheckedArgument(1));
    if (!key)
        return throwTypeError(exec);

    if (!key->allows(CryptoKeyUsageEncrypt)) {
        m_impl->document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'encrypt'"));
        setDOMException(exec, NOT_SUPPORTED_ERR);
        return jsUndefined();
    }

    CryptoOperationData data;
    if (!cryptoOperationDataFromJSValue(exec, exec->uncheckedArgument(2), data)) {
        ASSERT(exec->hadException());
        return jsUndefined();
    }

    
    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(exec, globalObject());
    DeferredWrapper wrapper(exec, globalObject(), promiseDeferred);
    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
        wrapper.resolve(result);
    };
    auto failureCallback = [wrapper]() mutable {
        wrapper.reject(nullptr);
    };

    ExceptionCode ec = 0;
    algorithm->encrypt(*parameters, *key, data, WTF::move(successCallback), WTF::move(failureCallback), ec);
    if (ec) {
        setDOMException(exec, ec);
        return jsUndefined();
    }

    return promiseDeferred->promise();
}
/*!
    \qmlmethod bool FacebookAlbum::unlike()
    Initiates a "delete like" operation on the album.

    If the network request was started successfully, the function
    will return true and the status of the album will change to
    \c SocialNetwork::Busy.  Otherwise, the function will return
    false.
*/
bool FacebookAlbumInterface::unlike()
{
    Q_D(FacebookAlbumInterface);
    bool requestMade = request(IdentifiableContentItemInterface::Delete,
                               identifier(), QLatin1String("likes"));

    if (!requestMade)
        return false;

    d->action = FacebookInterfacePrivate::DeleteLikeAction;
    d->connectFinishedAndErrors();
    return true;
}
Ejemplo n.º 17
0
SVGGlyph SVGGlyphElement::buildGlyphIdentifier() const
{
    SVGGlyph identifier(buildGenericGlyphIdentifier(this));
    identifier.glyphName = fastGetAttribute(SVGNames::glyph_nameAttr);
    identifier.orientation = parseOrientation(fastGetAttribute(SVGNames::orientationAttr));
    identifier.arabicForm = parseArabicForm(fastGetAttribute(SVGNames::arabic_formAttr));

    String language = fastGetAttribute(SVGNames::langAttr);
    if (!language.isEmpty())
        identifier.languages = parseDelimitedString(language, ',');

    return identifier;
}
Ejemplo n.º 18
0
bool ResourceLoader::shouldUseCredentialStorage()
{
    if (!fastMallocSize(documentLoader()->applicationCacheHost()))
        CRASH();
    if (!fastMallocSize(documentLoader()->frame()))
        CRASH();

    if (m_options.allowCredentials == DoNotAllowStoredCredentials)
        return false;
    
    RefPtr<ResourceLoader> protector(this);
    return frameLoader()->client()->shouldUseCredentialStorage(documentLoader(), identifier());
}
Ejemplo n.º 19
0
	/// Handle completion of a read operation.
	void handleRead( const boost::system::error_code& e, std::size_t bytesTransferred )
	{
		setTimeout( 0 );
		if ( !e )	{
			LOG_TRACE << "Read " << bytesTransferred << " bytes from " << identifier();
			m_connHandler->networkInput( m_readBuffer, bytesTransferred );
		}
		else	{
			LOG_TRACE << "Read error: " << e.message();
			signalError( e );
		}
		nextOperation();
	}
Ejemplo n.º 20
0
JSValue JSWebKitSubtleCrypto::sign(ExecState& state)
{
    VM& vm = state.vm();
    auto scope = DECLARE_THROW_SCOPE(vm);

    if (state.argumentCount() < 3)
        return throwException(&state, scope, createNotEnoughArgumentsError(&state));

    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    ASSERT(scope.exception() || algorithm);
    if (!algorithm)
        return jsUndefined();

    auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(&state, algorithm->identifier(), state.uncheckedArgument(0));
    ASSERT(scope.exception() || parameters);
    if (!parameters)
        return jsUndefined();

    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
    if (!key)
        return throwTypeError(&state, scope);

    if (!key->allows(CryptoKeyUsageSign)) {
        wrapped().document()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("Key usages do not include 'sign'"));
        setDOMException(&state, NOT_SUPPORTED_ERR);
        return jsUndefined();
    }

    CryptoOperationData data;
    auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
    ASSERT(scope.exception() || success);
    if (!success)
        return jsUndefined();

    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
    auto promise = wrapper->promise();
    auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
        fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
    };
    auto failureCallback = [wrapper]() mutable {
        wrapper->reject(nullptr);
    };

    auto result = algorithm->sign(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
    if (result.hasException()) {
        propagateException(state, scope, result.releaseException());
        return { };
    }

    return promise;
}
TotalBalancesCommand::TotalBalancesCommand(
    const CommandUUID &uuid,
    const string &commandBuffer):

    BaseUserCommand(
        uuid,
        identifier())
{
    const auto minCommandLength = 2;
    if (commandBuffer.size() < minCommandLength) {
        throw ValueError("TotalBalancesCommand: "
                             "Can't parse command. Received command is to short.");
    }
    size_t tokenSeparatorPos = commandBuffer.find(kTokensSeparator);
    string gatewaysCountStr = commandBuffer.substr(
        0,
        tokenSeparatorPos);
    if (gatewaysCountStr.at(0) == '-') {
        throw ValueError("TotalBalancesCommand: "
                             "Can't parse command. 'count gateways' token can't be negative.");
    }
    try {
        mGatewaysCount = std::stoul(gatewaysCountStr);
    } catch (...) {
        throw ValueError("TotalBalancesCommand: "
                             "Can't parse command. Error occurred while parsing  'count gateways' token.");
    }
    if (mGatewaysCount == 0) {
        return;
    }
    mGateways.reserve(mGatewaysCount);
    size_t gatewayStartPoint = tokenSeparatorPos + 1;
    for (size_t idx = 0; idx < mGatewaysCount; idx++) {
        try {
            string hexUUID = commandBuffer.substr(
                gatewayStartPoint,
                NodeUUID::kHexSize);
            mGateways.push_back(
                boost::lexical_cast<uuids::uuid>(
                    hexUUID));
            gatewayStartPoint += NodeUUID::kHexSize + 1;
        } catch (...) {
            throw ValueError("TotalBalancesCommand: "
                                 "Can't parse command. Error occurred while parsing 'Gateway UUID' token.");
        }
    }
    if (gatewayStartPoint + 1 < commandBuffer.length()) {
        throw ValueError("TotalBalancesCommand: "
                             "Can't parse command. Disparity between command count gateways and real count gateways.");
    }
}
Ejemplo n.º 22
0
void term(){
	if(look == '*'){
		match("*");
		term();
		emitln("xor ebx, ebx");
		settype(reduceptr(current_type));
		STRSWITCH(current_type)
			STRCASE("short")
				emitln("mov bx, word [eax]");
			STRCASE("char")
				emitln("mov bl, byte [eax]");
			STRDEFAULT
				emitln("mov ebx, dword [eax]");
		STRSWITCHEND
		emitln("xchg eax, ebx");
	} else if(look == '('){
		match("(");
		emitln("push eax");
		expression();
		match(")");
	}

	else if(look == '"'){
		emitln("mov eax, %s", add_string(getstring('"')));
		current_type = "char*";
	}
	
	else if(look == '\''){
		match("'");
		emitln("mov eax, %d", look);
		getcharacter();
		match("'");
		current_type = "char";
	}

	else if(is_in(dynstring("%c", look), "+", "-", NULL)){
		emitln("push dword 0");
		operator();
	}

	else if(isalpha(look)){
		identifier();
	}

	else if(isdigit(look)){
		emitln("mov eax, %s", getnumber());
	}

	else
		expected("Number or variable");
}
Ejemplo n.º 23
0
void DataFlowAnalysis::run(Program *program)
{
    AnalyzerOptions *options = program->options;
    bool verbose = options->verbose();

    /* Set the PAG options as specified on the command line. */
    setPagOptions(*options);
    setPrefixedPagOptions(options, p_impl);

    /* Build the program's ICFG if necessary. */
    if (program->icfg == NULL)
        program->icfg = createICFG(program, options);

    /* Run this analysis. */
    if (verbose)
    {
        std::cout
            << "performing analysis " << identifier() << " ... "
            << std::flush;
    }
    TimingPerformance *nestedTimer
        = new TimingPerformance("Actual data-flow analysis "
                                + identifier() + ":");
    p_impl->analysisDoit(program->icfg);
    delete nestedTimer;
    if (verbose) std::cout << "done" << std::endl;

    /* Make results persistent. We always do this (by default) to avoid
     * problems with garbage collected results. */
    p_impl->makePersistent();

#if HAVE_PAG
    /* If requested, compute call strings from PAG's call string data, and
     * store them in the ICFG. */
    if (options->computeCallStrings())
        computeCallStrings(program);
#endif
}
Ejemplo n.º 24
0
int program(struct parser* p)
{
    lstring(p, ".SYNTAX");
    identifier(p);
    out2("ADR", p->id);

    while (st(p)) {}

    if (lstring(p, ".END")) {
        out1("END");
        return 1;
    }
    return 1;
}
Ejemplo n.º 25
0
std::string ConcreteProblem::getProblemIdentifier() const{
    integer problemSize = m_numberOfRow * m_numberOfColumn;
    char* buffer = (char*)malloc(problemSize);
    memset(buffer, '0', problemSize *sizeof(char));
    for (CellPtrs::const_iterator cPtrIter = m_freeCellPtrs.begin(); cPtrIter != m_freeCellPtrs.end();cPtrIter++)  {
        CellPtr cellPtr = *cPtrIter;
        integer row = cellPtr->row;
        integer column= cellPtr->column;
        buffer[row * m_numberOfColumn + column] = '1';
    }
    std::string identifier(buffer, problemSize);
    free(buffer);
    return identifier;
}
/*!
    \qmlmethod bool FacebookPhoto::unlike()
    Initiates a "delete like" operation on the photo.

    If the network request was started successfully, the function
    will return true and the status of the photo will change to
    \c SocialNetwork::Busy.  Otherwise, the function will return
    false.
*/
bool FacebookPhotoInterface::unlike()
{
    bool requestMade = request(IdentifiableContentItemInterface::Delete,
                               identifier(), QLatin1String("likes"));

    if (!requestMade)
        return false;

    f->action = FacebookInterfacePrivate::DeleteLikeAction;
    connect(f->dd->reply(), SIGNAL(finished()), f, SLOT(finishedHandler()));
    connect(f->dd->reply(), SIGNAL(error(QNetworkReply::NetworkError)), f->dd, SLOT(defaultErrorHandler(QNetworkReply::NetworkError)));
    connect(f->dd->reply(), SIGNAL(sslErrors(QList<QSslError>)), f->dd, SLOT(defaultSslErrorsHandler(QList<QSslError>)));
    return true;
}
Ejemplo n.º 27
0
static bool get(ExecState* exec, JSValue object, const String& keyPathElement, JSValue& result)
{
    if (object.isString() && keyPathElement == "length") {
        result = jsNumber(object.toString(exec)->length());
        return true;
    }
    if (!object.isObject())
        return false;
    Identifier identifier(&exec->globalData(), keyPathElement.utf8().data());
    if (!asObject(object)->hasProperty(exec, identifier))
        return false;
    result = asObject(object)->get(exec, identifier);
    return true;
}
Ejemplo n.º 28
0
void WebSocketChannel::disconnect()
{
    LOG(Network, "WebSocketChannel %p disconnect", this);
#if ENABLE(INSPECTOR)
    if (m_context)
        if (InspectorController* controller = m_context->inspectorController())
            controller->didCloseWebSocket(identifier());
#endif
    m_handshake.clearScriptExecutionContext();
    m_client = 0;
    m_context = 0;
    if (m_handle)
        m_handle->close();
}
Ejemplo n.º 29
0
    std::string DumbRelayConsumer::checkid_setup(const std::string &return_to,
                                                 const std::string &trust_root) {
        // construct check_id url.
        char *tmp;
        std::string redirect_url(openid_provider());
        if(redirect_url.find_first_of('?') != redirect_url.npos)
            redirect_url.push_back('&');
        else
            redirect_url.push_back('?');

        redirect_url.append("openid.mode=checkid_setup");
        
        // cURL handle used for escaping.
        CURL *curl = new_curl_handle();
        redirect_url.append("&openid.identity=");
        tmp = curl_easy_escape(curl, identifier().c_str(), identifier().size());
        redirect_url.append(tmp);
        curl_free(tmp);
        
        redirect_url.append("&openid.return_to=");
        tmp = curl_easy_escape(curl, return_to.c_str(), return_to.size());
        redirect_url.append(tmp);
        curl_free(tmp);
        
        if(trust_root.size() > 0) {
            redirect_url.append("&openid.trust_root=");
            tmp = curl_easy_escape(curl, trust_root.c_str(), trust_root.size());
            redirect_url.append(tmp);
            curl_free(tmp);
        }
        
        // Clean up after curl.
        curl_easy_cleanup(curl);        
        
        return redirect_url;
    }
Ejemplo n.º 30
0
void RenderCounter::destroyCounterNodes(RenderObject* owner)
{
    CounterMaps& maps = counterMaps();
    CounterMaps::iterator mapsIterator = maps.find(owner);
    if (mapsIterator == maps.end())
        return;
    CounterMap* map = mapsIterator->second.get();
    CounterMap::const_iterator end = map->end();
    for (CounterMap::const_iterator it = map->begin(); it != end; ++it) {
        AtomicString identifier(it->first.get());
        destroyCounterNodeWithoutMapRemoval(identifier, it->second.get());
    }
    maps.remove(mapsIterator);
    owner->setHasCounterNodeMap(false);
}