]>
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),
52 # Map some generic typenames to wx types, using return value syntax
59 # Map some generic typenames to wx types, using parameter syntax
62 'string': 'const wxString&',
63 'colour': 'const wxColour&',
67 # Map of method info that needs tweaked. Either the name needs changed, or
68 # the method definition/implementation. Tuple items are:
70 # 1. New method name. None to skip the method, 0 to leave the
72 # 2. Method definition for the .h file, 0 to leave alone
73 # 3. Method implementation for the .cpp file, 0 to leave alone.
74 # 4. tuple of Doc string lines, or 0 to leave alone.
78 'void %s(const wxString& text);',
80 '''void %s(const wxString& text) {
81 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
82 SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
86 'void %s(const wxMemoryBuffer& data);',
88 '''void %s(const wxMemoryBuffer& data) {
89 SendMsg(%s, data.GetDataLen(), (long)data.GetData());''',
92 'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
93 'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
98 return (unsigned char)SendMsg(%s, pos, 0);''',
104 return (unsigned char)SendMsg(%s, pos, 0);''',
109 'wxMemoryBuffer %s(int startPos, int endPos);',
111 '''wxMemoryBuffer %s(int startPos, int endPos) {
113 if (endPos < startPos) {
118 int len = endPos - startPos;
119 if (!len) return buf;
121 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
122 tr.chrg.cpMin = startPos;
123 tr.chrg.cpMax = endPos;
124 len = SendMsg(%s, 0, (long)&tr);
125 buf.UngetWriteBuf(len);
128 ('Retrieve a buffer of cells.',)),
131 'PositionFromPoint' :
133 'int %s(wxPoint pt);',
135 '''int %s(wxPoint pt) {
136 return SendMsg(%s, pt.x, pt.y);''',
141 '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif',
143 '''wxString %s(int* linePos) {
144 int len = LineLength(GetCurrentLine());
146 if (linePos) *linePos = 0;
147 return wxEmptyString;
150 wxMemoryBuffer mbuf(len+1);
151 char* buf = (char*)mbuf.GetWriteBuf(len+1);
153 int pos = SendMsg(%s, len+1, (long)buf);
154 mbuf.UngetWriteBuf(len);
156 if (linePos) *linePos = pos;
157 return stc2wx(buf);''',
161 'SetUsePalette' : (None, 0,0,0),
163 'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0),
164 'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0),
168 '''void %s(int markerNumber, int markerSymbol,
169 const wxColour& foreground = wxNullColour,
170 const wxColour& background = wxNullColour);''',
172 '''void %s(int markerNumber, int markerSymbol,
173 const wxColour& foreground,
174 const wxColour& background) {
176 SendMsg(%s, markerNumber, markerSymbol);
178 MarkerSetForeground(markerNumber, foreground);
180 MarkerSetBackground(markerNumber, background);''',
182 ('Set the symbol used for a particular marker number,',
183 'and optionally the fore and background colours.')),
186 'MarkerDefinePixmap' :
187 ('MarkerDefineBitmap',
188 '''void %s(int markerNumber, const wxBitmap& bmp);''',
189 '''void %s(int markerNumber, const wxBitmap& bmp) {
190 // convert bmp to a xpm in a string
191 wxMemoryOutputStream strm;
192 wxImage img = bmp.ConvertToImage();
193 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
194 size_t len = strm.GetSize();
195 char* buff = new char[len+1];
196 strm.CopyTo(buff, len);
198 SendMsg(%s, markerNumber, (long)buff);
201 ('Define a marker from a bitmap',)),
204 'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
205 'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
206 'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0),
207 'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0),
208 'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0),
209 'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0),
210 'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
211 'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
213 'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
214 'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
215 'SetSelFore' : ('SetSelForeground', 0, 0, 0),
216 'SetSelBack' : ('SetSelBackground', 0, 0, 0),
217 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
218 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
222 'void %s(int key, int modifiers, int cmd);',
224 '''void %s(int key, int modifiers, int cmd) {
225 SendMsg(%s, MAKELONG(key, modifiers), cmd);''',
231 'void %s(int key, int modifiers);',
233 '''void %s(int key, int modifiers) {
234 SendMsg(%s, MAKELONG(key, modifiers));''',
237 'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0),
242 'void %s(int length, char* styleBytes);',
244 '''void %s(int length, char* styleBytes) {
245 SendMsg(%s, length, (long)styleBytes);''',
249 'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0),
250 'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
251 'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
252 'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
254 'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
255 'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
257 'AutoCShow' : ('AutoCompShow', 0, 0, 0),
258 'AutoCCancel' : ('AutoCompCancel', 0, 0, 0),
259 'AutoCActive' : ('AutoCompActive', 0, 0, 0),
260 'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0),
261 'AutoCComplete' : ('AutoCompComplete', 0, 0, 0),
262 'AutoCStops' : ('AutoCompStops', 0, 0, 0),
263 'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0),
264 'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0),
265 'AutoCSelect' : ('AutoCompSelect', 0, 0, 0),
266 'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0),
267 'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0),
268 'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0),
269 'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0),
270 'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
271 'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
272 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
273 'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
274 'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
275 'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
276 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
277 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0),
278 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0),
279 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0, 0),
283 '''void %s(int type, const wxBitmap& bmp);''',
284 '''void %s(int type, const wxBitmap& bmp) {
285 // convert bmp to a xpm in a string
286 wxMemoryOutputStream strm;
287 wxImage img = bmp.ConvertToImage();
288 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
289 size_t len = strm.GetSize();
290 char* buff = new char[len+1];
291 strm.CopyTo(buff, len);
293 SendMsg(%s, type, (long)buff);
296 ('Register an image for use in autocompletion lists.',)),
299 'ClearRegisteredImages' : (0, 0, 0,
300 ('Clear all the registered images.',)),
303 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
304 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
306 'SetVScrollBar' : ('SetUseVerticalScrollBar', 0, 0, 0),
307 'GetVScrollBar' : ('GetUseVerticalScrollBar', 0, 0, 0),
309 'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
311 'GetUsePalette' : (None, 0, 0, 0),
315 '''int %s(int minPos, int maxPos, const wxString& text, int flags=0);''',
317 '''int %s(int minPos, int maxPos,
318 const wxString& text,
321 ft.chrg.cpMin = minPos;
322 ft.chrg.cpMax = maxPos;
323 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
324 ft.lpstrText = (char*)(const char*)buf;
326 return SendMsg(%s, flags, (long)&ft);''',
331 '''int %s(bool doDraw,
337 wxRect pageRect);''',
338 ''' int %s(bool doDraw,
347 if (endPos < startPos) {
353 fr.hdcTarget = target;
354 fr.rc.top = renderRect.GetTop();
355 fr.rc.left = renderRect.GetLeft();
356 fr.rc.right = renderRect.GetRight();
357 fr.rc.bottom = renderRect.GetBottom();
358 fr.rcPage.top = pageRect.GetTop();
359 fr.rcPage.left = pageRect.GetLeft();
360 fr.rcPage.right = pageRect.GetRight();
361 fr.rcPage.bottom = pageRect.GetBottom();
362 fr.chrg.cpMin = startPos;
363 fr.chrg.cpMax = endPos;
365 return SendMsg(%s, doDraw, (long)&fr);''',
371 'wxString %s(int line);',
373 '''wxString %s(int line) {
374 int len = LineLength(line);
375 if (!len) return wxEmptyString;
377 wxMemoryBuffer mbuf(len+1);
378 char* buf = (char*)mbuf.GetWriteBuf(len+1);
379 SendMsg(%s, line, (long)buf);
380 mbuf.UngetWriteBuf(len);
382 return stc2wx(buf);''',
384 ('Retrieve the contents of a line.',)),
386 'SetSel' : ('SetSelection', 0, 0, 0),
396 GetSelection(&start, &end);
397 int len = end - start;
398 if (!len) return wxEmptyString;
400 wxMemoryBuffer mbuf(len+2);
401 char* buf = (char*)mbuf.GetWriteBuf(len+1);
402 SendMsg(%s, 0, (long)buf);
403 mbuf.UngetWriteBuf(len);
405 return stc2wx(buf);''',
407 ('Retrieve the selected text.',)),
412 'wxString %s(int startPos, int endPos);',
414 '''wxString %s(int startPos, int endPos) {
415 if (endPos < startPos) {
420 int len = endPos - startPos;
421 if (!len) return wxEmptyString;
422 wxMemoryBuffer mbuf(len+1);
423 char* buf = (char*)mbuf.GetWriteBuf(len);
426 tr.chrg.cpMin = startPos;
427 tr.chrg.cpMax = endPos;
428 SendMsg(%s, 0, (long)&tr);
429 mbuf.UngetWriteBuf(len);
431 return stc2wx(buf);''',
433 ('Retrieve a range of text.',)),
435 'PointXFromPosition' : (None, 0, 0, 0),
436 'PointYFromPosition' : (None, 0, 0, 0),
438 'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
439 'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
440 'Null' : (None, 0, 0, 0),
447 int len = GetTextLength();
448 wxMemoryBuffer mbuf(len+1); // leave room for the null...
449 char* buf = (char*)mbuf.GetWriteBuf(len+1);
450 SendMsg(%s, len+1, (long)buf);
451 mbuf.UngetWriteBuf(len);
453 return stc2wx(buf);''',
455 ('Retrieve all the text in the document.', )),
457 'GetDirectFunction' : (None, 0, 0, 0),
458 'GetDirectPointer' : (None, 0, 0, 0),
460 'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
461 'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
462 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
463 'CallTipSetFore' : ('CallTipSetForeground', 0, 0, 0),
464 'CallTipSetForeHlt' : ('CallTipSetForegroundHighlight', 0, 0, 0),
466 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
467 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
472 'int %s(const wxString& text);',
475 int %s(const wxString& text) {
476 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
477 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
482 'int %s(const wxString& text);',
485 int %s(const wxString& text) {
486 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
487 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
492 'int %s(const wxString& text);',
495 int %s(const wxString& text) {
496 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
497 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
505 return (void*)SendMsg(%s);''',
510 'void %s(void* docPointer);',
511 '''void %s(void* docPointer) {
512 SendMsg(%s, 0, (long)docPointer);''',
519 return (void*)SendMsg(%s);''',
524 'void %s(void* docPointer);',
525 '''void %s(void* docPointer) {
526 SendMsg(%s, 0, (long)docPointer);''',
531 'void %s(void* docPointer);',
532 '''void %s(void* docPointer) {
533 SendMsg(%s, 0, (long)docPointer);''',
539 '''void %s(int codePage) {
541 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
542 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
544 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
545 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
547 SendMsg(%s, codePage);''',
548 ("Set the code page used to interpret the bytes of the document as characters.",) ),
551 'GrabFocus' : (None, 0, 0, 0),
553 # Rename some that woudl otherwise hid the wxWindow methods
554 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
555 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
556 'SetCursor' : ('SetSTCCursor', 0, 0, 0),
557 'GetCursor' : ('GetSTCCursor', 0, 0, 0),
559 'LoadLexerLibrary' : (None, 0,0,0),
563 # Remove all methods that are key commands since they can be
564 # executed with CmdKeyExecute
565 'LineDown' : (None, 0, 0, 0),
566 'LineDownExtend' : (None, 0, 0, 0),
567 'LineUp' : (None, 0, 0, 0),
568 'LineUpExtend' : (None, 0, 0, 0),
569 'CharLeft' : (None, 0, 0, 0),
570 'CharLeftExtend' : (None, 0, 0, 0),
571 'CharRight' : (None, 0, 0, 0),
572 'CharRightExtend' : (None, 0, 0, 0),
573 'WordLeft' : (None, 0, 0, 0),
574 'WordLeftExtend' : (None, 0, 0, 0),
575 'WordRight' : (None, 0, 0, 0),
576 'WordRightExtend' : (None, 0, 0, 0),
577 'Home' : (None, 0, 0, 0),
578 'HomeExtend' : (None, 0, 0, 0),
579 'LineEnd' : (None, 0, 0, 0),
580 'LineEndExtend' : (None, 0, 0, 0),
581 'DocumentStart' : (None, 0, 0, 0),
582 'DocumentStartExtend' : (None, 0, 0, 0),
583 'DocumentEnd' : (None, 0, 0, 0),
584 'DocumentEndExtend' : (None, 0, 0, 0),
585 'PageUp' : (None, 0, 0, 0),
586 'PageUpExtend' : (None, 0, 0, 0),
587 'PageDown' : (None, 0, 0, 0),
588 'PageDownExtend' : (None, 0, 0, 0),
589 'EditToggleOvertype' : (None, 0, 0, 0),
590 'Cancel' : (None, 0, 0, 0),
591 'DeleteBack' : (None, 0, 0, 0),
592 'Tab' : (None, 0, 0, 0),
593 'BackTab' : (None, 0, 0, 0),
594 'NewLine' : (None, 0, 0, 0),
595 'FormFeed' : (None, 0, 0, 0),
596 'VCHome' : (None, 0, 0, 0),
597 'VCHomeExtend' : (None, 0, 0, 0),
598 'ZoomIn' : (None, 0, 0, 0),
599 'ZoomOut' : (None, 0, 0, 0),
600 'DelWordLeft' : (None, 0, 0, 0),
601 'DelWordRight' : (None, 0, 0, 0),
602 'LineCut' : (None, 0, 0, 0),
603 'LineDelete' : (None, 0, 0, 0),
604 'LineTranspose' : (None, 0, 0, 0),
605 'LowerCase' : (None, 0, 0, 0),
606 'UpperCase' : (None, 0, 0, 0),
607 'LineScrollDown' : (None, 0, 0, 0),
608 'LineScrollUp' : (None, 0, 0, 0),
609 'DeleteBackNotLine' : (None, 0, 0, 0),
610 'HomeWrap' : (None, 0, 0, 0),
611 'HomeWrapExtend' : (None, 0, 0, 0),
612 'LineEndWrap' : (None, 0, 0, 0),
613 'LineEndWrapExtend' : (None, 0, 0, 0),
614 'VCHomeWrap' : (None, 0, 0, 0),
615 'VCHomeWrapExtend' : (None, 0, 0, 0),
616 'ParaDown' : (None, 0, 0, 0),
617 'ParaDownExtend' : (None, 0, 0, 0),
618 'ParaUp' : (None, 0, 0, 0),
619 'ParaUpExtend' : (None, 0, 0, 0),
620 'LineDownRectExtend' : (None, 0, 0, 0),
621 'LineUpRectExtend' : (None, 0, 0, 0),
622 'CharLeftRectExtend' : (None, 0, 0, 0),
623 'CharRightRectExtend' : (None, 0, 0, 0),
624 'HomeRectExtend' : (None, 0, 0, 0),
625 'VCHomeRectExtend' : (None, 0, 0, 0),
626 'LineEndRectExtend' : (None, 0, 0, 0),
627 'PageUpRectExtend' : (None, 0, 0, 0),
628 'PageDownRectExtend' : (None, 0, 0, 0),
629 'StutteredPageUp' : (None, 0, 0, 0),
630 'StutteredPageUpExtend' : (None, 0, 0, 0),
631 'StutteredPageDown' : (None, 0, 0, 0),
632 'StutteredPageDownExtend' : (None, 0, 0, 0),
633 'WordLeftEnd' : (None, 0, 0, 0),
634 'WordLeftEndExtend' : (None, 0, 0, 0),
635 'WordRightEnd' : (None, 0, 0, 0),
636 'WordRightEndExtend' : (None, 0, 0, 0),
642 #----------------------------------------------------------------------------
644 def processIface(iface
, h_tmplt
, cpp_tmplt
, h_dest
, cpp_dest
):
651 fi
= FileInput(iface
)
654 if line
[:2] == '##' or line
== '':
659 if line
[:2] == '# ': # a doc string
660 curDocStrings
.append(line
[2:])
663 parseVal(line
[4:], values
, curDocStrings
)
666 elif op
== 'fun ' or op
== 'set ' or op
== 'get ':
667 parseFun(line
[4:], methods
, curDocStrings
, cmds
)
671 if string
.strip(line
[4:]) == 'Deprecated':
672 break # skip the rest of the file
684 print '***** Unknown line type: ', line
689 data
['VALUES'] = processVals(values
)
690 data
['CMDS'] = processVals(cmds
)
691 defs
, imps
= processMethods(methods
)
692 data
['METHOD_DEFS'] = defs
693 data
['METHOD_IMPS'] = imps
696 h_text
= open(h_tmplt
).read()
697 cpp_text
= open(cpp_tmplt
).read()
699 # do the substitutions
700 h_text
= h_text
% data
701 cpp_text
= cpp_text
% data
703 # write out destination files
704 open(h_dest
, 'w').write(h_text
)
705 open(cpp_dest
, 'w').write(cpp_text
)
709 #----------------------------------------------------------------------------
711 def processVals(values
):
713 for name
, value
, docs
in values
:
717 text
.append('// ' + x
)
718 text
.append('#define %s %s' % (name
, value
))
719 return string
.join(text
, '\n')
721 #----------------------------------------------------------------------------
723 def processMethods(methods
):
727 for retType
, name
, number
, param1
, param2
, docs
in methods
:
728 retType
= retTypeMap
.get(retType
, retType
)
729 params
= makeParamString(param1
, param2
)
731 name
, theDef
, theImp
, docs
= checkMethodOverride(name
, number
, docs
)
736 # Build the method definition for the .h file
740 defs
.append(' // ' + x
)
742 theDef
= ' %s %s(%s);' % (retType
, name
, params
)
745 # Build the method implementation string
749 imps
.append('// ' + x
)
751 theImp
= '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType
, name
, params
)
753 if retType
== 'wxColour':
754 theImp
= theImp
+ 'long c = '
755 elif retType
!= 'void':
756 theImp
= theImp
+ 'return '
757 theImp
= theImp
+ 'SendMsg(%s, %s, %s)' % (number
,
758 makeArgString(param1
),
759 makeArgString(param2
))
760 if retType
== 'bool':
761 theImp
= theImp
+ ' != 0'
762 if retType
== 'wxColour':
763 theImp
= theImp
+ ';\n return wxColourFromLong(c)'
765 theImp
= theImp
+ ';\n}'
769 return string
.join(defs
, '\n'), string
.join(imps
, '\n')
772 #----------------------------------------------------------------------------
774 def checkMethodOverride(name
, number
, docs
):
775 theDef
= theImp
= None
776 if methodOverrideMap
.has_key(name
):
777 item
= methodOverrideMap
[name
]
783 theDef
= ' ' + (item
[1] % name
)
785 theImp
= item
[2] % ('wxStyledTextCtrl::'+name
, number
) + '\n}'
789 print "*************", name
792 return name
, theDef
, theImp
, docs
794 #----------------------------------------------------------------------------
796 def makeArgString(param
):
803 return '(long)(const char*)wx2stc(%s)' % name
805 return 'wxColourAsLong(%s)' % name
809 #----------------------------------------------------------------------------
811 def makeParamString(param1
, param2
):
814 aType
= paramTypeMap
.get(param
[0], param
[0])
815 return aType
+ ' ' + param
[1]
822 st
= st
+ doOne(param2
)
826 #----------------------------------------------------------------------------
828 def parseVal(line
, values
, docs
):
829 name
, val
= string
.split(line
, '=')
831 # remove prefixes such as SCI, etc.
832 for old
, new
in valPrefixes
:
837 name
= new
+ name
[lo
:]
840 values
.append( ('wxSTC_' + name
, val
, docs
) )
842 #----------------------------------------------------------------------------
844 funregex
= re
.compile(r
'\s*([a-zA-Z0-9_]+)' # <ws>return type
845 '\s+([a-zA-Z0-9_]+)=' # <ws>name=
847 '\(([ a-zA-Z0-9_]*),' # (param,
848 '([ a-zA-Z0-9_]*)\)') # param)
850 def parseFun(line
, methods
, docs
, values
):
851 def parseParam(param
):
852 param
= string
.strip(param
)
856 param
= tuple(string
.split(param
))
859 mo
= funregex
.match(line
)
861 print "***** Line doesn't match! : " + line
863 retType
, name
, number
, param1
, param2
= mo
.groups()
865 param1
= parseParam(param1
)
866 param2
= parseParam(param2
)
868 # Special case. For the key command functions we want a value defined too
869 num
= string
.atoi(number
)
871 if (type(v
) == type(()) and v
[0] <= num
<= v
[1]) or v
== num
:
872 parseVal('CMD_%s=%s' % (string
.upper(name
), number
), values
, docs
)
874 #if retType == 'void' and not param1 and not param2:
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
)
890 if __name__
== '__main__':
893 #----------------------------------------------------------------------------