]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/gen_iface.py
revert part of r54233 that was included by accident
[wxWidgets.git] / src / stc / gen_iface.py
index dfbb28600e7e34b9f023c98122976ec930685f9e..b4cccc4d3a096ba00e1b9ceef473553f05c32247 100755 (executable)
@@ -144,9 +144,9 @@ methodOverrideMap = {
 
     'PositionFromPoint' :
     (0,
-     'int %s(wxPoint pt);',
+     'int %s(wxPoint pt) const;',
 
-     '''int %s(wxPoint pt) {
+     '''int %s(wxPoint pt) const {
         return SendMsg(%s, pt.x, pt.y);''',
      0),
 
@@ -234,7 +234,7 @@ methodOverrideMap = {
     'SetSelFore' : ('SetSelForeground', 0, 0, 0),
     'SetSelBack' : ('SetSelBackground', 0, 0, 0),
     'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
-    'StyleGetFont' : 
+    'StyleGetFont' :
     ('StyleGetFaceName',
      'wxString %s(int style);',
       '''wxString %s(int style) {
@@ -249,7 +249,7 @@ methodOverrideMap = {
          ('Get the font facename of a style',)),
     'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
     'StyleSetCharacterSet' : (None, 0, 0, 0),
-    
+
     'AssignCmdKey' :
     ('CmdKeyAssign',
      'void %s(int key, int modifiers, int cmd);',
@@ -285,7 +285,7 @@ methodOverrideMap = {
     '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),
 
@@ -317,7 +317,7 @@ methodOverrideMap = {
     'AutoCSetMaxHeight'     : ('AutoCompSetMaxHeight', 0, 0, 0),
     'AutoCGetMaxHeight'     : ('AutoCompGetMaxHeight', 0, 0, 0),
     'AutoCGetMaxHeight'     : ('AutoCompGetMaxHeight', 0, 0, 0),
-    
+
     'RegisterImage' :
     (0,
      '''void %s(int type, const wxBitmap& bmp);''',
@@ -374,14 +374,14 @@ methodOverrideMap = {
                int    startPos,
                int    endPos,
                wxDC*  draw,
-               wxDC*  target, 
+               wxDC*  target,
                wxRect renderRect,
                wxRect pageRect);''',
      ''' int %s(bool   doDraw,
                 int    startPos,
                 int    endPos,
                 wxDC*  draw,
-                wxDC*  target, 
+                wxDC*  target,
                 wxRect renderRect,
                 wxRect pageRect) {
              RangeToFormat fr;
@@ -410,9 +410,9 @@ methodOverrideMap = {
 
     'GetLine' :
     (0,
-     'wxString %s(int line);',
+     'wxString %s(int line) const;',
 
-     '''wxString %s(int line) {
+     '''wxString %s(int line) const {
          int len = LineLength(line);
          if (!len) return wxEmptyString;
 
@@ -483,9 +483,9 @@ methodOverrideMap = {
 
     'GetText' :
     (0,
-     'wxString %s();',
+     'wxString %s() const;',
 
-     '''wxString %s() {
+     '''wxString %s() const {
          int len  = GetTextLength();
          wxMemoryBuffer mbuf(len+1);   // leave room for the null...
          char* buf = (char*)mbuf.GetWriteBuf(len+1);
@@ -509,7 +509,7 @@ methodOverrideMap = {
     '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),
 
@@ -655,6 +655,18 @@ methodOverrideMap = {
 
     }
 
+# 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):
@@ -898,13 +910,14 @@ 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)
-            
+
             # 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), is_const) )
+
+    methods.append( (retType, name, number, param1, param2, tuple(docs),
+                     is_const or name in constNonGetterMethods) )
 
 
 #----------------------------------------------------------------------------
@@ -913,6 +926,10 @@ def parseFun(line, methods, docs, values, is_const):
 def main(args):
     # TODO: parse command line args to replace default input/output files???
 
+    if not os.path.exists(IFACE):
+        print 'Please run this script from src/stc subdirectory.'
+        sys.exit(1)
+
     # Now just do it
     processIface(IFACE, H_TEMPLATE, CPP_TEMPLATE, H_DEST, CPP_DEST, DOCSTR_DEST)