~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/linguist/shared/proitems.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
2
**
3
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
 
4
** All rights reserved.
4
5
** Contact: Nokia Corporation (qt-info@nokia.com)
5
6
**
6
7
** This file is part of the Qt Linguist of the Qt Toolkit.
7
8
**
8
9
** $QT_BEGIN_LICENSE:LGPL$
9
 
** Commercial Usage
10
 
** Licensees holding valid Qt Commercial licenses may use this file in
11
 
** accordance with the Qt Commercial License Agreement provided with the
12
 
** Software or, alternatively, in accordance with the terms contained in
13
 
** a written agreement between you and Nokia.
 
10
** No Commercial Usage
 
11
** This file contains pre-release code and may not be distributed.
 
12
** You may use this file in accordance with the terms and conditions
 
13
** contained in the Technology Preview License Agreement accompanying
 
14
** this package.
14
15
**
15
16
** GNU Lesser General Public License Usage
16
17
** Alternatively, this file may be used under the terms of the GNU Lesser
20
21
** ensure the GNU Lesser General Public License version 2.1 requirements
21
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22
23
**
23
 
** In addition, as a special exception, Nokia gives you certain
24
 
** additional rights. These rights are described in the Nokia Qt LGPL
25
 
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26
 
** package.
27
 
**
28
 
** GNU General Public License Usage
29
 
** Alternatively, this file may be used under the terms of the GNU
30
 
** General Public License version 3.0 as published by the Free Software
31
 
** Foundation and appearing in the file LICENSE.GPL included in the
32
 
** packaging of this file.  Please review the following information to
33
 
** ensure the GNU General Public License version 3.0 requirements will be
34
 
** met: http://www.gnu.org/copyleft/gpl.html.
35
 
**
36
 
** If you are unsure which license is appropriate for your use, please
37
 
** contact the sales department at http://www.qtsoftware.com/contact.
 
24
** In addition, as a special exception, Nokia gives you certain additional
 
25
** rights.  These rights are described in the Nokia Qt LGPL Exception
 
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
27
**
 
28
** If you have questions regarding the use of this file, please contact
 
29
** Nokia at qt-info@nokia.com.
 
30
**
 
31
**
 
32
**
 
33
**
 
34
**
 
35
**
 
36
**
 
37
**
38
38
** $QT_END_LICENSE$
39
39
**
40
40
****************************************************************************/
58
58
}
59
59
 
60
60
// --------------- ProBlock ----------------
 
61
 
61
62
ProBlock::ProBlock(ProBlock *parent)
62
63
{
63
64
    m_blockKind = 0;
64
65
    m_parent = parent;
 
66
    m_refCount = 1;
65
67
}
66
68
 
67
69
ProBlock::~ProBlock()
68
70
{
69
 
    qDeleteAll(m_proitems);
 
71
    foreach (ProItem *itm, m_proitems)
 
72
        if (itm->kind() == BlockKind)
 
73
            static_cast<ProBlock *>(itm)->deref();
 
74
        else
 
75
            delete itm;
70
76
}
71
77
 
72
78
void ProBlock::appendItem(ProItem *proitem)
109
115
    return ProItem::BlockKind;
110
116
}
111
117
 
112
 
bool ProBlock::Accept(AbstractProItemVisitor *visitor)
 
118
ProItem::ProItemReturn ProBlock::Accept(AbstractProItemVisitor *visitor)
113
119
{
114
 
    visitor->visitBeginProBlock(this);
115
 
    foreach (ProItem *item, m_proitems) {
116
 
        if (!item->Accept(visitor))
117
 
            return false;
 
120
    if (visitor->visitBeginProBlock(this) == ReturnSkip)
 
121
        return ReturnTrue;
 
122
    ProItemReturn rt = ReturnTrue;
 
123
    for (int i = 0; i < m_proitems.count(); ++i) {
 
124
        rt = m_proitems.at(i)->Accept(visitor);
 
125
        if (rt != ReturnTrue && rt != ReturnFalse) {
 
126
            if (rt == ReturnLoop) {
 
127
                rt = ReturnTrue;
 
128
                while (visitor->visitProLoopIteration())
 
129
                    for (int j = i; ++j < m_proitems.count(); ) {
 
130
                        rt = m_proitems.at(j)->Accept(visitor);
 
131
                        if (rt != ReturnTrue && rt != ReturnFalse) {
 
132
                            if (rt == ReturnNext) {
 
133
                                rt = ReturnTrue;
 
134
                                break;
 
135
                            }
 
136
                            if (rt == ReturnBreak)
 
137
                                rt = ReturnTrue;
 
138
                            goto do_break;
 
139
                        }
 
140
                    }
 
141
              do_break:
 
142
                visitor->visitProLoopCleanup();
 
143
            }
 
144
            break;
 
145
        }
118
146
    }
119
 
    return visitor->visitEndProBlock(this);
 
147
    visitor->visitEndProBlock(this);
 
148
    return rt;
120
149
}
121
150
 
122
151
// --------------- ProVariable ----------------
148
177
    return m_variable;
149
178
}
150
179
 
151
 
bool ProVariable::Accept(AbstractProItemVisitor *visitor)
 
180
ProItem::ProItemReturn ProVariable::Accept(AbstractProItemVisitor *visitor)
152
181
{
153
182
    visitor->visitBeginProVariable(this);
154
 
    foreach (ProItem *item, m_proitems) {
155
 
        if (!item->Accept(visitor))
156
 
            return false;
157
 
    }
158
 
    return visitor->visitEndProVariable(this);
 
183
    foreach (ProItem *item, m_proitems)
 
184
        item->Accept(visitor); // cannot fail
 
185
    visitor->visitEndProVariable(this);
 
186
    return ReturnTrue;
159
187
}
160
188
 
161
189
// --------------- ProValue ----------------
190
218
    return ProItem::ValueKind;
191
219
}
192
220
 
193
 
bool ProValue::Accept(AbstractProItemVisitor *visitor)
 
221
ProItem::ProItemReturn ProValue::Accept(AbstractProItemVisitor *visitor)
194
222
{
195
 
    return visitor->visitProValue(this);
 
223
    visitor->visitProValue(this);
 
224
    return ReturnTrue;
196
225
}
197
226
 
198
227
// --------------- ProFunction ----------------
216
245
    return ProItem::FunctionKind;
217
246
}
218
247
 
219
 
bool ProFunction::Accept(AbstractProItemVisitor *visitor)
 
248
ProItem::ProItemReturn ProFunction::Accept(AbstractProItemVisitor *visitor)
220
249
{
221
250
    return visitor->visitProFunction(this);
222
251
}
242
271
    return ProItem::ConditionKind;
243
272
}
244
273
 
245
 
bool ProCondition::Accept(AbstractProItemVisitor *visitor)
 
274
ProItem::ProItemReturn ProCondition::Accept(AbstractProItemVisitor *visitor)
246
275
{
247
 
    return visitor->visitProCondition(this);
 
276
    visitor->visitProCondition(this);
 
277
    return ReturnTrue;
248
278
}
249
279
 
250
280
// --------------- ProOperator ----------------
268
298
    return ProItem::OperatorKind;
269
299
}
270
300
 
271
 
bool ProOperator::Accept(AbstractProItemVisitor *visitor)
 
301
ProItem::ProItemReturn ProOperator::Accept(AbstractProItemVisitor *visitor)
272
302
{
273
 
    return visitor->visitProOperator(this);
 
303
    visitor->visitProOperator(this);
 
304
    return ReturnTrue;
274
305
}
275
306
 
276
307
// --------------- ProFile ----------------
315
346
    return m_modified;
316
347
}
317
348
 
318
 
bool ProFile::Accept(AbstractProItemVisitor *visitor)
 
349
ProItem::ProItemReturn ProFile::Accept(AbstractProItemVisitor *visitor)
319
350
{
320
 
    visitor->visitBeginProFile(this);
321
 
    foreach (ProItem *item, m_proitems) {
322
 
        if (!item->Accept(visitor))
323
 
            return false;
324
 
    }
 
351
    ProItemReturn rt;
 
352
    if ((rt = visitor->visitBeginProFile(this)) != ReturnTrue)
 
353
        return rt;
 
354
    ProBlock::Accept(visitor); // cannot fail
325
355
    return visitor->visitEndProFile(this);
326
356
}
327
357