b=539748; [qsgen] handle .* and - better; r=jorendorff

This commit is contained in:
Vladimir Vukicevic 2010-01-22 13:26:25 -08:00
Родитель aa57e0c3fe
Коммит 8953411732
1 изменённых файлов: 42 добавлений и 29 удалений

Просмотреть файл

@ -199,33 +199,7 @@ def removeStubMember(memberId, member):
member.iface.stubMembers.remove(member)
def addStubMember(memberId, member, traceable):
# Check that the member is ok.
mayTrace = False
if member.kind not in ('method', 'attribute'):
raise UserError("Member %s is %r, not a method or attribute."
% (memberId, member.kind))
if member.noscript:
raise UserError("%s %s is noscript."
% (member.kind.capitalize(), memberId))
if member.notxpcom:
raise UserError(
"%s %s: notxpcom methods are not supported."
% (member.kind.capitalize(), memberId))
if (member.kind == 'attribute'
and not member.readonly
and isSpecificInterfaceType(member.realtype, 'nsIVariant')):
raise UserError(
"Attribute %s: Non-readonly attributes of type nsIVariant "
"are not supported."
% memberId)
# Check for unknown properties.
for attrname, value in vars(member).items():
if value is True and attrname not in ('readonly','optional_argc',):
raise UserError("%s %s: unrecognized property %r"
% (member.kind.capitalize(), memberId,
attrname))
if member.kind == 'method':
if len(member.params) <= 3:
mayTrace = True
@ -248,6 +222,34 @@ def addStubMember(memberId, member, traceable):
# Add this member to the list.
member.iface.stubMembers.append(member)
def checkStubMember(member):
memberId = member.iface.name + "." + member.name
if member.kind not in ('method', 'attribute'):
raise UserError("Member %s is %r, not a method or attribute."
% (memberId, member.kind))
if member.noscript:
raise UserError("%s %s is noscript."
% (member.kind.capitalize(), memberId))
if member.notxpcom:
raise UserError(
"%s %s: notxpcom methods are not supported."
% (member.kind.capitalize(), memberId))
if (member.kind == 'attribute'
and not member.readonly
and isSpecificInterfaceType(member.realtype, 'nsIVariant')):
raise UserError(
"Attribute %s: Non-readonly attributes of type nsIVariant "
"are not supported."
% memberId)
# Check for unknown properties.
for attrname, value in vars(member).items():
if value is True and attrname not in ('readonly','optional_argc','traceable'):
raise UserError("%s %s: unrecognized property %r"
% (member.kind.capitalize(), memberId,
attrname))
def parseMemberId(memberId):
""" Split the geven member id into its parts. """
pieces = memberId.split('.')
@ -300,6 +302,8 @@ def readConfigFile(filename, includePath, cachedir, traceable):
interfacesByName[interfaceName] = iface
return iface
stubbedInterfaces = []
for memberId in conf.members:
add = True
interfaceName, memberName = parseMemberId(memberId)
@ -324,6 +328,8 @@ def readConfigFile(filename, includePath, cachedir, traceable):
if member.kind in ('method', 'attribute') and not member.noscript:
addStubMember(iface.name + '.' + member.name, member,
traceable)
if member.iface not in stubbedInterfaces:
stubbedInterfaces.append(member.iface)
else:
# Look up a member by name.
if memberName not in iface.namemap:
@ -332,10 +338,10 @@ def readConfigFile(filename, includePath, cachedir, traceable):
"(See IDL file %r.)"
% (interfaceName, memberName, idlFile))
member = iface.namemap.get(memberName, None)
if member in iface.stubMembers:
raise UserError("Member %s is specified more than once."
% memberId)
if add:
if member in iface.stubMembers:
raise UserError("Member %s is specified more than once."
% memberId)
mayTrace = True
if member.noscript:
cmc = conf.customMethodCalls.get(interfaceName + "_" + header.methodNativeName(member), None)
@ -344,9 +350,16 @@ def readConfigFile(filename, includePath, cachedir, traceable):
member.noscript = False
mayTrace = False
addStubMember(memberId, member, traceable and mayTrace)
if member.iface not in stubbedInterfaces:
stubbedInterfaces.append(member.iface)
else:
removeStubMember(memberId, member)
# Now go through and check all the interfaces' members
for iface in stubbedInterfaces:
for member in iface.stubMembers:
checkStubMember(member)
for iface in conf.customReturnInterfaces:
# just ensure that it exists so that we can grab it later
iface = getInterface(iface, errorLoc='looking for %s' % (iface,))