Bug 178656

Summary: [Settings] Add initial support for generating preferences related code
Product: WebKit Reporter: Sam Weinig <sam>
Component: New BugsAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dino, joepeck, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 178637    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Sam Weinig 2017-10-23 02:55:02 PDT
[Settings] Add initial support for generating preferences related code
Comment 1 Sam Weinig 2017-10-23 03:01:43 PDT Comment hidden (obsolete)
Comment 2 Sam Weinig 2017-10-23 03:54:05 PDT Comment hidden (obsolete)
Comment 3 Sam Weinig 2017-10-23 08:07:30 PDT
Created attachment 324557 [details]
Patch
Comment 4 Joseph Pecoraro 2017-10-23 10:59:39 PDT
Comment on attachment 324557 [details]
Patch

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

> Source/WebKit/Scripts/GeneratePreferences.rb:78
> +    @humanReadableName = "\"#{opts["humanReadableName"]}\"" || '""'
> +    @humanReadableDescription = "\"#{opts["humanReadableDescription"]}\"" || '""'

I don't think `||` part does anything here, the left side always produces a string that at least has quotes so it won't be falsey.

In the unlikely event that we might want to escape double quotes or other escape characters in the humanReadableDescription you could use String#inspect:
http://ruby-doc.org/core-2.1.1/String.html#method-i-inspect

    @humanReadableName = (opts["humanReadableName"] || "").inspect
    @humanReadableDescription = (opts["humanReadableDescription"] || "").inspect

That said, this might be cryptic, even for Rubyists. Perhaps just a simple:

    @humanReadableName = '"' + (opts["humanReadableName"] || "") + "'"
    @humanReadableDescription = '"' + (opts["humanReadableDescription"] || "") + '"'

> Source/WebKit/Scripts/GeneratePreferences.rb:119
> +    @boolPreferncesNotDebug = @preferences.select { |p| !p.category && !p.webkitOnly && p.type == "bool" }
> +    @doublePreferncesNotDebug = @preferences.select { |p| !p.category && !p.webkitOnly && p.type == "double" }

Typo (all members): "Prefernces" => "Preferences"
Comment 5 Sam Weinig 2017-10-23 15:22:32 PDT
Created attachment 324597 [details]
Patch
Comment 6 Sam Weinig 2017-10-23 15:36:09 PDT
Created attachment 324599 [details]
Patch
Comment 7 Sam Weinig 2017-10-23 15:45:56 PDT
Created attachment 324600 [details]
Patch
Comment 8 WebKit Commit Bot 2017-10-24 11:43:35 PDT
Comment on attachment 324600 [details]
Patch

Clearing flags on attachment: 324600

Committed r223903: <https://trac.webkit.org/changeset/223903>
Comment 9 WebKit Commit Bot 2017-10-24 11:43:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2017-11-15 13:02:47 PST
<rdar://problem/35568675>