~ubuntu-branches/ubuntu/utopic/kdevelop-php/utopic

« back to all changes in this revision

Viewing changes to duchain/integraltypeextended.h

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2010-01-17 17:10:22 UTC
  • Revision ID: james.westby@ubuntu.com-20100117171022-q2xlgd9ekewo2ijx
Tags: upstream-1.0.0~beta2
ImportĀ upstreamĀ versionĀ 1.0.0~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   This file is part of KDevelop                                         *
 
3
 *   Copyright 2009 Milian Wolff <mail@milianw.de>                         *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU Library General Public License as       *
 
7
 *   published by the Free Software Foundation; either version 2 of the    *
 
8
 *   License, or (at your option) any later version.                       *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU Library General Public     *
 
16
 *   License along with this program; if not, write to the                 *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 
19
 ***************************************************************************/
 
20
 
 
21
#ifndef INTEGRALTYPEEXTENDED_H
 
22
#define INTEGRALTYPEEXTENDED_H
 
23
 
 
24
#include <language/duchain/types/integraltype.h>
 
25
#include <language/duchain/types/typesystemdata.h>
 
26
#include "phpduchainexport.h"
 
27
 
 
28
namespace Php
 
29
{
 
30
 
 
31
typedef KDevelop::IntegralTypeData IntegralTypeExtendedData;
 
32
 
 
33
/**
 
34
 * Drop-In replacement for the IntegralType in KDevplatform with
 
35
 * some extended logic specific for PHP
 
36
 */
 
37
class KDEVPHPDUCHAIN_EXPORT IntegralTypeExtended: public KDevelop::IntegralType
 
38
{
 
39
public:
 
40
    typedef TypePtr<IntegralTypeExtended> Ptr;
 
41
 
 
42
    enum PHPIntegralTypes {
 
43
        TypeResource = KDevelop::IntegralType::TypeLanguageSpecific
 
44
    };
 
45
 
 
46
    /// Default constructor
 
47
    IntegralTypeExtended(uint type = TypeNone);
 
48
    /// Copy constructor. \param rhs type to copy
 
49
    IntegralTypeExtended(const IntegralTypeExtended& rhs);
 
50
    /// Constructor using raw data. \param data internal data.
 
51
    IntegralTypeExtended(IntegralTypeExtendedData& data);
 
52
 
 
53
    virtual QString toString() const;
 
54
 
 
55
    virtual KDevelop::AbstractType* clone() const;
 
56
 
 
57
    virtual bool equals(const KDevelop::AbstractType* rhs) const;
 
58
 
 
59
    virtual uint hash() const;
 
60
 
 
61
    enum {
 
62
        ///TODO: is that value OK?
 
63
        Identity = 50
 
64
    };
 
65
 
 
66
  typedef KDevelop::IntegralTypeData Data;
 
67
  typedef KDevelop::IntegralType BaseType;
 
68
 
 
69
protected:
 
70
    TYPE_DECLARE_DATA(IntegralTypeExtended);
 
71
};
 
72
 
 
73
}
 
74
 
 
75
namespace KDevelop
 
76
{
 
77
 
 
78
template<>
 
79
inline Php::IntegralTypeExtended* fastCast<Php::IntegralTypeExtended*>(AbstractType* from) {
 
80
    if ( !from || from->whichType() != AbstractType::TypeIntegral ) {
 
81
        return 0;
 
82
    } else {
 
83
        return dynamic_cast<Php::IntegralTypeExtended*>(from);
 
84
    }
 
85
}
 
86
 
 
87
}
 
88
 
 
89
#endif // PHPINTEGRALTYPE_H
 
90