#----------------------------------------------------------------------------
# Name: gen_iface.py
# Purpose: Generate stc.h and stc.cpp from the info in Scintilla.iface
#----------------------------------------------------------------------------
# Name: gen_iface.py
# Purpose: Generate stc.h and stc.cpp from the info in Scintilla.iface
CPP_TEMPLATE = os.path.abspath('./stc.cpp.in')
H_DEST = os.path.abspath('../../include/wx/stc/stc.h')
CPP_DEST = os.path.abspath('./stc.cpp')
CPP_TEMPLATE = os.path.abspath('./stc.cpp.in')
H_DEST = os.path.abspath('../../include/wx/stc/stc.h')
CPP_DEST = os.path.abspath('./stc.cpp')
- SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
+ SendMsg(%s, strlen(buf), (sptr_t)(const char*)buf);''',
0),
'AddStyledText' : (0,
'void %s(const wxMemoryBuffer& data);',
'''void %s(const wxMemoryBuffer& data) {
0),
'AddStyledText' : (0,
'void %s(const wxMemoryBuffer& data);',
'''void %s(const wxMemoryBuffer& data) {
- SendMsg(%s, data.GetDataLen(), (long)data.GetData());''',
+ SendMsg(%s, data.GetDataLen(), (sptr_t)data.GetData());''',
- SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
+ SendMsg(%s, strlen(buf), (sptr_t)(const char*)buf);''',
0),
'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
0),
'GetViewWS' : ( 'GetViewWhiteSpace', 0, 0, 0),
return (unsigned char)SendMsg(%s, pos, 0);''',
0),
'GetStyleAt' :
( 0, 0,
return (unsigned char)SendMsg(%s, pos, 0);''',
0),
'GetStyleAt' :
( 0, 0,
return (unsigned char)SendMsg(%s, pos, 0);''',
0),
return (unsigned char)SendMsg(%s, pos, 0);''',
0),
return SendMsg(%s, pt.x, pt.y);''',
0),
return SendMsg(%s, pt.x, pt.y);''',
0),
'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
+
+ 'StyleGetFore' : ('StyleGetForeground', 0, 0, 0),
+ 'StyleGetBack' : ('StyleGetBackground', 0, 0, 0),
'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
'SetSelFore' : ('SetSelForeground', 0, 0, 0),
'SetSelBack' : ('SetSelBackground', 0, 0, 0),
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
'SetSelFore' : ('SetSelForeground', 0, 0, 0),
'SetSelBack' : ('SetSelBackground', 0, 0, 0),
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
+ 'StyleGetFont' :
+ ('StyleGetFaceName',
+ 'wxString %s(int style);',
+ '''wxString %s(int style) {
+ long msg = %s;
+ long len = SendMsg(msg, style, 0);
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, style, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);''',
+ ('Get the font facename of a style',)),
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
'StyleSetCharacterSet' : (None, 0, 0, 0),
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
'StyleSetCharacterSet' : (None, 0, 0, 0),
'AssignCmdKey' :
('CmdKeyAssign',
'void %s(int key, int modifiers, int cmd);',
'AssignCmdKey' :
('CmdKeyAssign',
'void %s(int key, int modifiers, int cmd);',
'void %s(int length, char* styleBytes);',
'''void %s(int length, char* styleBytes) {
'void %s(int length, char* styleBytes);',
'''void %s(int length, char* styleBytes) {
- SendMsg(%s, length, (long)styleBytes);''',
+ SendMsg(%s, length, (sptr_t)styleBytes);''',
'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
+ 'IndicSetUnder': ('IndicatorSetUnder', 0, 0, 0),
+ 'IndicGetUnder': ('IndicatorGetUnder', 0, 0, 0),
'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0, 0),
'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0, 0),
'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
'AutoCGetMaxHeight' : ('AutoCompGetMaxHeight', 0, 0, 0),
- return SendMsg(%s, flags, (long)&ft);''',
+ return SendMsg(%s, flags, (sptr_t)&ft);''',
- return SendMsg(%s, doDraw, (long)&fr);''',
+ return SendMsg(%s, doDraw, (sptr_t)&fr);''',
int len = LineLength(line);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int len = LineLength(line);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
- 'SetSel' : ('SetSelection', 0, 0, 0),
+ 'SetSel' : (None, 0,0,0), #'SetSelection', 0, 0, 0),
int len = GetTextLength();
wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buf = (char*)mbuf.GetWriteBuf(len+1);
int len = GetTextLength();
wxMemoryBuffer mbuf(len+1); // leave room for the null...
char* buf = (char*)mbuf.GetWriteBuf(len+1);
'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
+ 'GetHotspotActiveFore' : ('GetHotspotActiveForeground', 0, 0, 0),
+ 'GetHotspotActiveBack' : ('GetHotspotActiveBackground', 0, 0, 0),
+
'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0),
'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0),
'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0),
'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0),
- return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
+ return SendMsg(%s, strlen(buf), (sptr_t)(const char*)buf);''',
- return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
+ return SendMsg(%s, strlen(buf), (sptr_t)(const char*)buf);''',
- return SendMsg(%s, strlen(buf), (long)(const char*)buf);''',
+ return SendMsg(%s, strlen(buf), (sptr_t)(const char*)buf);''',
'wxString %s(const wxString& key);',
'''wxString %s(const wxString& key) {
'wxString %s(const wxString& key);',
'''wxString %s(const wxString& key) {
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
'wxString %s(const wxString& key);',
'''wxString %s(const wxString& key) {
'wxString %s(const wxString& key);',
'''wxString %s(const wxString& key) {
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
(0,
'void %s(void* docPointer);',
'''void %s(void* docPointer) {
(0,
'void %s(void* docPointer);',
'''void %s(void* docPointer) {
- SendMsg(%s, 0, (long)docPointer);''',
+ SendMsg(%s, 0, (sptr_t)docPointer);''',
(0,
'void %s(void* docPointer);',
'''void %s(void* docPointer) {
(0,
'void %s(void* docPointer);',
'''void %s(void* docPointer) {
- SendMsg(%s, 0, (long)docPointer);''',
+ SendMsg(%s, 0, (sptr_t)docPointer);''',
0),
'ReleaseDocument' :
(0,
'void %s(void* docPointer);',
'''void %s(void* docPointer) {
0),
'ReleaseDocument' :
(0,
'void %s(void* docPointer);',
'''void %s(void* docPointer) {
- SendMsg(%s, 0, (long)docPointer);''',
+ SendMsg(%s, 0, (sptr_t)docPointer);''',
'LoadLexerLibrary' : (None, 0,0,0),
'LoadLexerLibrary' : (None, 0,0,0),
+ 'SetPositionCache' : ('SetPositionCacheSize', 0, 0, 0),
+ 'GetPositionCache' : ('GetPositionCacheSize', 0, 0, 0),
+
+# all Scintilla getters are transformed into const member of wxSTC class but
+# some non-getter methods are also logically const and this set contains their
+# names (notice that it's useless to include here methods manually overridden
+# above)
+constNonGetterMethods = set((
+ 'LineFromPosition',
+ 'PositionFromLine',
+ 'LineLength',
+ 'CanRedo',
+ 'CanUndo',
+))
+
#----------------------------------------------------------------------------
def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest, docstr_dest):
#----------------------------------------------------------------------------
def processIface(iface, h_tmplt, cpp_tmplt, h_dest, cpp_dest, docstr_dest):
- parseFun(line[4:], methods, curDocStrings, cmds)
+ parseFun(line[4:], methods, curDocStrings, cmds, op == 'get ')
- for retType, name, number, param1, param2, docs in methods:
+ for retType, name, number, param1, param2, docs, is_const in methods:
retType = retTypeMap.get(retType, retType)
params = makeParamString(param1, param2)
retType = retTypeMap.get(retType, retType)
params = makeParamString(param1, param2)
st = 'DocStr(wxStyledTextCtrl::%s,\n' \
'"%s", "");\n' % (name, '\n'.join(docs))
dstr.append(st)
st = 'DocStr(wxStyledTextCtrl::%s,\n' \
'"%s", "");\n' % (name, '\n'.join(docs))
dstr.append(st)
- theDef = ' %s %s(%s);' % (retType, name, params)
+ theDef = ' %s %s(%s)' % (retType, name, params)
+ if is_const:
+ theDef = theDef + ' const'
+ theDef = theDef + ';'
- theImp = '%s wxStyledTextCtrl::%s(%s) {\n ' % (retType, name, params)
-
+ theImp = '%s wxStyledTextCtrl::%s(%s)' % (retType, name, params)
+ if is_const:
+ theImp = theImp + ' const'
+ theImp = theImp + '\n{\n '
'\(([ a-zA-Z0-9_]*),' # (param,
'([ a-zA-Z0-9_]*)\)') # param)
'\(([ a-zA-Z0-9_]*),' # (param,
'([ a-zA-Z0-9_]*)\)') # param)
-def parseFun(line, methods, docs, values):
+def parseFun(line, methods, docs, values, is_const):
for v in cmdValues:
if (type(v) == type(()) and v[0] <= num <= v[1]) or v == num:
parseVal('CMD_%s=%s' % (string.upper(name), number), values, docs)
for v in cmdValues:
if (type(v) == type(()) and v[0] <= num <= v[1]) or v == num:
parseVal('CMD_%s=%s' % (string.upper(name), number), values, docs)
# if we are not also doing a function for CMD values, then
# just return, otherwise fall through to the append blow.
if not FUNC_FOR_CMD:
return
# if we are not also doing a function for CMD values, then
# just return, otherwise fall through to the append blow.
if not FUNC_FOR_CMD:
return
-
- methods.append( (retType, name, number, param1, param2, tuple(docs)) )
+
+ methods.append( (retType, name, number, param1, param2, tuple(docs),
+ is_const or name in constNonGetterMethods) )
# Now just do it
processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST, DOCSTR_DEST)
# Now just do it
processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST, DOCSTR_DEST)