]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/gen_iface.py
5c268849a3dcc090fbcd0adb9aa24b486ad19fd3
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),
296 'AutoCSetMaxWidth' : ('AutoCompSetMaxWidth', 0, 0, 0),
297 'AutoCGetMaxWidth' : ('AutoCompGetMaxWidth', 0, 0, 0),
298 'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0, 0),
299 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
300 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
304 '''void %s(int type, const wxBitmap& bmp);''',
305 '''void %s(int type, const wxBitmap& bmp) {
306 // convert bmp to a xpm in a string
307 wxMemoryOutputStream strm;
308 wxImage img = bmp.ConvertToImage();
310 img.ConvertAlphaToMask();
311 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
312 size_t len = strm.GetSize();
313 char* buff = new char[len+1];
314 strm.CopyTo(buff, len);
316 SendMsg(%s, type, (long)buff);
319 ('Register an image for use in autocompletion lists.',)),
322 'ClearRegisteredImages' : (0, 0, 0,
323 ('Clear all the registered images.',)),
326 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
327 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
329 'SetVScrollBar' : ('SetUseVerticalScrollBar', 0, 0, 0),
330 'GetVScrollBar' : ('GetUseVerticalScrollBar', 0, 0, 0),
332 'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
334 'GetUsePalette' : (None, 0, 0, 0),
338 '''int %s(int minPos, int maxPos, const wxString& text, int flags=0);''',
340 '''int %s(int minPos, int maxPos,
341 const wxString& text,
344 ft.chrg.cpMin = minPos;
345 ft.chrg.cpMax = maxPos;
346 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
347 ft.lpstrText = (char*)(const char*)buf;
349 return SendMsg(%s, flags, (long)&ft);''',
354 '''int %s(bool doDraw,
360 wxRect pageRect);''',
361 ''' int %s(bool doDraw,
370 if (endPos < startPos) {
376 fr.hdcTarget = target;
377 fr.rc.top = renderRect.GetTop();
378 fr.rc.left = renderRect.GetLeft();
379 fr.rc.right = renderRect.GetRight();
380 fr.rc.bottom = renderRect.GetBottom();
381 fr.rcPage.top = pageRect.GetTop();
382 fr.rcPage.left = pageRect.GetLeft();
383 fr.rcPage.right = pageRect.GetRight();
384 fr.rcPage.bottom = pageRect.GetBottom();
385 fr.chrg.cpMin = startPos;
386 fr.chrg.cpMax = endPos;
388 return SendMsg(%s, doDraw, (long)&fr);''',
394 'wxString %s(int line);',
396 '''wxString %s(int line) {
397 int len = LineLength(line);
398 if (!len) return wxEmptyString;
400 wxMemoryBuffer mbuf(len+1);
401 char* buf = (char*)mbuf.GetWriteBuf(len+1);
402 SendMsg(%s, line, (long)buf);
403 mbuf.UngetWriteBuf(len);
405 return stc2wx(buf);''',
407 ('Retrieve the contents of a line.',)),
409 'SetSel' : ('SetSelection', 0, 0, 0),
419 GetSelection(&start, &end);
420 int len = end - start;
421 if (!len) return wxEmptyString;
423 wxMemoryBuffer mbuf(len+2);
424 char* buf = (char*)mbuf.GetWriteBuf(len+1);
425 SendMsg(%s, 0, (long)buf);
426 mbuf.UngetWriteBuf(len);
428 return stc2wx(buf);''',
430 ('Retrieve the selected text.',)),
435 'wxString %s(int startPos, int endPos);',
437 '''wxString %s(int startPos, int endPos) {
438 if (endPos < startPos) {
443 int len = endPos - startPos;
444 if (!len) return wxEmptyString;
445 wxMemoryBuffer mbuf(len+1);
446 char* buf = (char*)mbuf.GetWriteBuf(len);
449 tr.chrg.cpMin = startPos;
450 tr.chrg.cpMax = endPos;
451 SendMsg(%s, 0, (long)&tr);
452 mbuf.UngetWriteBuf(len);
454 return stc2wx(buf);''',
456 ('Retrieve a range of text.',)),
458 'PointXFromPosition' : (None, 0, 0, 0),
459 'PointYFromPosition' : (None, 0, 0, 0),
461 'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
462 'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
463 'Null' : (None, 0, 0, 0),
470 int len = GetTextLength();
471 wxMemoryBuffer mbuf(len+1); // leave room for the null...
472 char* buf = (char*)mbuf.GetWriteBuf(len+1);
473 SendMsg(%s, len+1, (long)buf);
474 mbuf.UngetWriteBuf(len);
476 return stc2wx(buf);''',
478 ('Retrieve all the text in the document.', )),
480 'GetDirectFunction' : (None, 0, 0, 0),
481 'GetDirectPointer' : (None, 0, 0, 0),
483 'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
484 'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
485 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
486 'CallTipSetFore' : ('CallTipSetForeground', 0, 0, 0),
487 'CallTipSetForeHlt' : ('CallTipSetForegroundHighlight', 0, 0, 0),
489 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
490 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
495 'int %s(const wxString& text);',
498 int %s(const wxString& text) {
499 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
500 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
505 'int %s(const wxString& text);',
508 int %s(const wxString& text) {
509 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
510 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
515 'int %s(const wxString& text);',
518 int %s(const wxString& text) {
519 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
520 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
523 # not sure what to do about these yet
524 'TargetAsUTF8' : ( None, 0, 0, 0),
525 'SetLengthForEncode' : ( None, 0, 0, 0),
526 'EncodedFromUTF8' : ( None, 0, 0, 0),
531 'wxString %s(const wxString& key);',
533 '''wxString %s(const wxString& key) {
534 int len = SendMsg(SCI_GETPROPERTY, (long)(const char*)wx2stc(key), (long)NULL);
535 if (!len) return wxEmptyString;
537 wxMemoryBuffer mbuf(len+1);
538 char* buf = (char*)mbuf.GetWriteBuf(len+1);
539 SendMsg(%s, (long)(const char*)wx2stc(key), (long)buf);
540 mbuf.UngetWriteBuf(len);
542 return stc2wx(buf);''',
543 ("Retrieve a 'property' value previously set with SetProperty.",)),
545 'GetPropertyExpanded' :
547 'wxString %s(const wxString& key);',
549 '''wxString %s(const wxString& key) {
550 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2stc(key), (long)NULL);
551 if (!len) return wxEmptyString;
553 wxMemoryBuffer mbuf(len+1);
554 char* buf = (char*)mbuf.GetWriteBuf(len+1);
555 SendMsg(%s, (long)(const char*)wx2stc(key), (long)buf);
556 mbuf.UngetWriteBuf(len);
558 return stc2wx(buf);''',
559 ("Retrieve a 'property' value previously set with SetProperty,",
560 "with '$()' variable replacement on returned buffer.")),
562 'GetPropertyInt' : (0, 0, 0,
563 ("Retrieve a 'property' value previously set with SetProperty,",
564 "interpreted as an int AFTER any '$()' variable replacement.")),
571 return (void*)SendMsg(%s);''',
576 'void %s(void* docPointer);',
577 '''void %s(void* docPointer) {
578 SendMsg(%s, 0, (long)docPointer);''',
585 return (void*)SendMsg(%s);''',
590 'void %s(void* docPointer);',
591 '''void %s(void* docPointer) {
592 SendMsg(%s, 0, (long)docPointer);''',
597 'void %s(void* docPointer);',
598 '''void %s(void* docPointer) {
599 SendMsg(%s, 0, (long)docPointer);''',
605 '''void %s(int codePage) {
607 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
608 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
610 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
611 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
613 SendMsg(%s, codePage);''',
614 ("Set the code page used to interpret the bytes of the document as characters.",) ),
617 'GrabFocus' : (None, 0, 0, 0),
619 # Rename some that would otherwise hide the wxWindow methods
620 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
621 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
622 'SetCursor' : ('SetSTCCursor', 0, 0, 0),
623 'GetCursor' : ('GetSTCCursor', 0, 0, 0),
625 'LoadLexerLibrary' : (None, 0,0,0),
632 #----------------------------------------------------------------------------
634 def processIface(iface
, h_tmplt
, cpp_tmplt
, h_dest
, cpp_dest
, docstr_dest
):
641 fi
= FileInput(iface
)
644 if line
[:2] == '##' or line
== '':
649 if line
[:2] == '# ': # a doc string
650 curDocStrings
.append(line
[2:])
653 parseVal(line
[4:], values
, curDocStrings
)
656 elif op
== 'fun ' or op
== 'set ' or op
== 'get ':
657 parseFun(line
[4:], methods
, curDocStrings
, cmds
)
661 if string
.strip(line
[4:]) == 'Deprecated':
662 break # skip the rest of the file
674 print '***** Unknown line type: ', line
679 data
['VALUES'] = processVals(values
)
680 data
['CMDS'] = processVals(cmds
)
681 defs
, imps
, docstrings
= processMethods(methods
)
682 data
['METHOD_DEFS'] = defs
683 data
['METHOD_IMPS'] = imps
686 h_text
= open(h_tmplt
).read()
687 cpp_text
= open(cpp_tmplt
).read()
689 # do the substitutions
690 h_text
= h_text
% data
691 cpp_text
= cpp_text
% data
693 # write out destination files
694 open(h_dest
, 'w').write(h_text
)
695 open(cpp_dest
, 'w').write(cpp_text
)
696 open(docstr_dest
, 'w').write(docstrings
)
700 #----------------------------------------------------------------------------
702 def processVals(values
):
704 for name
, value
, docs
in values
:
708 text
.append('// ' + x
)
709 text
.append('#define %s %s' % (name
, value
))
710 return string
.join(text
, '\n')
712 #----------------------------------------------------------------------------
714 def processMethods(methods
):
719 for retType
, name
, number
, param1
, param2
, docs
in methods
:
720 retType
= retTypeMap
.get(retType
, retType
)
721 params
= makeParamString(param1
, param2
)
723 name
, theDef
, theImp
, docs
= checkMethodOverride(name
, number
, docs
)
729 st
= 'DocStr(wxStyledTextCtrl::%s,\n' \
730 '"%s", "");\n' % (name
, '\n'.join(docs
))
733 # Build the method definition for the .h file
737 defs
.append(' // ' + x
)
739 theDef
= ' %s %s(%s);' % (retType
, name
, params
)
742 # Build the method implementation string
746 imps
.append('// ' + x
)
748 theImp
= '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType
, name
, params
)
750 if retType
== 'wxColour':
751 theImp
= theImp
+ 'long c = '
752 elif retType
!= 'void':
753 theImp
= theImp
+ 'return '
754 theImp
= theImp
+ 'SendMsg(%s, %s, %s)' % (number
,
755 makeArgString(param1
),
756 makeArgString(param2
))
757 if retType
== 'bool':
758 theImp
= theImp
+ ' != 0'
759 if retType
== 'wxColour':
760 theImp
= theImp
+ ';\n return wxColourFromLong(c)'
762 theImp
= theImp
+ ';\n}'
766 return '\n'.join(defs
), '\n'.join(imps
), '\n'.join(dstr
)
769 #----------------------------------------------------------------------------
771 def checkMethodOverride(name
, number
, docs
):
772 theDef
= theImp
= None
773 if methodOverrideMap
.has_key(name
):
774 item
= methodOverrideMap
[name
]
780 theDef
= ' ' + (item
[1] % name
)
782 theImp
= item
[2] % ('wxStyledTextCtrl::'+name
, number
) + '\n}'
786 print "*************", name
789 return name
, theDef
, theImp
, docs
791 #----------------------------------------------------------------------------
793 def makeArgString(param
):
800 return '(long)(const char*)wx2stc(%s)' % name
802 return 'wxColourAsLong(%s)' % name
806 #----------------------------------------------------------------------------
808 def makeParamString(param1
, param2
):
811 aType
= paramTypeMap
.get(param
[0], param
[0])
812 return aType
+ ' ' + param
[1]
819 st
= st
+ doOne(param2
)
823 #----------------------------------------------------------------------------
825 def parseVal(line
, values
, docs
):
826 name
, val
= string
.split(line
, '=')
828 # remove prefixes such as SCI, etc.
829 for old
, new
in valPrefixes
:
834 name
= new
+ name
[lo
:]
837 values
.append( ('wxSTC_' + name
, val
, docs
) )
839 #----------------------------------------------------------------------------
841 funregex
= re
.compile(r
'\s*([a-zA-Z0-9_]+)' # <ws>return type
842 '\s+([a-zA-Z0-9_]+)=' # <ws>name=
844 '\(([ a-zA-Z0-9_]*),' # (param,
845 '([ a-zA-Z0-9_]*)\)') # param)
847 def parseFun(line
, methods
, docs
, values
):
848 def parseParam(param
):
849 param
= string
.strip(param
)
853 param
= tuple(string
.split(param
))
856 mo
= funregex
.match(line
)
858 print "***** Line doesn't match! : " + line
860 retType
, name
, number
, param1
, param2
= mo
.groups()
862 param1
= parseParam(param1
)
863 param2
= parseParam(param2
)
865 # Special case. For the key command functions we want a value defined too
866 num
= string
.atoi(number
)
868 if (type(v
) == type(()) and v
[0] <= num
<= v
[1]) or v
== num
:
869 parseVal('CMD_%s=%s' % (string
.upper(name
), number
), values
, docs
)
871 # if we are not also doing a function for CMD values, then
872 # just return, otherwise fall through to the append blow.
876 methods
.append( (retType
, name
, number
, param1
, param2
, tuple(docs
)) )
879 #----------------------------------------------------------------------------
883 # TODO: parse command line args to replace default input/output files???
886 processIface(IFACE
, H_TEMPLATE
, CPP_TEMPLATE
, H_DEST
, CPP_DEST
, DOCSTR_DEST
)
890 if __name__
== '__main__':
893 #----------------------------------------------------------------------------