]>
git.saurik.com Git - wxWidgets.git/blob - contrib/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),
551 # Rename some that woudl otherwise hid the wxWindow methods
552 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
553 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
554 'SetCursor' : ('SetSTCCursor', 0, 0, 0),
555 'GetCursor' : ('GetSTCCursor', 0, 0, 0),
557 'LoadLexerLibrary' : (None, 0,0,0),
561 # Remove all methods that are key commands since they can be
562 # executed with CmdKeyExecute
563 'LineDown' : (None, 0, 0, 0),
564 'LineDownExtend' : (None, 0, 0, 0),
565 'LineUp' : (None, 0, 0, 0),
566 'LineUpExtend' : (None, 0, 0, 0),
567 'CharLeft' : (None, 0, 0, 0),
568 'CharLeftExtend' : (None, 0, 0, 0),
569 'CharRight' : (None, 0, 0, 0),
570 'CharRightExtend' : (None, 0, 0, 0),
571 'WordLeft' : (None, 0, 0, 0),
572 'WordLeftExtend' : (None, 0, 0, 0),
573 'WordRight' : (None, 0, 0, 0),
574 'WordRightExtend' : (None, 0, 0, 0),
575 'Home' : (None, 0, 0, 0),
576 'HomeExtend' : (None, 0, 0, 0),
577 'LineEnd' : (None, 0, 0, 0),
578 'LineEndExtend' : (None, 0, 0, 0),
579 'DocumentStart' : (None, 0, 0, 0),
580 'DocumentStartExtend' : (None, 0, 0, 0),
581 'DocumentEnd' : (None, 0, 0, 0),
582 'DocumentEndExtend' : (None, 0, 0, 0),
583 'PageUp' : (None, 0, 0, 0),
584 'PageUpExtend' : (None, 0, 0, 0),
585 'PageDown' : (None, 0, 0, 0),
586 'PageDownExtend' : (None, 0, 0, 0),
587 'EditToggleOvertype' : (None, 0, 0, 0),
588 'Cancel' : (None, 0, 0, 0),
589 'DeleteBack' : (None, 0, 0, 0),
590 'Tab' : (None, 0, 0, 0),
591 'BackTab' : (None, 0, 0, 0),
592 'NewLine' : (None, 0, 0, 0),
593 'FormFeed' : (None, 0, 0, 0),
594 'VCHome' : (None, 0, 0, 0),
595 'VCHomeExtend' : (None, 0, 0, 0),
596 'ZoomIn' : (None, 0, 0, 0),
597 'ZoomOut' : (None, 0, 0, 0),
598 'DelWordLeft' : (None, 0, 0, 0),
599 'DelWordRight' : (None, 0, 0, 0),
600 'LineCut' : (None, 0, 0, 0),
601 'LineDelete' : (None, 0, 0, 0),
602 'LineTranspose' : (None, 0, 0, 0),
603 'LowerCase' : (None, 0, 0, 0),
604 'UpperCase' : (None, 0, 0, 0),
605 'LineScrollDown' : (None, 0, 0, 0),
606 'LineScrollUp' : (None, 0, 0, 0),
607 'DeleteBackNotLine' : (None, 0, 0, 0),
608 'HomeWrap' : (None, 0, 0, 0),
609 'HomeWrapExtend' : (None, 0, 0, 0),
610 'LineEndWrap' : (None, 0, 0, 0),
611 'LineEndWrapExtend' : (None, 0, 0, 0),
612 'VCHomeWrap' : (None, 0, 0, 0),
613 'VCHomeWrapExtend' : (None, 0, 0, 0),
614 'ParaDown' : (None, 0, 0, 0),
615 'ParaDownExtend' : (None, 0, 0, 0),
616 'ParaUp' : (None, 0, 0, 0),
617 'ParaUpExtend' : (None, 0, 0, 0),
625 #----------------------------------------------------------------------------
627 def processIface(iface
, h_tmplt
, cpp_tmplt
, h_dest
, cpp_dest
):
634 fi
= FileInput(iface
)
637 if line
[:2] == '##' or line
== '':
642 if line
[:2] == '# ': # a doc string
643 curDocStrings
.append(line
[2:])
646 parseVal(line
[4:], values
, curDocStrings
)
649 elif op
== 'fun ' or op
== 'set ' or op
== 'get ':
650 parseFun(line
[4:], methods
, curDocStrings
, cmds
)
654 if string
.strip(line
[4:]) == 'Deprecated':
655 break # skip the rest of the file
667 print '***** Unknown line type: ', line
672 data
['VALUES'] = processVals(values
)
673 data
['CMDS'] = processVals(cmds
)
674 defs
, imps
= processMethods(methods
)
675 data
['METHOD_DEFS'] = defs
676 data
['METHOD_IMPS'] = imps
679 h_text
= open(h_tmplt
).read()
680 cpp_text
= open(cpp_tmplt
).read()
682 # do the substitutions
683 h_text
= h_text
% data
684 cpp_text
= cpp_text
% data
686 # write out destination files
687 open(h_dest
, 'w').write(h_text
)
688 open(cpp_dest
, 'w').write(cpp_text
)
692 #----------------------------------------------------------------------------
694 def processVals(values
):
696 for name
, value
, docs
in values
:
700 text
.append('// ' + x
)
701 text
.append('#define %s %s' % (name
, value
))
702 return string
.join(text
, '\n')
704 #----------------------------------------------------------------------------
706 def processMethods(methods
):
710 for retType
, name
, number
, param1
, param2
, docs
in methods
:
711 retType
= retTypeMap
.get(retType
, retType
)
712 params
= makeParamString(param1
, param2
)
714 name
, theDef
, theImp
, docs
= checkMethodOverride(name
, number
, docs
)
719 # Build the method definition for the .h file
723 defs
.append(' // ' + x
)
725 theDef
= ' %s %s(%s);' % (retType
, name
, params
)
728 # Build the method implementation string
732 imps
.append('// ' + x
)
734 theImp
= '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType
, name
, params
)
736 if retType
== 'wxColour':
737 theImp
= theImp
+ 'long c = '
738 elif retType
!= 'void':
739 theImp
= theImp
+ 'return '
740 theImp
= theImp
+ 'SendMsg(%s, %s, %s)' % (number
,
741 makeArgString(param1
),
742 makeArgString(param2
))
743 if retType
== 'bool':
744 theImp
= theImp
+ ' != 0'
745 if retType
== 'wxColour':
746 theImp
= theImp
+ ';\n return wxColourFromLong(c)'
748 theImp
= theImp
+ ';\n}'
752 return string
.join(defs
, '\n'), string
.join(imps
, '\n')
755 #----------------------------------------------------------------------------
757 def checkMethodOverride(name
, number
, docs
):
758 theDef
= theImp
= None
759 if methodOverrideMap
.has_key(name
):
760 item
= methodOverrideMap
[name
]
766 theDef
= ' ' + (item
[1] % name
)
768 theImp
= item
[2] % ('wxStyledTextCtrl::'+name
, number
) + '\n}'
772 print "*************", name
775 return name
, theDef
, theImp
, docs
777 #----------------------------------------------------------------------------
779 def makeArgString(param
):
786 return '(long)(const char*)wx2stc(%s)' % name
788 return 'wxColourAsLong(%s)' % name
792 #----------------------------------------------------------------------------
794 def makeParamString(param1
, param2
):
797 aType
= paramTypeMap
.get(param
[0], param
[0])
798 return aType
+ ' ' + param
[1]
805 st
= st
+ doOne(param2
)
809 #----------------------------------------------------------------------------
811 def parseVal(line
, values
, docs
):
812 name
, val
= string
.split(line
, '=')
814 # remove prefixes such as SCI, etc.
815 for old
, new
in valPrefixes
:
820 name
= new
+ name
[lo
:]
823 values
.append( ('wxSTC_' + name
, val
, docs
) )
825 #----------------------------------------------------------------------------
827 funregex
= re
.compile(r
'\s*([a-zA-Z0-9_]+)' # <ws>return type
828 '\s+([a-zA-Z0-9_]+)=' # <ws>name=
830 '\(([ a-zA-Z0-9_]*),' # (param,
831 '([ a-zA-Z0-9_]*)\)') # param)
833 def parseFun(line
, methods
, docs
, values
):
834 def parseParam(param
):
835 param
= string
.strip(param
)
839 param
= tuple(string
.split(param
))
842 mo
= funregex
.match(line
)
844 print "***** Line doesn't match! : " + line
846 retType
, name
, number
, param1
, param2
= mo
.groups()
848 param1
= parseParam(param1
)
849 param2
= parseParam(param2
)
851 # Special case. For the key command functions we want a value defined too
852 num
= string
.atoi(number
)
854 if (type(v
) == type(()) and v
[0] <= num
<= v
[1]) or v
== num
:
855 parseVal('CMD_%s=%s' % (string
.upper(name
), number
), values
, docs
)
857 #if retType == 'void' and not param1 and not param2:
859 methods
.append( (retType
, name
, number
, param1
, param2
, tuple(docs
)) )
862 #----------------------------------------------------------------------------
866 # TODO: parse command line args to replace default input/output files???
869 processIface(IFACE
, H_TEMPLATE
, CPP_TEMPLATE
, H_DEST
, CPP_DEST
)
873 if __name__
== '__main__':
876 #----------------------------------------------------------------------------