~efargaspro/+junk/codeblocks-16.01-release

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* This file is part of wxSmith plugin for Code::Blocks Studio
* Copyright (C) 2007  Bartlomiej Swiecki
*
* wxSmith 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 3 of the License, or
* (at your option) any later version.
*
* wxSmith 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 wxSmith. If not, see <http://www.gnu.org/licenses/>.
*
* $Revision: 8704 $
* $Id: wxscodegenerator.h 8704 2012-12-23 20:32:03Z mortenmacfly $
* $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-16.xx/src/plugins/contrib/wxSmith/wxwidgets/wxscodegenerator.h $
*/

#ifndef WXSCODEGENERATOR_H
#define WXSCODEGENERATOR_H

#include "wxscodercontext.h"

#include <prep.h>

/** \brief Base class for items which generate source code */
class wxsCodeGenerator
{
    public:

        /** \brief Ctor */
        wxsCodeGenerator();

        /** \brief Dctor */
        virtual ~wxsCodeGenerator();

        /** \brief Request to build the code */
        void BuildCode(wxsCoderContext* Context);

    protected:

        virtual void OnBuildCreatingCode() = 0;              ///< \brief Building code manually creating resource, it may also be used to add header files
        virtual void OnBuildHeadersCode() {}                 ///< \brief Building headers arrays, it's not required since headers can be added in OnBuildCreatingCode()
        virtual void OnBuildDeclarationsCode() = 0;          ///< \brief Building variable declaration / forward declaration
        virtual void OnBuildEventsConnectingCode() = 0;      ///< \brief Building code connecting events
        virtual void OnBuildIdCode() = 0;                    ///< \brief Building code declaring class members and values of identifiers
        virtual void OnBuildXRCFetchingCode() = 0;           ///< \brief Building code which fetches this item from xrc resource
        virtual void OnUpdateFlags(cb_unused long& Flags) {} ///< \brief Function called to update context flags just before the code is generated, previous flags are restored after code is generated

        /** \brief Getting current coding context */
        inline wxsCoderContext* GetCoderContext() { return m_Context; }

        /** \brief Getting current language */
        inline wxsCodingLang GetLanguage() { return m_Context ? m_Context->m_Language : wxsUnknownLanguage; }

        /** \brief Getting flags of current coding context */
        inline long GetCoderFlags() { return m_Context ? m_Context->m_Flags : 0; }

        /** \brief Adding header file into current context */
        inline void AddHeader(const wxString& Header,const wxString& DeclaredClass,long HeaderFlags=0)
        {
            if ( GetCoderContext() ) GetCoderContext()->AddHeader(Header,DeclaredClass,HeaderFlags);
        }

        /*** \brief Adding forward declaration of item's class */
        inline void AddDeclaration(const wxString& Declaration)
        {
            if ( GetCoderContext() ) GetCoderContext()->AddDeclaration(Declaration);
        }

        /** \brief Adding XRC fetching code */
        inline void AddXRCFetchingCode(const wxString& Code)
        {
            if ( GetCoderContext() ) GetCoderContext()->AddXRCFetchingCode(Code);
        }

        /** \brief Adding Manually building code */
        inline void AddBuildingCode(const wxString& Code)
        {
            if ( GetCoderContext() ) GetCoderContext()->AddBuildingCode(Code);
        }

        /** \brief Adding event connecting code */
        inline void AddEventCode(const wxString& Code)
        {
            if ( GetCoderContext() ) GetCoderContext()->AddEventCode(Code);
        }

        /** \brief Adding id-generating code */
        inline void AddIdCode(const wxString& Enumeration,const wxString& Initialization)
        {
            if ( GetCoderContext() ) GetCoderContext()->AddIdCode(Enumeration,Initialization);
        }

    private:

        wxsCoderContext* m_Context;
};

#endif