Changeset 192839 in webkit


Ignore:
Timestamp:
Nov 30, 2015 3:57:31 PM (8 years ago)
Author:
Darin Adler
Message:

Use Optional instead of isNull out argument for nullable getters
https://bugs.webkit.org/show_bug.cgi?id=151676

Reviewed by Anders Carlsson.

No behavior change, just cleaner code.

  • Modules/geolocation/Coordinates.cpp:

(WebCore::Coordinates::altitude): Return an Optional.
(WebCore::Coordinates::altitudeAccuracy): Ditto.
(WebCore::Coordinates::heading): Ditto.
(WebCore::Coordinates::speed): Ditto.

  • Modules/geolocation/Coordinates.h: Ditto.
  • Modules/indexeddb/IDBVersionChangeEvent.cpp:

(WebCore::IDBVersionChangeEvent::create): Added. The code before was calling
through to Event::create, which is clearly not what was wanted. Also removed
unneeded explicit destructor.

  • Modules/indexeddb/IDBVersionChangeEvent.h: Changed return type of newVersion

to Optional and updated for above change.

  • Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp:

(WebCore::IDBClient::IDBVersionChangeEvent::newVersion): Changed to return
an Optional.

  • Modules/indexeddb/client/IDBVersionChangeEventImpl.h: Removed unused

default argument values; the event type one, at least, was clearly incorrect.
Made more things private, got rid of unneeded destructor, marked class final
instead of marking all functions final.

  • Modules/indexeddb/legacy/LegacyVersionChangeEvent.cpp:

(WebCore::LegacyVersionChangeEvent::newVersion): Same as above.

  • Modules/indexeddb/legacy/LegacyVersionChangeEvent.h: Ditto.
  • Modules/mediastream/MediaTrackConstraints.cpp:

(WebCore::MediaTrackConstraints::optional): Removed bogus bool value. If we
come back to finish later we will have to implement optional return values
for arrays in the JavaScript bindings generator, which should be straightforward.

  • Modules/mediastream/MediaTrackConstraints.h: Ditto.
  • bindings/js/JSDOMBinding.h:

(WebCore::toNullableJSNumber): Added. This function template is used for
return values that are nullable numbers.

  • bindings/scripts/CodeGeneratorGObject.pm:

(GenerateFunction): Replaced some existing bogus code to handle nullables with
new equally-bogus code that should be no worse and will compile.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation): Removed old support for nullables.
(NativeToJSValue): Added new support for nullable numbers.

  • bindings/scripts/CodeGeneratorObjC.pm:

(GenerateImplementation): Removed support for nullables. We almost certainly
won't need it for Objective-C bindings.

  • bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Updated.
  • bindings/scripts/test/JS/JSTestObj.cpp: Updated.
  • bindings/scripts/test/ObjC/DOMTestObj.mm: Updated.
Location:
trunk/Source/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r192838 r192839  
     12015-11-30  Darin Adler  <darin@apple.com>
     2
     3        Use Optional instead of isNull out argument for nullable getters
     4        https://bugs.webkit.org/show_bug.cgi?id=151676
     5
     6        Reviewed by Anders Carlsson.
     7
     8        No behavior change, just cleaner code.
     9
     10        * Modules/geolocation/Coordinates.cpp:
     11        (WebCore::Coordinates::altitude): Return an Optional.
     12        (WebCore::Coordinates::altitudeAccuracy): Ditto.
     13        (WebCore::Coordinates::heading): Ditto.
     14        (WebCore::Coordinates::speed): Ditto.
     15        * Modules/geolocation/Coordinates.h: Ditto.
     16
     17        * Modules/indexeddb/IDBVersionChangeEvent.cpp:
     18        (WebCore::IDBVersionChangeEvent::create): Added. The code before was calling
     19        through to Event::create, which is clearly not what was wanted. Also removed
     20        unneeded explicit destructor.
     21        * Modules/indexeddb/IDBVersionChangeEvent.h: Changed return type of newVersion
     22        to Optional and updated for above change.
     23
     24        * Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp:
     25        (WebCore::IDBClient::IDBVersionChangeEvent::newVersion): Changed to return
     26        an Optional.
     27        * Modules/indexeddb/client/IDBVersionChangeEventImpl.h: Removed unused
     28        default argument values; the event type one, at least, was clearly incorrect.
     29        Made more things private, got rid of unneeded destructor, marked class final
     30        instead of marking all functions final.
     31
     32        * Modules/indexeddb/legacy/LegacyVersionChangeEvent.cpp:
     33        (WebCore::LegacyVersionChangeEvent::newVersion): Same as above.
     34        * Modules/indexeddb/legacy/LegacyVersionChangeEvent.h: Ditto.
     35
     36        * Modules/mediastream/MediaTrackConstraints.cpp:
     37        (WebCore::MediaTrackConstraints::optional): Removed bogus bool value. If we
     38        come back to finish later we will have to implement optional return values
     39        for arrays in the JavaScript bindings generator, which should be straightforward.
     40        * Modules/mediastream/MediaTrackConstraints.h: Ditto.
     41
     42        * bindings/js/JSDOMBinding.h:
     43        (WebCore::toNullableJSNumber): Added. This function template is used for
     44        return values that are nullable numbers.
     45
     46        * bindings/scripts/CodeGeneratorGObject.pm:
     47        (GenerateFunction): Replaced some existing bogus code to handle nullables with
     48        new equally-bogus code that should be no worse and will compile.
     49
     50        * bindings/scripts/CodeGeneratorJS.pm:
     51        (GenerateImplementation): Removed old support for nullables.
     52        (NativeToJSValue): Added new support for nullable numbers.
     53
     54        * bindings/scripts/CodeGeneratorObjC.pm:
     55        (GenerateImplementation): Removed support for nullables. We almost certainly
     56        won't need it for Objective-C bindings.
     57
     58        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Updated.
     59        * bindings/scripts/test/JS/JSTestObj.cpp: Updated.
     60        * bindings/scripts/test/ObjC/DOMTestObj.mm: Updated.
     61
    1622015-11-30  Wenson Hsieh  <wenson_hsieh@apple.com>
    263
  • trunk/Source/WebCore/Modules/geolocation/Coordinates.cpp

    r146585 r192839  
    2929namespace WebCore {
    3030
    31 double Coordinates::altitude(bool& isNull) const
     31Optional<double> Coordinates::altitude() const
    3232{
    33     if (m_canProvideAltitude)
    34         return m_altitude;
    35 
    36     isNull = true;
    37     return 0;
     33    if (!m_canProvideAltitude)
     34        return Nullopt;
     35    return m_altitude;
    3836}
    3937
    40 double Coordinates::altitudeAccuracy(bool& isNull) const
     38Optional<double> Coordinates::altitudeAccuracy() const
    4139{
    42     if (m_canProvideAltitudeAccuracy)
    43         return m_altitudeAccuracy;
    44 
    45     isNull = true;
    46     return 0;
     40    if (!m_canProvideAltitudeAccuracy)
     41        return Nullopt;
     42    return m_altitudeAccuracy;
    4743}
    4844
    49 double Coordinates::heading(bool& isNull) const
     45Optional<double> Coordinates::heading() const
    5046{
    51     if (m_canProvideHeading)
    52         return m_heading;
    53 
    54     isNull = true;
    55     return 0;
     47    if (!m_canProvideHeading)
     48        return Nullopt;
     49    return m_heading;
    5650}
    5751
    58 double Coordinates::speed(bool& isNull) const
     52Optional<double> Coordinates::speed() const
    5953{
    60     if (m_canProvideSpeed)
    61         return m_speed;
    62 
    63     isNull = true;
    64     return 0;
     54    if (!m_canProvideSpeed)
     55        return Nullopt;
     56    return m_speed;
    6557}
    6658   
  • trunk/Source/WebCore/Modules/geolocation/Coordinates.h

    r177733 r192839  
    2828
    2929#include "Event.h"
     30#include <wtf/Optional.h>
    3031#include <wtf/RefCounted.h>
    3132
     
    4344    double latitude() const { return m_latitude; }
    4445    double longitude() const { return m_longitude; }
    45     double altitude(bool& isNull) const;
     46    Optional<double> altitude() const;
    4647    double accuracy() const { return m_accuracy; }
    47     double altitudeAccuracy(bool& isNull) const;
    48     double heading(bool& isNull) const;
    49     double speed(bool& isNull) const;
     48    Optional<double> altitudeAccuracy() const;
     49    Optional<double> heading() const;
     50    Optional<double> speed() const;
    5051   
    5152private:
  • trunk/Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.cpp

    r189746 r192839  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
     31#include "EventNames.h"
     32#include "IDBVersionChangeEventImpl.h"
     33
    3134namespace WebCore {
    3235
     
    3639}
    3740
     41Ref<IDBVersionChangeEvent> IDBVersionChangeEvent::create()
     42{
     43    // FIXME: This is called only by document.createEvent. I don't see how it's valuable to create an event with
     44    // read-only oldVersion attribute of 0 and newVersion of null; preserving that behavior for now.
     45    return IDBClient::IDBVersionChangeEvent::create(0, 0, eventNames().versionchangeEvent);
     46}
     47
    3848} // namespace WebCore
    3949
  • trunk/Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.h

    r192698 r192839  
    3030
    3131#include "Event.h"
    32 #include <wtf/PassRefPtr.h>
    33 #include <wtf/RefPtr.h>
    34 #include <wtf/text/WTFString.h>
     32#include <wtf/Optional.h>
    3533
    3634namespace WebCore {
     
    3836class IDBVersionChangeEvent : public Event {
    3937public:
    40     virtual ~IDBVersionChangeEvent() { }
     38    static Ref<IDBVersionChangeEvent> create();
    4139
    4240    virtual uint64_t oldVersion() const = 0;
    43     virtual uint64_t newVersion(bool& isNull) const = 0;
     41    virtual Optional<uint64_t> newVersion() const = 0;
    4442
    4543protected:
    46     IDBVersionChangeEvent(const AtomicString&);
     44    explicit IDBVersionChangeEvent(const AtomicString& type);
    4745};
    4846
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBVersionChangeEventImpl.cpp

    r192698 r192839  
    3939}
    4040
    41 uint64_t IDBVersionChangeEvent::newVersion(bool& isNull) const
     41Optional<uint64_t> IDBVersionChangeEvent::newVersion() const
    4242{
    43     isNull = !m_newVersion;
     43    if (!m_newVersion)
     44        return Nullopt;
    4445    return m_newVersion;
    4546}
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBVersionChangeEventImpl.h

    r192698 r192839  
    3434namespace IDBClient {
    3535
    36 class IDBVersionChangeEvent : public WebCore::IDBVersionChangeEvent {
     36class IDBVersionChangeEvent final : public WebCore::IDBVersionChangeEvent {
    3737public:
    38     static Ref<IDBVersionChangeEvent> create(uint64_t oldVersion = 0, uint64_t newVersion = 0, const AtomicString& eventType = AtomicString())
     38    static Ref<IDBVersionChangeEvent> create(uint64_t oldVersion, uint64_t newVersion, const AtomicString& eventType)
    3939    {
    4040        return adoptRef(*new IDBVersionChangeEvent(oldVersion, newVersion, eventType));
    4141    }
    4242
    43     virtual uint64_t oldVersion() const override final { return m_oldVersion; }
    44     virtual uint64_t newVersion(bool& isNull) const override final;
    45 
    46     virtual EventInterface eventInterface() const override final;
    47 
    4843private:
    4944    IDBVersionChangeEvent(uint64_t oldVersion, uint64_t newVersion, const AtomicString& eventType);
    5045
    51     uint64_t m_oldVersion { 0 };
    52     uint64_t m_newVersion { 0 };
     46    virtual uint64_t oldVersion() const override { return m_oldVersion; }
     47    virtual Optional<uint64_t> newVersion() const override;
     48    virtual EventInterface eventInterface() const override;
     49
     50    uint64_t m_oldVersion;
     51    uint64_t m_newVersion;
    5352};
    5453
  • trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyVersionChangeEvent.cpp

    r192698 r192839  
    3838}
    3939
    40 LegacyVersionChangeEvent::~LegacyVersionChangeEvent()
     40Optional<uint64_t> LegacyVersionChangeEvent::newVersion() const
    4141{
    42 }
    43 
    44 uint64_t LegacyVersionChangeEvent::newVersion(bool& isNull) const
    45 {
    46     isNull = false;
    4742    return m_newVersion;
    4843}
  • trunk/Source/WebCore/Modules/indexeddb/legacy/LegacyVersionChangeEvent.h

    r192698 r192839  
    3434namespace WebCore {
    3535
    36 class LegacyVersionChangeEvent : public IDBVersionChangeEvent {
     36class LegacyVersionChangeEvent final : public IDBVersionChangeEvent {
    3737public:
    38     static Ref<LegacyVersionChangeEvent> create(unsigned long long oldVersion = 0, unsigned long long newVersion = 0, const AtomicString& eventType = AtomicString())
     38    static Ref<LegacyVersionChangeEvent> create(unsigned long long oldVersion, unsigned long long newVersion, const AtomicString& eventType)
    3939    {
    4040        return adoptRef(*new LegacyVersionChangeEvent(oldVersion, newVersion, eventType));
    4141    }
    4242
    43     virtual ~LegacyVersionChangeEvent();
    44 
    45     virtual uint64_t oldVersion() const override final { return m_oldVersion; }
    46     virtual uint64_t newVersion(bool& isNull) const override final;
    47 
    48     virtual EventInterface eventInterface() const override final;
    49 
    5043private:
    5144    LegacyVersionChangeEvent(unsigned long long oldVersion, unsigned long long newVersion, const AtomicString& eventType);
     45
     46    virtual uint64_t oldVersion() const override { return m_oldVersion; }
     47    virtual Optional<uint64_t> newVersion() const override;
     48    virtual EventInterface eventInterface() const override;
    5249
    5350    uint64_t m_oldVersion;
  • trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp

    r190030 r192839  
    4949}
    5050
    51 Vector<PassRefPtr<MediaTrackConstraint>> MediaTrackConstraints::optional(bool) const
     51Vector<PassRefPtr<MediaTrackConstraint>> MediaTrackConstraints::optional() const
    5252{
    5353    // https://bugs.webkit.org/show_bug.cgi?id=121954
  • trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.h

    r190030 r192839  
    4545    static Ref<MediaTrackConstraints> create(PassRefPtr<MediaConstraintsImpl>);
    4646
    47     Vector<PassRefPtr<MediaTrackConstraint>> optional(bool) const;
     47    Vector<PassRefPtr<MediaTrackConstraint>> optional() const;
    4848    MediaTrackConstraintSet* mandatory() const;
    4949
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r191543 r192839  
    5252#include <wtf/Vector.h>
    5353
     54// FIXME: We could make this file a lot easier to read by putting all function declarations at the top,
     55// and function definitions below, even for template and inline functions.
     56
    5457namespace JSC {
    5558class HashEntry;
     
    284287
    285288JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode);
     289
    286290// Convert a DOM implementation exception code into a JavaScript exception in the execution state.
    287291WEBCORE_EXPORT void setDOMException(JSC::ExecState*, ExceptionCode);
     
    305309String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
    306310String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
     311
     312template<typename T> JSC::JSValue toNullableJSNumber(Optional<T>); // null if the optional is null
    307313
    308314inline int32_t finiteInt32Value(JSC::JSValue value, JSC::ExecState* exec, bool& okay)
     
    351357WEBCORE_EXPORT uint64_t toUInt64(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
    352358
    353 // Returns a Date instnace for the specified value, or NaN if the date is not a number.
     359// Returns a Date instance for the specified value, or NaN if the date is not a number.
    354360JSC::JSValue jsDateOrNaN(JSC::ExecState*, double);
     361
    355362// Returns a Date instance for the specified value, or null if the value is NaN or infinity.
    356363JSC::JSValue jsDateOrNull(JSC::ExecState*, double);
     364
    357365// NaN if the value can't be converted to a date.
    358366double valueToDate(JSC::ExecState*, JSC::JSValue);
     
    686694    JSC::JSObject::put(&object, &exec, JSC::Identifier::fromString(&exec, name), value, propertySlot);
    687695}
    688    
     696
     697template<typename T> inline JSC::JSValue toNullableJSNumber(Optional<T> optionalNumber)
     698{
     699    return optionalNumber ? JSC::jsNumber(optionalNumber.value()) : JSC::jsNull();
     700}
     701
    689702} // namespace WebCore
    690703
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

    r191841 r192839  
    576576    push(@txtGetProps, "    case ${propEnum}:\n");
    577577
    578     # FIXME: Should we return a default value when isNull == true?
    579 
    580578    my $postConvertFunction = "";
    581579    if ($gtype eq "string") {
     
    12401238        } else {
    12411239            $assign = "${returnType} result = ";
     1240            if ($function->signature->isNullable) {
     1241                # FIXME: Returning 0 is probably not right for all nullable attribute values.
     1242                # We may want to handle this the way we do in the Objective-C bindings: not
     1243                # handle it at all, and not expose any nullables.
     1244                $assignPost = ".valueOr(0)";
     1245            }
    12421246        }
    12431247
     
    12461250            $assignPost = "->toString())";
    12471251        }
    1248     }
    1249 
    1250     # FIXME: Should we return a default value when isNull == true?
    1251     if ($function->signature->isNullable) {
    1252         push(@cBody, "    bool isNull = false;\n");
    1253         push(@callImplParams, "isNull");
    12541252    }
    12551253
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r192750 r192839  
    22792279            my $name = $attribute->signature->name;
    22802280            my $type = $attribute->signature->type;
    2281             # Nullable wrapper types do not need any special handling as the implementation can return a null pointer.
    2282             my $isNullable = $attribute->signature->isNullable && !$codeGenerator->IsWrapperType($type);
    22832281            $codeGenerator->AssertNotSequenceType($type);
    22842282            my $getFunctionName = GetAttributeGetterName($interfaceName, $className, $interface, $attribute);
     
    24122410                }
    24132411            } elsif (!$attribute->signature->extendedAttributes->{"GetterRaisesException"}) {
    2414                 push(@implContent, "    bool isNull = false;\n") if $isNullable;
    2415 
    24162412                my $cacheIndex = 0;
    24172413                if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
     
    24362432                } else {
    24372433                    my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
    2438                     push(@arguments, "isNull") if $isNullable;
    24392434                    if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    24402435                        my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
     
    24572452                        push(@implContent, "    JSValue result = $jsType;\n");
    24582453                    }
    2459 
    2460                     if ($isNullable) {
    2461                         push(@implContent, "    if (isNull)\n");
    2462                         push(@implContent, "        return JSValue::encode(jsNull());\n");
    2463                     }
    24642454                }
    24652455
     
    24682458
    24692459            } else {
    2470                 if ($isNullable) {
    2471                     push(@implContent, "    bool isNull = false;\n");
    2472                     unshift(@arguments, "isNull");
    2473                 }
    2474 
    24752460                unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "JSValue::encode(jsUndefined())"));
    24762461
     
    24842469
    24852470                push(@implContent, "    setDOMException(state, ec);\n");
    2486 
    2487                 if ($isNullable) {
    2488                     push(@implContent, "    if (isNull)\n");
    2489                     push(@implContent, "        return JSValue::encode(jsNull());\n");
    2490                 }
    24912471
    24922472                push(@implContent, "    return JSValue::encode(result);\n");
     
    41624142    }
    41634143
    4164     if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) {
    4165         $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
    4166         return "jsNumber(std::max(0, " . $value . "))";
    4167     }
    4168 
    41694144    if ($codeGenerator->IsPrimitiveType($type) or $type eq "DOMTimeStamp") {
    4170         return "jsNumber($value)";
     4145        # We could instead overload a function to work with optional as well as non-optional numbers, but this
     4146        # is slightly better because it guarantees we will fail to compile if the IDL file doesn't match the C++.
     4147        my $function = $signature->isNullable ? "toNullableJSNumber" : "jsNumber";
     4148        if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) {
     4149            $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
     4150            return "$function(std::max(0, " . $value . "))";
     4151        }
     4152        return "$function($value)";
    41714153    }
    41724154
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm

    r192750 r192839  
    106106# Constants
    107107my $shouldUseCGColor = defined $ENV{PLATFORM_NAME} && $ENV{PLATFORM_NAME} ne "macosx";
    108 my $nullableInit = "bool isNull = false;";
    109108my $exceptionInit = "WebCore::ExceptionCode ec = 0;";
    110109my $jsContextSetter = "WebCore::JSMainThreadNullState state;";
     
    13611360            }
    13621361
     1362            # It would be easy to add nullable support here if we ever need it, but we probably never
     1363            # will since we are unlikely to add Objective-C bindings that require it in the future.
     1364            # In particular, we'd have to decide what return type to use for "number or null".
     1365
    13631366            my $getterContent;
    1364             if ($hasGetterException || $attribute->signature->isNullable) {
     1367            if ($hasGetterException) {
    13651368                $getterContent = $getterContentHead;
    13661369                my $getterWithoutAttributes = $getterContentHead =~ /\($|, $/ ? "ec" : ", ec";
    1367                 if ($attribute->signature->isNullable) {
    1368                     $getterContent .= $getterWithoutAttributes ? "isNull" : ", isNull";
    1369                     $getterWithoutAttributes = 0;
    1370                 }
    13711370                if ($hasGetterException) {
    13721371                    $getterContent .= $getterWithoutAttributes ? "ec" : ", ec";
     
    13831382            push(@implContent, "    $jsContextSetter\n");
    13841383            push(@implContent, @customGetterContent);
    1385 
    1386             # FIXME: Should we return a default value when isNull == true?
    1387             if ($attribute->signature->isNullable) {
    1388                 push(@implContents, "    $nullableInit\n");
    1389             }
    13901384
    13911385            if ($hasGetterException) {
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r190039 r192839  
    24162416    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
    24172417    WebCore::TestObj* item = WebKit::core(self);
    2418     bool isNull = false;
    2419     gdouble result = item->nullableDoubleAttribute(isNull);
     2418    gdouble result = item->nullableDoubleAttribute().valueOr(0);
    24202419    return result;
    24212420}
     
    24262425    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
    24272426    WebCore::TestObj* item = WebKit::core(self);
    2428     bool isNull = false;
    2429     glong result = item->nullableLongAttribute(isNull);
     2427    glong result = item->nullableLongAttribute().valueOr(0);
    24302428    return result;
    24312429}
     
    24362434    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), FALSE);
    24372435    WebCore::TestObj* item = WebKit::core(self);
    2438     bool isNull = false;
    2439     gboolean result = item->nullableBooleanAttribute(isNull);
     2436    gboolean result = item->nullableBooleanAttribute().valueOr(0);
    24402437    return result;
    24412438}
     
    24462443    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
    24472444    WebCore::TestObj* item = WebKit::core(self);
    2448     bool isNull = false;
    2449     gchar* result = convertToUTF8String(item->nullableStringAttribute(isNull));
     2445    gchar* result = convertToUTF8String(item->nullableStringAttribute());
    24502446    return result;
    24512447}
     
    24562452    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
    24572453    WebCore::TestObj* item = WebKit::core(self);
    2458     bool isNull = false;
    2459     glong result = item->nullableLongSettableAttribute(isNull);
     2454    glong result = item->nullableLongSettableAttribute().valueOr(0);
    24602455    return result;
    24612456}
     
    24752470    g_return_val_if_fail(!error || !*error, 0);
    24762471    WebCore::TestObj* item = WebKit::core(self);
    2477     bool isNull = false;
    24782472    WebCore::ExceptionCode ec = 0;
    2479     glong result = item->nullableStringValue(isNull, ec);
     2473    glong result = item->nullableStringValue(ec).valueOr(0);
    24802474    if (ec) {
    24812475        WebCore::ExceptionCodeDescription ecdesc(ec);
     
    25162510    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
    25172511    WebCore::TestObj* item = WebKit::core(self);
    2518     bool isNull = false;
    2519     RefPtr<WebCore::TestNode> gobjectResult = WTF::getPtr(item->putForwardsNullableAttribute(isNull));
     2512    RefPtr<WebCore::TestNode> gobjectResult = WTF::getPtr(item->putForwardsNullableAttribute());
    25202513    return WebKit::kit(gobjectResult.get());
    25212514}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r191887 r192839  
    18251825        return throwGetterTypeError(*state, "TestObj", "nullableDoubleAttribute");
    18261826    }
    1827     bool isNull = false;
    1828     auto& impl = castedThis->wrapped();
    1829     JSValue result = jsNumber(impl.nullableDoubleAttribute(isNull));
    1830     if (isNull)
    1831         return JSValue::encode(jsNull());
     1827    auto& impl = castedThis->wrapped();
     1828    JSValue result = toNullableJSNumber(impl.nullableDoubleAttribute());
    18321829    return JSValue::encode(result);
    18331830}
     
    18451842        return throwGetterTypeError(*state, "TestObj", "nullableLongAttribute");
    18461843    }
    1847     bool isNull = false;
    1848     auto& impl = castedThis->wrapped();
    1849     JSValue result = jsNumber(impl.nullableLongAttribute(isNull));
    1850     if (isNull)
    1851         return JSValue::encode(jsNull());
     1844    auto& impl = castedThis->wrapped();
     1845    JSValue result = toNullableJSNumber(impl.nullableLongAttribute());
    18521846    return JSValue::encode(result);
    18531847}
     
    18651859        return throwGetterTypeError(*state, "TestObj", "nullableBooleanAttribute");
    18661860    }
    1867     bool isNull = false;
    1868     auto& impl = castedThis->wrapped();
    1869     JSValue result = jsBoolean(impl.nullableBooleanAttribute(isNull));
    1870     if (isNull)
    1871         return JSValue::encode(jsNull());
     1861    auto& impl = castedThis->wrapped();
     1862    JSValue result = jsBoolean(impl.nullableBooleanAttribute());
    18721863    return JSValue::encode(result);
    18731864}
     
    18851876        return throwGetterTypeError(*state, "TestObj", "nullableStringAttribute");
    18861877    }
    1887     bool isNull = false;
    1888     auto& impl = castedThis->wrapped();
    1889     JSValue result = jsStringWithCache(state, impl.nullableStringAttribute(isNull));
    1890     if (isNull)
    1891         return JSValue::encode(jsNull());
     1878    auto& impl = castedThis->wrapped();
     1879    JSValue result = jsStringWithCache(state, impl.nullableStringAttribute());
    18921880    return JSValue::encode(result);
    18931881}
     
    19051893        return throwGetterTypeError(*state, "TestObj", "nullableLongSettableAttribute");
    19061894    }
    1907     bool isNull = false;
    1908     auto& impl = castedThis->wrapped();
    1909     JSValue result = jsNumber(impl.nullableLongSettableAttribute(isNull));
    1910     if (isNull)
    1911         return JSValue::encode(jsNull());
     1895    auto& impl = castedThis->wrapped();
     1896    JSValue result = toNullableJSNumber(impl.nullableLongSettableAttribute());
    19121897    return JSValue::encode(result);
    19131898}
     
    19261911    }
    19271912    ExceptionCode ec = 0;
    1928     bool isNull = false;
    1929     auto& impl = castedThis->wrapped();
    1930     JSValue result = jsNumber(impl.nullableStringValue(isNull, ec));
     1913    auto& impl = castedThis->wrapped();
     1914    JSValue result = toNullableJSNumber(impl.nullableStringValue(ec));
    19311915    setDOMException(state, ec);
    1932     if (isNull)
    1933         return JSValue::encode(jsNull());
    19341916    return JSValue::encode(result);
    19351917}
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

    r190620 r192839  
    801801{
    802802    WebCore::JSMainThreadNullState state;
    803     return IMPL->nullableDoubleAttribute(isNull);
     803    return IMPL->nullableDoubleAttribute();
    804804}
    805805
     
    807807{
    808808    WebCore::JSMainThreadNullState state;
    809     return IMPL->nullableLongAttribute(isNull);
     809    return IMPL->nullableLongAttribute();
    810810}
    811811
     
    813813{
    814814    WebCore::JSMainThreadNullState state;
    815     return IMPL->nullableBooleanAttribute(isNull);
     815    return IMPL->nullableBooleanAttribute();
    816816}
    817817
     
    819819{
    820820    WebCore::JSMainThreadNullState state;
    821     return IMPL->nullableStringAttribute(isNull);
     821    return IMPL->nullableStringAttribute();
    822822}
    823823
     
    825825{
    826826    WebCore::JSMainThreadNullState state;
    827     return IMPL->nullableLongSettableAttribute(isNull);
     827    return IMPL->nullableLongSettableAttribute();
    828828}
    829829
     
    838838    WebCore::JSMainThreadNullState state;
    839839    WebCore::ExceptionCode ec = 0;
    840     int result = IMPL->nullableStringValue(isNull, ec);
     840    int result = IMPL->nullableStringValue(ec);
    841841    WebCore::raiseOnDOMError(ec);
    842842    return result;
     
    864864{
    865865    WebCore::JSMainThreadNullState state;
    866     return kit(WTF::getPtr(IMPL->putForwardsNullableAttribute(isNull)));
     866    return kit(WTF::getPtr(IMPL->putForwardsNullableAttribute()));
    867867}
    868868
Note: See TracChangeset for help on using the changeset viewer.