RESOLVED FIXED 112475
Add IDL 'enum' support to CodeGeneratorJS.pm
https://bugs.webkit.org/show_bug.cgi?id=112475
Summary Add IDL 'enum' support to CodeGeneratorJS.pm
arno.
Reported 2013-03-15 16:01:07 PDT
Hi, this bug is to add enum support for JavaScriptCore bindings. It is similar to what has been done for V8 in bug #106553.
Attachments
patch proposal (20.92 KB, patch)
2013-03-15 16:16 PDT, arno.
no flags
updated patch: check for exception after calling toString() (21.15 KB, patch)
2013-03-15 18:24 PDT, arno.
no flags
updated patch: second check for exception after calling toString() (21.38 KB, patch)
2013-03-18 09:54 PDT, arno.
no flags
patch modification: use a reference to String to avoid a copy (21.38 KB, patch)
2013-03-18 11:57 PDT, arno.
no flags
arno.
Comment 1 2013-03-15 16:16:06 PDT
Created attachment 193394 [details] patch proposal
arno.
Comment 2 2013-03-15 18:24:52 PDT
Created attachment 193411 [details] updated patch: check for exception after calling toString()
Kentaro Hara
Comment 3 2013-03-16 07:49:37 PDT
Comment on attachment 193411 [details] updated patch: check for exception after calling toString() View in context: https://bugs.webkit.org/attachment.cgi?id=193411&action=review > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2134 > + push(@implContent, " String string = value.isEmpty() ? String() : value.toString(exec)->value(exec);\n"); Don't you need to add 'if (exec->hadException()) return' ?
arno.
Comment 4 2013-03-18 09:54:33 PDT
Created attachment 193586 [details] updated patch: second check for exception after calling toString()
arno.
Comment 5 2013-03-18 11:57:25 PDT
Created attachment 193621 [details] patch modification: use a reference to String to avoid a copy
Kentaro Hara
Comment 6 2013-03-18 17:20:25 PDT
Comment on attachment 193621 [details] patch modification: use a reference to String to avoid a copy View in context: https://bugs.webkit.org/attachment.cgi?id=193621&action=review LGTM, thanks! > Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp:1892 > + if (args.Length() < 1) > + return throwNotEnoughArgumentsError(args.GetIsolate()); > + TestObj* imp = V8TestObj::toNative(args.Holder()); > + V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, enumArg, args[0]); > + imp->methodWithEnumArg(enumArg); > + return v8Undefined(); If you have time, I'd be happy if you could support 'enum' in DOM methods in V8 as well.
WebKit Review Bot
Comment 7 2013-03-18 17:35:52 PDT
Comment on attachment 193621 [details] patch modification: use a reference to String to avoid a copy Clearing flags on attachment: 193621 Committed r146161: <http://trac.webkit.org/changeset/146161>
WebKit Review Bot
Comment 8 2013-03-18 17:35:56 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 9 2013-03-19 17:33:23 PDT
Comment on attachment 193621 [details] patch modification: use a reference to String to avoid a copy View in context: https://bugs.webkit.org/attachment.cgi?id=193621&action=review > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2152 > + push(@implContent, " String& string = value.isEmpty() ? String() : value.toString(exec)->value(exec);\n"); This would work with const String&, but won’t work with String& — it will likely simply fail to compile.
Kentaro Hara
Comment 10 2013-03-19 17:33:42 PDT
Comment on attachment 193621 [details] patch modification: use a reference to String to avoid a copy View in context: https://bugs.webkit.org/attachment.cgi?id=193621&action=review > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2152 > + push(@implContent, " String& string = value.isEmpty() ? String() : value.toString(exec)->value(exec);\n"); Sorry, this is wrong. This should be String, not String&. If you are concerned about performance of String comparisons below, we should optimize it somehow. However, I think it is OK to just use String until we find any scenarios in which the String comparisons are bottlenecks. > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2794 > + push(@$outputArray, " const String& ${name}(${argValue}.isEmpty() ? String() : ${argValue}.toString(exec)->value(exec));\n"); Ditto.
Kentaro Hara
Comment 11 2013-03-19 17:34:42 PDT
(In reply to comment #9) > (From update of attachment 193621 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=193621&action=review > > > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2152 > > + push(@implContent, " String& string = value.isEmpty() ? String() : value.toString(exec)->value(exec);\n"); > > This would work with const String&, but won’t work with String& — it will likely simply fail to compile. Ah, const String& sounds the best.
Kentaro Hara
Comment 12 2013-03-19 17:35:13 PDT
arno: would you fix it please?
Darin Adler
Comment 13 2013-03-19 17:35:56 PDT
Comment on attachment 193621 [details] patch modification: use a reference to String to avoid a copy View in context: https://bugs.webkit.org/attachment.cgi?id=193621&action=review >>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2152 >>> + push(@implContent, " String& string = value.isEmpty() ? String() : value.toString(exec)->value(exec);\n"); >> >> This would work with const String&, but won’t work with String& — it will likely simply fail to compile. > > Sorry, this is wrong. This should be String, not String&. If you are concerned about performance of String comparisons below, we should optimize it somehow. However, I think it is OK to just use String until we find any scenarios in which the String comparisons are bottlenecks. I don’t think that const String& will give better performance than String. In either case there is still a local String value. The use of the reference might seem to eliminate a copy, but in practice is does not. So please just change back to "String" for clarity. >> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2794 >> + push(@$outputArray, " const String& ${name}(${argValue}.isEmpty() ? String() : ${argValue}.toString(exec)->value(exec));\n"); > > Ditto. Ditto.
Kentaro Hara
Comment 14 2013-03-19 18:04:41 PDT
The fix is going to be landed in bug 112760.
Note You need to log in before you can comment on or make changes to this bug.