void tst_qnearfieldtagtype2::testSequence()
{
    tester.touchTarget();
    QByteArray uid = tester.target->uid();
    QVERIFY(!uid.isEmpty());

    OperationList rawCommandList;
    const char data[] = {0,1,2,3};
    QByteArray blockData;
    blockData.append(data, sizeof(data));

    for (int i = 4; i < 8; ++i)
    {
        NfcTagRawCommandOperationType2 * op1 = new NfcTagRawCommandOperationType2(tester.target);
        op1->setWriteBlock(i, blockData);
        op1->setExpectedOkSignal();
        op1->setExpectedResponse(QVariant(true));

        if (i == 6)
        {
            op1->setWaitOperation(NfcTagRawCommandOperationCommon::EWaitTrue);
        }
        rawCommandList.append(op1);
    }

    QList<QByteArray> cmdList;
    QByteArray command;
    command.append(char(0xff)); // Invalid command
    command.append(char(0xff));
    command.append(char(0xff));
    command.append(char(0xff));
    command.append(char(0xff));
    command.append(char(0xff));
    cmdList.append(command);
    cmdList.append(command);

    QVariantList expectRsp;
    expectRsp.push_back(QVariant());
    expectRsp.push_back(QVariant());

    NfcTagSendCommandsCommon * op7 = new NfcTagSendCommandsCommon(tester.target);
    op7->SetCommandLists(cmdList);
    op7->setExpectedErrorSignal(QNearFieldTarget::InvalidParametersError);
    op7->SetExpectedResponse(expectRsp);
    op7->setWaitOperation(NfcTagRawCommandOperationCommon::EWaitFalse);
    rawCommandList.append(op7);

    tester.testSequence(rawCommandList);
    qDeleteAll(rawCommandList);

    tester.removeTarget();
}
Exemplo n.º 2
0
bool
CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
    string scoped = p->scoped();
    string name = getName(p);
    string type = getTypeVar(p);
    string abs = getAbsolute(p, _ns);
    string prxName = getName(p, "Prx");
    string prxType = getTypeVar(p, "Prx");
    string prxAbs = getAbsolute(p, _ns, "", "Prx");
    ClassList bases = p->bases();
    ClassDefPtr base;
    OperationList ops = p->operations();
    OperationList::iterator oli;
    DataMemberList members = p->dataMembers();
    bool isInterface = p->isInterface();
    bool isAbstract = isInterface || p->allOperations().size() > 0; // Don't use isAbstract() - see bug 3739

    startNamespace(p);

    //
    // Define the class.
    //
    if(isInterface)
    {
        _out << sp << nl << "if(!interface_exists('" << escapeName(abs) << "'))";
        _out << sb;
        _out << nl << "interface " << name;
        if(!bases.empty())
        {
            _out << " extends ";
            for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
            {
                if(q != bases.begin())
                {
                    _out << ", ";
                }
                _out << getAbsolute(*q, _ns);
            }
        }
        _out << sb;
        for(oli = ops.begin(); oli != ops.end(); ++oli)
        {
            _out << nl << "public function " << fixIdent((*oli)->name()) << '(';
            ParamDeclList params = (*oli)->parameters();
            for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q)
            {
                if(q != params.begin())
                {
                    _out << ", ";
                }
                _out << '$' << fixIdent((*q)->name());
            }
            _out << ");";
        }
        _out << eb;
    }
    else
    {
        _out << sp << nl << "if(!class_exists('" << escapeName(abs) << "'))";
        _out << sb;
        _out << nl;
        if(isAbstract)
        {
            _out << "abstract ";
        }
        _out << "class " << name;
        if(!bases.empty() && !bases.front()->isInterface())
        {
            base = bases.front();
            bases.pop_front();
        }
        if(base)
        {
            _out << " extends " << getAbsolute(base, _ns);
        }
        else
        {
            if(!p->isLocal())
            {
                _out << " extends " << scopedToName("::Ice::ObjectImpl", _ns);
            }
        }
        if(!bases.empty())
        {
            _out << " implements ";
            for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
            {
                if(q != bases.begin())
                {
                    _out << ", ";
                }
                _out << getAbsolute(*q, _ns);
            }
        }

        _out << sb;

        //
        // __construct
        //
        _out << nl << "public function __construct(";
        MemberInfoList allMembers;
        collectClassMembers(p, allMembers, false);
        writeConstructorParams(allMembers);
        _out << ")";
        _out << sb;
        if(base)
        {
            _out << nl << "parent::__construct(";
            int count = 0;
            for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
            {
                if(q->inherited)
                {
                    if(count)
                    {
                        _out << ", ";
                    }
                    _out << '$' << q->fixedName;
                    ++count;
                }
            }
            _out << ");";
        }
        {
            for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
            {
                if(!q->inherited)
                {
                    writeAssign(*q);
                }
            }
        }
        _out << eb;

        if(!ops.empty())
        {
            _out << sp;
            for(oli = ops.begin(); oli != ops.end(); ++oli)
            {
                _out << nl << "abstract public function " << fixIdent((*oli)->name()) << '(';
                ParamDeclList params = (*oli)->parameters();
                for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q)
                {
                    if(q != params.begin())
                    {
                        _out << ", ";
                    }
                    _out << '$' << fixIdent((*q)->name());
                }
                _out << ");";
            }
        }

        if(!p->isLocal())
        {
            //
            // ice_staticId
            //
            _out << sp << nl << "public static function ice_staticId()";
            _out << sb;
            _out << nl << "return '" << scoped << "';";
            _out << eb;
        }

        //
        // __toString
        //
        _out << sp << nl << "public function __toString()";
        _out << sb;
        _out << nl << "global " << type << ';';
        _out << nl << "return IcePHP_stringify($this, " << type << ");";
        _out << eb;

        if(!members.empty())
        {
            _out << sp;
            bool isProtected = p->hasMetaData("protected");
            for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
            {
                _out << nl;
                if(isProtected || (*q)->hasMetaData("protected"))
                {
                    _out << "protected ";
                }
                else
                {
                    _out << "public ";
                }
                _out << "$" << fixIdent((*q)->name()) << ";";
            }
        }

        _out << eb; // End of class.
    }

    //
    // Define the proxy class.
    //
    if(!p->isLocal())
    {
        _out << sp << nl << "class " << prxName << "Helper";
        _out << sb;

        _out << sp << nl << "public static function checkedCast($proxy, $facetOrCtx=null, $ctx=null)";
        _out << sb;
        _out << nl << "return $proxy->ice_checkedCast('" << scoped << "', $facetOrCtx, $ctx);";
        _out << eb;

        _out << sp << nl << "public static function uncheckedCast($proxy, $facet=null)";
        _out << sb;
        _out << nl << "return $proxy->ice_uncheckedCast('" << scoped << "', $facet);";
        _out << eb;

        _out << eb;
    }

    if(_classHistory.count(scoped) == 0 && p->canBeCyclic())
    {
        //
        // Emit a forward declaration for the class in case a data member refers to this type.
        //
        _out << sp << nl << type << " = IcePHP_declareClass('" << scoped << "');";
    }

    //
    // Emit the type information.
    //
    _out << sp << nl << type << " = IcePHP_defineClass('" << scoped << "', '" << escapeName(abs) << "', "
         << (isAbstract ? "true" : "false") << ", ";
    if(!base)
    {
        _out << "$Ice__t_Object";
    }
    else
    {
        _out << getTypeVar(base);
    }
    _out << ", ";
    //
    // Interfaces
    //
    if(!bases.empty())
    {
        _out << "array(";
        for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
        {
            if(q != bases.begin())
            {
                _out << ", ";
            }
            _out << getTypeVar(*q);
        }
        _out << ')';
    }
    else
    {
        _out << "null";
    }
    _out << ", ";
    //
    // Members
    //
    // Data members are represented as an array:
    //
    //   ('MemberName', MemberType)
    //
    // where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type.
    //
    if(!members.empty())
    {
        _out << "array(";
        for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
        {
            if(q != members.begin())
            {
                _out << ',' << nl;
            }
            _out.inc();
            _out << nl << "array('" << fixIdent((*q)->name()) << "', ";
            writeType((*q)->type());
            _out << ')';
            _out.dec();
        }
        _out << ')';
    }
    else
    {
        _out << "null";
    }
    _out << ");";

    if(!p->isLocal())
    {
        _out << sp << nl << prxType << " = IcePHP_defineProxy(" << type << ");";

        //
        // Define each operation. The arguments to IcePHP_defineOperation are:
        //
        // $ClassType, 'opName', Mode, SendMode, (InParams), (OutParams), ReturnType, (Exceptions)
        //
        // where InParams and OutParams are arrays of type descriptions, and Exceptions
        // is an array of exception type ids.
        //
        if(!ops.empty())
        {
            _out << sp;
            for(oli = ops.begin(); oli != ops.end(); ++oli)
            {
                ParamDeclList params = (*oli)->parameters();
                ParamDeclList::iterator t;
                int count;

                _out << nl << "IcePHP_defineOperation(" << type << ", '" << (*oli)->name() << "', "
                     << getOperationMode((*oli)->mode(), _ns) << ", " << getOperationMode((*oli)->sendMode(), _ns)
                     << ", ";
                for(t = params.begin(), count = 0; t != params.end(); ++t)
                {
                    if(!(*t)->isOutParam())
                    {
                        if(count == 0)
                        {
                            _out << "array(";
                        }
                        else if(count > 0)
                        {
                            _out << ", ";
                        }
                        writeType((*t)->type());
                        ++count;
                    }
                }
                if(count > 0)
                {
                    _out << ')';
                }
                else
                {
                    _out << "null";
                }
                _out << ", ";
                for(t = params.begin(), count = 0; t != params.end(); ++t)
                {
                    if((*t)->isOutParam())
                    {
                        if(count == 0)
                        {
                            _out << "array(";
                        }
                        else if(count > 0)
                        {
                            _out << ", ";
                        }
                        writeType((*t)->type());
                        ++count;
                    }
                }
                if(count > 0)
                {
                    _out << ')';
                }
                else
                {
                    _out << "null";
                }
                _out << ", ";
                TypePtr returnType = (*oli)->returnType();
                if(returnType)
                {
                    writeType(returnType);
                }
                else
                {
                    _out << "null";
                }
                _out << ", ";
                ExceptionList exceptions = (*oli)->throws();
                if(!exceptions.empty())
                {
                    _out << "array(";
                    for(ExceptionList::iterator u = exceptions.begin(); u != exceptions.end(); ++u)
                    {
                        if(u != exceptions.begin())
                        {
                            _out << ", ";
                        }
                        _out << getTypeVar(*u);
                    }
                    _out << ')';
                }
                else
                {
                    _out << "null";
                }
                _out << ");";
            }
        }
    }

    _out << eb;

    endNamespace();

    if(_classHistory.count(scoped) == 0)
    {
        _classHistory.insert(scoped); // Avoid redundant declarations.
    }

    return false;
}
Exemplo n.º 3
0
bool
Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
{
    string scoped = p->scoped();
    string name = fixIdent(p->name(), IdentToUpper);
    ClassList bases = p->bases();
    ClassDefPtr base;
    OperationList ops = p->operations();
    OperationList::iterator oli;

    //
    // Define a mix-in module for the class.
    //
    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << "_mixin)";
    _out.inc();
    _out << nl << "module " << name << "_mixin";
    _out.inc();

    if(!p->isLocal())
    {
        if(!bases.empty() && !bases.front()->isInterface())
        {
            base = bases.front();
            _out << nl << "include " << getAbsolute(bases.front(), IdentToUpper) << "_mixin";
        }
        else
        {
            _out << nl << "include ::Ice::Object_mixin";
        }

        //
        // ice_ids
        //
        ClassList allBases = p->allBases();
        StringList ids;
#if defined(__IBMCPP__) && defined(NDEBUG)
//
// VisualAge C++ 6.0 does not see that ClassDef is a Contained,
// when inlining is on. The code below issues a warning: better
// than an error!
//
        transform(allBases.begin(), allBases.end(), back_inserter(ids),
                  IceUtil::constMemFun<string,ClassDef>(&Contained::scoped));
#else
        transform(allBases.begin(), allBases.end(), back_inserter(ids), IceUtil::constMemFun(&Contained::scoped));
#endif
        StringList other;
        other.push_back(scoped);
        other.push_back("::Ice::Object");
        other.sort();
        ids.merge(other);
        ids.unique();
        _out << sp << nl << "def ice_ids(current=nil)";
        _out.inc();
        _out << nl << "[";
        for(StringList::iterator q = ids.begin(); q != ids.end(); ++q)
        {
            if(q != ids.begin())
            {
                _out << ", ";
            }
            _out << "'" << *q << "'";
        }
        _out << ']';
        _out.dec();
        _out << nl << "end";

        //
        // ice_id
        //
        _out << sp << nl << "def ice_id(current=nil)";
        _out.inc();
        _out << nl << "'" << scoped << "'";
        _out.dec();
        _out << nl << "end";
    }

    if(!ops.empty())
    {
        //
        // Emit a comment for each operation.
        //
        _out << sp
             << nl << "#"
             << nl << "# Operation signatures."
             << nl << "#";
        for(oli = ops.begin(); oli != ops.end(); ++oli)
        {
            string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
/* If AMI/AMD is ever implemented...
            if(!p->isLocal() && (p->hasMetaData("amd") || (*oli)->hasMetaData("amd")))
            {
                _out << nl << "# def " << fixedOpName << "_async(_cb";

                ParamDeclList params = (*oli)->parameters();

                for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
                {
                    if(!(*pli)->isOutParam())
                    {
                        _out << ", " << fixIdent((*pli)->name(), IdentToLower);
                    }
                }
                if(!p->isLocal())
                {
                    _out << ", current=nil";
                }
                _out << ")";
            }
            else
*/
            {
                _out << nl << "# def " << fixedOpName << "(";

                ParamDeclList params = (*oli)->parameters();

                bool first = true;
                for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
                {
                    if(!(*pli)->isOutParam())
                    {
                        if(first)
                        {
                            first = false;
                        }
                        else
                        {
                            _out << ", ";
                        }
                        _out << fixIdent((*pli)->name(), IdentToLower);
                    }
                }
                if(!p->isLocal())
                {
                    if(!first)
                    {
                        _out << ", ";
                    }
                    _out << "current=nil";
                }
                _out << ")";
            }
        }
    }

    //
    // inspect
    //
    _out << sp << nl << "def inspect";
    _out.inc();
    _out << nl << "::Ice::__stringify(self, T_" << name << ")";
    _out.dec();
    _out << nl << "end";

    //
    // read/write accessors for data members.
    //
    DataMemberList members = p->dataMembers();
    if(!members.empty())
    {
        bool prot = p->hasMetaData("protected");
        DataMemberList protectedMembers;
        DataMemberList::iterator q;

        _out << sp << nl << "attr_accessor ";
        for(q = members.begin(); q != members.end(); ++q)
        {
            if(q != members.begin())
            {
                _out << ", ";
            }
            _out << ":" << fixIdent((*q)->name(), IdentNormal);
            if(prot || (*q)->hasMetaData("protected"))
            {
                protectedMembers.push_back(*q);
            }
        }

        if(!protectedMembers.empty())
        {
            _out << nl << "protected ";
            for(q = protectedMembers.begin(); q != protectedMembers.end(); ++q)
            {
                if(q != protectedMembers.begin())
                {
                    _out << ", ";
                }
                //
                // We need to list the symbols of the reader and the writer (e.g., ":member" and ":member=").
                //
                _out << ":" << fixIdent((*q)->name(), IdentNormal) << ", :"
                     << fixIdent((*q)->name(), IdentNormal) << '=';
            }
        }
    }

    _out.dec();
    _out << nl << "end"; // End of mix-in module for class.

    if(p->isInterface())
    {
        //
        // Class.
        //
        _out << nl << "class " << name;
        _out.inc();
        _out << nl << "include " << name << "_mixin";
        _out << nl;
        _out << nl << "def " << name << ".ice_staticId()";
        _out.inc();
        _out << nl << "'" << scoped << "'";
        _out.dec();
        _out << nl << "end";
        _out.dec();
        _out << nl << "end";
    }
    else
    {
        //
        // Class.
        //
        _out << nl << "class " << name;
        if(base)
        {
            _out << " < " << getAbsolute(base, IdentToUpper);
        }
        _out.inc();
        _out << nl << "include " << name << "_mixin";
        _out << nl;
        _out << nl << "def " << name << ".ice_staticId()";
        _out.inc();
        _out << nl << "'" << scoped << "'";
        _out.dec();
        _out << nl << "end";

        //
        // initialize
        //
        MemberInfoList allMembers;
        collectClassMembers(p, allMembers, false);
        if(!allMembers.empty())
        {
            _out << sp << nl << "def initialize(";
            writeConstructorParams(allMembers);
            _out << ')';
            _out.inc();

            MemberInfoList::iterator q;
            bool inheritsMembers = false;
            for(q = allMembers.begin(); q != allMembers.end(); ++q)
            {
                if(q->inherited)
                {
                    inheritsMembers = true;
                    break;
                }
            }

            if(inheritsMembers)
            {
                _out << nl << "super" << spar;
                for(q = allMembers.begin(); q != allMembers.end(); ++q)
                {
                    if(q->inherited)
                    {
                        _out << q->lowerName;
                    }
                }
                _out << epar;
            }

            for(q = allMembers.begin(); q != allMembers.end(); ++q)
            {
                if(!q->inherited)
                {
                    _out << nl << '@' << q->fixedName << " = " << q->lowerName;
                }
            }

            _out.dec();
            _out << nl << "end";
        }

        _out.dec();
        _out << nl << "end"; // End of class.
    }

    //
    // Generate proxy support. This includes a mix-in module for the proxy's
    // operations and a class for the proxy itself.
    //
    if(!p->isLocal())
    {
        _out << nl << "module " << name << "Prx_mixin";
        _out.inc();
        for(ClassList::iterator cli = bases.begin(); cli != bases.end(); ++cli)
        {
            _out << nl << "include " << getAbsolute(*cli, IdentToUpper) << "Prx_mixin";
        }
        for(oli = ops.begin(); oli != ops.end(); ++oli)
        {
            string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
            if(fixedOpName == "checkedCast" || fixedOpName == "uncheckedCast")
            {
                fixedOpName.insert(0, "_");
            }
            TypePtr ret = (*oli)->returnType();
            ParamDeclList paramList = (*oli)->parameters();
            string inParams;

            for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
            {
                if(!(*q)->isOutParam())
                {
                    if(!inParams.empty())
                    {
                        inParams.append(", ");
                    }
                    inParams.append(fixIdent((*q)->name(), IdentToLower));
                }
            }

            _out << sp << nl << "def " << fixedOpName << "(";
            if(!inParams.empty())
            {
                _out << inParams << ", ";
            }
            _out << "_ctx=nil)";
            _out.inc();
            _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invoke(self, [" << inParams;
            _out << "], _ctx)";
            _out.dec();
            _out << nl << "end";

/* If AMI/AMD is ever implemented...
            if(p->hasMetaData("ami") || (*oli)->hasMetaData("ami"))
            {
                _out << sp << nl << "def " << fixedOpName << "_async(_cb";
                if(!inParams.empty())
                {
                    _out << ", " << inParams;
                }
                _out << ", _ctx=nil)";
                _out.inc();
                _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invokeAsync(self, _cb, [" << inParams;
                if(!inParams.empty() && inParams.find(',') == string::npos)
                {
                    _out << ", ";
                }
                _out << "], _ctx)";
                _out.dec();
                _out << nl << "end";
            }
*/
        }
        _out.dec();
        _out << nl << "end"; // End of mix-in module for proxy.

        _out << nl << "class " << name << "Prx < ::Ice::ObjectPrx";
        _out.inc();
        _out << nl << "include " << name << "Prx_mixin";

        _out << sp << nl << "def " << name << "Prx.checkedCast(proxy, facetOrCtx=nil, _ctx=nil)";
        _out.inc();
        _out << nl << "ice_checkedCast(proxy, '" << scoped << "', facetOrCtx, _ctx)";
        _out.dec();
        _out << nl << "end";

        _out << sp << nl << "def " << name << "Prx.uncheckedCast(proxy, facet=nil)";
        _out.inc();
        _out << nl << "ice_uncheckedCast(proxy, facet)";
        _out.dec();
        _out << nl << "end";

        _out.dec();
        _out << nl << "end"; // End of proxy class.
    }

    //
    // Emit type descriptions.
    //
    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
    _out.inc();
    if(p->isLocal())
    {
        _out << nl << "T_" << name << " = ::Ice::__declareLocalClass('" << scoped << "')";
    }
    else
    {
        _out << nl << "T_" << name << " = ::Ice::__declareClass('" << scoped << "')";
        _out << nl << "T_" << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
    }
    _out.dec();
    _out << nl << "end";
    _classHistory.insert(scoped); // Avoid redundant declarations.

    bool isAbstract = p->isInterface() || p->allOperations().size() > 0; // Don't use isAbstract() here - see bug 3739
    _out << sp << nl << "T_" << name << ".defineClass(" << name << ", " << (isAbstract ? "true" : "false") << ", ";
    if(!base)
    {
        _out << "nil";
    }
    else
    {
        _out << getAbsolute(base, IdentToUpper, "T_");
    }
    _out << ", [";
    //
    // Interfaces
    //
    // TODO: Necessary?
    //
    {
        int interfaceCount = 0;
        for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
        {
            if((*q)->isInterface())
            {
                if(interfaceCount > 0)
                {
                    _out << ", ";
                }
                _out << getAbsolute(*q, IdentToUpper, "T_");
                ++interfaceCount;
            }
        }
    }
    //
    // Members
    //
    // Data members are represented as an array:
    //
    //   ['MemberName', MemberType]
    //
    // where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type.
    //
    _out << "], [";
    if(members.size() > 1)
    {
        _out.inc();
        _out << nl;
    }
    {
        for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
        {
            if(q != members.begin())
            {
                _out << ',' << nl;
            }
            _out << "['" << fixIdent((*q)->name(), IdentNormal) << "', ";
            writeType((*q)->type());
            _out << ']';
        }
    }
    if(members.size() > 1)
    {
        _out.dec();
        _out << nl;
    }
    _out << "])";
    _out << nl << name << "_mixin::ICE_TYPE = T_" << name;

    //
    // Define each operation. The arguments to __defineOperation are:
    //
    // 'opName', Mode, [InParams], [OutParams], ReturnType, [Exceptions]
    //
    // where InParams and OutParams are arrays of type descriptions, and Exceptions
    // is an array of exception types.
    //
    if(!p->isLocal())
    {
        _out << sp << nl << "T_" << name << "Prx.defineProxy(" << name << "Prx, T_" << name << ')';
        _out << nl << name << "Prx::ICE_TYPE = T_" << name << "Prx";

        if(!ops.empty())
        {
            _out << sp;
        }
        for(OperationList::iterator s = ops.begin(); s != ops.end(); ++s)
        {
            ParamDeclList params = (*s)->parameters();
            ParamDeclList::iterator t;
            int count;

            _out << nl << name << "_mixin::OP_" << (*s)->name() << " = ::Ice::__defineOperation('"
                 << (*s)->name() << "', ";
            switch((*s)->mode())
            {
            case Operation::Normal:
                _out << "::Ice::OperationMode::Normal";
                break;
            case Operation::Nonmutating:
                _out << "::Ice::OperationMode::Nonmutating";
                break;
            case Operation::Idempotent:
                _out << "::Ice::OperationMode::Idempotent";
                break;
            }
            _out << ", ";
            switch((*s)->sendMode())
            {
            case Operation::Normal:
                _out << "::Ice::OperationMode::Normal";
                break;
            case Operation::Nonmutating:
                _out << "::Ice::OperationMode::Nonmutating";
                break;
            case Operation::Idempotent:
                _out << "::Ice::OperationMode::Idempotent";
                break;
            }
            _out << ", " << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "true" : "false") << ", [";
            for(t = params.begin(), count = 0; t != params.end(); ++t)
            {
                if(!(*t)->isOutParam())
                {
                    if(count > 0)
                    {
                        _out << ", ";
                    }
                    writeType((*t)->type());
                    ++count;
                }
            }
            _out << "], [";
            for(t = params.begin(), count = 0; t != params.end(); ++t)
            {
                if((*t)->isOutParam())
                {
                    if(count > 0)
                    {
                        _out << ", ";
                    }
                    writeType((*t)->type());
                    ++count;
                }
            }
            _out << "], ";
            TypePtr returnType = (*s)->returnType();
            if(returnType)
            {
                writeType(returnType);
            }
            else
            {
                _out << "nil";
            }
            _out << ", [";
            ExceptionList exceptions = (*s)->throws();
            for(ExceptionList::iterator u = exceptions.begin(); u != exceptions.end(); ++u)
            {
                if(u != exceptions.begin())
                {
                    _out << ", ";
                }
                _out << getAbsolute(*u, IdentToUpper, "T_");
            }
            _out << "])";

            string deprecateMetadata;
            if((*s)->findMetaData("deprecate", deprecateMetadata) || p->findMetaData("deprecate", deprecateMetadata))
            {
                string msg;
                string::size_type pos = deprecateMetadata.find(':');
                if(pos != string::npos && pos < deprecateMetadata.size() - 1)
                {
                    msg = deprecateMetadata.substr(pos + 1);
                }
                _out << nl << name << "_mixin::OP_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
            }
        }
    }

    _out.dec();
    _out << nl << "end"; // if not defined?()

    return false;
}
Exemplo n.º 4
0
bool Slice::ChecksumVisitor::visitClassDefStart(const ClassDefPtr& p)
{
  if (p->isLocal()) {
    return false;
  }

  ClassList bases = p->bases();

  ostringstream ostr;

  if (p->isInterface()) {
    ostr << "interface ";
  } else {
    ostr << "class ";
  }
  ostr << p->name();

  if (!bases.empty()) {
    if (!bases.front()->isInterface()) {
      ostr << " extends " << bases.front()->scoped();
      bases.erase(bases.begin());
    }
    if (!bases.empty()) {
      if (p->isInterface()) {
        ostr << " extends ";
      } else {
        ostr << " implements ";
      }
      for (ClassList::iterator q = bases.begin(); q != bases.end(); ++q) {
        if (q != bases.begin()) {
          ostr << ", ";
        }
        ostr << (*q)->scoped();
      }
    }
  }
  ostr << endl;

  if (p->hasDataMembers()) {
    DataMemberList members = p->dataMembers();
    for (DataMemberList::iterator q = members.begin(); q != members.end(); ++q) {
      ostr << typeToString((*q)->type()) << ' ' << (*q)->name() << endl;
    }
  }

  if (p->hasOperations()) {
    OperationList ops = p->operations();
    for (OperationList::iterator q = ops.begin(); q != ops.end(); ++q) {
      ostr << typeToString((*q)->returnType()) << ' ' << (*q)->name() << '(';
      ParamDeclList params = (*q)->parameters();
      for (ParamDeclList::iterator r = params.begin(); r != params.end(); ++r) {
        if (r != params.begin()) {
          ostr << ", ";
        }
        if ((*r)->isOutParam()) {
          ostr << "out ";
        }
        ostr << typeToString((*r)->type()) << ' ' << (*r)->name();
      }
      ostr << ')';
      ExceptionList ex = (*q)->throws();
      if (!ex.empty()) {
        ostr << " throws ";
        for (ExceptionList::iterator s = ex.begin(); s != ex.end(); ++s) {
          if (s != ex.begin()) {
            ostr << ", ";
          }
          ostr << (*s)->scoped();
        }
      }
      ostr << endl;
    }
  }

  updateMap(p->scoped(), ostr.str());

  return false;
}
Exemplo n.º 5
0
void CompositeProgressWidget::display(OperationList operations)
{
  QString status;
  int now = 0;
  int max = 0;

  int noProgressData=0;

  switch (operations.count()) {
    case 0:
    {
      status = i18nc("The operation has completed", "Finished");
      now=max=1;
    }
    break;
    case 1:
    {
      QPointer<Operation> op = operations.at(0);
      if (!op) break;;
      status = op->name();
      now = op->currentProgress();
      max = op->maxProgress();
    }
    break;
    default:
    {
      now = max =0;
      foreach (QPointer<Operation> op, operations) {
        if (!op) continue;

        status += op->name()+", ";
        if (op->maxProgress() != 0) {
          now += op->currentProgress();
          max += op->maxProgress();
        }
        else {
          noProgressData++;
        }
      }

      //get rid of last ", "
      status = status.left(status.count()-2);

      if (noProgressData != 0) {
                                                  //there are processes without progress data
        if (operations.count() == noProgressData) {
          now=max=0;
        }
        else {
          int averageMax = max / (operations.count() - noProgressData);
          max += (averageMax*noProgressData);
        }
      }
    }
  }

  foreach (ProgressWidget *widget, progressWidgets) {
    if ((!widget->operation()) || (!operations.contains(widget->operation()))) {
      popupWidget->layout()->removeWidget(widget);
      progressWidgets.removeAll(widget);
      widget->deleteLater();
    }
    else {
      operations.removeAll(widget->operation());
      widget->update();
    }
  }

  foreach (QPointer<Operation> op, operations) {
    if (!op) continue;

    ProgressWidget *widget = new ProgressWidget(op, ProgressWidget::Compact, designatedParent);
    popupWidget->layout()->addWidget(widget);
    progressWidgets << widget;
  }

  if (progressWidgets.count() > 0) {
    togglePopup->setEnabled(true);
    if (togglePopup->isChecked())
      showDetails(true);                          //resize / move
  }
  else {
    showDetails(false);                           //hide empty widget
    togglePopup->setEnabled(false);
    togglePopup->setChecked(false);
  }

  if (status.size() > 60)
    status = "..."+status.right(60);
  statusLabel->setText(status);
  bar->setValue(now);
  bar->setMaximum(max);
}