~ubuntu-branches/ubuntu/utopic/lasso/utopic-proposed

« back to all changes in this revision

Viewing changes to bindings/utils.py

  • Committer: Package Import Robot
  • Author(s): Frederic Peters
  • Date: 2014-01-07 13:22:21 UTC
  • mfrom: (1.1.11) (7.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20140107132221-htp0go0s9z5lqvj8
Tags: 2.4.0-1
* New upstream version.
* debian/control, debian/rules: use autoreconf
* debian/source/version: switch to 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# GNU General Public License for more details.
17
17
#
18
18
# You should have received a copy of the GNU General Public License
19
 
# along with this program; if not, write to the Free Software
20
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
# along with this program; if not, see <http://www.gnu.org/licenses/>.
21
20
 
22
21
import re
23
22
import string
30
29
    return _mapping_convert_type_from_gobject_annotation.get(type, type)
31
30
 
32
31
def clean_type(type):
 
32
    '''Convert struct references to their typedef counterpart'''
33
33
    if not type:
34
34
        return type
35
35
    type = type.strip()
36
36
    type = re.sub('\s+', ' ', type)
 
37
    m = re.match('\s*struct\s+_(\w+)\s*\*', type)
 
38
    if m:
 
39
        type = '%s*' % m.group(1)
37
40
    return re.sub('\s*\*\s*', '*', type)
38
41
 
39
42
 
254
257
def is_time_t_pointer(arg):
255
258
    return re.match(r'\btime_t\*', unconstify(arg_type(arg)))
256
259
 
257
 
def is_transfer_full(arg):
 
260
def is_transfer_full(arg, default=False):
258
261
    if not isinstance(arg, tuple):
259
 
        return False
 
262
        return default
260
263
    transfer = arg[2].get('transfer')
261
264
    if transfer:
262
265
        return transfer == 'full'
263
 
    else:
264
 
        return is_out(arg) or is_object(arg)
 
266
    if is_cstring(arg) and is_const(arg):
 
267
        return False
 
268
    return default or is_out(arg) or is_object(arg)
265
269
 
266
270
_not_objects = ( 'GHashTable', 'GList', 'GType' )
267
271
 
268
272
def is_object(arg):
269
 
    t = unconstify(arg_type(arg))
 
273
    t = clean_type(unconstify(arg_type(arg)))
270
274
    return t and t[0] in string.uppercase and not [ x for x in _not_objects if x in t ]
271
275
 
272
276
if __name__ == '__main__':