Changeset 158361 in webkit


Ignore:
Timestamp:
Oct 31, 2013 9:28:14 AM (10 years ago)
Author:
ap@apple.com
Message:

CryptoAlgorithmDescriptionBuilder should support producing nested algorithms
https://bugs.webkit.org/show_bug.cgi?id=123461

Reviewed by Darin Adler.

To add a nested algorithm, clone a builder with createEmptyClone(), fill it,
and add it using add().

  • bindings/js/JSCryptoAlgorithmBuilder.h:
  • crypto/CryptoAlgorithmDescriptionBuilder.h:
  • bindings/js/JSCryptoAlgorithmBuilder.cpp:

(WebCore::JSCryptoAlgorithmBuilder::createEmptyClone):
(WebCore::JSCryptoAlgorithmBuilder::add): Keep VM in a local variable for marginally
better performance.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158360 r158361  
     12013-10-30  Alexey Proskuryakov  <ap@apple.com>
     2
     3        CryptoAlgorithmDescriptionBuilder should support producing nested algorithms
     4        https://bugs.webkit.org/show_bug.cgi?id=123461
     5
     6        Reviewed by Darin Adler.
     7
     8        To add a nested algorithm, clone a builder with createEmptyClone(), fill it,
     9        and add it using add().
     10
     11        * bindings/js/JSCryptoAlgorithmBuilder.h:
     12        * crypto/CryptoAlgorithmDescriptionBuilder.h:
     13        * bindings/js/JSCryptoAlgorithmBuilder.cpp:
     14        (WebCore::JSCryptoAlgorithmBuilder::createEmptyClone):
     15        (WebCore::JSCryptoAlgorithmBuilder::add): Keep VM in a local variable for marginally
     16        better performance.
     17
    1182013-10-31  Philippe Normand  <pnormand@igalia.com>
    219
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp

    r157936 r158361  
    4545}
    4646
    47 void JSCryptoAlgorithmBuilder::add(const char* key, unsigned long value)
     47std::unique_ptr<CryptoAlgorithmDescriptionBuilder> JSCryptoAlgorithmBuilder::createEmptyClone() const
    4848{
    49     Identifier identifier(m_exec, key);
    50     m_dictionary->putDirect(m_exec->vm(), identifier, jsNumber(value));
     49    return std::make_unique<JSCryptoAlgorithmBuilder>(m_exec);
     50}
     51
     52void JSCryptoAlgorithmBuilder::add(const char* key, unsigned value)
     53{
     54    VM& vm = m_exec->vm();
     55    Identifier identifier(&vm, key);
     56    m_dictionary->putDirect(vm, identifier, jsNumber(value));
    5157}
    5258
    5359void JSCryptoAlgorithmBuilder::add(const char* key, const String& value)
    5460{
    55     Identifier identifier(m_exec, key);
    56     m_dictionary->putDirect(m_exec->vm(), identifier, jsString(m_exec, value));
     61    VM& vm = m_exec->vm();
     62    Identifier identifier(&vm, key);
     63    m_dictionary->putDirect(vm, identifier, jsString(m_exec, value));
     64}
     65
     66void JSCryptoAlgorithmBuilder::add(const char* key, const CryptoAlgorithmDescriptionBuilder& nestedBuilder)
     67{
     68    VM& vm = m_exec->vm();
     69    Identifier identifier(&vm, key);
     70    const JSCryptoAlgorithmBuilder& jsBuilder = static_cast<const JSCryptoAlgorithmBuilder&>(nestedBuilder);
     71    m_dictionary->putDirect(vm, identifier, jsBuilder.result());
    5772}
    5873
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h

    r157936 r158361  
    4343    virtual ~JSCryptoAlgorithmBuilder();
    4444
    45     JSC::JSObject* result() { return m_dictionary; }
     45    JSC::JSObject* result() const { return m_dictionary; }
    4646
    47     virtual void add(const char*, unsigned long) OVERRIDE;
     47    virtual std::unique_ptr<CryptoAlgorithmDescriptionBuilder> createEmptyClone() const OVERRIDE;
     48
     49    virtual void add(const char*, unsigned) OVERRIDE;
    4850    virtual void add(const char*, const String&) OVERRIDE;
     51    virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&) OVERRIDE;
    4952
    5053private:
  • trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h

    r157936 r158361  
    4040    virtual ~CryptoAlgorithmDescriptionBuilder();
    4141
    42     virtual void add(const char*, unsigned long) = 0;
     42    virtual std::unique_ptr<CryptoAlgorithmDescriptionBuilder> createEmptyClone() const = 0;
     43
     44    virtual void add(const char*, unsigned) = 0;
    4345    virtual void add(const char*, const String&) = 0;
     46    virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&) = 0;
    4447};
    4548
Note: See TracChangeset for help on using the changeset viewer.