[Qt-creator] Scripting plugin

Campbell Barton ideasman42 at gmail.com
Thu Mar 1 08:06:15 CET 2012


Hi there (late reply), this is really interesting and something I've
wanted for quite a while.

I even considered writing a scripting interface myself since I already
maintain some C/C++/CPython api code ) but when found that javascript
was the language of choice. I gave up on the idea.


One thing that Im interested in is the possibility of using this for
refactoring large source code...

# psudo code (in python, sure js can do similar) - find unused defines.
^ import qtcreator
^ prj = qtcreator.projects.active
^ for file in prj.files:
^     if file.type in {'C', 'C++'}:
^         for dec in file.defines:
^             if not dec.id.startswith("_"):
^                 if len(dec.find_users()) == 0:
^                     print("%s: %s:%d - has no users" % (dec.id,
file.filepath, dec.lineno))

Other things that should be possible with a scripting API.

* find out if a function always takes the same constant value for an argument.
* find out if functions return values which are never used.
* check if there are functions that could be made static (defined but
not used in any other files).

Currently I wrote scripts in python to help keep code clean (millions
of lines codebase), but suffer from not having access to a real
parser.

Will this kind of thing be possible?

On Mon, Feb 6, 2012 at 5:18 AM, Nicolas Arnaud-Cormos
<nicolas.arnaud-cormos at kdab.com> wrote:
> Hi all,
>
> The Scripting plugin is also available in qt-project, and everybody is free to
> get, compile and contribute to it.
>
> You'll find all informations here:
> http://wiki.qt-project.org/Qt_Creator/Plugins/Scripting
>
> To answer some questions:
>
> What's the status
> * The scripting plugin is far from being done. You can barely do anything
> usefull right now, and the script API must be reviewed
>
> Why not integrate it in Qt Creator
> * Because it won't be ready for 2.5, and I want people to be able to test it.
> Also, I'm not sure that putting all and every plugins in Qt Creator master is
> a good thing, I think we should work on an easy 3rd party plugin installer
> inside Qt Creator.
>
> What's the long term plan
> * to rule the world...
> But except that, I want to be able to do anything boring and repetitive with
> scripts, and would like to replace the macros plugin with something generating
> scripts. Once I have achieved those 2 goals, I think I'll try to find new
> interesting things to do.
>
> Cheers,
> Nicolas
> --
> Nicolas Arnaud-Cormos | nicolas.arnaud-cormos at kdab.com | Senior Software
> Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
> KDAB - Qt Experts - Platform-independent software solutions
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator



-- 
- Campbell



More information about the Qt-creator mailing list