Bug 1007878 part 5. Implement callback codegen for MozMap. r=khuey

This commit is contained in:
Boris Zbarsky
2014-05-23 17:32:39 -04:00
parent 3abb6acbbc
commit 70420bfdf4
4 changed files with 125 additions and 6 deletions

View File

@@ -3874,19 +3874,25 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
"${declName}.SetNull();\n",
notMozMap)
declType = typeName
declArgs = None
holderType = None
holderArgs = None
# MozMap arguments that might contain traceable things need
# to get traced
if not isMember and typeNeedsRooting(valueType):
if not isMember and isCallbackReturnValue:
# Go ahead and just convert directly into our actual return value
declType = CGWrapper(declType, post="&")
declArgs = "aRetVal"
elif not isMember and typeNeedsRooting(valueType):
holderType = CGTemplatedType("MozMapRooter", valueInfo.declType)
# If our MozMap is nullable, this will set the Nullable to be
# not-null, but that's ok because we make an explicit SetNull() call
# on it as needed if our JS value is actually null.
holderArgs = "cx, &%s" % mozMapRef
else:
holderType = None
holderArgs = None
return JSToNativeConversionInfo(templateBody, declType=typeName,
return JSToNativeConversionInfo(templateBody, declType=declType,
declArgs=declArgs,
holderType=holderType,
dealWithOptional=isOptional,
holderArgs=holderArgs)
@@ -11534,6 +11540,13 @@ class CGNativeMember(ClassMethod):
else:
returnCode = "aRetVal.SwapElements(${declName});\n"
return "void", "", returnCode
if type.isMozMap():
# If we want to handle MozMap-of-MozMap return values, we're
# going to need to fix example codegen to not produce MozMap<void>
# for the relevant argument...
assert not isMember
# In this case we convert directly into our outparam to start with
return "void", "", ""
if type.isDate():
result = CGGeneric("Date")
if type.nullable():
@@ -11628,7 +11641,8 @@ class CGNativeMember(ClassMethod):
is a const ref, as well as whether the type should be wrapped in
Nullable as needed.
isMember can be false or one of the strings "Sequence" or "Variadic"
isMember can be false or one of the strings "Sequence", "Variadic",
"MozMap"
"""
if type.isArray():
raise TypeError("Can't handle array arguments yet")
@@ -11642,6 +11656,15 @@ class CGNativeMember(ClassMethod):
decl = CGTemplatedType("Sequence", argType)
return decl.define(), True, True
if type.isMozMap():
nullable = type.nullable()
if nullable:
type = type.inner
elementType = type.inner
argType = self.getArgType(elementType, False, "MozMap")[0]
decl = CGTemplatedType("MozMap", argType)
return decl.define(), True, True
if type.isUnion():
# unionTypeDecl will handle nullable types, so return False for
# auto-wrapping in Nullable