mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add stubs for inline event handler manipulation.
This commit is contained in:
parent
2717ab65ec
commit
2d6153772c
10 changed files with 223 additions and 23 deletions
|
@ -34,6 +34,7 @@ DOMInterfaces = {
|
|||
'DOMParser': {},
|
||||
'Element': {},
|
||||
'Event': {},
|
||||
'EventHandler': {},
|
||||
'EventListener': {
|
||||
'nativeType': 'EventListenerBinding::EventListener',
|
||||
},
|
||||
|
|
|
@ -705,17 +705,17 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
"rooting issues")
|
||||
# XXXbz we're going to assume that callback types are always
|
||||
# nullable and always have [TreatNonCallableAsNull] for now.
|
||||
haveCallable = "${val}.isObject() && JS_ObjectIsCallable(cx, &${val}.toObject())"
|
||||
haveCallable = "${val}.is_object() && JS_ObjectIsCallable(cx, ${val}.to_object()) != 0"
|
||||
if defaultValue is not None:
|
||||
assert(isinstance(defaultValue, IDLNullValue))
|
||||
haveCallable = "${haveValue} && " + haveCallable
|
||||
return (
|
||||
"if (%s) {\n"
|
||||
" ${declName} = &${val}.toObject();\n"
|
||||
" ${val}.to_object()\n"
|
||||
"} else {\n"
|
||||
" ${declName} = NULL;\n"
|
||||
" ptr::mut_null()\n"
|
||||
"}" % haveCallable,
|
||||
CGGeneric("JSObject*"), None, needsRooting)
|
||||
CGGeneric("*mut JSObject"), needsRooting)
|
||||
|
||||
if type.isAny():
|
||||
assert not isEnforceRange and not isClamp
|
||||
|
@ -1346,6 +1346,14 @@ class CGIfWrapper(CGWrapper):
|
|||
CGWrapper.__init__(self, CGIndenter(child), pre=pre.define(),
|
||||
post="\n}")
|
||||
|
||||
class CGTemplatedType(CGWrapper):
|
||||
def __init__(self, templateName, child, isConst=False, isReference=False):
|
||||
const = "const " if isConst else ""
|
||||
pre = "%s%s<" % (const, templateName)
|
||||
ref = "&" if isReference else ""
|
||||
post = ">%s" % ref
|
||||
CGWrapper.__init__(self, child, pre=pre, post=post)
|
||||
|
||||
class CGNamespace(CGWrapper):
|
||||
def __init__(self, namespace, child, public=False):
|
||||
pre = "%smod %s {\n" % ("pub " if public else "", namespace)
|
||||
|
@ -3128,7 +3136,7 @@ class ClassMember(ClassItem):
|
|||
ClassItem.__init__(self, name, visibility)
|
||||
|
||||
def declare(self, cgClass):
|
||||
return '%s: %s,\n' % (self.name, self.type)
|
||||
return '%s %s: %s,\n' % (self.visibility, self.name, self.type)
|
||||
|
||||
def define(self, cgClass):
|
||||
if not self.static:
|
||||
|
@ -4357,7 +4365,7 @@ class CGNativeMember(ClassMethod):
|
|||
elif type.isAny():
|
||||
typeDecl, template = "JS::Value", "return ${declName};"
|
||||
elif type.isObject():
|
||||
typeDecl, template = "JSObject*", "return ${declName};"
|
||||
typeDecl, template = "*JSObject", "return ${declName};"
|
||||
elif type.isSpiderMonkeyInterface():
|
||||
if type.nullable():
|
||||
returnCode = "return ${declName}.IsNull() ? nullptr : ${declName}.Value().Obj();"
|
||||
|
@ -4561,7 +4569,7 @@ class CGNativeMember(ClassMethod):
|
|||
elif optional:
|
||||
# Note: All variadic args claim to be optional, but we can just use
|
||||
# empty arrays to represent them not being present.
|
||||
decl = CGTemplatedType("Optional", decl)
|
||||
decl = CGTemplatedType("Option", decl)
|
||||
ref = True
|
||||
return (decl, ref)
|
||||
|
||||
|
@ -4816,6 +4824,7 @@ class CallbackMember(CGNativeMember):
|
|||
def getResultConversion(self):
|
||||
replacements = {
|
||||
"val": "rval",
|
||||
"declName": "rvalDecl",
|
||||
}
|
||||
|
||||
if isJSImplementedDescriptor(self.descriptorProvider):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue