Bug 122239 - IDL parser should remove a leading "_" from identifier names
Summary: IDL parser should remove a leading "_" from identifier names
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-02 14:02 PDT by Eric Carlson
Modified: 2013-10-02 16:32 PDT (History)
5 users (show)

See Also:


Attachments
Proposed patch (28.30 KB, patch)
2013-10-02 14:14 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2013-10-02 14:02:37 PDT
According the the WebIDL spec [1]:

... the identifier is the value of the identifier token with any single leading U+005F LOW LINE ("_") character (underscore) removed.

Note
A leading "_" is used to escape an identifier from looking like a reserved word so that, for example, an interface named “interface” can be defined. The leading "_" is dropped to unescape the identifier.


http://www.w3.org/TR/WebIDL/#idl-names
Comment 1 Eric Carlson 2013-10-02 14:14:05 PDT
Created attachment 213198 [details]
Proposed patch
Comment 2 WebKit Commit Bot 2013-10-02 14:16:43 PDT
Attachment 213198 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/bindings/scripts/IDLParser.pm', u'Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp', u'Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h', u'Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.symbols', u'Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp', u'Source/WebCore/bindings/scripts/test/JS/JSTestObj.h', u'Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h', u'Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm', u'Source/WebCore/bindings/scripts/test/TestException.idl', u'Source/WebCore/bindings/scripts/test/TestInterface.idl', u'Source/WebCore/bindings/scripts/test/TestObj.idl']" exit_code: 1
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h:63:  enum members should use InterCaps with an initial capital letter.  [readability/enum_casing] [4]
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h:68:  enum members should use InterCaps with an initial capital letter.  [readability/enum_casing] [4]
Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h:212:  The parameter name "a" adds no information, so it should be removed.  [readability/parameter_name] [5]
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp:213:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 4 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Jer Noble 2013-10-02 14:45:44 PDT
Comment on attachment 213198 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=213198&action=review

> Source/WebCore/bindings/scripts/IDLParser.pm:318
> +sub identifierRemoveNullablePrefix
> +{
> +    my $type = shift;
> +    $type =~ s/\_// if $type =~ /^\_/;
> +    return $type;
> +}
> +

A regexp seems heavy handed here.  How about just:

my $type = shift;
return substr($type, 0, 1) == "_" ? substr($type, 1) : $type;

If you want to leave in the regexp, we should just do:

my $type = shift;
return $type =~ s/^\_//;
Comment 4 Eric Carlson 2013-10-02 16:32:27 PDT
Committed r156808: https://trac.webkit.org/r156808