Closed Bug 1023698 Opened 10 years ago Closed 10 years ago

Missing JSContext* parameter in Generated Event Constructor

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: schien, Assigned: smaug)

Details

Attachments

(3 files, 1 obsolete file)

Attached patch test caseSplinter Review
===Example WebIDL===
[Constructor(DOMString type, optional TestBaseEventInit eventInitDict)]
interface TestBaseEvent: Event {
  readonly attribute any data;
};

dictionary TestBaseEventInit : EventInit {
  any data;
};

[Constructor(DOMString type, optional TestEventInit eventInitDict)]
interface TestEvent: TestBaseEvent {
  readonly attribute DOMString someString;
};

dictionary TestEventInit : TestBaseEventInit {
  DOMString someString = "";
};


===Compile Error===
3:45.54 ./TestEventBinding.cpp:303:12: error: no matching function for call to 'Constructor'
 3:45.54   result = mozilla::dom::TestEvent::Constructor(global, cx, NonNullHelper(Constify(arg0)), Constify(arg1), rv);
 3:45.55            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3:45.55 ./TestEvent.cpp:61:12: note: candidate function not viable: requires 3 arguments, but 5 were provided
 3:45.55 TestEvent::Constructor(mozilla::dom::EventTarget* aOwner, const nsAString& aType, const TestEventInit& aEventInitDict)
 3:45.55            ^
 3:45.55 ./TestEvent.cpp:74:12: note: candidate function not viable: requires 4 arguments, but 5 were provided
 3:45.55 TestEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType, const TestEventInit& aEventInitDict, ErrorResult& aRv)
 3:45.55            ^
CGEventMethod should also check inherited interfaces for appending JSContext* in argument list.
http://dxr.mozilla.org/mozilla-central/source/dom/bindings/Codegen.py?from=codegen.py&case=true#13567
Or maybe just examine the types in the signature of self.member instead?  That's what really matters here; the fact that those happen to match the interface member types in the case of events is somewhat accidental.
Attached patch patch (obsolete) — Splinter Review
+ "\n" removal is to fix .h coding style. No extra newlines.

Event codegen very much relies on interface attributes and dictionary properties
etc. to match.
Attachment #8438639 - Flags: review?(bzbarsky)
Comment on attachment 8438639 [details] [diff] [review]
patch

>+        while iface.identifier.name != "Event":

Why not just:

  while iface:

?  

But also, is this really simpler/better than:

  return needCx(None, self.member.signatures()[0][1], [], True)

?
(In reply to Boris Zbarsky [:bz] from comment #4)
> Why not just:
> 
>   while iface:
> 
> ?  
Just because rest of the codegen tends to iterate up to Event


> 
> But also, is this really simpler/better than:
> 
>   return needCx(None, self.member.signatures()[0][1], [], True)

I have no idea what that does. Hard to read at least.
> I have no idea what that does.

It passes the list of our actual IDL arguments to needCx, which is how needCx is _meant_ to be used.  The fact that it even worked with an interface member list is just because both arguments and attributes happen to have the type in .type (which I've been planning to change for attributes, btw!) and because we only support attributes in codegenned events.

So how about this:

1)  Add an arguments() method to IDLMethod, which asserts that there is only one signature and returns that signatures arguments.

2)  Use self.member.arguments() here.
Need to still change .member name to be something which might hint what it is about, or
hide .member here and add arguments to CGNativeMember or something.
Attachment #8438639 - Attachment is obsolete: true
Attachment #8438639 - Flags: review?(bzbarsky)
Attachment #8438668 - Flags: review?(bzbarsky)
Comment on attachment 8438668 [details] [diff] [review]
hide the magic behind def arguments()

>+    def arguments(self):
>+        return self.member.signatures()[0][1];

Oh, I meant adding arguments() to IDLMethod over in the parser.  But this is ok, I guess.

r=me
Attachment #8438668 - Flags: review?(bzbarsky) → review+
Yeah, I realized you wanted arguments() to IDLMethod, but one would still need to use .member
which is too magical ;)
Attached patch without ;Splinter Review
Assignee: nobody → bugs
https://hg.mozilla.org/mozilla-central/rev/19ba96e89095
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: