Bug 808698. Set up example codegen for proxy bindings to work correctly. r=jst

This commit is contained in:
Boris Zbarsky 2012-11-09 08:24:32 -08:00
parent 3f363542b4
commit 03231584a7
4 changed files with 88 additions and 14 deletions

View File

@ -664,6 +664,11 @@ DOMInterfaces = {
'binaryNames': { 'methodRenamedFrom': 'methodRenamedTo',
'attributeGetterRenamedFrom': 'attributeGetterRenamedTo',
'attributeRenamedFrom': 'attributeRenamedTo' }
},
'TestExampleProxyInterface' : {
'headerFile': 'TestExampleProxyInterface-example.h',
'register': False
}
}

View File

@ -7116,12 +7116,66 @@ class CGExampleClass(CGClass):
appendMethod(iface.ctor())
for m in iface.members:
if m.isMethod():
if (m.isIdentifierLess() and
m != descriptor.operations['Stringifier']):
continue
appendMethod(m)
elif m.isAttr():
methodDecls.append(CGExampleGetter(descriptor, m))
if not m.readonly:
methodDecls.append(CGExampleSetter(descriptor, m))
# Now do the special operations
def appendSpecialOperation(name, op):
if op is None:
return
if name == "IndexedCreator" or name == "NamedCreator":
# These are identical to the setters
return
assert len(op.signatures()) == 1
(returnType, args) = op.signatures()[0]
# Make a copy of the args, since we plan to modify them.
args = list(args)
if op.isGetter() or op.isDeleter():
# This is a total hack. The '&' belongs with the
# type, not the name! But it works, and is simpler
# than trying to somehow make this pretty.
args.append(FakeArgument(BuiltinTypes[IDLBuiltinType.Types.boolean],
op, name="&found"))
if name == "Stringifier" and op.isIdentifierLess():
# XXXbz I wish we were consistent about our renaming here.
name = "__stringify"
methodDecls.append(
CGNativeMember(descriptor, op,
name,
(returnType, args),
descriptor.getExtendedAttributes(op)))
# Sort things by name so we get stable ordering in the output.
ops = descriptor.operations.items()
ops.sort(key=lambda x: x[0])
for (name, op) in ops:
appendSpecialOperation(name, op)
# If we support indexed properties, then we need a Length()
# method so we know which indices are supported.
if descriptor.supportsIndexedProperties():
methodDecls.append(
CGNativeMember(descriptor, FakeMember(),
"Length",
(BuiltinTypes[IDLBuiltinType.Types.unsigned_long],
[]),
{ "infallible": True }))
# And if we support named properties we need to be able to
# enumerate the supported names.
if descriptor.supportsNamedProperties():
methodDecls.append(
CGNativeMember(
descriptor, FakeMember(),
"GetSupportedNames",
(IDLSequenceType(None,
BuiltinTypes[IDLBuiltinType.Types.domstring]),
[]),
{ "infallible": True }))
wrapArgs = [Argument('JSContext*', 'aCx'),
Argument('JSObject*', 'aScope')]
if descriptor.wrapperCache:
@ -7336,6 +7390,21 @@ class CGCallbackFunction(CGClass):
body=bodyWithoutThis),
callCallback]
class FakeMember():
def __init__(self):
self.treatUndefinedAs = self.treatNullAs = "Default"
def isStatic(self):
return False
def isAttr(self):
return False
def getExtendedAttribute(self, name):
# Claim to be a [Creator] so we can avoid the "mark this
# resultNotAddRefed" comments CGNativeMember codegen would
# otherwise stick in.
if name == "Creator":
return True
return None
class CallCallback(CGNativeMember):
def __init__(self, callback, descriptorProvider):
sig = callback.signatures()[0]
@ -7343,20 +7412,6 @@ class CallCallback(CGNativeMember):
self.callback = callback
args = sig[1]
self.argCount = len(args)
class FakeMember():
def __init__(self):
self.treatUndefinedAs = self.treatNullAs = "Default"
def isStatic(self):
return False
def isAttr(self):
return False
def getExtendedAttribute(self, name):
# Claim to be a [Creator] so we can avoid the "mark this
# resultNotAddRefed" comments CGNativeMember codegen would
# otherwise stick in.
if name == "Creator":
return True
return None
CGNativeMember.__init__(self, descriptorProvider, FakeMember(),
"Call", (self.retvalType, args),
extendedAttrs={},

View File

@ -77,6 +77,7 @@ include $(topsrcdir)/config/rules.mk
$(CPPSRCS): ../%Binding.cpp: $(bindinggen_dependencies) \
../%.webidl \
TestExampleInterface-example \
TestExampleProxyInterface-example \
$(NULL)
$(MAKE) -C .. $*Binding.h
$(MAKE) -C .. $*Binding.cpp
@ -84,6 +85,9 @@ $(CPPSRCS): ../%Binding.cpp: $(bindinggen_dependencies) \
TestExampleInterface-example:
$(MAKE) -C .. TestExampleInterface-example
TestExampleProxyInterface-example:
$(MAKE) -C .. TestExampleProxyInterface-example
check::
PYTHONDONTWRITEBYTECODE=1 $(PYTHON) $(topsrcdir)/config/pythonpath.py \
$(PLY_INCLUDE) $(srcdir)/../parser/runtests.py

View File

@ -319,3 +319,13 @@ interface TestExampleInterface {
// If you add things here, add them to TestCodeGen as well
};
interface TestExampleProxyInterface {
getter long longIndexedGetter(unsigned long ix);
deleter void (unsigned long ix);
setter creator void longIndexedSetter(unsigned long y, long z);
stringifier DOMString myStringifier();
getter short shortNameGetter(DOMString nom);
deleter void (DOMString nomnom);
setter creator void shortNamedSetter(DOMString me, short value);
};