]> git.saurik.com Git - wxWidgets.git/blame_incremental - contrib/src/stc/gen_iface.py
Fix Cygwin and MinGW compilation
[wxWidgets.git] / contrib / src / stc / gen_iface.py
... / ...
CommitLineData
1#!/bin/env python
2#----------------------------------------------------------------------------
3# Name: gen_iface.py
4# Purpose: Generate stc.h and stc.cpp from the info in Scintilla.iface
5#
6# Author: Robin Dunn
7#
8# Created: 5-Sept-2000
9# RCS-ID: $Id$
10# Copyright: (c) 2000 by Total Control Software
11# Licence: wxWindows license
12#----------------------------------------------------------------------------
13
14
15import sys, string, re, os
16from fileinput import FileInput
17
18
19IFACE = os.path.abspath('./scintilla/include/Scintilla.iface')
20H_TEMPLATE = os.path.abspath('./stc.h.in')
21CPP_TEMPLATE = os.path.abspath('./stc.cpp.in')
22H_DEST = os.path.abspath('../../include/wx/stc/stc.h')
23CPP_DEST = os.path.abspath('./stc.cpp')
24
25
26# Value prefixes to convert
27valPrefixes = [('SCI_', ''),
28 ('SC_', ''),
29 ('SCN_', None), # just toss these out...
30 ('SCEN_', None),
31 ('SCE_', ''),
32 ('SCLEX_', 'LEX_'),
33 ('SCK_', 'KEY_'),
34 ('SCFIND_', 'FIND_'),
35 ('SCWS_', 'WS_'),
36]
37
38# Message function values that should have a CMD_ constant as well
39cmdValues = [ (2300, 2350), 2011, 2013, (2176, 2180) ]
40
41
42# Map some generic typenames to wx types, using return value syntax
43retTypeMap = {
44 'position': 'int',
45 'string': 'wxString',
46 'colour': 'wxColour',
47 }
48
49# Map some generic typenames to wx types, using parameter syntax
50paramTypeMap = {
51 'position': 'int',
52 'string': 'const wxString&',
53 'colour': 'const wxColour&',
54 'keymod': 'int',
55}
56
57# Map of method info that needs tweaked. Either the name needs changed, or
58# the method definition/implementation. Tuple items are:
59#
60# 1. New method name. None to skip the method, 0 to leave the
61# default name.
62# 2. Method definition for the .h file, 0 to leave alone
63# 3. Method implementation for the .cpp file, 0 to leave alone.
64# 4. tuple of Doc string lines, or 0 to leave alone.
65#
66methodOverrideMap = {
67 'AddText' : (0,
68 'void %s(const wxString& text);',
69
70 '''void %s(const wxString& text) {
71 SendMsg(%s, text.Len(), (long)text.c_str());''',
72 0),
73
74 'AddStyledText' : (0,
75 'void %s(const wxString& text);',
76
77 '''void %s(const wxString& text) {
78 SendMsg(%s, text.Len(), (long)text.c_str());''',
79 0),
80
81 'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
82 'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
83
84 'GetStyledText' : (0,
85 'wxString %s(int startPos, int endPos);',
86
87 '''wxString %s(int startPos, int endPos) {
88 wxString text;
89 if (endPos < startPos) {
90 int temp = startPos;
91 startPos = endPos;
92 endPos = temp;
93 }
94 int len = endPos - startPos;
95 if (!len) return "";
96 TextRange tr;
97 tr.lpstrText = text.GetWriteBuf(len*2);
98 tr.chrg.cpMin = startPos;
99 tr.chrg.cpMax = endPos;
100 SendMsg(%s, 0, (long)&tr);
101 text.UngetWriteBuf(len*2);
102 return text;''',
103
104 ('Retrieve a buffer of cells.',)),
105
106
107 'PositionFromPoint' : (0,
108 'int %s(wxPoint pt);',
109
110 '''int %s(wxPoint pt) {
111 return SendMsg(%s, pt.x, pt.y);''',
112
113 0),
114
115 'GetCurLine' : (0,
116 '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif',
117
118 '''wxString %s(int* linePos) {
119 wxString text;
120 int len = LineLength(GetCurrentLine());
121 if (!len) {
122 if (linePos) *linePos = 0;
123 return "";
124 }
125 // Need an extra byte because SCI_GETCURLINE writes a null to the string
126 char* buf = text.GetWriteBuf(len+1);
127
128 int pos = SendMsg(%s, len+1, (long)buf);
129 text.UngetWriteBuf(len);
130 if (linePos) *linePos = pos;
131
132 return text;''',
133
134 0),
135
136 'SetUsePalette' : (None, 0,0,0),
137
138 'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0),
139 'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0),
140
141 'MarkerDefine' : (0,
142 '''void %s(int markerNumber, int markerSymbol,
143 const wxColour& foreground = wxNullColour,
144 const wxColour& background = wxNullColour);''',
145
146 '''void %s(int markerNumber, int markerSymbol,
147 const wxColour& foreground,
148 const wxColour& background) {
149
150 SendMsg(%s, markerNumber, markerSymbol);
151 if (foreground.Ok())
152 MarkerSetForeground(markerNumber, foreground);
153 if (background.Ok())
154 MarkerSetBackground(markerNumber, background);''',
155
156 ('Set the symbol used for a particular marker number,',
157 'and optionally the for and background colours.')),
158
159 'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
160 'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
161 'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0),
162 'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0),
163 'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0),
164 'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0),
165 'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
166 'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
167
168 'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
169 'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
170 'SetSelFore' : ('SetSelForeground', 0, 0, 0),
171 'SetSelBack' : ('SetSelBackground', 0, 0, 0),
172 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
173 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
174
175 # need to fix this to map between wx and scintilla encoding flags, leave it out for now...
176 'StyleSetCharacterSet' : (None, 0, 0, 0),
177
178 'AssignCmdKey' : ('CmdKeyAssign',
179 'void %s(int key, int modifiers, int cmd);',
180
181 '''void %s(int key, int modifiers, int cmd) {
182 SendMsg(%s, MAKELONG(key, modifiers), cmd);''',
183
184 0),
185
186 'ClearCmdKey' : ('CmdKeyClear',
187 'void %s(int key, int modifiers);',
188
189 '''void %s(int key, int modifiers) {
190 SendMsg(%s, MAKELONG(key, modifiers));''',
191
192 0),
193
194 'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0),
195
196
197 'SetStylingEx' : ('SetStyleBytes',
198 'void %s(int length, char* styleBytes);',
199
200 '''void %s(int length, char* styleBytes) {
201 SendMsg(%s, length, (long)styleBytes);''',
202
203 0),
204
205
206 'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0),
207 'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
208 'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
209 'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
210
211 'AutoCShow' : ('AutoCompShow', 0, 0, 0),
212 'AutoCCancel' : ('AutoCompCancel', 0, 0, 0),
213 'AutoCActive' : ('AutoCompActive', 0, 0, 0),
214 'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0),
215 'AutoCComplete' : ('AutoCompComplete', 0, 0, 0),
216 'AutoCStops' : ('AutoCompStops', 0, 0, 0),
217 'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0),
218 'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0),
219 'AutoCSelect' : ('AutoCompSelect', 0, 0, 0),
220 'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0),
221 'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0),
222 'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0),
223 'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0),
224 'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
225 'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
226 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
227 'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
228 'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
229
230
231 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
232 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
233
234 'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
235
236 'GetUsePalette' : (None, 0, 0, 0),
237
238 'FindText' : (0,
239 '''int %s(int minPos, int maxPos,
240 const wxString& text,
241 bool caseSensitive, bool wholeWord);''',
242 '''int %s(int minPos, int maxPos,
243 const wxString& text,
244 bool caseSensitive, bool wholeWord) {
245 TextToFind ft;
246 int flags = 0;
247
248 flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
249 flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
250 ft.chrg.cpMin = minPos;
251 ft.chrg.cpMax = maxPos;
252 ft.lpstrText = (char*)text.c_str();
253
254 return SendMsg(%s, flags, (long)&ft);''',
255 0),
256
257 'FormatRange' : (0,
258 '''int %s(bool doDraw,
259 int startPos,
260 int endPos,
261 wxDC* draw,
262 wxDC* target, // Why does it use two? Can they be the same?
263 wxRect renderRect,
264 wxRect pageRect);''',
265 ''' int %s(bool doDraw,
266 int startPos,
267 int endPos,
268 wxDC* draw,
269 wxDC* target, // Why does it use two? Can they be the same?
270 wxRect renderRect,
271 wxRect pageRect) {
272 RangeToFormat fr;
273
274 if (endPos < startPos) {
275 int temp = startPos;
276 startPos = endPos;
277 endPos = temp;
278 }
279 fr.hdc = draw;
280 fr.hdcTarget = target;
281 fr.rc.top = renderRect.GetTop();
282 fr.rc.left = renderRect.GetLeft();
283 fr.rc.right = renderRect.GetRight();
284 fr.rc.bottom = renderRect.GetBottom();
285 fr.rcPage.top = pageRect.GetTop();
286 fr.rcPage.left = pageRect.GetLeft();
287 fr.rcPage.right = pageRect.GetRight();
288 fr.rcPage.bottom = pageRect.GetBottom();
289 fr.chrg.cpMin = startPos;
290 fr.chrg.cpMax = endPos;
291
292 return SendMsg(%s, doDraw, (long)&fr);''',
293 0),
294
295
296 'GetLine' : (0,
297 'wxString %s(int line);',
298
299 '''wxString %s(int line) {
300 wxString text;
301 int len = LineLength(line);
302 if (!len) return "";
303 char* buf = text.GetWriteBuf(len);
304
305 int pos = SendMsg(%s, line, (long)buf);
306 text.UngetWriteBuf(len);
307
308 return text;''',
309
310 ('Retrieve the contents of a line.',)),
311
312 'SetSel' : ('SetSelection', 0, 0, 0),
313 'GetSelText' : ('GetSelectedText',
314 'wxString %s();',
315
316 '''wxString %s() {
317 wxString text;
318 int start;
319 int end;
320
321 GetSelection(&start, &end);
322 int len = end - start;
323 if (!len) return "";
324 char* buff = text.GetWriteBuf(len);
325
326 SendMsg(%s, 0, (long)buff);
327 text.UngetWriteBuf(len);
328 return text;''',
329
330 ('Retrieve the selected text.',)),
331
332 'GetTextRange' : (0,
333 'wxString %s(int startPos, int endPos);',
334
335 '''wxString %s(int startPos, int endPos) {
336 wxString text;
337 if (endPos < startPos) {
338 int temp = startPos;
339 startPos = endPos;
340 endPos = temp;
341 }
342 int len = endPos - startPos;
343 if (!len) return "";
344 char* buff = text.GetWriteBuf(len);
345 TextRange tr;
346 tr.lpstrText = buff;
347 tr.chrg.cpMin = startPos;
348 tr.chrg.cpMax = endPos;
349
350 SendMsg(%s, 0, (long)&tr);
351 text.UngetWriteBuf(len);
352 return text;''',
353
354 ('Retrieve a range of text.',)),
355
356 'PointXFromPosition' : (None, 0, 0, 0),
357 'PointYFromPosition' : (None, 0, 0, 0),
358
359 'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
360 'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
361 'Null' : (None, 0, 0, 0),
362
363 'GetText' : (0,
364 'wxString %s();',
365
366 '''wxString %s() {
367 wxString text;
368 int len = GetTextLength();
369 char* buff = text.GetWriteBuf(len+1); // leave room for the null...
370
371 SendMsg(%s, len+1, (long)buff);
372 text.UngetWriteBuf(len);
373 return text;''',
374
375 ('Retrieve all the text in the document.', )),
376
377 'GetDirectFunction' : (None, 0, 0, 0),
378 'GetDirectPointer' : (None, 0, 0, 0),
379
380 'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
381 'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
382 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
383
384
385 'ReplaceTarget' : (0,
386 'int %s(const wxString& text);',
387
388 '''
389 int %s(const wxString& text) {
390 return SendMsg(%s, text.Len(), (long)text.c_str());
391 ''',
392
393 0),
394
395 'ReplaceTargetRE' : (0,
396 'int %s(const wxString& text);',
397
398 '''
399 int %s(const wxString& text) {
400 return SendMsg(%s, text.Len(), (long)text.c_str());
401 ''',
402
403 0),
404
405 'SearchInTarget' : (0,
406 'int %s(const wxString& text);',
407
408 '''
409 int %s(const wxString& text) {
410 return SendMsg(%s, text.Len(), (long)text.c_str());
411 ''',
412
413 0),
414
415
416
417 # Remove all methods that are key commands since they can be
418 # executed with CmdKeyExecute
419 'LineDown' : (None, 0, 0, 0),
420 'LineDownExtend' : (None, 0, 0, 0),
421 'LineUp' : (None, 0, 0, 0),
422 'LineUpExtend' : (None, 0, 0, 0),
423 'CharLeft' : (None, 0, 0, 0),
424 'CharLeftExtend' : (None, 0, 0, 0),
425 'CharRight' : (None, 0, 0, 0),
426 'CharRightExtend' : (None, 0, 0, 0),
427 'WordLeft' : (None, 0, 0, 0),
428 'WordLeftExtend' : (None, 0, 0, 0),
429 'WordRight' : (None, 0, 0, 0),
430 'WordRightExtend' : (None, 0, 0, 0),
431 'Home' : (None, 0, 0, 0),
432 'HomeExtend' : (None, 0, 0, 0),
433 'LineEnd' : (None, 0, 0, 0),
434 'LineEndExtend' : (None, 0, 0, 0),
435 'DocumentStart' : (None, 0, 0, 0),
436 'DocumentStartExtend' : (None, 0, 0, 0),
437 'DocumentEnd' : (None, 0, 0, 0),
438 'DocumentEndExtend' : (None, 0, 0, 0),
439 'PageUp' : (None, 0, 0, 0),
440 'PageUpExtend' : (None, 0, 0, 0),
441 'PageDown' : (None, 0, 0, 0),
442 'PageDownExtend' : (None, 0, 0, 0),
443 'EditToggleOvertype' : (None, 0, 0, 0),
444 'Cancel' : (None, 0, 0, 0),
445 'DeleteBack' : (None, 0, 0, 0),
446 'Tab' : (None, 0, 0, 0),
447 'BackTab' : (None, 0, 0, 0),
448 'NewLine' : (None, 0, 0, 0),
449 'FormFeed' : (None, 0, 0, 0),
450 'VCHome' : (None, 0, 0, 0),
451 'VCHomeExtend' : (None, 0, 0, 0),
452 'ZoomIn' : (None, 0, 0, 0),
453 'ZoomOut' : (None, 0, 0, 0),
454 'DelWordLeft' : (None, 0, 0, 0),
455 'DelWordRight' : (None, 0, 0, 0),
456 'LineCut' : (None, 0, 0, 0),
457 'LineDelete' : (None, 0, 0, 0),
458 'LineTranspose' : (None, 0, 0, 0),
459 'LowerCase' : (None, 0, 0, 0),
460 'UpperCase' : (None, 0, 0, 0),
461 'LineScrollDown' : (None, 0, 0, 0),
462 'LineScrollUp' : (None, 0, 0, 0),
463
464
465 'GetDocPointer' : (0,
466 'void* %s();',
467 '''void* %s() {
468 return (void*)SendMsg(%s);''',
469 0),
470
471 'SetDocPointer' : (0,
472 'void %s(void* docPointer);',
473 '''void %s(void* docPointer) {
474 SendMsg(%s, 0, (long)docPointer);''',
475 0),
476
477 'CreateDocument' : (0,
478 'void* %s();',
479 '''void* %s() {
480 return (void*)SendMsg(%s);''',
481 0),
482
483 'AddRefDocument' : (0,
484 'void %s(void* docPointer);',
485 '''void %s(void* docPointer) {
486 SendMsg(%s, (long)docPointer);''',
487 0),
488
489 'ReleaseDocument' : (0,
490 'void %s(void* docPointer);',
491 '''void %s(void* docPointer) {
492 SendMsg(%s, (long)docPointer);''',
493 0),
494
495 'GrabFocus' : (None, 0, 0, 0),
496 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
497 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
498
499
500 '' : ('', 0, 0, 0),
501
502 }
503
504#----------------------------------------------------------------------------
505
506def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest):
507 curDocStrings = []
508 values = []
509 methods = []
510
511 # parse iface file
512 fi = FileInput(iface)
513 for line in fi:
514 line = line[:-1]
515 if line[:2] == '##' or line == '':
516 #curDocStrings = []
517 continue
518
519 op = line[:4]
520 if line[:2] == '# ': # a doc string
521 curDocStrings.append(line[2:])
522
523 elif op == 'val ':
524 parseVal(line[4:], values, curDocStrings)
525 curDocStrings = []
526
527 elif op == 'fun ' or op == 'set ' or op == 'get ':
528 parseFun(line[4:], methods, curDocStrings, values)
529 curDocStrings = []
530
531 elif op == 'cat ':
532 if string.strip(line[4:]) == 'Deprecated':
533 break # skip the rest of the file
534
535 elif op == 'evt ':
536 pass
537
538 else:
539 print '***** Unknown line type: ', line
540
541
542 # process templates
543 data = {}
544 data['VALUES'] = processVals(values)
545 defs, imps = processMethods(methods)
546 data['METHOD_DEFS'] = defs
547 data['METHOD_IMPS'] = imps
548
549 # get template text
550 h_text = open(h_tmplt).read()
551 cpp_text = open(cpp_tmplt).read()
552
553 # do the substitutions
554 h_text = h_text % data
555 cpp_text = cpp_text % data
556
557 # write out destination files
558 open(h_dest, 'w').write(h_text)
559 open(cpp_dest, 'w').write(cpp_text)
560
561
562
563#----------------------------------------------------------------------------
564
565def processVals(values):
566 text = []
567 for name, value, docs in values:
568 if docs:
569 text.append('')
570 for x in docs:
571 text.append('// ' + x)
572 text.append('#define %s %s' % (name, value))
573 return string.join(text, '\n')
574
575#----------------------------------------------------------------------------
576
577def processMethods(methods):
578 defs = []
579 imps = []
580
581 for retType, name, number, param1, param2, docs in methods:
582 retType = retTypeMap.get(retType, retType)
583 params = makeParamString(param1, param2)
584
585 name, theDef, theImp, docs = checkMethodOverride(name, number, docs)
586
587 if name is None:
588 continue
589
590 # Build the method definition for the .h file
591 if docs:
592 defs.append('')
593 for x in docs:
594 defs.append(' // ' + x)
595 if not theDef:
596 theDef = ' %s %s(%s);' % (retType, name, params)
597 defs.append(theDef)
598
599 # Build the method implementation string
600 if docs:
601 imps.append('')
602 for x in docs:
603 imps.append('// ' + x)
604 if not theImp:
605 theImp = '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType, name, params)
606
607 if retType == 'wxColour':
608 theImp = theImp + 'long c = '
609 elif retType != 'void':
610 theImp = theImp + 'return '
611 theImp = theImp + 'SendMsg(%s, %s, %s)' % (number,
612 makeArgString(param1),
613 makeArgString(param2))
614 if retType == 'bool':
615 theImp = theImp + ' != 0'
616 if retType == 'wxColour':
617 theImp = theImp + ';\n return wxColourFromLong(c)'
618
619 theImp = theImp + ';\n}'
620 imps.append(theImp)
621
622
623 return string.join(defs, '\n'), string.join(imps, '\n')
624
625
626#----------------------------------------------------------------------------
627
628def checkMethodOverride(name, number, docs):
629 theDef = theImp = None
630 if methodOverrideMap.has_key(name):
631 item = methodOverrideMap[name]
632
633 if item[0] != 0:
634 name = item[0]
635 if item[1] != 0:
636 theDef = ' ' + (item[1] % name)
637 if item[2] != 0:
638 theImp = item[2] % ('wxStyledTextCtrl::'+name, number) + '\n}'
639 if item[3] != 0:
640 docs = item[3]
641
642 return name, theDef, theImp, docs
643
644#----------------------------------------------------------------------------
645
646def makeArgString(param):
647 if not param:
648 return '0'
649
650 typ, name = param
651
652 if typ == 'string':
653 return '(long)%s.c_str()' % name
654 if typ == 'colour':
655 return 'wxColourAsLong(%s)' % name
656
657 return name
658
659#----------------------------------------------------------------------------
660
661def makeParamString(param1, param2):
662 def doOne(param):
663 if param:
664 aType = paramTypeMap.get(param[0], param[0])
665 return aType + ' ' + param[1]
666 else:
667 return ''
668
669 st = doOne(param1)
670 if st and param2:
671 st = st + ', '
672 st = st + doOne(param2)
673 return st
674
675
676#----------------------------------------------------------------------------
677
678def parseVal(line, values, docs):
679 name, val = string.split(line, '=')
680
681 # remove prefixes such as SCI, etc.
682 for old, new in valPrefixes:
683 lo = len(old)
684 if name[:lo] == old:
685 if new is None:
686 return
687 name = new + name[lo:]
688
689 # add it to the list
690 values.append( ('wxSTC_' + name, val, docs) )
691
692#----------------------------------------------------------------------------
693
694funregex = re.compile(r'\s*([a-zA-Z0-9_]+)' # <ws>return type
695 '\s+([a-zA-Z0-9_]+)=' # <ws>name=
696 '([0-9]+)' # number
697 '\(([ a-zA-Z0-9_]*),' # (param,
698 '([ a-zA-Z0-9_]*)\)') # param)
699
700def parseFun(line, methods, docs, values):
701 def parseParam(param):
702 param = string.strip(param)
703 if param == '':
704 param = None
705 else:
706 param = tuple(string.split(param))
707 return param
708
709 mo = funregex.match(line)
710 if mo is None:
711 print "***** Line doesn't match! : " + line
712
713 retType, name, number, param1, param2 = mo.groups()
714
715 param1 = parseParam(param1)
716 param2 = parseParam(param2)
717
718 # Special case. For the key command functionss we want a value defined too
719 num = string.atoi(number)
720 for v in cmdValues:
721 if (type(v) == type(()) and v[0] <= num < v[1]) or v == num:
722 parseVal('CMD_%s=%s' % (string.upper(name), number), values, ())
723
724 #if retType == 'void' and not param1 and not param2:
725
726 methods.append( (retType, name, number, param1, param2, tuple(docs)) )
727
728
729#----------------------------------------------------------------------------
730
731
732def main(args):
733 # TODO: parse command line args to replace default input/output files???
734
735 # Now just do it
736 processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST)
737
738
739
740if __name__ == '__main__':
741 main(sys.argv)
742
743#----------------------------------------------------------------------------
744