~ubuntu-branches/ubuntu/trusty/enigmail/trusty-updates

« back to all changes in this revision

Viewing changes to util/xpidl.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2015-08-26 20:07:19 UTC
  • mfrom: (0.12.19)
  • Revision ID: package-import@ubuntu.com-20150826200719-t3qktwtjhs7qzjq1
Tags: 2:1.8.2-0ubuntu0.14.04.1
* New upstream release v1.8.2 to support Thunderbird 38
  - Fixes LP: #1489103 - Per-account settings missing after Thunderbird
    update

* Depend on gnupg2 instead of gnupg. Whilst this enigmail version still
  works with gnupg 1.4.*, it pops up an alert warning that it will be the
  last version to do so
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
    Builtin('double', 'double', True, False),
132
132
    Builtin('char', 'char', True, False),
133
133
    Builtin('string', 'char *', False, False),
134
 
    Builtin('wchar', 'PRUnichar', False, False),
135
 
    Builtin('wstring', 'PRUnichar *', False, False),
 
134
    Builtin('wchar', 'char16_t', False, False),
 
135
    Builtin('wstring', 'char16_t *', False, False),
136
136
]
137
137
 
138
138
builtinMap = {}
429
429
        return self.modifier == 'ref'
430
430
 
431
431
    def isPtr(self, calltype):
432
 
        return self.modifier == 'ptr' or (self.modifier == 'ref' and self.specialtype == 'jsval' and calltype == 'out')
 
432
        return self.modifier == 'ptr'
433
433
 
434
434
    def isRef(self, calltype):
435
 
        return self.modifier == 'ref' and not (self.specialtype == 'jsval' and calltype == 'out')
 
435
        return self.modifier == 'ref'
436
436
 
437
437
    def nativeType(self, calltype, const=False, shared=False):
438
438
        if shared:
443
443
        if self.specialtype is not None and calltype == 'in':
444
444
            const = True
445
445
 
 
446
        if self.specialtype == 'jsval':
 
447
            if calltype == 'out' or calltype == 'inout':
 
448
                return "JS::MutableHandleValue "
 
449
            return "JS::HandleValue "
 
450
 
446
451
        if self.isRef(calltype):
447
452
            m = '& '
448
453
        elif self.isPtr(calltype):
454
459
    def __str__(self):
455
460
        return "native %s(%s)\n" % (self.name, self.nativename)
456
461
 
457
 
class BaseInterface(object):
 
462
class Interface(object):
 
463
    kind = 'interface'
 
464
 
458
465
    def __init__(self, name, attlist, base, members, location, doccomments):
459
466
        self.name = name
460
467
        self.attributes = InterfaceAttributes(attlist, location)
461
468
        self.base = base
462
 
        if self.kind == 'dictionary':
463
 
            members.sort(key=lambda x:x.name)
464
469
        self.members = members
465
470
        self.location = location
466
471
        self.namemap = NameMap()
498
503
        parent.setName(self)
499
504
        if self.base is not None:
500
505
            realbase = parent.getName(self.base, self.location)
501
 
            if realbase.kind != self.kind:
502
 
                raise IDLError("%s '%s' inherits from non-%s type '%s'" % (self.kind, self.name, self.kind, self.base), self.location)
 
506
            if realbase.kind != 'interface':
 
507
                raise IDLError("interface '%s' inherits from non-interface type '%s'" % (self.name, self.base), self.location)
503
508
 
504
509
            if self.attributes.scriptable and not realbase.attributes.scriptable:
505
510
                print >>sys.stderr, IDLError("interface '%s' is scriptable but derives from non-scriptable '%s'" % (self.name, self.base), self.location, warning=True)
570
575
            total += realbase.countEntries()
571
576
        return total
572
577
 
573
 
class Interface(BaseInterface):
574
 
    kind = 'interface'
575
 
 
576
 
    def __init__(self, name, attlist, base, members, location, doccomments):
577
 
        BaseInterface.__init__(self, name, attlist, base, members, location, doccomments)
578
 
 
579
 
        if self.attributes.uuid is None:
580
 
            raise IDLError("interface has no uuid", location)
581
 
 
582
 
class Dictionary(BaseInterface):
583
 
    kind = 'dictionary'
584
 
 
585
 
    def __init__(self, name, attlist, base, members, location, doccomments):
586
 
        BaseInterface.__init__(self, name, attlist, base, members, location, doccomments)
587
 
 
588
578
class InterfaceAttributes(object):
589
579
    uuid = None
590
580
    scriptable = False
640
630
 
641
631
                action(self)
642
632
 
 
633
        if self.uuid is None:
 
634
            raise IDLError("interface has no uuid", location)
 
635
 
643
636
    def __str__(self):
644
637
        l = []
645
638
        if self.uuid:
691
684
    null = None
692
685
    undefined = None
693
686
    deprecated = False
694
 
    nullable = False
695
687
    infallible = False
696
 
    defvalue = None
697
688
 
698
 
    def __init__(self, type, name, attlist, readonly, nullable, defvalue, location, doccomments):
 
689
    def __init__(self, type, name, attlist, readonly, location, doccomments):
699
690
        self.type = type
700
691
        self.name = name
701
692
        self.attlist = attlist
702
693
        self.readonly = readonly
703
 
        self.nullable = nullable
704
 
        self.defvalue = defvalue
705
694
        self.location = location
706
695
        self.doccomments = doccomments
707
696
 
762
751
            getBuiltinOrNativeTypeName(self.realtype) != '[domstring]'):
763
752
            raise IDLError("'Undefined' attribute can only be used on DOMString",
764
753
                           self.location)
765
 
        if (self.nullable and
766
 
            getBuiltinOrNativeTypeName(self.realtype) != '[domstring]'):
767
 
            raise IDLError("Nullable types (T?) is supported only for DOMString",
768
 
                           self.location)
769
754
        if self.infallible and not self.realtype.kind == 'builtin':
770
755
            raise IDLError('[infallible] only works on builtin types '
771
756
                           '(numbers, booleans, and raw char types)',
1001
986
    keywords = {
1002
987
        'const': 'CONST',
1003
988
        'interface': 'INTERFACE',
1004
 
        'dictionary': 'DICTIONARY',
1005
989
        'in': 'IN',
1006
990
        'inout': 'INOUT',
1007
991
        'out': 'OUT',
1023
1007
        'LSHIFT',
1024
1008
        'RSHIFT',
1025
1009
        'NATIVEID',
1026
 
        'STRING',
1027
1010
        ]
1028
1011
 
1029
1012
    tokens.extend(keywords.values())
1039
1022
    t_LSHIFT = r'<<'
1040
1023
    t_RSHIFT=  r'>>'
1041
1024
 
1042
 
    literals = '"(){}[],;:=|+-*?'
 
1025
    literals = '"(){}[],;:=|+-*'
1043
1026
 
1044
1027
    t_ignore = ' \t'
1045
1028
 
1074
1057
        t.value = value
1075
1058
        return t
1076
1059
 
1077
 
    def t_STRING(self, t):
1078
 
        r'"[^"\n]+"'
1079
 
        begin, value, end = t.value.split('"')
1080
 
        t.value = value
1081
 
        return t
1082
 
 
1083
1060
    def t_directive(self, t):
1084
1061
        r'\#(?P<directive>[a-zA-Z]+)[^\n]+'
1085
1062
        raise IDLError("Unrecognized directive %s" % t.lexer.lexmatch.group('directive'),
1131
1108
 
1132
1109
    def p_productions_interface(self, p):
1133
1110
        """productions : interface productions
1134
 
                       | dictionary productions
1135
1111
                       | typedef productions
1136
1112
                       | native productions"""
1137
1113
        p[0] = list(p[2])
1309
1285
        p[0] = lambda i: n1(i) | n2(i)
1310
1286
 
1311
1287
    def p_member_att(self, p):
1312
 
        """member : attributes optreadonly ATTRIBUTE IDENTIFIER identifier ';'"""
 
1288
        """member : attributes optreadonly ATTRIBUTE IDENTIFIER IDENTIFIER ';'"""
1313
1289
        if 'doccomments' in p[1]:
1314
1290
            doccomments = p[1]['doccomments']
1315
1291
        elif p[2] is not None:
1321
1297
                         name=p[5],
1322
1298
                         attlist=p[1]['attlist'],
1323
1299
                         readonly=p[2] is not None,
1324
 
                         nullable=False,
1325
 
                         defvalue=None,
1326
1300
                         location=self.getLocation(p, 3),
1327
1301
                         doccomments=doccomments)
1328
1302
 
1360
1334
        p[0].insert(0, p[2])
1361
1335
 
1362
1336
    def p_param(self, p):
1363
 
        """param : attributes paramtype IDENTIFIER identifier"""
 
1337
        """param : attributes paramtype IDENTIFIER IDENTIFIER"""
1364
1338
        p[0] = Param(paramtype=p[2],
1365
1339
                     type=p[3],
1366
1340
                     name=p[4],
1381
1355
        else:
1382
1356
            p[0] = None
1383
1357
 
1384
 
    def p_dictionary(self, p):
1385
 
        """dictionary : attributes DICTIONARY IDENTIFIER ifacebase dictbody ';'"""
1386
 
        atts, DICTIONARY, name, base, body, SEMI = p[1:]
1387
 
        attlist = atts['attlist']
1388
 
        doccomments = []
1389
 
        if 'doccomments' in atts:
1390
 
            doccomments.extend(atts['doccomments'])
1391
 
        doccomments.extend(p.slice[2].doccomments)
1392
 
 
1393
 
        l = lambda: self.getLocation(p, 2)
1394
 
 
1395
 
        p[0] = Dictionary(name=name,
1396
 
                          attlist=attlist,
1397
 
                          base=base,
1398
 
                          members=body,
1399
 
                          location=l(),
1400
 
                          doccomments=doccomments)
1401
 
 
1402
 
    def p_dictbody(self, p):
1403
 
        """dictbody : '{' dictmembers '}'
1404
 
                     | """
1405
 
        if len(p) > 1:
1406
 
            p[0] = p[2]
1407
 
 
1408
 
    def p_dictmembers_start(self, p):
1409
 
        """dictmembers : """
1410
 
        p[0] = []
1411
 
 
1412
 
    def p_dictmembers_continue(self, p):
1413
 
        """dictmembers : dictmember dictmembers"""
1414
 
        p[0] = list(p[2])
1415
 
        p[0].insert(0, p[1])
1416
 
 
1417
 
    def p_dictmember(self, p):
1418
 
        """dictmember : attributes IDENTIFIER optnullable IDENTIFIER optdefvalue ';'"""
1419
 
        if 'doccomments' in p[1]:
1420
 
            doccomments = p[1]['doccomments']
1421
 
        else:
1422
 
            doccomments = p.slice[2].doccomments
1423
 
 
1424
 
        p[0] = Attribute(type=p[2],
1425
 
                         name=p[4],
1426
 
                         attlist=p[1]['attlist'],
1427
 
                         readonly=False,
1428
 
                         nullable=p[3] is not None,
1429
 
                         defvalue=p[5],
1430
 
                         location=self.getLocation(p, 1),
1431
 
                         doccomments=doccomments)
1432
 
 
1433
 
    def p_optnullable(self, p):
1434
 
        """optnullable : '?'
1435
 
                       | """
1436
 
        if len(p) > 1:
1437
 
            p[0] = p[1]
1438
 
        else:
1439
 
            p[0] = None
1440
 
 
1441
 
    def p_optdefvalue(self, p):
1442
 
        """optdefvalue : '=' STRING
1443
 
                       | '=' INFINITY
1444
 
                       | '=' '-' INFINITY
1445
 
                       | """
1446
 
        if len(p) > 1:
1447
 
            p[0] = "".join(p[2:])
1448
 
        else:
1449
 
            p[0] = None
1450
 
 
1451
 
    def p_identifier(self, p):
1452
 
        """identifier : DICTIONARY
1453
 
                      | IDENTIFIER"""
1454
 
        p[0] = p[1]
1455
 
 
1456
1358
    def p_raises(self, p):
1457
1359
        """raises : RAISES '(' idlist ')'
1458
1360
                  | """