]>
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') 
  24 DOCSTR_DEST   
= os
.path
.abspath('../../../wxPython/contrib/stc/_stc_gendocs.i') 
  27 # Value prefixes to convert 
  28 valPrefixes 
= [('SCI_', ''), 
  30                ('SCN_', None),  # just toss these out... 
  39 # Message function values that should have a CMD_ constant generated 
  40 cmdValues 
= [ (2300, 2349), 
  53 # Should a funciton be also generated for the CMDs? 
  57 # Map some generic typenames to wx types, using return value syntax 
  64 # Map some generic typenames to wx types, using parameter syntax 
  67     'string':   'const wxString&', 
  68     'colour':   'const wxColour&', 
  72 # Map of method info that needs tweaked.  Either the name needs changed, or 
  73 # the method definition/implementation.  Tuple items are: 
  75 #         1. New method name.  None to skip the method, 0 to leave the 
  77 #         2. Method definition for the .h file, 0 to leave alone 
  78 #         3. Method implementation for the .cpp file, 0 to leave alone. 
  79 #         4. tuple of Doc string lines, or 0 to leave alone. 
  83                  'void %s(const wxString& text);', 
  85                  '''void %s(const wxString& text) { 
  86                     wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); 
  87                     SendMsg(%s, strlen(buf), (long)(const char*)buf);''', 
  91                        'void %s(const wxMemoryBuffer& data);', 
  93                        '''void %s(const wxMemoryBuffer& data) { 
  94                           SendMsg(%s, data.GetDataLen(), (long)data.GetData());''', 
  98                  'void %s(const wxString& text);', 
 100                  '''void %s(const wxString& text) { 
 101                     wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); 
 102                     SendMsg(%s, strlen(buf), (long)(const char*)buf);''', 
 105     'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0), 
 106     'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0), 
 111          return (unsigned char)SendMsg(%s, pos, 0);''', 
 117          return (unsigned char)SendMsg(%s, pos, 0);''', 
 122      'wxMemoryBuffer %s(int startPos, int endPos);', 
 124      '''wxMemoryBuffer %s(int startPos, int endPos) { 
 126         if (endPos < startPos) { 
 131         int len = endPos - startPos; 
 132         if (!len) return buf; 
 134         tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1); 
 135         tr.chrg.cpMin = startPos; 
 136         tr.chrg.cpMax = endPos; 
 137         len = SendMsg(%s, 0, (long)&tr); 
 138         buf.UngetWriteBuf(len); 
 141      ('Retrieve a buffer of cells.',)), 
 144     'PositionFromPoint' : 
 146      'int %s(wxPoint pt);', 
 148      '''int %s(wxPoint pt) { 
 149         return SendMsg(%s, pt.x, pt.y);''', 
 154      '#ifdef SWIG\n    wxString %s(int* OUTPUT);\n#else\n    wxString GetCurLine(int* linePos=NULL);\n#endif', 
 156         '''wxString %s(int* linePos) { 
 157         int len = LineLength(GetCurrentLine()); 
 159             if (linePos)  *linePos = 0; 
 160             return wxEmptyString; 
 163         wxMemoryBuffer mbuf(len+1); 
 164         char* buf = (char*)mbuf.GetWriteBuf(len+1); 
 166         int pos = SendMsg(%s, len+1, (long)buf); 
 167         mbuf.UngetWriteBuf(len); 
 169         if (linePos)  *linePos = pos; 
 170         return stc2wx(buf);''', 
 174     'SetUsePalette' : (None, 0,0,0), 
 176     'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0), 
 177     'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0), 
 181      '''void %s(int markerNumber, int markerSymbol, 
 182                 const wxColour& foreground = wxNullColour, 
 183                 const wxColour& background = wxNullColour);''', 
 185      '''void %s(int markerNumber, int markerSymbol, 
 186                 const wxColour& foreground, 
 187                 const wxColour& background) { 
 189                 SendMsg(%s, markerNumber, markerSymbol); 
 191                     MarkerSetForeground(markerNumber, foreground); 
 193                     MarkerSetBackground(markerNumber, background);''', 
 195      ('Set the symbol used for a particular marker number,', 
 196       'and optionally the fore and background colours.')), 
 199     'MarkerDefinePixmap' : 
 200     ('MarkerDefineBitmap', 
 201      '''void %s(int markerNumber, const wxBitmap& bmp);''', 
 202      '''void %s(int markerNumber, const wxBitmap& bmp) { 
 203         // convert bmp to a xpm in a string 
 204         wxMemoryOutputStream strm; 
 205         wxImage img = bmp.ConvertToImage(); 
 207             img.ConvertAlphaToMask(); 
 208         img.SaveFile(strm, wxBITMAP_TYPE_XPM); 
 209         size_t len = strm.GetSize(); 
 210         char* buff = new char[len+1]; 
 211         strm.CopyTo(buff, len); 
 213         SendMsg(%s, markerNumber, (long)buff); 
 216      ('Define a marker from a bitmap',)), 
 219     'SetMarginTypeN' : ('SetMarginType', 0, 0, 0), 
 220     'GetMarginTypeN' : ('GetMarginType', 0, 0, 0), 
 221     'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0), 
 222     'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0), 
 223     'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0), 
 224     'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0), 
 225     'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0), 
 226     'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0), 
 228     'StyleSetFore' : ('StyleSetForeground', 0, 0, 0), 
 229     'StyleSetBack' : ('StyleSetBackground', 0, 0, 0), 
 230     'SetSelFore' : ('SetSelForeground', 0, 0, 0), 
 231     'SetSelBack' : ('SetSelBackground', 0, 0, 0), 
 232     'SetCaretFore' : ('SetCaretForeground', 0, 0, 0), 
 233     'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0), 
 234     'StyleSetCharacterSet' : (None, 0, 0, 0), 
 238      'void %s(int key, int modifiers, int cmd);', 
 240      '''void %s(int key, int modifiers, int cmd) { 
 241          SendMsg(%s, MAKELONG(key, modifiers), cmd);''', 
 247      'void %s(int key, int modifiers);', 
 249      '''void %s(int key, int modifiers) { 
 250          SendMsg(%s, MAKELONG(key, modifiers));''', 
 253     'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0), 
 258      'void %s(int length, char* styleBytes);', 
 260      '''void %s(int length, char* styleBytes) { 
 261         SendMsg(%s, length, (long)styleBytes);''', 
 265     'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0), 
 266     'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0), 
 267     'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0), 
 268     'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0), 
 270     'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0), 
 271     'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0), 
 273     'AutoCShow' : ('AutoCompShow', 0, 0, 0), 
 274     'AutoCCancel' : ('AutoCompCancel', 0, 0, 0), 
 275     'AutoCActive' : ('AutoCompActive', 0, 0, 0), 
 276     'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0), 
 277     'AutoCComplete' : ('AutoCompComplete', 0, 0, 0), 
 278     'AutoCStops' : ('AutoCompStops', 0, 0, 0), 
 279     'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0), 
 280     'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0), 
 281     'AutoCSelect' : ('AutoCompSelect', 0, 0, 0), 
 282     'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0), 
 283     'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0), 
 284     'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0), 
 285     'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0), 
 286     'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0), 
 287     'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0), 
 288     'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0), 
 289     'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0), 
 290     'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0), 
 291     'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0), 
 292     'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0), 
 293     'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0), 
 294     'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0), 
 295     'AutoCGetCurrent'       : ('AutoCompGetCurrent', 0, 0, 0), 
 299      '''void %s(int type, const wxBitmap& bmp);''', 
 300      '''void %s(int type, const wxBitmap& bmp) { 
 301         // convert bmp to a xpm in a string 
 302         wxMemoryOutputStream strm; 
 303         wxImage img = bmp.ConvertToImage(); 
 305             img.ConvertAlphaToMask(); 
 306         img.SaveFile(strm, wxBITMAP_TYPE_XPM); 
 307         size_t len = strm.GetSize(); 
 308         char* buff = new char[len+1]; 
 309         strm.CopyTo(buff, len); 
 311         SendMsg(%s, type, (long)buff); 
 314      ('Register an image for use in autocompletion lists.',)), 
 317     'ClearRegisteredImages' : (0, 0, 0, 
 318                                ('Clear all the registered images.',)), 
 321     'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0), 
 322     'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0), 
 324     'SetVScrollBar' : ('SetUseVerticalScrollBar', 0, 0, 0), 
 325     'GetVScrollBar' : ('GetUseVerticalScrollBar', 0, 0, 0), 
 327     'GetCaretFore' : ('GetCaretForeground', 0, 0, 0), 
 329     'GetUsePalette' : (None, 0, 0, 0), 
 333      '''int %s(int minPos, int maxPos, const wxString& text, int flags=0);''', 
 335      '''int %s(int minPos, int maxPos, 
 336                const wxString& text, 
 339             ft.chrg.cpMin = minPos; 
 340             ft.chrg.cpMax = maxPos; 
 341             wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); 
 342             ft.lpstrText = (char*)(const char*)buf; 
 344             return SendMsg(%s, flags, (long)&ft);''', 
 349      '''int %s(bool   doDraw, 
 355                wxRect pageRect);''', 
 356      ''' int %s(bool   doDraw, 
 365              if (endPos < startPos) { 
 371              fr.hdcTarget = target; 
 372              fr.rc.top = renderRect.GetTop(); 
 373              fr.rc.left = renderRect.GetLeft(); 
 374              fr.rc.right = renderRect.GetRight(); 
 375              fr.rc.bottom = renderRect.GetBottom(); 
 376              fr.rcPage.top = pageRect.GetTop(); 
 377              fr.rcPage.left = pageRect.GetLeft(); 
 378              fr.rcPage.right = pageRect.GetRight(); 
 379              fr.rcPage.bottom = pageRect.GetBottom(); 
 380              fr.chrg.cpMin = startPos; 
 381              fr.chrg.cpMax = endPos; 
 383              return SendMsg(%s, doDraw, (long)&fr);''', 
 389      'wxString %s(int line);', 
 391      '''wxString %s(int line) { 
 392          int len = LineLength(line); 
 393          if (!len) return wxEmptyString; 
 395          wxMemoryBuffer mbuf(len+1); 
 396          char* buf = (char*)mbuf.GetWriteBuf(len+1); 
 397          SendMsg(%s, line, (long)buf); 
 398          mbuf.UngetWriteBuf(len); 
 400          return stc2wx(buf);''', 
 402      ('Retrieve the contents of a line.',)), 
 404     'SetSel' : ('SetSelection', 0, 0, 0), 
 414          GetSelection(&start, &end); 
 415          int   len  = end - start; 
 416          if (!len) return wxEmptyString; 
 418          wxMemoryBuffer mbuf(len+2); 
 419          char* buf = (char*)mbuf.GetWriteBuf(len+1); 
 420          SendMsg(%s, 0, (long)buf); 
 421          mbuf.UngetWriteBuf(len); 
 423          return stc2wx(buf);''', 
 425      ('Retrieve the selected text.',)), 
 430      'wxString %s(int startPos, int endPos);', 
 432      '''wxString %s(int startPos, int endPos) { 
 433          if (endPos < startPos) { 
 438          int   len  = endPos - startPos; 
 439          if (!len) return wxEmptyString; 
 440          wxMemoryBuffer mbuf(len+1); 
 441          char* buf = (char*)mbuf.GetWriteBuf(len); 
 444          tr.chrg.cpMin = startPos; 
 445          tr.chrg.cpMax = endPos; 
 446          SendMsg(%s, 0, (long)&tr); 
 447          mbuf.UngetWriteBuf(len); 
 449          return stc2wx(buf);''', 
 451      ('Retrieve a range of text.',)), 
 453     'PointXFromPosition' : (None, 0, 0, 0), 
 454     'PointYFromPosition' : (None, 0, 0, 0), 
 456     'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0), 
 457     'ReplaceSel' : ('ReplaceSelection', 0, 0, 0), 
 458     'Null' : (None, 0, 0, 0), 
 465          int len  = GetTextLength(); 
 466          wxMemoryBuffer mbuf(len+1);   // leave room for the null... 
 467          char* buf = (char*)mbuf.GetWriteBuf(len+1); 
 468          SendMsg(%s, len+1, (long)buf); 
 469          mbuf.UngetWriteBuf(len); 
 471          return stc2wx(buf);''', 
 473      ('Retrieve all the text in the document.', )), 
 475     'GetDirectFunction' : (None, 0, 0, 0), 
 476     'GetDirectPointer' : (None, 0, 0, 0), 
 478     'CallTipPosStart'   : ('CallTipPosAtStart', 0, 0, 0), 
 479     'CallTipSetHlt'     : ('CallTipSetHighlight', 0, 0, 0), 
 480     'CallTipSetBack'    : ('CallTipSetBackground', 0, 0, 0), 
 481     'CallTipSetFore'    : ('CallTipSetForeground', 0, 0, 0), 
 482     'CallTipSetForeHlt' : ('CallTipSetForegroundHighlight', 0, 0, 0), 
 484     'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0), 
 485     'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0), 
 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);''', 
 500      'int %s(const wxString& text);', 
 503      int %s(const wxString& text) { 
 504          wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); 
 505          return SendMsg(%s, strlen(buf), (long)(const char*)buf);''', 
 510      'int %s(const wxString& text);', 
 513      int %s(const wxString& text) { 
 514          wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); 
 515          return SendMsg(%s, strlen(buf), (long)(const char*)buf);''', 
 518     # not sure what to do about these yet 
 519     'TargetAsUTF8' :       ( None, 0, 0, 0), 
 520     'SetLengthForEncode' : ( None, 0, 0, 0), 
 521     'EncodedFromUTF8' :    ( None, 0, 0, 0), 
 528          return (void*)SendMsg(%s);''', 
 533      'void %s(void* docPointer);', 
 534      '''void %s(void* docPointer) { 
 535          SendMsg(%s, 0, (long)docPointer);''', 
 542          return (void*)SendMsg(%s);''', 
 547      'void %s(void* docPointer);', 
 548      '''void %s(void* docPointer) { 
 549          SendMsg(%s, 0, (long)docPointer);''', 
 554      'void %s(void* docPointer);', 
 555      '''void %s(void* docPointer) { 
 556          SendMsg(%s, 0, (long)docPointer);''', 
 562      '''void %s(int codePage) { 
 564     wxASSERT_MSG(codePage == wxSTC_CP_UTF8, 
 565                  wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on.")); 
 567     wxASSERT_MSG(codePage != wxSTC_CP_UTF8, 
 568                  wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off.")); 
 570     SendMsg(%s, codePage);''', 
 571      ("Set the code page used to interpret the bytes of the document as characters.",) ), 
 574     'GrabFocus' : (None, 0, 0, 0), 
 576     # Rename some that would otherwise hide the wxWindow methods 
 577     'SetFocus'  : ('SetSTCFocus', 0, 0, 0), 
 578     'GetFocus'  : ('GetSTCFocus', 0, 0, 0), 
 579     'SetCursor' : ('SetSTCCursor', 0, 0, 0), 
 580     'GetCursor' : ('GetSTCCursor', 0, 0, 0), 
 582     'LoadLexerLibrary' : (None, 0,0,0), 
 589 #---------------------------------------------------------------------------- 
 591 def processIface(iface
, h_tmplt
, cpp_tmplt
, h_dest
, cpp_dest
, docstr_dest
): 
 598     fi 
= FileInput(iface
) 
 601         if line
[:2] == '##' or line 
== '': 
 606         if line
[:2] == '# ':   # a doc string 
 607             curDocStrings
.append(line
[2:]) 
 610             parseVal(line
[4:], values
, curDocStrings
) 
 613         elif op 
== 'fun ' or op 
== 'set ' or op 
== 'get ': 
 614             parseFun(line
[4:], methods
, curDocStrings
, cmds
) 
 618             if string
.strip(line
[4:]) == 'Deprecated': 
 619                 break    # skip the rest of the file 
 631             print '***** Unknown line type: ', line
 
 636     data
['VALUES'] = processVals(values
) 
 637     data
['CMDS']   = processVals(cmds
) 
 638     defs
, imps
, docstrings 
= processMethods(methods
) 
 639     data
['METHOD_DEFS'] = defs
 
 640     data
['METHOD_IMPS'] = imps
 
 643     h_text 
= open(h_tmplt
).read() 
 644     cpp_text 
= open(cpp_tmplt
).read() 
 646     # do the substitutions 
 647     h_text 
= h_text 
% data
 
 648     cpp_text 
= cpp_text 
% data
 
 650     # write out destination files 
 651     open(h_dest
, 'w').write(h_text
) 
 652     open(cpp_dest
, 'w').write(cpp_text
) 
 653     open(docstr_dest
, 'w').write(docstrings
) 
 657 #---------------------------------------------------------------------------- 
 659 def processVals(values
): 
 661     for name
, value
, docs 
in values
: 
 665                 text
.append('// ' + x
) 
 666         text
.append('#define %s %s' % (name
, value
)) 
 667     return string
.join(text
, '\n') 
 669 #---------------------------------------------------------------------------- 
 671 def processMethods(methods
): 
 676     for retType
, name
, number
, param1
, param2
, docs 
in methods
: 
 677         retType 
= retTypeMap
.get(retType
, retType
) 
 678         params 
= makeParamString(param1
, param2
) 
 680         name
, theDef
, theImp
, docs 
= checkMethodOverride(name
, number
, docs
) 
 686         st 
= 'DocStr(wxStyledTextCtrl::%s,\n' \
 
 687              '"%s", "");\n' % (name
, '\n'.join(docs
)) 
 690         # Build the method definition for the .h file 
 694                 defs
.append('    // ' + x
) 
 696             theDef 
= '    %s %s(%s);' % (retType
, name
, params
) 
 699         # Build the method implementation string 
 703                 imps
.append('// ' + x
) 
 705             theImp 
= '%s wxStyledTextCtrl::%s(%s) {\n    ' % (retType
, name
, params
) 
 707             if retType 
== 'wxColour': 
 708                 theImp 
= theImp 
+ 'long c = ' 
 709             elif retType 
!= 'void': 
 710                 theImp 
= theImp 
+ 'return ' 
 711             theImp 
= theImp 
+ 'SendMsg(%s, %s, %s)' % (number
, 
 712                                                        makeArgString(param1
), 
 713                                                        makeArgString(param2
)) 
 714             if retType 
== 'bool': 
 715                 theImp 
= theImp 
+ ' != 0' 
 716             if retType 
== 'wxColour': 
 717                 theImp 
= theImp 
+ ';\n    return wxColourFromLong(c)' 
 719             theImp 
= theImp 
+ ';\n}' 
 723     return '\n'.join(defs
), '\n'.join(imps
), '\n'.join(dstr
) 
 726 #---------------------------------------------------------------------------- 
 728 def checkMethodOverride(name
, number
, docs
): 
 729     theDef 
= theImp 
= None 
 730     if methodOverrideMap
.has_key(name
): 
 731         item 
= methodOverrideMap
[name
] 
 737                 theDef 
= '    ' + (item
[1] % name
) 
 739                 theImp 
= item
[2] % ('wxStyledTextCtrl::'+name
, number
) + '\n}' 
 743             print "*************", name
 
 746     return name
, theDef
, theImp
, docs
 
 748 #---------------------------------------------------------------------------- 
 750 def makeArgString(param
): 
 757         return '(long)(const char*)wx2stc(%s)' % name
 
 759         return 'wxColourAsLong(%s)' % name
 
 763 #---------------------------------------------------------------------------- 
 765 def makeParamString(param1
, param2
): 
 768             aType 
= paramTypeMap
.get(param
[0], param
[0]) 
 769             return aType 
+ ' ' + param
[1] 
 776     st 
= st 
+ doOne(param2
) 
 780 #---------------------------------------------------------------------------- 
 782 def parseVal(line
, values
, docs
): 
 783     name
, val 
= string
.split(line
, '=') 
 785     # remove prefixes such as SCI, etc. 
 786     for old
, new 
in valPrefixes
: 
 791             name 
= new 
+ name
[lo
:] 
 794     values
.append( ('wxSTC_' + name
, val
, docs
) ) 
 796 #---------------------------------------------------------------------------- 
 798 funregex 
= re
.compile(r
'\s*([a-zA-Z0-9_]+)'  # <ws>return type 
 799                       '\s+([a-zA-Z0-9_]+)='  # <ws>name= 
 801                       '\(([ a-zA-Z0-9_]*),'  # (param, 
 802                       '([ a-zA-Z0-9_]*)\)')  # param) 
 804 def parseFun(line
, methods
, docs
, values
): 
 805     def parseParam(param
): 
 806         param 
= string
.strip(param
) 
 810             param 
= tuple(string
.split(param
)) 
 813     mo 
= funregex
.match(line
) 
 815         print "***** Line doesn't match! : " + line
 
 817     retType
, name
, number
, param1
, param2 
= mo
.groups() 
 819     param1 
= parseParam(param1
) 
 820     param2 
= parseParam(param2
) 
 822     # Special case.  For the key command functions we want a value defined too 
 823     num 
= string
.atoi(number
) 
 825         if (type(v
) == type(()) and v
[0] <= num 
<= v
[1]) or v 
== num
: 
 826             parseVal('CMD_%s=%s' % (string
.upper(name
), number
), values
, docs
) 
 828             # if we are not also doing a function for CMD values, then 
 829             # just return, otherwise fall through to the append blow. 
 833     methods
.append( (retType
, name
, number
, param1
, param2
, tuple(docs
)) ) 
 836 #---------------------------------------------------------------------------- 
 840     # TODO: parse command line args to replace default input/output files??? 
 843     processIface(IFACE
, H_TEMPLATE
, CPP_TEMPLATE
, H_DEST
, CPP_DEST
, DOCSTR_DEST
) 
 847 if __name__ 
== '__main__': 
 850 #----------------------------------------------------------------------------