File: generatorenvironment.cpp

package info (click to toggle)
kdebindings 4%3A4.4.5-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 59,736 kB
  • ctags: 90,959
  • sloc: cs: 164,940; cpp: 97,781; ruby: 32,408; perl: 9,410; xml: 4,092; php: 2,798; python: 2,000; ansic: 948; java: 560; makefile: 301; sh: 220
file content (52 lines) | stat: -rw-r--r-- 1,898 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
    Copyright (C) 2009  Arno Rehn <arno@arnorehn.de>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "generatorenvironment.h"

#include <rpp/pp-macro.h>
#include "options.h"

GeneratorEnvironment::GeneratorEnvironment(rpp::pp * preprocessor) : rpp::Environment(preprocessor), q_property(new rpp::pp_macro("Q_PROPERTY"))
{
    q_property->formals.append(IndexedString("text"));
    q_property->setDefinitionText("void __q_property(const char* foo = #text);");
    q_property->function_like = true;
}

GeneratorEnvironment::~GeneratorEnvironment()
{
    if (!ParserOptions::qtMode) {
        // if not in qt-mode, this won't be deleted by rpp::Environment
        delete q_property;
    }
}

void GeneratorEnvironment::setMacro(rpp::pp_macro* macro)
{
    QString macroName = macro->name.str();
    if (   macroName == "signals" || macroName == "slots" || macroName == "Q_SIGNALS" || macroName == "Q_SLOTS"
        || ParserOptions::dropMacros.contains(macroName)) {
        delete macro;
        return;
    } else if (ParserOptions::qtMode && macroName == "Q_PROPERTY") {
        delete macro;
        rpp::Environment::setMacro(q_property);
        return;
    }
    rpp::Environment::setMacro(macro);
}