コード例 #1
0
void CheckVisitor::visit(NewExpressionNode* node)
{
    for ( auto param : node -> typeInfo().templateArgumentsInfo() )
    {
        if ( param.which() == 0 ) {
            boost::get< std::shared_ptr<ExprNode> >(param) -> accept(*this);
        }
    }

    auto tp = fromTypeInfo(node -> typeInfo(), node -> scope.get()).base();
    assert(tp -> isObjectType());
    auto type = static_cast<const ObjectType*>(tp);

    auto types = std::vector<VariableType> { };
    for ( const auto& param : node -> params() )
    {
        param -> accept(*this);
        types.emplace_back(param -> getType());
    }

    auto arguments = extractArguments(node -> params());
    auto constructor = type -> resolveMethod(type -> typeName(), types);

    node -> callInfo(checkCall(constructor, arguments));
}
コード例 #2
0
void
cmd_processOptions(cmdlineParser   const cpP,
                   int             const argc,
                   const char **   const argv, 
                   const char **   const errorP) {

    struct optionx * longopts;

    longopts = createLongOptsArray(cpP->optionDescArray, cpP->numOptions);

    if (longopts == NULL) 
        casprintf(errorP, "Unable to get memory for longopts array");
    else {
        int endOfOptions;
        unsigned int i;

        *errorP = NULL;

        /* Set up initial assumption:  No options present */

        for (i = 0; i < cpP->numOptions; ++i)
            cpP->optionDescArray[i].present = false;

        endOfOptions = false;  /* initial value */
            
        while (!endOfOptions && !*errorP) {
            int const opterr0 = 0;
                /* Don't let getopt_long_only() print an error message */
            unsigned int longoptsIndex;
            const char * unrecognizedOption;
            const char * optarg;
            
            getopt_long_onlyx(argc, (char**) argv, "", longopts, 
                              &longoptsIndex, opterr0,
                              &endOfOptions, &optarg, &unrecognizedOption);
                              
            if (unrecognizedOption)
                casprintf(errorP, "Unrecognized option: '%s'", 
                          unrecognizedOption);
            else {
                if (!endOfOptions)
                    processOption(&cpP->optionDescArray[longoptsIndex], optarg,
                                  errorP);
            }
        }
        if (!*errorP)
            extractArguments(cpP, argc, argv);

        free(longopts);
    }
}
コード例 #3
0
ファイル: EventHub.cpp プロジェクト: coral-framework/coral-qt
bool EventHub::eventFilter( QObject* watched, QEvent* event )
{
    assert( _filteredObjects[watched] );

    co::Any args[MAX_ARGS];
    extractArguments( event, args, MAX_ARGS );

    if( !_filteredObjects[watched]->onEvent( reinterpret_cast<co::int64>( watched ), event->type(),
            args[0], args[1], args[2], args[3], args[4], args[5] ) )
    {
        event->ignore();
        return true;
    }

    return false;
}
コード例 #4
0
CppFunction *CppFunction::create(int line, int column, const QString &fileName)
{
    const CPlusPlus::Function* fun = function(line, column, fileName );
    if (!fun)
        return 0;

    // The fun object might be destructed at any time, so we need to collect all the information.
    CppFunction* result = new CppFunction; // QtScript takes ownership
    result->m_name = extractName(fun);
    result->m_returnType = extractReturnType(fun);
    result->m_arguments = extractArguments(fun);
    result->m_isVirtual = fun->isVirtual();
    result->m_isOverride = fun->isOverride();
    result->m_isFinal = fun->isFinal();
    result->m_isVariadic = fun->isVariadic();
    result->m_isConst = fun->isConst();
    result->m_isVolatile = fun->isVolatile();
    result->m_isPureVirtual = fun->isPureVirtual();
    result->m_start = Position(fun->line(),fun->column());

    return result;
}
コード例 #5
0
void CheckVisitor::visit(VariableDeclarationNode* node)
{
    for ( auto param : node -> typeInfo().templateArgumentsInfo() )
    {
        if ( param.which() == 0 ) {
            boost::get< std::shared_ptr<ExprNode> >(param) -> accept(*this);
        }
    }

    if ( !node -> isField() )
    {
        auto types = std::vector<VariableType> { };
        for ( const auto& param : node -> constructorParams() )
        {
            param -> accept(*this);
            types.emplace_back(param -> getType());
        }

        if ( !node -> typeInfo().isRef() && node -> typeInfo().modifiers().empty() )
        {
            auto var_type = fromTypeInfo(node -> typeInfo(), node -> scope.get());
            assert(var_type.unqualified() -> isObjectType());

            auto struct_symbol = static_cast<const ObjectType*>(var_type.unqualified());

            auto arguments = extractArguments(node -> constructorParams());
            auto constructor = struct_symbol -> resolveMethod(struct_symbol -> typeName(), types);

            if ( constructor == nullptr ) {
                throw SemanticError("No constructor defined");
            }

            node -> callInfo(checkCall(constructor, arguments));
        }
    }
}