Skip to content

Commit 2f951ac

Browse files
committed
check_
1 parent 3de152e commit 2f951ac

108 files changed

Lines changed: 403 additions & 351 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/geode/basic/algorithm.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ namespace geode
5656
index_t delete_vector_elements(
5757
const DeleteContainer& to_delete, ValueContainer& values )
5858
{
59-
OpenGeodeBasicException::assertion( to_delete.size() == values.size(),
59+
OpenGeodeBasicException::check_assertion(
60+
to_delete.size() == values.size(),
6061
"[delete_vector_elements] Number of elements in the two vectors "
6162
"should match" );
6263
const auto first_true = absl::c_find( to_delete, true );
@@ -92,7 +93,8 @@ namespace geode
9293
[[nodiscard]] ValueContainer extract_vector_elements(
9394
const DeleteContainer& to_keep, const ValueContainer& in_values )
9495
{
95-
OpenGeodeBasicException::assertion( to_keep.size() == in_values.size(),
96+
OpenGeodeBasicException::check_assertion(
97+
to_keep.size() == in_values.size(),
9698
"[extract_vector_elements] Number of elements in the two vectors "
9799
"should match" );
98100
const auto nb_to_keep =

include/geode/basic/attribute_manager.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace geode
7979
auto attribute =
8080
std::dynamic_pointer_cast< ReadOnlyAttribute< T > >(
8181
find_attribute_base( name ) );
82-
OpenGeodeBasicException::check( attribute.get(), nullptr,
82+
OpenGeodeBasicException::check_exception( attribute.get(), nullptr,
8383
OpenGeodeException::TYPE::data,
8484
"[AttributeManager::find_attribute] Could not find attribute '",
8585
name,
@@ -129,8 +129,8 @@ namespace geode
129129
{
130130
return typed_attribute;
131131
}
132-
OpenGeodeBasicException::check( attribute.use_count() < 2, nullptr,
133-
OpenGeodeException::TYPE::internal,
132+
OpenGeodeBasicException::check_exception( attribute.use_count() < 2,
133+
nullptr, OpenGeodeException::TYPE::internal,
134134
"[AttributeManager::find_or_create_attribute] Do not "
135135
"instantiate an attribute "
136136
"if an instantiated attribute of the same name "

include/geode/basic/attribute_utils.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ namespace geode
115115
absl::Span< const double > lambdas )
116116
: indices_( indices.size() ), lambdas_( lambdas.size() )
117117
{
118-
OpenGeodeBasicException::check( indices_.size() == lambdas_.size(),
119-
nullptr, OpenGeodeException::TYPE::data,
118+
OpenGeodeBasicException::check_exception(
119+
indices_.size() == lambdas_.size(), nullptr,
120+
OpenGeodeException::TYPE::data,
120121
"[AttributeLinearInterpolation] Both arrays should have the "
121122
"same size" );
122123
for( const auto index : Indices{ indices } )
@@ -299,7 +300,7 @@ namespace geode
299300
[[nodiscard]] static float converted_item_value( \
300301
const Container& value, local_index_t item ) \
301302
{ \
302-
OpenGeodeBasicException::assertion( item < nb_items(), \
303+
OpenGeodeBasicException::check_assertion( item < nb_items(), \
303304
"[GenericAttributeConversion] Accessing " \
304305
"incorrect item value" ); \
305306
return static_cast< float >( value[item] ); \

include/geode/basic/detail/geode_input_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ namespace geode::detail
4343
filename = absl::StripAsciiWhitespace( filename );
4444
const auto extension =
4545
absl::AsciiStrToLower( extension_from_filename( filename ) );
46-
OpenGeodeBasicException::check( Factory::has_creator( extension ),
47-
nullptr, OpenGeodeException::TYPE::data,
48-
"Unknown extension: ", extension );
46+
OpenGeodeBasicException::check_exception(
47+
Factory::has_creator( extension ), nullptr,
48+
OpenGeodeException::TYPE::data, "Unknown extension: ", extension );
4949
return Factory::create(
5050
extension, expand_predefined_folders( filename ) );
5151
}

include/geode/basic/detail/geode_output_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ namespace geode::detail
4444
filename = absl::StripAsciiWhitespace( filename );
4545
const auto extension =
4646
absl::AsciiStrToLower( extension_from_filename( filename ) );
47-
OpenGeodeBasicException::check( Factory::has_creator( extension ),
48-
nullptr, OpenGeodeException::TYPE::data,
49-
"Unknown extension: ", extension );
47+
OpenGeodeBasicException::check_exception(
48+
Factory::has_creator( extension ), nullptr,
49+
OpenGeodeException::TYPE::data, "Unknown extension: ", extension );
5050
return Factory::create(
5151
extension, expand_predefined_folders( filename ) );
5252
}

include/geode/basic/factory.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ namespace geode
9292
{
9393
const auto &store = get_store();
9494
const auto creator = store.find( key );
95-
OpenGeodeBasicException::check( creator != store.end(), nullptr,
96-
OpenGeodeException::TYPE::data,
95+
OpenGeodeBasicException::check_exception( creator != store.end(),
96+
nullptr, OpenGeodeException::TYPE::data,
9797
"[Factory::create] Factory does not "
9898
"contain the requested key" );
9999
return creator->second( std::forward< Args >( args )... );

include/geode/basic/internal/array_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace geode::internal
5454
[[nodiscard]] CellIndices cell_indices(
5555
const CellArray< dimension >& array, index_t index ) const
5656
{
57-
OpenGeodeBasicException::assertion( index < array.nb_cells(),
57+
OpenGeodeBasicException::check_assertion( index < array.nb_cells(),
5858
"[CellArray::cell_index] Invalid index" );
5959
CellIndices cell_id;
6060
for( const auto d : LRange{ dimension } )

include/geode/basic/library.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace geode
8585
} \
8686
\
8787
template < typename DataProvider, typename... Args > \
88-
static void check_impl( bool condition, \
88+
static void exception( bool condition, \
8989
DataProvider&& data_provider, \
9090
TYPE type, \
9191
const Args&... message ) \
@@ -98,8 +98,7 @@ namespace geode
9898
} \
9999
\
100100
template < typename Condition, typename... Args > \
101-
static void assertion_impl( \
102-
Condition&& condition, const Args&... message ) \
101+
static void assertion( Condition&& condition, const Args&... message ) \
103102
{ \
104103
if constexpr( is_debug_build ) \
105104
{ \
@@ -124,15 +123,15 @@ namespace geode
124123
} \
125124
}
126125

127-
#define assertion( condition, ... ) \
128-
assertion_impl( \
126+
#define check_assertion( condition, ... ) \
127+
assertion( \
129128
[&] { \
130129
return ( condition ); \
131130
}, \
132131
__VA_ARGS__ )
133132

134-
#define check( condition, data, ... ) \
135-
check_impl( ( condition ), \
133+
#define check_exception( condition, data, ... ) \
134+
exception( ( condition ), \
136135
[&]() -> std::any { \
137136
return ( data ); \
138137
}, \

include/geode/basic/range.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ namespace geode
8888
const auto unsined_begin = static_cast< T1U >( begin );
8989
const auto unsined_end = static_cast< T2U >( end );
9090
const auto max = std::numeric_limits< Type >::max();
91-
OpenGeodeBasicException::assertion( unsined_begin <= max,
91+
OpenGeodeBasicException::check_assertion( unsined_begin <= max,
9292
"[Range] Invalid range: ", begin, " > ", max );
93-
OpenGeodeBasicException::assertion( unsined_end <= max,
93+
OpenGeodeBasicException::check_assertion( unsined_end <= max,
9494
"[Range] Invalid range: ", end, " > ", max );
9595
}
9696
}

include/geode/basic/sparse_attribute.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ namespace geode
224224
const auto new_index = old2new[i];
225225
if( value( i ) != default_value_ && new_index != NO_ID )
226226
{
227-
OpenGeodeBasicException::check( new_index < nb_elements,
228-
nullptr, OpenGeodeException::TYPE::data,
227+
OpenGeodeBasicException::check_exception(
228+
new_index < nb_elements, nullptr,
229+
OpenGeodeException::TYPE::data,
229230
"[SparseAttribute::extract] The given mapping "
230231
"contains values that go beyond the given number of "
231232
"elements." );
@@ -249,8 +250,9 @@ namespace geode
249250
{
250251
for( const auto new_index : outs )
251252
{
252-
OpenGeodeBasicException::check( new_index < nb_elements,
253-
nullptr, OpenGeodeException::TYPE::data,
253+
OpenGeodeBasicException::check_exception(
254+
new_index < nb_elements, nullptr,
255+
OpenGeodeException::TYPE::data,
254256
"[SparseAttribute::extract] The given mapping "
255257
"contains values that go beyond the given number "
256258
"of elements." );

0 commit comments

Comments
 (0)