Bug 129235 - Use variadic templates to reduce the line count of wtf/text/StringConcatenate.h
Summary: Use variadic templates to reduce the line count of wtf/text/StringConcatenate.h
Status: RESOLVED DUPLICATE of bug 147142
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-23 12:56 PST by Sam Weinig
Modified: 2016-12-15 16:22 PST (History)
6 users (show)

See Also:


Attachments
Patch (33.72 KB, patch)
2014-02-23 12:59 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Just the new code (3.67 KB, text/plain)
2014-02-23 13:01 PST, Sam Weinig
no flags Details
Patch (26.19 KB, patch)
2014-02-28 20:06 PST, Sam Weinig
joepeck: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2014-02-23 12:56:35 PST
Use variadic templates to reduce the line count of wtf/text/StringConcatenate.h
Comment 1 Sam Weinig 2014-02-23 12:59:00 PST
Created attachment 225012 [details]
Patch
Comment 2 WebKit Commit Bot 2014-02-23 13:00:49 PST
Attachment 225012 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/text/StringConcatenate.h:518:  Do not use 'using namespace TryMakeStringDetails;'.  [build/using_namespace] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Sam Weinig 2014-02-23 13:01:28 PST
Created attachment 225013 [details]
Just the new code

Adding a file with just new code, as the diff is a bit hard to read.
Comment 4 Sam Weinig 2014-02-23 13:02:49 PST
(In reply to comment #2)
> Attachment 225012 [details] did not pass style-queue:
> 
> 
> ERROR: Source/WTF/wtf/text/StringConcatenate.h:518:  Do not use 'using namespace TryMakeStringDetails;'.  [build/using_namespace] [4]

I don't think this should be an error. The using namespace declaration is used inside a function.
Comment 5 Sam Weinig 2014-02-28 20:06:04 PST
Created attachment 225523 [details]
Patch
Comment 6 Brent Fulgham 2014-04-16 14:03:19 PDT
This doesn't seem to work on Windows. Sometimes we run into problems with char*/wchar_t* 

Example error:

     WebSocketFrame.cpp
     1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(521): error C2079: 'adaptedStrings' uses undefined class 'std::tuple<WTF::StringTypeAdapter<StringType1>,WTF::StringTypeAdapter<const char*>>'
                 with
                 [
                     StringType1=WTF::StringAppend<const char *,WTF::String>
                 ] (..\Modules\websockets\WebSocketFrame.cpp)
                 C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringOperators.h(38) : see reference to function template instantiation 'WTF::PassRefPtr<WTF::StringImpl> WTF::tryMakeString<StringType1,StringType2>(StringType1,StringType2)' being compiled
                 with
                 [
                     StringType1=WTF::StringAppend<const char *,WTF::String>
         ,            StringType2=const char *
                 ]
                 C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringOperators.h(37) : while compiling class template member function 'WTF::StringAppend<WTF::StringAppend<const char *,WTF::String>,const char *>::operator WTF::String(void) const'
                 ..\Modules\websockets\WebSocketFrame.cpp(99) : see reference to function template instantiation 'WTF::StringAppend<WTF::StringAppend<const char *,WTF::String>,const char *>::operator WTF::String(void) const' being compiled
                 ..\Modules\websockets\WebSocketFrame.cpp(99) : see reference to class template instantiation 'WTF::StringAppend<WTF::StringAppend<const char *,WTF::String>,const char *>' being compiled
     1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(521): error C2078: too many initializers (..\Modules\websockets\WebSocketFrame.cpp)
     1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(521): error C2440: 'initializing' : cannot convert from 'const char *' to 'int' (..\Modules\websockets\WebSocketFrame.cpp)
                 There is no context in which this conversion is possible
     1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(522): error C2783: 'WTF::PassRefPtr<WTF::StringImpl> WTF::TryMakeStringDetails::tryMakeStringTuple(Tuple)' : could not deduce template argument for 'Indicies' (..\Modules\websockets\WebSocketFrame.cpp)
                 C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(509) : see declaration of 'WTF::TryMakeStringDetails::tryMakeStringTuple'
     1>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(522): error C2780: 'WTF::PassRefPtr<WTF::StringImpl> WTF::TryMakeStringDetails::tryMakeStringTuple(Tuple &&,std::index_sequence<Index...>)' : expects 2 arguments - 1 provided (..\Modules\websockets\WebSocketFrame.cpp)
                 C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\include\private\wtf/text/StringConcatenate.h(503) : see declaration of 'WTF::TryMakeStringDetails::tryMakeStringTuple'
Comment 7 Mark Rowe (bdash) 2014-06-30 20:20:07 PDT
I wrote up a very similar patch this evening since I wasn't aware of this one. I don't think it's necessary to use std::tuple for this.
Comment 8 Joseph Pecoraro 2016-03-13 18:47:48 PDT
Comment on attachment 225523 [details]
Patch

This patch doesn't apply anymore, but it looks like it would be useful. Put up a rebaselined patch!
Comment 9 Brent Fulgham 2016-05-18 20:57:06 PDT
(In reply to comment #8)
> Comment on attachment 225523 [details]
> Patch
> 
> This patch doesn't apply anymore, but it looks like it would be useful. Put
> up a rebaselined patch!

+1!

And I think our Windows builds can handle this now...
Comment 10 Sam Weinig 2016-12-15 16:22:31 PST

*** This bug has been marked as a duplicate of bug 147142 ***