mirror of
https://github.com/servo/servo.git
synced 2025-06-17 21:04:28 +00:00
Remove the preSuccess and postSuccess arguments to getJSToNativeConversionTemplate.
They were used for unions until 06f9afdad5
.
This commit is contained in:
parent
4ba093939a
commit
022dfa0a5e
1 changed files with 6 additions and 17 deletions
|
@ -92,13 +92,8 @@ class CastableObjectUnwrapper():
|
||||||
|
|
||||||
codeOnFailure is the code to run if unwrapping fails.
|
codeOnFailure is the code to run if unwrapping fails.
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, source, target, codeOnFailure, isOptional=False,
|
def __init__(self, descriptor, source, target, codeOnFailure, isOptional=False):
|
||||||
preUnwrapped=None, postUnwrapped=None):
|
|
||||||
assert descriptor.castable
|
assert descriptor.castable
|
||||||
|
|
||||||
unwrappedVal = "val"
|
|
||||||
if preUnwrapped or postUnwrapped:
|
|
||||||
unwrappedVal = preUnwrapped + unwrappedVal + postUnwrapped
|
|
||||||
self.substitution = { "type" : descriptor.nativeType,
|
self.substitution = { "type" : descriptor.nativeType,
|
||||||
"depth": descriptor.interface.inheritanceDepth(),
|
"depth": descriptor.interface.inheritanceDepth(),
|
||||||
"prototype": "PrototypeList::id::" + descriptor.name,
|
"prototype": "PrototypeList::id::" + descriptor.name,
|
||||||
|
@ -106,7 +101,7 @@ class CastableObjectUnwrapper():
|
||||||
"source" : source,
|
"source" : source,
|
||||||
"target" : target,
|
"target" : target,
|
||||||
"codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure), 4).define(),
|
"codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure), 4).define(),
|
||||||
"unwrapped_val" : ("Some(%s)" % unwrappedVal) if isOptional else unwrappedVal,
|
"unwrapped_val" : "Some(val)" if isOptional else "val",
|
||||||
"unwrapFn": "unwrap_jsmanaged" if 'JS' in descriptor.nativeType else "unwrap_object"}
|
"unwrapFn": "unwrap_jsmanaged" if 'JS' in descriptor.nativeType else "unwrap_object"}
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -428,9 +423,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
isClamp=False,
|
isClamp=False,
|
||||||
exceptionCode=None,
|
exceptionCode=None,
|
||||||
isCallbackReturnValue=False,
|
isCallbackReturnValue=False,
|
||||||
sourceDescription="value",
|
sourceDescription="value"):
|
||||||
preSuccess=None,
|
|
||||||
postSuccess=None):
|
|
||||||
"""
|
"""
|
||||||
Get a template for converting a JS value to a native object based on the
|
Get a template for converting a JS value to a native object based on the
|
||||||
given type and descriptor. If failureCode is given, then we're actually
|
given type and descriptor. If failureCode is given, then we're actually
|
||||||
|
@ -654,8 +647,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
"(${val}).to_object()",
|
"(${val}).to_object()",
|
||||||
"${declName}",
|
"${declName}",
|
||||||
failureCode,
|
failureCode,
|
||||||
isOptional or type.nullable(),
|
isOptional or type.nullable()))
|
||||||
preUnwrapped=preSuccess, postUnwrapped=postSuccess))
|
|
||||||
else:
|
else:
|
||||||
templateBody += str(FailureFatalCastableObjectUnwrapper(
|
templateBody += str(FailureFatalCastableObjectUnwrapper(
|
||||||
descriptor,
|
descriptor,
|
||||||
|
@ -886,15 +878,12 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
if failureCode is None:
|
if failureCode is None:
|
||||||
failureCode = 'return 0'
|
failureCode = 'return 0'
|
||||||
|
|
||||||
successVal = "v"
|
|
||||||
if preSuccess or postSuccess:
|
|
||||||
successVal = preSuccess + successVal + postSuccess
|
|
||||||
#XXXjdm support conversionBehavior here
|
#XXXjdm support conversionBehavior here
|
||||||
template = (
|
template = (
|
||||||
"match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
|
"match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
|
||||||
" Ok(v) => ${declName} = %s,\n"
|
" Ok(v) => ${declName} = v,\n"
|
||||||
" Err(_) => { %s }\n"
|
" Err(_) => { %s }\n"
|
||||||
"}" % (successVal, exceptionCode))
|
"}" % exceptionCode)
|
||||||
|
|
||||||
declType = CGGeneric(builtinNames[type.tag()])
|
declType = CGGeneric(builtinNames[type.tag()])
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue