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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
/***************************************************************************
* Copyright (C) 2005 by David Saxton *
* david@bluehaze.org *
* *
* 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. *
***************************************************************************/
#ifndef LANGUAGE_H
#define LANGUAGE_H
#include <tqobject.h>
#include <tqstringlist.h>
class FlowCodeDocument;
class KTechlab;
class LogView;
class MessageInfo;
class MicroSettings;
class OutputMethodInfo;
class ProcessChain;
class ProcessOptions;
class TextDocument;
class TQProcess;
typedef TQValueList<ProcessOptions> ProcessOptionsList;
class ProcessOptionsSpecial
{
public:
ProcessOptionsSpecial();
bool b_addToProject;
bool b_forceList;
TQString m_picID;
FlowCodeDocument * p_flowCodeDocument;
// Linking
TQString m_hexFormat;
bool m_bOutputMapFile;
TQString m_libraryDir;
TQString m_linkerScript;
TQStringList m_linkLibraries;
TQString m_linkOther;
// Programming
TQString m_port;
TQString m_program;
};
class ProcessOptionsHelper : public TQObject
{
TQ_OBJECT
#define protected public
signals:
#undef protected
void textOutputtedTo( TextDocument * outputtedTo );
};
class ProcessOptions : public ProcessOptionsSpecial
{
public:
ProcessOptions();
ProcessOptions( OutputMethodInfo info );
class ProcessPath { public:
enum MediaType
{
AssemblyAbsolute,
AssemblyRelocatable,
C,
Disassembly,
FlowCode,
Library,
Microbe,
Object,
Pic,
Program,
Unknown // Used for guessing the media type
};
enum Path // From_To // processor that will be invoked first
{
AssemblyAbsolute_PIC, // gpasm (indirect)
AssemblyAbsolute_Program, // gpasm (direct)
AssemblyRelocatable_Library, // gpasm (indirect)
AssemblyRelocatable_Object, // gpasm (direct)
AssemblyRelocatable_PIC, // gpasm (indirect)
AssemblyRelocatable_Program, // gpasm (indirect)
C_AssemblyRelocatable, // sdcc (direct)
C_Library, // sdcc (indirect)
C_Object, // sdcc (indirect)
C_PIC, // sdcc (indirect)
C_Program, // sdcc (indirect)
FlowCode_AssemblyAbsolute, // flowcode (indirect)
FlowCode_Microbe, // flowcode (direct)
FlowCode_PIC, // flowcode (indirect)
FlowCode_Program, // flowcode (indirect)
Microbe_AssemblyAbsolute, // microbe (direct)
Microbe_PIC, // microbe (indirect)
Microbe_Program, // microbe (indirect)
Object_Disassembly, // gpdasm (direct)
Object_Library, // gplib (direct)
Object_PIC, // gplink (indirect)
Object_Program, // gplink (direct)
PIC_AssemblyAbsolute, // download from pic (direct)
Program_Disassembly, // gpdasm (direct)
Program_PIC, // upload to pic (direct)
Invalid, // From and to types are incompatible
None // From and to types are the same
};
static Path path( MediaType from, MediaType to );
static MediaType from( Path path );
static MediaType to( Path path );
};
class Method
{
public: enum type
{
Forget, // Don't do anything after processing successfully
LoadAsNew, // Load the output as a new file
Load // Load the output file
};
};
/**
* Tries to guess the media type from the url (and possible the contents
* of the file as well).
*/
static ProcessPath::MediaType guessMediaType( const TQString & url );
/**
* The *final* target file (not any intermediatary ones)
*/
TQString targetFile() const { return m_targetFile; }
/**
* This sets the final target file, as well as the initial intermediatary one
*/
void setTargetFile( const TQString &file );
void setIntermediaryOutput( const TQString &file ) { m_intermediaryFile = file; }
TQString intermediaryOutput() const { return m_intermediaryFile; }
void setInputFiles( const TQStringList & files ) { m_inputFiles = files; }
TQStringList inputFiles() const { return m_inputFiles; }
void setMethod( Method::type method ) { m_method = method; }
Method::type method() const { return m_method; }
void setProcessPath( ProcessPath::Path path ) { m_processPath = path; }
ProcessPath::Path processPath() const { return m_processPath; }
/**
* If the output is text; If the user has selected (in config options)
* ReuseSameViewForOutput, then the given TextDocument will have its
* text set to the output if the TextDocument is not modified and has
* an empty url. Otherwise a new TextDocument will be created. Either
* way, once the the processing has finished, a signal will be emitted
* to the given receiver passing a TextDocument * as an argument. This
* is not to be confused with setTextOutputtedTo, which is called once
* the processing has finished, and will call-back to the slot given.
*/
void setTextOutputTarget( TextDocument * target, TQObject * receiver, const char * slot );
/**
* @see setTextOutputTarget
*/
TextDocument * textOutputTarget() const { return m_pTextOutputTarget; }
/**
* @see setTextOuputTarget
*/
void setTextOutputtedTo( TextDocument * outputtedTo );
protected:
TextDocument * m_pTextOutputTarget;
ProcessOptionsHelper * m_pHelper;
bool b_targetFileSet;
TQStringList m_inputFiles;
TQString m_targetFile;
TQString m_intermediaryFile;
Method::type m_method;
ProcessPath::Path m_processPath;
};
/**
@author Daniel Clarke
@author David Saxton
*/
class Language : public TQObject
{
TQ_OBJECT
public:
Language( ProcessChain *processChain, KTechlab *parent, const TQString &name );
~Language();
/**
* Compile / assemble / dissassembly / whatever the given input.
* @returns true if processing was started succesfully (this is different to finishing successfuly).
*/
virtual void processInput( ProcessOptions options ) = 0;
/**
* Return the ProcessOptions object current state
*/
ProcessOptions processOptions() const { return m_processOptions; }
/**
* Return the output path from the given input path. Will return None
* if we've done processing.
*/
virtual ProcessOptions::ProcessPath::Path outputPath( ProcessOptions::ProcessPath::Path inputPath ) const = 0;
signals:
/**
* Emitted when the processing was successful.
* @param language Pointer to this class
*/
void processSucceeded( Language *language );
/**
* Emitted when the processing failed.
* @param language Pointer to this class
*/
void processFailed( Language *language );
protected:
/**
* Examines the string for the line number if applicable, and creates a new
* MessageInfo for it.
*/
virtual MessageInfo extractMessageInfo( const TQString &text );
/**
* Reset the error count
*/
void reset();
void outputMessage( const TQString &message );
void outputWarning( const TQString &message );
void outputError( const TQString &error );
void finish( bool successful );
int m_errorCount;
KTechlab *p_ktechlab;
ProcessOptions m_processOptions;
ProcessChain *p_processChain;
/**
* A message appropriate to the language's success after compilation or similar.
*/
TQString m_successfulMessage;
/**
* A message appropriate to the language's failure after compilation or similar.
*/
TQString m_failedMessage;
};
#endif
|