Menu

#297 Terminal Plugin architecture

open
nobody
None
2
2009-06-01
2006-10-05
No

This is a page created to host the successive patches I
will write to provide a plugin architecture for gnuplot.

The goal is to loosen the link dependencies on the core
executable, while adding a little flexibility for
packagers.

There will be several incremental steps, I will post
patches along with comments.

The idea is first to separate clearly the core and the
terminals since some functions have spread across the
two, mainly the hooks for 'raise' and 'lower'. Then I
will provide some code to look for valid plugins at
run-time, and to add their functions table to the
terminal table which is currently created at compile-time.

Discussion

  • Timothée Lecomte

    Logged In: YES
    user_id=1333817

    Here is a first patch that modifies the "termentry"
    structure so that functions for interactive operations are
    in a sub-structure. It is then easier to add functions to
    this structure without having to go through the main one for
    all terminals.

    A function called 'raise_termwindow' is introduced in this
    structure, in addition to 'waitforinput', 'put_tmptext',
    'set_ruler', 'set_cursor', and 'set_clipboard'. It is
    supposed to replace the direct calls in command.c
    (raise_lower_command). The implementation is not yet
    provided, so the 'raise' and 'lower' commands do not work
    yet anymore. It will come a little bit later !

    On a side note, I have already got the plugin system working
    quite nicely with a couple of lines of code for the
    wxWidgets terminal. The terminal architecture of gnuplot is
    already nicely adapted to be used with external libraries.
    I'm using GLib for its dynamically-loaded-module functions.
    I will cleanup the code and provide patches in the next days
    hopefully.

     
  • Timothée Lecomte

    • priority: 5 --> 3
     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817

    Here is the second patch that implements the new
    'raise_termwindow' entry in the terminal table for pm, win,
    wxt, and x11. It is to be applied on top of the previous
    patch. 'raise' and 'lower' are functional. I have tested it
    both x11 and wxt. I will test win as soon as I reboot to
    Windows. I would be glad to see Petr or Bastian test pm.

    If you think they are ok, these two patches can go in cvs head.

    Now that there is a clear boarder between the core and the
    terminal, I will later send patches to make wxt (and maybe
    gd if I have time) a dynamically-loadable plugin.

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817

    Here is a third patch for a missing part of the entanglement
    between the core and the wxWidgets terminal. There has been
    a special call in plot.c when gnuplot is exiting, but just
    before the terminal is reset, to give it a chance to handle
    the "persist" settings.
    I am really not much inspired by the "persist" stuff. Here I
    chose to replace the hardcoded call to a dynamic list of
    functions to call at exit (but before the terminal is reset
    - I remember trying a simple atexit(...) call and it didn't
    work). The wxWidgets terminal registers its own function
    there when it is initialized. The machinery is in two new
    small files: termexit.{c|h}

    There's one more entanglement between the core and the
    wxWidgets terminal: this one is specific to Windows, where
    the terminal events are handled in the Windows main loop. I
    don't know yet how to handle this one... One more dynamic
    list of hooks like for termexit ? GUI events are handled so
    differently in gnuplot for Windows and on Unix...

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817

    Upload new plugin1.diff and plugin2.diff to fix typos and
    missed lines in Windows code.

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817

    Fixing the last entanglement specific to Windows was
    actually quite easy and straightforward. I am more than
    happy of the result, that I should have written that way
    since the beginning. The corresponding plugin4.diff is attached.

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817

    The last two patches have been committed to CVS since they
    allowed me to fix the "persist" behaviour once and for all.
    (The last patch has been committed as-is, the third one
    modified to be simpler, using atexit()).

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817
    Originator: YES

    I've attached plugin5.diff (to be applied after plugin1.diff and plugin2.diff). It implements a module framework in modules.c/modules.h for the core gnuplot to load dynamically the modules. The core looks in $(pkglibdir)/$(VERSION_MAJOR)/modules, in the path pointed out by $GNUPLOT_MODULE_DIR, and in $HOME/.gnuplot/modules, and tries to load the files that have the right extension. It then looks for the two symbols it needs: the terminal table, and a number corresponding to the API version, so that we can forbid loading modules that were compiled for an old version of gnuplot.
    Then the core fills the list of terminals with those compiled statically and those found at run-time. It checks for duplicates, and issue a warning when it finds one.

    This patch also moved the wxt terminal to a module, using the above framework.

    The module loader is implemented using GModule (probided by GLib), so it is expected to be cross-platform (not tested outside from linux right now). Thus the core executable is linked against GLib, while libwxt.so (the wxt module) is linked against all the other libraries it needs (wxWidgets, cairo, pango).

    That way, the core executable goes from 1.27 kB to 1.10 kB (debugging symbols stripped), and libwxt.so is 0.23 kB (stripped too).

    It's working quite nicely but has a certain number of caveats right now (I may be missing some):
    * the docs are not modular !
    In the current state, this means that the terminal has to be compiled at the same time as the docs, so that gnuplot.gih contains the help from wxt.
    We would need some modularization work in the help system to make terminals completely modular.

    * term.c:init_terminal() lists the first terminal to be loaded when gnuplot starts, so it has to have "wxt" in that list.
    In other words, if I remove the line 'term_name = "wxt";' in term.c:init_terminal(), the wxt won't be the active terminal when gnuplot starts, even if it's available.
    We need to find another mechanism to choose which terminal is to be set in order to make screen terminals completely modular.

    * As said above, I've added a symbol supposed to track the terminal/module API version, so that we don't load module that were built for an older version.
    The problem is that there isn't only the terminal/module API which is at stake, but all of gnuplot features exposed in its headers ! (For example, all the definitions in mouse.h should not change.) I don't really know how to handle that one. How could we thouroughly check that the module has been compiled against the running core ?
    File Added: plugin5.diff

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817
    Originator: YES

    File Added: plugin1.diff

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817
    Originator: YES

    File Added: plugin2.diff

     
  • Timothée Lecomte

    Modularisation framework, wxt is built as a module

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817
    Originator: YES

    File Added: plugin5.diff

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817
    Originator: YES

    Patches updated for current CVS HEAD.

    I would really appreciate some review/comments for plugin1.diff and plugin2.diff which are reworks of the interactive hooks in the terminal structure and in particular to move the 'raise' and 'lower' ugly terminal-specific codes from command.c to where they belong.

     
  • Timothée Lecomte

    Logged In: YES
    user_id=1333817
    Originator: YES

    plugin1.diff and plugin2.diff are now superseded by the two patches in #1677582

     
  • Ethan Merritt

    Ethan Merritt - 2009-06-01
    • priority: 3 --> 2
     
  • Ethan Merritt

    Ethan Merritt - 2009-06-01

    In preparation for eventual release of gnuplot version 4.4, existing bugs and patchsets are being re-prioritized.

    I have chosen to use the following categories

    9 - should be included in 4.4.rc1 if possible
    7 - looks reasonable to me, but not high priority for 4.4.rc1
    5 - default priority for newly submitted patches
    2 - not under active consideration

    These are my personal ratings. If you want to argue for a different priority on one or more patches - go right ahead.

    Ethan Merritt (sfeam)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.