Commit Graph

10 Commits

Author SHA1 Message Date
Ewout van Bekkum
f89f1379d4 pw_string: redo pw::string::Length
Moves and renames the existing pw::string::Length to
pw::string::internal::ClampedLength. Instead two new helpers are added:
1) pw::string::NullTerminatedLength(...) which returns the length IFF
   the string is null terminated.
2) pw::string::ClampedCString(...) which returns a string_view of
   the clamped string. This is considered safer compared to strnlen_s
   and the existing internal::ClampedLength implementation, since
   sting_view does not require null termination.

Change-Id: Ie6486df13b205332633f3970109ca97f578e6993
Requires: pigweed-internal:12460
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/43463
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
2021-05-13 16:27:34 +00:00
Wyatt Hepler
4298fd053e pw_assert: Remove the deprecated light.h header
Bug: 350
Change-Id: I35f37a3d102eb96dde2e8bf0a92acffc52153711
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/38741
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2021-04-30 04:19:47 +00:00
Ewout van Bekkum
3a260a20be pw_result: add PW_TRY_ASSIGN support
Adds PW_TRY_ASSIGN to pw::Result<T>.

Change-Id: I7cc73c14f7f36bc048098abd17f543b8ddf252af
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/41900
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
2021-04-21 20:15:03 +00:00
Wyatt Hepler
d49f8fe3f3 BUILD.gn files: Improve import formatting
The "# gn-format disable" comments are no longer necessary. Delete these
comments and reformat with a Vim macro and gn format.

Change-Id: Ia62c40ad73eef91187d0d443d6e3b0fa723e5aa9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21380
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-15 18:12:55 +00:00
Alexei Frolov
de3c2a1fac pw_result: Add some size reports
This adds some simple size reports to the result module to provide some
data on how it compares to traditional function prototypes.

Change-Id: I711fa5d04ff5720ed3184b6250f3993606bd34ec
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/17162
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
2020-09-02 18:29:10 +00:00
Ewout van Bekkum
d418968d67 pw_result: resolve TODOs by adding asserts
Resolves the two existing TODOs by using pw_assert's check macros.

Change-Id: Id9abc1086293fa57c96343975175143ee2772c03
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/14644
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
2020-07-24 20:40:16 +00:00
Armando Montanez
82bbce4aeb Remove legacy_target.gni
Transition to args is done, so this import is no longer needed.

Change-Id: Id42e06ec9fcc16eace2cc7ef51a5dacaf012147a
2020-06-16 09:50:59 -07:00
Armando Montanez
fb3d3fba79 Don't declare pigweed variables as globals
Require targets to explicitly import pigweed variable definitions. This
moves out some necessary logic from the BUILDCONFIG.gn file.

Change-Id: If9c9fe5a680cc9d897a0e8a55889873be618ed84
2020-06-16 09:50:59 -07:00
Alexei Frolov
edd2f148be pw_build: Switch to pw_* target types
This change replaces the implicit overrides of the default GN target
types in BUILDCONFIG.gn with explicit pw_* versions. This is done to
allow Pigweed to build within larger GN projects without modifying their
BUILDCONFIG files.

Change-Id: I1d1e41d5e9bde8fe076f7031f3c2b98b9630ff70
2020-06-16 09:50:59 -07:00
Alexei Frolov
41b32d3e07 pw_result: Add experimental result module
The pw_result module defines a Result type which stores a Status
alongside some data. It is provided as a convenient way to return a
value and a status together, without requiring an "out" pointer.

Change-Id: Ibb630c7167faf6832e2b5e943220250ac820604e
2020-03-20 21:01:37 +00:00