mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Share code to compute the type of a union.
This does not change the generated code.
This commit is contained in:
parent
e7748216df
commit
b40966981c
1 changed files with 9 additions and 5 deletions
|
@ -422,6 +422,12 @@ def typeIsSequenceOrHasSequenceMember(type):
|
|||
def typeNeedsRooting(type, descriptorProvider):
|
||||
return type.isGeckoInterface() and descriptorProvider.getDescriptor(type.name).needsRooting
|
||||
|
||||
|
||||
def union_native_type(t):
|
||||
name = t.unroll().name
|
||||
return '%s::%s' % (name, name)
|
||||
|
||||
|
||||
def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||
isDefinitelyObject=False,
|
||||
isMember=False,
|
||||
|
@ -576,7 +582,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
raise TypeError("Can't handle sequence arguments yet")
|
||||
|
||||
if type.isUnion():
|
||||
declType = CGGeneric(type.name + "::" + type.name)
|
||||
declType = CGGeneric(union_native_type(type))
|
||||
if type.nullable():
|
||||
declType = CGWrapper(declType, pre="Option<", post=" >")
|
||||
|
||||
|
@ -1075,7 +1081,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
|
|||
result = CGWrapper(result, pre="Option<", post=">")
|
||||
return result
|
||||
if returnType.isUnion():
|
||||
result = CGGeneric('%s::%s' % (returnType.unroll().name, returnType.unroll().name))
|
||||
result = CGGeneric(union_native_type(returnType))
|
||||
if returnType.nullable():
|
||||
result = CGWrapper(result, pre="Option<", post=">")
|
||||
return result
|
||||
|
@ -4751,9 +4757,7 @@ class CGNativeMember(ClassMethod):
|
|||
return decl.define(), True, True
|
||||
|
||||
if type.isUnion():
|
||||
if type.nullable():
|
||||
type = type.inner
|
||||
return str(type) + "::" + str(type), False, True
|
||||
return union_native_type(type), False, True
|
||||
|
||||
if type.isGeckoInterface() and not type.isCallbackInterface():
|
||||
iface = type.unroll().inner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue