~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to libslparse/vardef.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////---------------------------------------------------------------------
 
2
////    Associated header file: VARDEF.H
 
3
////    Class definition file:  VARDEF.CPP
 
4
////
 
5
////    Author:                                 Paul C. Gregory
 
6
////    Creation date:                  22/07/99
 
7
////---------------------------------------------------------------------
 
8
 
 
9
//? Is .h included already?
 
10
#ifndef VARDEF_H_INCLUDED
 
11
#define VARDEF_H_INCLUDED 1
 
12
 
 
13
#include        <vector>
 
14
 
 
15
#include        "aqsis.h"
 
16
 
 
17
#include        "sstring.h"
 
18
#include        "ivardef.h"
 
19
 
 
20
START_NAMESPACE( Aqsis )
 
21
 
 
22
 
 
23
struct IqParseNode;
 
24
 
 
25
 
 
26
///----------------------------------------------------------------------
 
27
/// CqVarDef
 
28
/// Class storing information about variables.
 
29
 
 
30
class CqParseNode;
 
31
class CqVarDef : public IqVarDef
 
32
{
 
33
public:
 
34
    CqVarDef() :
 
35
            m_Type( Type_Nil ),
 
36
            m_fExtern( TqFalse ),
 
37
            m_strName( "" ),
 
38
            m_pDefValue( 0 ),
 
39
            m_UseCount( 0 ),
 
40
            m_ArrayLength( 0 ),
 
41
            m_ReadOnly(0)
 
42
    {}
 
43
    CqVarDef( const CqVarDef& from );
 
44
    CqVarDef( TqInt Type, const char* strName, TqInt Length = 0, TqInt ReadOnly = 0 ) :
 
45
            m_Type( Type ),
 
46
            m_fExtern( TqFalse ),
 
47
            m_strName( strName ),
 
48
            m_pDefValue( 0 ),
 
49
            m_UseCount( 0 ),
 
50
            m_ArrayLength( Length ),
 
51
            m_ReadOnly(ReadOnly)
 
52
    {}
 
53
    virtual ~CqVarDef();
 
54
 
 
55
    // Overridden from IqVarDef
 
56
    virtual const IqParseNode*  pInitialiser() const;
 
57
    virtual IqParseNode*        pInitialiser();
 
58
    virtual     TqInt   Type() const
 
59
    {
 
60
        return ( m_Type );
 
61
    }
 
62
    virtual     const char*     strName() const
 
63
    {
 
64
        return ( m_strName.c_str() );
 
65
    }
 
66
    virtual     void    IncUseCount()
 
67
    {
 
68
        m_UseCount++;
 
69
    }
 
70
    virtual     TqInt   UseCount() const
 
71
    {
 
72
        return ( m_UseCount );
 
73
    }
 
74
    virtual     TqInt   ArrayLength() const
 
75
    {
 
76
        return ( m_ArrayLength );
 
77
    }
 
78
    virtual     TqBool  fExtern() const
 
79
    {
 
80
        return ( m_fExtern );
 
81
    }
 
82
    virtual     SqVarRef        vrExtern() const
 
83
    {
 
84
        return ( m_vrExtern );
 
85
    }
 
86
    virtual     void    SetParam( TqBool fParam = TqTrue )
 
87
    {
 
88
        m_Type = ( m_Type & ~Type_Param ) | ( fParam ? Type_Param : 0 );
 
89
    }
 
90
    virtual     void    SetOutput( TqBool fOutput = TqTrue )
 
91
    {
 
92
        m_Type = ( m_Type & ~Type_Output ) | ( fOutput ? Type_Output : 0 );
 
93
    }
 
94
    virtual     void    SetDefaultStorage( TqInt Storage )
 
95
    {
 
96
        // If no storage has been explicitly specified, default to the
 
97
        // passed value.
 
98
        if ( ( m_Type & Storage_Mask ) == 0 )
 
99
            m_Type = ( m_Type | ( Storage & Storage_Mask ) );
 
100
    }
 
101
 
 
102
 
 
103
    CqVarDef&   operator=( const CqVarDef& from );
 
104
 
 
105
    void        SetType( const TqInt Type )
 
106
    {
 
107
        m_Type = Type;
 
108
    }
 
109
    CqParseNode*        pDefValue()
 
110
    {
 
111
        return ( m_pDefValue );
 
112
    }
 
113
    void        SetpDefValue( CqParseNode* pDefValue )
 
114
    {
 
115
        m_pDefValue = pDefValue;
 
116
    }
 
117
    void        SetExtern( TqBool f, SqVarRef vrExtern )
 
118
    {
 
119
        m_fExtern = f;
 
120
        m_vrExtern = vrExtern;
 
121
    }
 
122
    TqBool ReadOnly( EqShaderType type )
 
123
    {
 
124
        return( ( m_ReadOnly & (1<<type) ) != 0 );
 
125
    }
 
126
 
 
127
    static      TqBool  FindVariable( const char* strName, SqVarRef& Ref );
 
128
    static      CqVarDef*       GetVariablePtr( const SqVarRef& Ref );
 
129
    static      TqInt   AddVariable( CqVarDef& Def );
 
130
 
 
131
protected:
 
132
    TqInt       m_Type;
 
133
    TqBool      m_fExtern;
 
134
    SqVarRef    m_vrExtern;
 
135
    CqString    m_strName;
 
136
    CqParseNode*        m_pDefValue;
 
137
    TqInt       m_UseCount;
 
138
    TqInt       m_ArrayLength;
 
139
    TqInt       m_ReadOnly;
 
140
};
 
141
 
 
142
extern std::vector<CqVarDef>    gLocalVars;
 
143
extern CqVarDef gStandardVars[];
 
144
 
 
145
//-----------------------------------------------------------------------
 
146
 
 
147
END_NAMESPACE( Aqsis )
 
148
 
 
149
#endif  // !VARDEF_H_INCLUDED