Skip to content

Add a getter and setter for booleans in JSON#6682

Merged
dlang-bot merged 1 commit intodlang:masterfrom
Erikvv:feature/json-boolean-getter-setter
Aug 28, 2018
Merged

Add a getter and setter for booleans in JSON#6682
dlang-bot merged 1 commit intodlang:masterfrom
Erikvv:feature/json-boolean-getter-setter

Conversation

@Erikvv
Copy link
Contributor

@Erikvv Erikvv commented Aug 26, 2018

Works the same as integer, floating etc.

Seems obvious you need this to use the module in any real-world usage.

@Erikvv Erikvv requested a review from CyberShadow as a code owner August 26, 2018 23:35
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @Erikvv! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + phobos#6682"

Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your pull request looks good to me, modulo some minor comments about the documentation:

std/json.d Outdated
}

/***
* Value getter/setter for boolean stored in JSON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing full stop at the end of the sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

std/json.d Outdated
/***
* Value getter/setter for boolean stored in JSON
* Throws: `JSONException` for read access if `this.type` is not
* `JSONType.true_` or `false_`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer spelling out the full name:

`JSONType.true_` or `JSONType.false_`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I find the comment has too much implementation details but it's the same in the rest of the module.

@PetarKirov
Copy link
Member

Since this adds a new public symbol, @andralex will need to sign off on this PR before it can be merged. On the other hand the newly added @property is done analogously to the other ones so process should be straightforward.

Copy link
Member

@CyberShadow CyberShadow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too, looks like a no-brainer.

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting change of signature. Otherwise I'm fine with the addition.

std/json.d Outdated
* Throws: `JSONException` for read access if `this.type` is not
* `JSONType.true_` or `JSONType.false_`.
*/
@property inout(bool) boolean() inout pure @safe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why inout? This should suffice: @property bool boolean() const pure @safe. That ensures no surprise with functions that initialize an auto with the result of the call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right I changed it to const. I'll make another PR to change the other getters as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std/json.d Outdated
return false;
default:
throw new JSONException("JSONValue is not a boolean type");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A three-branch switch seems a bit much to me.

if (type == JSONType.true_) return true;
if (type == JSONType.false_) return false;
throw ...

But... six vs. half a dozen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@PetarKirov PetarKirov dismissed andralex’s stale review August 28, 2018 08:05

Requested changes were made.

@dlang-bot dlang-bot merged commit 3e3c65d into dlang:master Aug 28, 2018
n8sh added a commit to n8sh/phobos that referenced this pull request May 24, 2019
…loat

Fixes Issue 19899 - std.bitmanip.bitsSet should accept const arguments

This also makes `swapEndian` not propagate `const` to its return value
which is arguably an improvement
(see dlang#6682 (comment)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants