Menu

#1297 Extend Scintilla.iface with more type information

Committed
closed
scintilla (295)
5
2019-07-05
2019-06-18
No

More data could be provided by Scintilla.iface to allow downstream projects to produce more typesafe interfaces to Scintilla.

SciTE 4.1.6 wraps Scintilla in a better C++ interface that uses 'enum class' and separate types for 'position' and 'line' which helped ensure that positions and lines are handled consistently as 64-bit values on 64-bit builds and aren't truncated. SciTE augmented Scintilla.iface with extra type information in a script. This extra type information is now being moved into Scintilla so that it can be used more widely. At some point, after this has stabilised, it may be worthwhile including the typesafe wrapper with Scintilla.

The changes are:
1. Move CheckMentioned.py to Scintilla
2. Add line type to Scintilla.iface and position type more
3. Add pointer type to Scintilla.iface - equivalent to void*
4. Add some extra enumerations and _NONE (0) values where they help
5. Tidy up INDIC_ enumeration values which were not really all the same thing
6. Use enumerations as parameters and return values
7. Current enumeration value names do not separate words so add aliases to allow better CamelCase names in wrapper.

There are multiple places in Scintilla and SciTE that use Scintilla.iface and each may need to change. This list includes the relevant scripts along with the files they generate.

Scintilla
    scripts
        HFacer.py
            No impact
        LexGen.py
            No impact
        CheckMentioned.py
            scintilla/doc/ScintillaDoc.html
                -- Add position, line, and pointer types to documentation
    qt
        ScintillaEdit/WidgetGen.py
            ScintillaEdit.h
            ScintillaEdit.cpp
            ScintillaEditPy/ScintillaConstants.py
                No types
        ScintillaEditPy/sepbuild.py
    gtk
        No types
    test
        ScintillaCallable.py
SciTE
    commandsdoc.py
        CommandValues.html
    IFaceTableGen.py
        IFaceTable.cxx
        PaneAPI.html
    APIFacer.py
        ScintillaTypes.h
        ScintillaMessages.h
        ScintillaCall.h
        ScintillaCall.cxx

Initial sets of patches that perform these changes are attached.

2 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2019-06-19
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,13 +4,12 @@
    
     The changes are:
     1. Move CheckMentioned.py to Scintilla
    -2. Move CheckMentioned.py to Scintilla
    -3. Add line type to Scintilla.iface and position type more
    -4. Add pointer type to Scintilla.iface - equivalent to void\*
    -5. Add some extra enumerations and \_NONE (0) values where they help
    -6. Tidy up INDIC\_ enumeration values which were not really all the same thing
    -7. Use enumerations as parameters and return values
    -8. Current enumeration value names do not separate words so add aliases to allow better CamelCase names in wrapper.
    +2. Add line type to Scintilla.iface and position type more
    +3. Add pointer type to Scintilla.iface - equivalent to void\*
    +4. Add some extra enumerations and \_NONE (0) values where they help
    +5. Tidy up INDIC\_ enumeration values which were not really all the same thing
    +6. Use enumerations as parameters and return values
    +7. Current enumeration value names do not separate words so add aliases to allow better CamelCase names in wrapper.
    
     There are multiple places in Scintilla and SciTE that use Scintilla.iface and each may need to change. This list includes the relevant scripts along with the files they generate.
     ~~~
    
     
  • Zufu Liu

    Zufu Liu - 2019-06-19

    Some code need to handle this:

    +ali SC_CHARSET_8859_15=I_S_O_8859_15 # => ISO8859_15 not ISO885915
    
     
    • Neil Hodgson

      Neil Hodgson - 2019-06-20

      Here's an additional change to preserve '_' between digits.

       

      Last edit: Neil Hodgson 2019-06-20
  • Neil Hodgson

    Neil Hodgson - 2019-06-22

    Aliases tweaked so that acronyms longer than 2 characters are treated as words and are also good SNAKE_CASE. 'FindOption::POSIX’ changes to 'FindOption::Posix’. This is consistent with published style guides including those from Google and Microsoft.

    Change sets: [d96faf] and [5de213].

     

    Related

    Commit: [5de213]
    Commit: [d96faf]

  • Zufu Liu

    Zufu Liu - 2019-06-22

    Add changes to margin type.

    Some ideas:
    prototype for events not updated, they still use int (int position, int line, etc,).

    maybe need a type for API returns stringresult, as the return value is normally length of string or bytes.

     
    • Neil Hodgson

      Neil Hodgson - 2019-06-22

      Committed as [a5bcfd] with documentation update and [1b4e49] for SciTE.

      The temptation with stringresult is to return std::string but that may cause an allocation on each call and the client may want to reuse a buffer to be more efficient. For example, saving files in SciTE repeatedly calls TargetText with a single fixed size buffer.

      Something more could be done with events but currently no scripts interpret evt apart from generating an SCN_ identifier. Without any use of the better type information, its very likely that there will be mistakes.

      Each piece of SciTE's event handling code just looks into SCNotification which is a union of the fields. There is no 'event cracker' in SciTE that would be implemented from the added type information. Most of the events don't go through to Extension events (for Lua and others) and those that do have different signatures.

      The signals defined for the ScintillaEditBase class for the Qt platform are likely the most productive area to implement code generation for events. However, widening positions to intptr_t would cause currently written client code to fail to build so probably needs to be deferred to the next major version.

       

      Related

      Commit: [1b4e49]
      Commit: [a5bcfd]

  • Neil Hodgson

    Neil Hodgson - 2019-06-22

    Added changes for *_NONE and INDICATOR_* enumeration values.
    Moved old INDIC?_MASK to deprecated section.

    [5b7428]

    Update to use INDICATOR_ instead of INDIC_ as INDIC_ is also used for indicator styles.

    [190079]

     

    Related

    Commit: [190079]
    Commit: [5b7428]

  • Neil Hodgson

    Neil Hodgson - 2019-07-05
    • status: open --> closed
    • Group: Completed --> Committed
     

Log in to post a comment.