]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/gen_iface.py
bde1a8447d3e5971a8ac448d446f05ba4f8bbf19
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
54 # Should a funciton be also generated for the CMDs?
58 # Map some generic typenames to wx types, using return value syntax
65 # Map some generic typenames to wx types, using parameter syntax
68 'string': 'const wxString&',
69 'colour': 'const wxColour&',
73 # Map of method info that needs tweaked. Either the name needs changed, or
74 # the method definition/implementation. Tuple items are:
76 # 1. New method name. None to skip the method, 0 to leave the
78 # 2. Method definition for the .h file, 0 to leave alone
79 # 3. Method implementation for the .cpp file, 0 to leave alone.
80 # 4. tuple of Doc string lines, or 0 to leave alone.
84 'void %s(const wxString& text);',
86 '''void %s(const wxString& text) {
87 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
88 SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
92 'void %s(const wxMemoryBuffer& data);',
94 '''void %s(const wxMemoryBuffer& data) {
95 SendMsg(%s, data.GetDataLen(), (long)data.GetData());''',
99 'void %s(const wxString& text);',
101 '''void %s(const wxString& text) {
102 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
103 SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
106 'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
107 'SetViewWS' : ( 'SetViewWhiteSpace', 0, 0, 0),
111 '''int %s(int pos) const {
112 return (unsigned char)SendMsg(%s, pos, 0);''',
117 '''int %s(int pos) const {
118 return (unsigned char)SendMsg(%s, pos, 0);''',
123 'wxMemoryBuffer %s(int startPos, int endPos);',
125 '''wxMemoryBuffer %s(int startPos, int endPos) {
127 if (endPos < startPos) {
132 int len = endPos - startPos;
133 if (!len) return buf;
135 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
136 tr.chrg.cpMin = startPos;
137 tr.chrg.cpMax = endPos;
138 len = SendMsg(%s, 0, (long)&tr);
139 buf.UngetWriteBuf(len);
142 ('Retrieve a buffer of cells.',)),
145 'PositionFromPoint' :
147 'int %s(wxPoint pt);',
149 '''int %s(wxPoint pt) {
150 return SendMsg(%s, pt.x, pt.y);''',
155 '#ifdef SWIG\n wxString %s(int* OUTPUT);\n#else\n wxString GetCurLine(int* linePos=NULL);\n#endif',
157 '''wxString %s(int* linePos) {
158 int len = LineLength(GetCurrentLine());
160 if (linePos) *linePos = 0;
161 return wxEmptyString;
164 wxMemoryBuffer mbuf(len+1);
165 char* buf = (char*)mbuf.GetWriteBuf(len+1);
167 int pos = SendMsg(%s, len+1, (long)buf);
168 mbuf.UngetWriteBuf(len);
170 if (linePos) *linePos = pos;
171 return stc2wx(buf);''',
175 'SetUsePalette' : (None, 0,0,0),
177 'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0),
178 'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0),
182 '''void %s(int markerNumber, int markerSymbol,
183 const wxColour& foreground = wxNullColour,
184 const wxColour& background = wxNullColour);''',
186 '''void %s(int markerNumber, int markerSymbol,
187 const wxColour& foreground,
188 const wxColour& background) {
190 SendMsg(%s, markerNumber, markerSymbol);
192 MarkerSetForeground(markerNumber, foreground);
194 MarkerSetBackground(markerNumber, background);''',
196 ('Set the symbol used for a particular marker number,',
197 'and optionally the fore and background colours.')),
200 'MarkerDefinePixmap' :
201 ('MarkerDefineBitmap',
202 '''void %s(int markerNumber, const wxBitmap& bmp);''',
203 '''void %s(int markerNumber, const wxBitmap& bmp) {
204 // convert bmp to a xpm in a string
205 wxMemoryOutputStream strm;
206 wxImage img = bmp.ConvertToImage();
208 img.ConvertAlphaToMask();
209 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
210 size_t len = strm.GetSize();
211 char* buff = new char[len+1];
212 strm.CopyTo(buff, len);
214 SendMsg(%s, markerNumber, (long)buff);
217 ('Define a marker from a bitmap',)),
220 'SetMarginTypeN' : ('SetMarginType', 0, 0, 0),
221 'GetMarginTypeN' : ('GetMarginType', 0, 0, 0),
222 'SetMarginWidthN' : ('SetMarginWidth', 0, 0, 0),
223 'GetMarginWidthN' : ('GetMarginWidth', 0, 0, 0),
224 'SetMarginMaskN' : ('SetMarginMask', 0, 0, 0),
225 'GetMarginMaskN' : ('GetMarginMask', 0, 0, 0),
226 'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
227 'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
230 'StyleGetFore' : ('StyleGetForeground', 0, 0, 0),
231 'StyleGetBack' : ('StyleGetBackground', 0, 0, 0),
232 'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
233 'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
234 'SetSelFore' : ('SetSelForeground', 0, 0, 0),
235 'SetSelBack' : ('SetSelBackground', 0, 0, 0),
236 'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
239 'wxString %s(int style);',
240 '''wxString %s(int style) {
242 long len = SendMsg(msg, style, 0);
243 wxMemoryBuffer mbuf(len+1);
244 char* buf = (char*)mbuf.GetWriteBuf(len+1);
245 SendMsg(msg, style, (long)buf);
246 mbuf.UngetWriteBuf(len);
248 return stc2wx(buf);''',
249 ('Get the font facename of a style',)),
250 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
251 'StyleSetCharacterSet' : (None, 0, 0, 0),
255 'void %s(int key, int modifiers, int cmd);',
257 '''void %s(int key, int modifiers, int cmd) {
258 SendMsg(%s, MAKELONG(key, modifiers), cmd);''',
264 'void %s(int key, int modifiers);',
266 '''void %s(int key, int modifiers) {
267 SendMsg(%s, MAKELONG(key, modifiers));''',
270 'ClearAllCmdKeys' : ('CmdKeyClearAll', 0, 0, 0),
275 'void %s(int length, char* styleBytes);',
277 '''void %s(int length, char* styleBytes) {
278 SendMsg(%s, length, (long)styleBytes);''',
282 'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0),
283 'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
284 'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
285 'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
286 'IndicSetUnder': ('IndicatorSetUnder', 0, 0, 0),
287 'IndicGetUnder': ('IndicatorGetUnder', 0, 0, 0),
289 'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
290 'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
292 'AutoCShow' : ('AutoCompShow', 0, 0, 0),
293 'AutoCCancel' : ('AutoCompCancel', 0, 0, 0),
294 'AutoCActive' : ('AutoCompActive', 0, 0, 0),
295 'AutoCPosStart' : ('AutoCompPosStart', 0, 0, 0),
296 'AutoCComplete' : ('AutoCompComplete', 0, 0, 0),
297 'AutoCStops' : ('AutoCompStops', 0, 0, 0),
298 'AutoCSetSeparator' : ('AutoCompSetSeparator', 0, 0, 0),
299 'AutoCGetSeparator' : ('AutoCompGetSeparator', 0, 0, 0),
300 'AutoCSelect' : ('AutoCompSelect', 0, 0, 0),
301 'AutoCSetCancelAtStart' : ('AutoCompSetCancelAtStart', 0, 0, 0),
302 'AutoCGetCancelAtStart' : ('AutoCompGetCancelAtStart', 0, 0, 0),
303 'AutoCSetFillUps' : ('AutoCompSetFillUps', 0, 0, 0),
304 'AutoCSetChooseSingle' : ('AutoCompSetChooseSingle', 0, 0, 0),
305 'AutoCGetChooseSingle' : ('AutoCompGetChooseSingle', 0, 0, 0),
306 'AutoCSetIgnoreCase' : ('AutoCompSetIgnoreCase', 0, 0, 0),
307 'AutoCGetIgnoreCase' : ('AutoCompGetIgnoreCase', 0, 0, 0),
308 'AutoCSetAutoHide' : ('AutoCompSetAutoHide', 0, 0, 0),
309 'AutoCGetAutoHide' : ('AutoCompGetAutoHide', 0, 0, 0),
310 'AutoCSetDropRestOfWord' : ('AutoCompSetDropRestOfWord', 0,0,0),
311 'AutoCGetDropRestOfWord' : ('AutoCompGetDropRestOfWord', 0,0,0),
312 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0),
313 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0),
314 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0, 0),
315 'AutoCSetMaxWidth' : ('AutoCompSetMaxWidth', 0, 0, 0),
316 'AutoCGetMaxWidth' : ('AutoCompGetMaxWidth', 0, 0, 0),
317 'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0, 0),
318 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
319 'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
323 '''void %s(int type, const wxBitmap& bmp);''',
324 '''void %s(int type, const wxBitmap& bmp) {
325 // convert bmp to a xpm in a string
326 wxMemoryOutputStream strm;
327 wxImage img = bmp.ConvertToImage();
329 img.ConvertAlphaToMask();
330 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
331 size_t len = strm.GetSize();
332 char* buff = new char[len+1];
333 strm.CopyTo(buff, len);
335 SendMsg(%s, type, (long)buff);
338 ('Register an image for use in autocompletion lists.',)),
341 'ClearRegisteredImages' : (0, 0, 0,
342 ('Clear all the registered images.',)),
345 'SetHScrollBar' : ('SetUseHorizontalScrollBar', 0, 0, 0),
346 'GetHScrollBar' : ('GetUseHorizontalScrollBar', 0, 0, 0),
348 'SetVScrollBar' : ('SetUseVerticalScrollBar', 0, 0, 0),
349 'GetVScrollBar' : ('GetUseVerticalScrollBar', 0, 0, 0),
351 'GetCaretFore' : ('GetCaretForeground', 0, 0, 0),
353 'GetUsePalette' : (None, 0, 0, 0),
357 '''int %s(int minPos, int maxPos, const wxString& text, int flags=0);''',
359 '''int %s(int minPos, int maxPos,
360 const wxString& text,
363 ft.chrg.cpMin = minPos;
364 ft.chrg.cpMax = maxPos;
365 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
366 ft.lpstrText = (char*)(const char*)buf;
368 return SendMsg(%s, flags, (long)&ft);''',
373 '''int %s(bool doDraw,
379 wxRect pageRect);''',
380 ''' int %s(bool doDraw,
389 if (endPos < startPos) {
395 fr.hdcTarget = target;
396 fr.rc.top = renderRect.GetTop();
397 fr.rc.left = renderRect.GetLeft();
398 fr.rc.right = renderRect.GetRight();
399 fr.rc.bottom = renderRect.GetBottom();
400 fr.rcPage.top = pageRect.GetTop();
401 fr.rcPage.left = pageRect.GetLeft();
402 fr.rcPage.right = pageRect.GetRight();
403 fr.rcPage.bottom = pageRect.GetBottom();
404 fr.chrg.cpMin = startPos;
405 fr.chrg.cpMax = endPos;
407 return SendMsg(%s, doDraw, (long)&fr);''',
413 'wxString %s(int line);',
415 '''wxString %s(int line) {
416 int len = LineLength(line);
417 if (!len) return wxEmptyString;
419 wxMemoryBuffer mbuf(len+1);
420 char* buf = (char*)mbuf.GetWriteBuf(len+1);
421 SendMsg(%s, line, (long)buf);
422 mbuf.UngetWriteBuf(len);
424 return stc2wx(buf);''',
426 ('Retrieve the contents of a line.',)),
428 'SetSel' : ('SetSelection', 0, 0, 0),
438 GetSelection(&start, &end);
439 int len = end - start;
440 if (!len) return wxEmptyString;
442 wxMemoryBuffer mbuf(len+2);
443 char* buf = (char*)mbuf.GetWriteBuf(len+1);
444 SendMsg(%s, 0, (long)buf);
445 mbuf.UngetWriteBuf(len);
447 return stc2wx(buf);''',
449 ('Retrieve the selected text.',)),
454 'wxString %s(int startPos, int endPos);',
456 '''wxString %s(int startPos, int endPos) {
457 if (endPos < startPos) {
462 int len = endPos - startPos;
463 if (!len) return wxEmptyString;
464 wxMemoryBuffer mbuf(len+1);
465 char* buf = (char*)mbuf.GetWriteBuf(len);
468 tr.chrg.cpMin = startPos;
469 tr.chrg.cpMax = endPos;
470 SendMsg(%s, 0, (long)&tr);
471 mbuf.UngetWriteBuf(len);
473 return stc2wx(buf);''',
475 ('Retrieve a range of text.',)),
477 'PointXFromPosition' : (None, 0, 0, 0),
478 'PointYFromPosition' : (None, 0, 0, 0),
480 'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0),
481 'ReplaceSel' : ('ReplaceSelection', 0, 0, 0),
482 'Null' : (None, 0, 0, 0),
489 int len = GetTextLength();
490 wxMemoryBuffer mbuf(len+1); // leave room for the null...
491 char* buf = (char*)mbuf.GetWriteBuf(len+1);
492 SendMsg(%s, len+1, (long)buf);
493 mbuf.UngetWriteBuf(len);
495 return stc2wx(buf);''',
497 ('Retrieve all the text in the document.', )),
499 'GetDirectFunction' : (None, 0, 0, 0),
500 'GetDirectPointer' : (None, 0, 0, 0),
502 'CallTipPosStart' : ('CallTipPosAtStart', 0, 0, 0),
503 'CallTipSetHlt' : ('CallTipSetHighlight', 0, 0, 0),
504 'CallTipSetBack' : ('CallTipSetBackground', 0, 0, 0),
505 'CallTipSetFore' : ('CallTipSetForeground', 0, 0, 0),
506 'CallTipSetForeHlt' : ('CallTipSetForegroundHighlight', 0, 0, 0),
508 'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
509 'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
510 'GetHotspotActiveFore' : ('GetHotspotActiveForeground', 0, 0, 0),
511 'GetHotspotActiveBack' : ('GetHotspotActiveBackground', 0, 0, 0),
513 'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0),
514 'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0),
518 'int %s(const wxString& text);',
521 int %s(const wxString& text) {
522 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
523 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
528 'int %s(const wxString& text);',
531 int %s(const wxString& text) {
532 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
533 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
538 'int %s(const wxString& text);',
541 int %s(const wxString& text) {
542 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
543 return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
546 # not sure what to do about these yet
547 'TargetAsUTF8' : ( None, 0, 0, 0),
548 'SetLengthForEncode' : ( None, 0, 0, 0),
549 'EncodedFromUTF8' : ( None, 0, 0, 0),
554 'wxString %s(const wxString& key);',
556 '''wxString %s(const wxString& key) {
557 int len = SendMsg(SCI_GETPROPERTY, (long)(const char*)wx2stc(key), 0);
558 if (!len) return wxEmptyString;
560 wxMemoryBuffer mbuf(len+1);
561 char* buf = (char*)mbuf.GetWriteBuf(len+1);
562 SendMsg(%s, (long)(const char*)wx2stc(key), (long)buf);
563 mbuf.UngetWriteBuf(len);
565 return stc2wx(buf);''',
566 ("Retrieve a 'property' value previously set with SetProperty.",)),
568 'GetPropertyExpanded' :
570 'wxString %s(const wxString& key);',
572 '''wxString %s(const wxString& key) {
573 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2stc(key), 0);
574 if (!len) return wxEmptyString;
576 wxMemoryBuffer mbuf(len+1);
577 char* buf = (char*)mbuf.GetWriteBuf(len+1);
578 SendMsg(%s, (long)(const char*)wx2stc(key), (long)buf);
579 mbuf.UngetWriteBuf(len);
581 return stc2wx(buf);''',
582 ("Retrieve a 'property' value previously set with SetProperty,",
583 "with '$()' variable replacement on returned buffer.")),
585 'GetPropertyInt' : (0, 0, 0,
586 ("Retrieve a 'property' value previously set with SetProperty,",
587 "interpreted as an int AFTER any '$()' variable replacement.")),
594 return (void*)SendMsg(%s);''',
599 'void %s(void* docPointer);',
600 '''void %s(void* docPointer) {
601 SendMsg(%s, 0, (long)docPointer);''',
608 return (void*)SendMsg(%s);''',
613 'void %s(void* docPointer);',
614 '''void %s(void* docPointer) {
615 SendMsg(%s, 0, (long)docPointer);''',
620 'void %s(void* docPointer);',
621 '''void %s(void* docPointer) {
622 SendMsg(%s, 0, (long)docPointer);''',
628 '''void %s(int codePage) {
630 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
631 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
633 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
634 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
636 SendMsg(%s, codePage);''',
637 ("Set the code page used to interpret the bytes of the document as characters.",) ),
640 'GrabFocus' : (None, 0, 0, 0),
642 # Rename some that would otherwise hide the wxWindow methods
643 'SetFocus' : ('SetSTCFocus', 0, 0, 0),
644 'GetFocus' : ('GetSTCFocus', 0, 0, 0),
645 'SetCursor' : ('SetSTCCursor', 0, 0, 0),
646 'GetCursor' : ('GetSTCCursor', 0, 0, 0),
648 'LoadLexerLibrary' : (None, 0,0,0),
650 'SetPositionCache' : ('SetPositionCacheSize', 0, 0, 0),
651 'GetPositionCache' : ('GetPositionCacheSize', 0, 0, 0),
658 #----------------------------------------------------------------------------
660 def processIface(iface
, h_tmplt
, cpp_tmplt
, h_dest
, cpp_dest
, docstr_dest
):
667 fi
= FileInput(iface
)
670 if line
[:2] == '##' or line
== '':
675 if line
[:2] == '# ': # a doc string
676 curDocStrings
.append(line
[2:])
679 parseVal(line
[4:], values
, curDocStrings
)
682 elif op
== 'fun ' or op
== 'set ' or op
== 'get ':
683 parseFun(line
[4:], methods
, curDocStrings
, cmds
, op
== 'get ')
687 if string
.strip(line
[4:]) == 'Deprecated':
688 break # skip the rest of the file
700 print '***** Unknown line type: ', line
705 data
['VALUES'] = processVals(values
)
706 data
['CMDS'] = processVals(cmds
)
707 defs
, imps
, docstrings
= processMethods(methods
)
708 data
['METHOD_DEFS'] = defs
709 data
['METHOD_IMPS'] = imps
712 h_text
= open(h_tmplt
).read()
713 cpp_text
= open(cpp_tmplt
).read()
715 # do the substitutions
716 h_text
= h_text
% data
717 cpp_text
= cpp_text
% data
719 # write out destination files
720 open(h_dest
, 'w').write(h_text
)
721 open(cpp_dest
, 'w').write(cpp_text
)
722 open(docstr_dest
, 'w').write(docstrings
)
726 #----------------------------------------------------------------------------
728 def processVals(values
):
730 for name
, value
, docs
in values
:
734 text
.append('// ' + x
)
735 text
.append('#define %s %s' % (name
, value
))
736 return string
.join(text
, '\n')
738 #----------------------------------------------------------------------------
740 def processMethods(methods
):
745 for retType
, name
, number
, param1
, param2
, docs
, is_const
in methods
:
746 retType
= retTypeMap
.get(retType
, retType
)
747 params
= makeParamString(param1
, param2
)
749 name
, theDef
, theImp
, docs
= checkMethodOverride(name
, number
, docs
)
755 st
= 'DocStr(wxStyledTextCtrl::%s,\n' \
756 '"%s", "");\n' % (name
, '\n'.join(docs
))
759 # Build the method definition for the .h file
763 defs
.append(' // ' + x
)
765 theDef
= ' %s %s(%s)' % (retType
, name
, params
)
767 theDef
= theDef
+ ' const'
768 theDef
= theDef
+ ';'
771 # Build the method implementation string
775 imps
.append('// ' + x
)
777 theImp
= '%s wxStyledTextCtrl::%s(%s)' % (retType
, name
, params
)
779 theImp
= theImp
+ ' const'
780 theImp
= theImp
+ '\n{\n '
781 if retType
== 'wxColour':
782 theImp
= theImp
+ 'long c = '
783 elif retType
!= 'void':
784 theImp
= theImp
+ 'return '
785 theImp
= theImp
+ 'SendMsg(%s, %s, %s)' % (number
,
786 makeArgString(param1
),
787 makeArgString(param2
))
788 if retType
== 'bool':
789 theImp
= theImp
+ ' != 0'
790 if retType
== 'wxColour':
791 theImp
= theImp
+ ';\n return wxColourFromLong(c)'
793 theImp
= theImp
+ ';\n}'
797 return '\n'.join(defs
), '\n'.join(imps
), '\n'.join(dstr
)
800 #----------------------------------------------------------------------------
802 def checkMethodOverride(name
, number
, docs
):
803 theDef
= theImp
= None
804 if methodOverrideMap
.has_key(name
):
805 item
= methodOverrideMap
[name
]
811 theDef
= ' ' + (item
[1] % name
)
813 theImp
= item
[2] % ('wxStyledTextCtrl::'+name
, number
) + '\n}'
817 print "*************", name
820 return name
, theDef
, theImp
, docs
822 #----------------------------------------------------------------------------
824 def makeArgString(param
):
831 return '(long)(const char*)wx2stc(%s)' % name
833 return 'wxColourAsLong(%s)' % name
837 #----------------------------------------------------------------------------
839 def makeParamString(param1
, param2
):
842 aType
= paramTypeMap
.get(param
[0], param
[0])
843 return aType
+ ' ' + param
[1]
850 st
= st
+ doOne(param2
)
854 #----------------------------------------------------------------------------
856 def parseVal(line
, values
, docs
):
857 name
, val
= string
.split(line
, '=')
859 # remove prefixes such as SCI, etc.
860 for old
, new
in valPrefixes
:
865 name
= new
+ name
[lo
:]
868 values
.append( ('wxSTC_' + name
, val
, docs
) )
870 #----------------------------------------------------------------------------
872 funregex
= re
.compile(r
'\s*([a-zA-Z0-9_]+)' # <ws>return type
873 '\s+([a-zA-Z0-9_]+)=' # <ws>name=
875 '\(([ a-zA-Z0-9_]*),' # (param,
876 '([ a-zA-Z0-9_]*)\)') # param)
878 def parseFun(line
, methods
, docs
, values
, is_const
):
879 def parseParam(param
):
880 param
= string
.strip(param
)
884 param
= tuple(string
.split(param
))
887 mo
= funregex
.match(line
)
889 print "***** Line doesn't match! : " + line
891 retType
, name
, number
, param1
, param2
= mo
.groups()
893 param1
= parseParam(param1
)
894 param2
= parseParam(param2
)
896 # Special case. For the key command functions we want a value defined too
897 num
= string
.atoi(number
)
899 if (type(v
) == type(()) and v
[0] <= num
<= v
[1]) or v
== num
:
900 parseVal('CMD_%s=%s' % (string
.upper(name
), number
), values
, docs
)
902 # if we are not also doing a function for CMD values, then
903 # just return, otherwise fall through to the append blow.
907 methods
.append( (retType
, name
, number
, param1
, param2
, tuple(docs
), is_const
) )
910 #----------------------------------------------------------------------------
914 # TODO: parse command line args to replace default input/output files???
916 if not os
.path
.exists(IFACE
):
917 print 'Please run this script from src/stc subdirectory.'
921 processIface(IFACE
, H_TEMPLATE
, CPP_TEMPLATE
, H_DEST
, CPP_DEST
, DOCSTR_DEST
)
925 if __name__
== '__main__':
928 #----------------------------------------------------------------------------