mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 774970. Add the ability to generate code for dealing with an XPConnect 'this' object in some cases. r=peterv
This commit is contained in:
parent
95b6463acc
commit
ce68006223
@ -1470,11 +1470,29 @@ class CastableObjectUnwrapper():
|
||||
"""
|
||||
def __init__(self, descriptor, source, target, codeOnFailure):
|
||||
assert descriptor.castable
|
||||
|
||||
self.substitution = { "type" : descriptor.nativeType,
|
||||
"protoID" : "prototypes::id::" + descriptor.name,
|
||||
"source" : source,
|
||||
"target" : target,
|
||||
"codeOnFailure" : CGIndenter(CGGeneric(codeOnFailure), 4).define() }
|
||||
if descriptor.hasXPConnectImpls:
|
||||
# We don't use xpc_qsUnwrapThis because it will always throw on
|
||||
# unwrap failure, whereas we want to control whether we throw or
|
||||
# not.
|
||||
self.substitution["codeOnFailure"] = CGIndenter(CGGeneric(string.Template(
|
||||
"${type} *objPtr;\n"
|
||||
"xpc_qsSelfRef objRef;\n"
|
||||
"JS::Value val = JS::ObjectValue(*${source});\n"
|
||||
"nsresult rv = xpc_qsUnwrapArg<${type}>(cx, val, &objPtr, &objRef.ptr, &val);\n"
|
||||
"if (NS_FAILED(rv)) {\n"
|
||||
"${codeOnFailure}\n"
|
||||
"}\n"
|
||||
"// We should be castable!\n"
|
||||
"MOZ_ASSERT(!objRef.ptr);\n"
|
||||
"// We should have an object, too!\n"
|
||||
"MOZ_ASSERT(objPtr);\n"
|
||||
"${target} = objPtr;").substitute(self.substitution)), 4).define()
|
||||
|
||||
def __str__(self):
|
||||
return string.Template(
|
||||
@ -3301,6 +3319,7 @@ class FakeCastableDescriptor():
|
||||
self.workers = descriptor.workers
|
||||
self.nativeType = descriptor.nativeType
|
||||
self.name = descriptor.name
|
||||
self.hasXPConnectImpls = descriptor.hasXPConnectImpls
|
||||
|
||||
class CGAbstractBindingMethod(CGAbstractStaticMethod):
|
||||
"""
|
||||
|
@ -161,6 +161,8 @@ class Descriptor(DescriptorProvider):
|
||||
self.notflattened = desc.get('notflattened', False)
|
||||
self.register = desc.get('register', True)
|
||||
|
||||
self.hasXPConnectImpls = desc.get('hasXPConnectImpls', False)
|
||||
|
||||
# If we're concrete, we need to crawl our ancestor interfaces and mark
|
||||
# them as having a concrete descendant.
|
||||
self.concrete = desc.get('concrete', not self.interface.isExternal())
|
||||
|
Loading…
Reference in New Issue
Block a user