]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/gen_iface.py
2 #----------------------------------------------------------------------------
4 # Purpose: Generate stc.h and stc.cpp from the info in Scintilla.iface
10 # Copyright: (c) 2000 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------------
15 import sys
, string
, re
, os
16 from fileinput
import FileInput
19 IFACE
= os
.path
.abspath('./scintilla/include/Scintilla.iface')
20 H_TEMPLATE
= os
.path
.abspath('./stc.h.in')
21 CPP_TEMPLATE
= os
.path
.abspath('./stc.cpp.in')
22 H_DEST
= os
.path
.abspath('../../include/wx/stc/stc.h')
23 CPP_DEST
= os
.path
.abspath('./stc.cpp')
26 # Value prefixes to convert
27 valPrefixes
= [('SCI_', ''),
29 ('SCN_', None), # just toss these out...
38 # Message function values that should have a CMD_ constant as well
39 cmdValues
= [ (2300, 2349),
51 # Map some generic typenames to wx types, using return value syntax
58 # Map some generic typenames to wx types, using parameter syntax
61 'string': 'const wxString&',
62 'colour': 'const wxColour&',
66 # Map of method info that needs tweaked. Either the name needs changed, or
67 # the method definition/implementation. Tuple items are:
69 # 1. New method name. None to skip the method, 0 to leave the
71 # 2. Method definition for the .h file, 0 to leave alone
72 # 3. Method implementation for the .cpp file, 0 to leave alone.
73 # 4. tuple of Doc string lines, or 0 to leave alone.
77 'void %s(const wxString& text);',
79 '''void %s(const wxString& text) {
80 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
81 SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
85 'void %s(const wxMemoryBuffer& data);',
87 '''void %s(const wxMemoryBuffer& data) {
88 SendMsg(%s, data.GetDataLen(), (long)data.GetData());''',
91 'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
92 'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
97 return (unsigned char)SendMsg(%s, pos, 0);''',
103 return (unsigned char)SendMsg(%s, pos, 0);''',
108 'wxMemoryBuffer %s(int startPos, int endPos);',
110 '''wxMemoryBuffer %s(int startPos, int endPos) {
112 if (endPos < startPos) {
117 int len = endPos - startPos;
118 if (!len) return buf;
120 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
121 tr.chrg.cpMin = startPos;
122 tr.chrg.cpMax = endPos;
123 len = SendMsg(%s, 0, (long)&tr);
124 buf.UngetWriteBuf(len);
127 ('Retrieve a buffer of cells.',)),
130 'PositionFromPoint' :
132 'int %s(wxPoint pt);',
134 '''int %s(wxPoint pt) {
135 return SendMsg(%s, pt.x, pt.y);''',
140 '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif',
142 '''wxString %s(int* linePos) {
143 int len = LineLength(GetCurrentLine());
145 if (linePos) *linePos = 0;
146 return wxEmptyString;
149 wxMemoryBuffer mbuf(len+1);
150 char* buf = (char*)mbuf.GetWriteBuf(len+1);
152 int pos = SendMsg(%s, len+1, (long)buf);
153 mbuf.UngetWriteBuf(len);
155 if (linePos) *linePos = pos;
156 return stc2wx(buf);''',
160 'SetUsePalette' : (None, 0,0,0),
162 'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0),
163 'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0),
167 '''void %s(int markerNumber, int markerSymbol,
168 const wxColour& foreground = wxNullColour,
169 const wxColour& background = wxNullColour);''',
171 '''void %s(int markerNumber, int markerSymbol,
172 const wxColour& foreground,
173 const wxColour& background) {
175 SendMsg(%s, markerNumber, markerSymbol);
177 MarkerSetForeground(markerNumber, foreground);
179 MarkerSetBackground(markerNumber, background);''',
181 ('Set the symbol used for a particular marker number,',
182 'and optionally the fore and background colours.')),
185 'MarkerDefinePixmap' :
186 ('MarkerDefineBitmap',
187 '''void %s(int markerNumber, const wxBitmap& bmp);''',
188 '''void %s(int markerNumber, const wxBitmap& bmp) {
189 // convert bmp to a xpm in a string
190 wxMemoryOutputStream strm;
191 wxImage img = bmp.ConvertToImage();
192 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
193 size_t len = strm.GetSize();
194 char* buff = new char[len+1];
195 strm.CopyTo(buff, len);
197 SendMsg(%s, markerNumber, (long)buff);
200 ('Define a marker from a bitmap',)),
203 'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
204 'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
205 'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0),
206 'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0),
207 'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0),
208 'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0),
209 'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
210 'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
212 'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
213 'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
214 'SetSelFore' : ('SetSelForeground', 0, 0, 0),
215 'SetSelBack' : ('SetSelBackground', 0, 0, 0),
216 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
217 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
221 'void %s(int key, int modifiers, int cmd);',
223 '''void %s(int key, int modifiers, int cmd) {
224 SendMsg(%s, MAKELONG(key, modifiers), cmd);''',
230 'void %s(int key, int modifiers);',
232 '''void %s(int key, int modifiers) {
233 SendMsg(%s, MAKELONG(key, modifiers));''',
236 'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0),
241 'void %s(int length, char* styleBytes);',
243 '''void %s(int length, char* styleBytes) {
244 SendMsg(%s, length, (long)styleBytes);''',
248 'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0),
249 'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
250 'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
251 'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
253 'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
254 'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
256 'AutoCShow' : ('AutoCompShow', 0, 0, 0),
257 'AutoCCancel' : ('AutoCompCancel', 0, 0, 0),
258 'AutoCActive' : ('AutoCompActive', 0, 0, 0),
259 'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0),
260 'AutoCComplete' : ('AutoCompComplete', 0, 0, 0),
261 'AutoCStops' : ('AutoCompStops', 0, 0, 0),
262 'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0),
263 'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0),
264 'AutoCSelect' : ('AutoCompSelect', 0, 0, 0),
265 'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0),
266 'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0),
267 'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0),
268 'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0),
269 'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
270 'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
271 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
272 'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
273 'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
274 'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
275 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
276 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0),
277 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0),
281 '''void %s(int type, const wxBitmap& bmp);''',
282 '''void %s(int type, const wxBitmap& bmp) {
283 // convert bmp to a xpm in a string
284 wxMemoryOutputStream strm;
285 wxImage img = bmp.ConvertToImage();
286 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
287 size_t len = strm.GetSize();
288 char* buff = new char[len+1];
289 strm.CopyTo(buff, len);
291 SendMsg(%s, type, (long)buff);
294 ('Register an image for use in autocompletion lists.',)),
297 'ClearRegisteredImages' : (0, 0, 0,
298 ('Clear all the registered images.',)),
301 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
302 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
304 'SetVScrollBar' : ('SetUseVerticalScrollBar', 0, 0, 0),
305 'GetVScrollBar' : ('GetUseVerticalScrollBar', 0, 0, 0),
307 'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
309 'GetUsePalette' : (None, 0, 0, 0),
313 '''int %s(int minPos, int maxPos, const wxString& text, int flags=0);''',
315 '''int %s(int minPos, int maxPos,
316 const wxString& text,
319 ft.chrg.cpMin = minPos;
320 ft.chrg.cpMax = maxPos;
321 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
322 ft.lpstrText = (char*)(const char*)buf;
324 return SendMsg(%s, flags, (long)&ft);''',
329 '''int %s(bool doDraw,
333 wxDC* target, // Why does it use two? Can they be the same?
335 wxRect pageRect);''',
336 ''' int %s(bool doDraw,
340 wxDC* target, // Why does it use two? Can they be the same?
345 if (endPos < startPos) {
351 fr.hdcTarget = target;
352 fr.rc.top = renderRect.GetTop();
353 fr.rc.left = renderRect.GetLeft();
354 fr.rc.right = renderRect.GetRight();
355 fr.rc.bottom = renderRect.GetBottom();
356 fr.rcPage.top = pageRect.GetTop();
357 fr.rcPage.left = pageRect.GetLeft();
358 fr.rcPage.right = pageRect.GetRight();
359 fr.rcPage.bottom = pageRect.GetBottom();
360 fr.chrg.cpMin = startPos;
361 fr.chrg.cpMax = endPos;
363 return SendMsg(%s, doDraw, (long)&fr);''',
369 'wxString %s(int line);',
371 '''wxString %s(int line) {
372 int len = LineLength(line);
373 if (!len) return wxEmptyString;
375 wxMemoryBuffer mbuf(len+1);
376 char* buf = (char*)mbuf.GetWriteBuf(len+1);
377 SendMsg(%s, line, (long)buf);
378 mbuf.UngetWriteBuf(len);
380 return stc2wx(buf);''',
382 ('Retrieve the contents of a line.',)),
384 'SetSel' : ('SetSelection', 0, 0, 0),
394 GetSelection(&start, &end);
395 int len = end - start;
396 if (!len) return wxEmptyString;
398 wxMemoryBuffer mbuf(len+2);
399 char* buf = (char*)mbuf.GetWriteBuf(len+1);
400 SendMsg(%s, 0, (long)buf);
401 mbuf.UngetWriteBuf(len);
403 return stc2wx(buf);''',
405 ('Retrieve the selected text.',)),
410 'wxString %s(int startPos, int endPos);',
412 '''wxString %s(int startPos, int endPos) {
413 if (endPos < startPos) {
418 int len = endPos - startPos;
419 if (!len) return wxEmptyString;
420 wxMemoryBuffer mbuf(len+1);
421 char* buf = (char*)mbuf.GetWriteBuf(len);
424 tr.chrg.cpMin = startPos;
425 tr.chrg.cpMax = endPos;
426 SendMsg(%s, 0, (long)&tr);
427 mbuf.UngetWriteBuf(len);
429 return stc2wx(buf);''',
431 ('Retrieve a range of text.',)),
433 'PointXFromPosition' : (None, 0, 0, 0),
434 'PointYFromPosition' : (None, 0, 0, 0),
436 'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
437 'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
438 'Null' : (None, 0, 0, 0),
445 int len = GetTextLength();
446 wxMemoryBuffer mbuf(len+1); // leave room for the null...
447 char* buf = (char*)mbuf.GetWriteBuf(len+1);
448 SendMsg(%s, len+1, (long)buf);
449 mbuf.UngetWriteBuf(len);
451 return stc2wx(buf);''',
453 ('Retrieve all the text in the document.', )),
455 'GetDirectFunction' : (None, 0, 0, 0),
456 'GetDirectPointer' : (None, 0, 0, 0),
458 'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
459 'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
460 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
461 'CallTipSetFore' : ('CallTipSetForeground', 0, 0, 0),
462 'CallTipSetForeHlt' : ('CallTipSetForegroundHighlight', 0, 0, 0),
464 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
465 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
470 'int %s(const wxString& text);',
473 int %s(const wxString& text) {
474 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
475 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
480 'int %s(const wxString& text);',
483 int %s(const wxString& text) {
484 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
485 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
490 'int %s(const wxString& text);',
493 int %s(const wxString& text) {
494 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
495 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
503 return (void*)SendMsg(%s);''',
508 'void %s(void* docPointer);',
509 '''void %s(void* docPointer) {
510 SendMsg(%s, 0, (long)docPointer);''',
517 return (void*)SendMsg(%s);''',
522 'void %s(void* docPointer);',
523 '''void %s(void* docPointer) {
524 SendMsg(%s, 0, (long)docPointer);''',
529 'void %s(void* docPointer);',
530 '''void %s(void* docPointer) {
531 SendMsg(%s, 0, (long)docPointer);''',
537 '''void %s(int codePage) {
539 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
540 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
542 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
543 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
545 SendMsg(%s, codePage);''',
546 ("Set the code page used to interpret the bytes of the document as characters.",) ),
549 'GrabFocus' : (None, 0, 0, 0),
550 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
551 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
554 'LoadLexerLibrary' : (None, 0,0,0),
558 # Remove all methods that are key commands since they can be
559 # executed with CmdKeyExecute
560 'LineDown' : (None, 0, 0, 0),
561 'LineDownExtend' : (None, 0, 0, 0),
562 'LineUp' : (None, 0, 0, 0),
563 'LineUpExtend' : (None, 0, 0, 0),
564 'CharLeft' : (None, 0, 0, 0),
565 'CharLeftExtend' : (None, 0, 0, 0),
566 'CharRight' : (None, 0, 0, 0),
567 'CharRightExtend' : (None, 0, 0, 0),
568 'WordLeft' : (None, 0, 0, 0),
569 'WordLeftExtend' : (None, 0, 0, 0),
570 'WordRight' : (None, 0, 0, 0),
571 'WordRightExtend' : (None, 0, 0, 0),
572 'Home' : (None, 0, 0, 0),
573 'HomeExtend' : (None, 0, 0, 0),
574 'LineEnd' : (None, 0, 0, 0),
575 'LineEndExtend' : (None, 0, 0, 0),
576 'DocumentStart' : (None, 0, 0, 0),
577 'DocumentStartExtend' : (None, 0, 0, 0),
578 'DocumentEnd' : (None, 0, 0, 0),
579 'DocumentEndExtend' : (None, 0, 0, 0),
580 'PageUp' : (None, 0, 0, 0),
581 'PageUpExtend' : (None, 0, 0, 0),
582 'PageDown' : (None, 0, 0, 0),
583 'PageDownExtend' : (None, 0, 0, 0),
584 'EditToggleOvertype' : (None, 0, 0, 0),
585 'Cancel' : (None, 0, 0, 0),
586 'DeleteBack' : (None, 0, 0, 0),
587 'Tab' : (None, 0, 0, 0),
588 'BackTab' : (None, 0, 0, 0),
589 'NewLine' : (None, 0, 0, 0),
590 'FormFeed' : (None, 0, 0, 0),
591 'VCHome' : (None, 0, 0, 0),
592 'VCHomeExtend' : (None, 0, 0, 0),
593 'ZoomIn' : (None, 0, 0, 0),
594 'ZoomOut' : (None, 0, 0, 0),
595 'DelWordLeft' : (None, 0, 0, 0),
596 'DelWordRight' : (None, 0, 0, 0),
597 'LineCut' : (None, 0, 0, 0),
598 'LineDelete' : (None, 0, 0, 0),
599 'LineTranspose' : (None, 0, 0, 0),
600 'LowerCase' : (None, 0, 0, 0),
601 'UpperCase' : (None, 0, 0, 0),
602 'LineScrollDown' : (None, 0, 0, 0),
603 'LineScrollUp' : (None, 0, 0, 0),
604 'DeleteBackNotLine' : (None, 0, 0, 0),
605 'HomeWrap' : (None, 0, 0, 0),
606 'HomeWrapExtend' : (None, 0, 0, 0),
607 'LineEndWrap' : (None, 0, 0, 0),
608 'LineEndWrapExtend' : (None, 0, 0, 0),
609 'VCHomeWrap' : (None, 0, 0, 0),
610 'VCHomeWrapExtend' : (None, 0, 0, 0),
611 'ParaDown' : (None, 0, 0, 0),
612 'ParaDownExtend' : (None, 0, 0, 0),
613 'ParaUp' : (None, 0, 0, 0),
614 'ParaUpExtend' : (None, 0, 0, 0),
622 #----------------------------------------------------------------------------
624 def processIface(iface
, h_tmplt
, cpp_tmplt
, h_dest
, cpp_dest
):
631 fi
= FileInput(iface
)
634 if line
[:2] == '##' or line
== '':
639 if line
[:2] == '# ': # a doc string
640 curDocStrings
.append(line
[2:])
643 parseVal(line
[4:], values
, curDocStrings
)
646 elif op
== 'fun ' or op
== 'set ' or op
== 'get ':
647 parseFun(line
[4:], methods
, curDocStrings
, cmds
)
651 if string
.strip(line
[4:]) == 'Deprecated':
652 break # skip the rest of the file
664 print '***** Unknown line type: ', line
669 data
['VALUES'] = processVals(values
)
670 data
['CMDS'] = processVals(cmds
)
671 defs
, imps
= processMethods(methods
)
672 data
['METHOD_DEFS'] = defs
673 data
['METHOD_IMPS'] = imps
676 h_text
= open(h_tmplt
).read()
677 cpp_text
= open(cpp_tmplt
).read()
679 # do the substitutions
680 h_text
= h_text
% data
681 cpp_text
= cpp_text
% data
683 # write out destination files
684 open(h_dest
, 'w').write(h_text
)
685 open(cpp_dest
, 'w').write(cpp_text
)
689 #----------------------------------------------------------------------------
691 def processVals(values
):
693 for name
, value
, docs
in values
:
697 text
.append('// ' + x
)
698 text
.append('#define %s %s' % (name
, value
))
699 return string
.join(text
, '\n')
701 #----------------------------------------------------------------------------
703 def processMethods(methods
):
707 for retType
, name
, number
, param1
, param2
, docs
in methods
:
708 retType
= retTypeMap
.get(retType
, retType
)
709 params
= makeParamString(param1
, param2
)
711 name
, theDef
, theImp
, docs
= checkMethodOverride(name
, number
, docs
)
716 # Build the method definition for the .h file
720 defs
.append(' // ' + x
)
722 theDef
= ' %s %s(%s);' % (retType
, name
, params
)
725 # Build the method implementation string
729 imps
.append('// ' + x
)
731 theImp
= '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType
, name
, params
)
733 if retType
== 'wxColour':
734 theImp
= theImp
+ 'long c = '
735 elif retType
!= 'void':
736 theImp
= theImp
+ 'return '
737 theImp
= theImp
+ 'SendMsg(%s, %s, %s)' % (number
,
738 makeArgString(param1
),
739 makeArgString(param2
))
740 if retType
== 'bool':
741 theImp
= theImp
+ ' != 0'
742 if retType
== 'wxColour':
743 theImp
= theImp
+ ';\n return wxColourFromLong(c)'
745 theImp
= theImp
+ ';\n}'
749 return string
.join(defs
, '\n'), string
.join(imps
, '\n')
752 #----------------------------------------------------------------------------
754 def checkMethodOverride(name
, number
, docs
):
755 theDef
= theImp
= None
756 if methodOverrideMap
.has_key(name
):
757 item
= methodOverrideMap
[name
]
763 theDef
= ' ' + (item
[1] % name
)
765 theImp
= item
[2] % ('wxStyledTextCtrl::'+name
, number
) + '\n}'
769 print "*************", name
772 return name
, theDef
, theImp
, docs
774 #----------------------------------------------------------------------------
776 def makeArgString(param
):
783 return '(long)(const char*)wx2stc(%s)' % name
785 return 'wxColourAsLong(%s)' % name
789 #----------------------------------------------------------------------------
791 def makeParamString(param1
, param2
):
794 aType
= paramTypeMap
.get(param
[0], param
[0])
795 return aType
+ ' ' + param
[1]
802 st
= st
+ doOne(param2
)
806 #----------------------------------------------------------------------------
808 def parseVal(line
, values
, docs
):
809 name
, val
= string
.split(line
, '=')
811 # remove prefixes such as SCI, etc.
812 for old
, new
in valPrefixes
:
817 name
= new
+ name
[lo
:]
820 values
.append( ('wxSTC_' + name
, val
, docs
) )
822 #----------------------------------------------------------------------------
824 funregex
= re
.compile(r
'\s*([a-zA-Z0-9_]+)' # <ws>return type
825 '\s+([a-zA-Z0-9_]+)=' # <ws>name=
827 '\(([ a-zA-Z0-9_]*),' # (param,
828 '([ a-zA-Z0-9_]*)\)') # param)
830 def parseFun(line
, methods
, docs
, values
):
831 def parseParam(param
):
832 param
= string
.strip(param
)
836 param
= tuple(string
.split(param
))
839 mo
= funregex
.match(line
)
841 print "***** Line doesn't match! : " + line
843 retType
, name
, number
, param1
, param2
= mo
.groups()
845 param1
= parseParam(param1
)
846 param2
= parseParam(param2
)
848 # Special case. For the key command functions we want a value defined too
849 num
= string
.atoi(number
)
851 if (type(v
) == type(()) and v
[0] <= num
<= v
[1]) or v
== num
:
852 parseVal('CMD_%s=%s' % (string
.upper(name
), number
), values
, docs
)
854 #if retType == 'void' and not param1 and not param2:
856 methods
.append( (retType
, name
, number
, param1
, param2
, tuple(docs
)) )
859 #----------------------------------------------------------------------------
863 # TODO: parse command line args to replace default input/output files???
866 processIface(IFACE
, H_TEMPLATE
, CPP_TEMPLATE
, H_DEST
, CPP_DEST
)
870 if __name__
== '__main__':
873 #----------------------------------------------------------------------------