~ubuntu-branches/ubuntu/raring/geany/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/genapi.py

  • Committer: Bazaar Package Importer
  • Author(s): Damián Viano
  • Date: 2009-05-29 21:22:54 UTC
  • mfrom: (1.3.1 upstream) (3.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: james.westby@ubuntu.com-20090529212254-cx6t2a7itgii3p5f
Tags: 0.17-1
* New upstream release
* 20_add_debdiff_as_diff_type.dpatch renamed as
  20_add_debian_specific_filetypes.dpatch, 
  - add .dpatch as a diff filetype
  - add control as a conf filetype
* 20_change_gpl_location.dpatch freshen
* add 20_debian_control_tags.dpatch better handling of debian/control files.
  Thanks to Enrico Tröger. (Closes: #520776)
* debian/copyright Add Frank Lanitz, update years

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
#       genapi.py - this file is part of Geany, a fast and lightweight IDE
 
5
#
 
6
#       Copyright 2008-2009 Nick Treleaven <nick.treleaven<at>btinternet.com>
 
7
#       Copyright 2008-2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
 
8
#
 
9
#       This program is free software; you can redistribute it and/or modify
 
10
#       it under the terms of the GNU General Public License as published by
 
11
#       the Free Software Foundation; either version 2 of the License, or
 
12
#       (at your option) any later version.
 
13
#
 
14
#       This program is distributed in the hope that it will be useful,
 
15
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
#       GNU General Public License for more details.
 
18
#
 
19
#       You should have received a copy of the GNU General Public License
 
20
#       along with this program; if not, write to the Free Software
 
21
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
22
#
 
23
# $(Id)
 
24
 
 
25
r"""
 
26
Creates macros for each plugin API function pointer, e.g.:
 
27
 
 
28
#define plugin_add_toolbar_item \
 
29
        p_plugin->add_toolbar_item
 
30
"""
 
31
 
 
32
 
 
33
import re, sys
 
34
 
 
35
def get_function_names():
 
36
        names = []
 
37
        try:
 
38
                f = open('../src/plugins.c')
 
39
                while 1:
 
40
                        l = f.readline()
 
41
                        if l == "":
 
42
                                break;
 
43
                        m = re.match("^\t&([a-z][a-z0-9_]+)", l)
 
44
                        if m:
 
45
                                s = m.group(1)
 
46
                                if not s.endswith('_funcs'):
 
47
                                        names.append(s)
 
48
                f.close
 
49
        except:
 
50
                pass
 
51
        return names
 
52
 
 
53
def get_api_tuple(str):
 
54
        m = re.match("^([a-z]+)_([a-z][a-z0-9_]+)$", str)
 
55
        return 'p_' + m.group(1), m.group(2)
 
56
 
 
57
 
 
58
if __name__ == "__main__":
 
59
        outfile = 'geanyfunctions.h'
 
60
 
 
61
        fnames = get_function_names()
 
62
        if not fnames:
 
63
                sys.exit("No function names read!")
 
64
 
 
65
        f = open(outfile, 'w')
 
66
        print >>f, '/* This file is generated automatically by genapi.py - do not edit.\n *\n' +\
 
67
                ' * @file %s @ref geany_functions wrappers.\n' % (outfile) +\
 
68
                ' * This allows the use of normal API function names in plugins.\n' +\
 
69
                ' * You need to declare the @ref geany_functions symbol yourself.\n */\n'
 
70
        print >>f, '#ifndef GEANY_FUNCTIONS_H'
 
71
        print >>f, '#define GEANY_FUNCTIONS_H\n'
 
72
        for fname in fnames:
 
73
                ptr, name = get_api_tuple(fname)
 
74
                print >>f, '#define %s \\\n\tgeany_functions->%s->%s' % (fname, ptr, name)
 
75
        print >>f, '\n#endif'
 
76
        f.close
 
77
 
 
78
        if not '-q' in sys.argv:
 
79
                print 'Generated ' + outfile