Update the initial repository to use the correct indentation style.

This commit is contained in:
Robert Maynard 2014-02-11 16:20:30 -05:00
parent 262f07c9b0
commit c80fb9259f
38 changed files with 1106 additions and 991 deletions

@ -57,7 +57,8 @@ template<typename T> struct TypeTraits;
/// override behavior of called functions.
///
template<typename T>
class TypeTraits {
class TypeTraits
{
typedef int tag_type; // Shut up, test compile.
public:
@ -82,16 +83,16 @@ struct TypeTraits<const T> : TypeTraits<T>
{ };
#define VTKM_BASIC_REAL_TYPE(T) \
template<> struct TypeTraits<T> { \
template<> struct TypeTraits<T> { \
typedef TypeTraitsRealTag NumericTag; \
typedef TypeTraitsScalarTag DimensionalityTag; \
}
}
#define VTKM_BASIC_INTEGER_TYPE(T) \
template<> struct TypeTraits<T> { \
template<> struct TypeTraits<T> { \
typedef TypeTraitsIntegerTag NumericTag; \
typedef TypeTraitsScalarTag DimensionalityTag; \
}
}
/// Traits for basic C++ types.
///
@ -118,10 +119,10 @@ VTKM_BASIC_INTEGER_TYPE(unsigned long long);
#undef VTKM_BASIC_INTEGER_TYPE
#define VTKM_VECTOR_TYPE(T, NTag) \
template<> struct TypeTraits<T> { \
template<> struct TypeTraits<T> { \
typedef NTag NumericTag; \
typedef TypeTraitsVectorTag DimensionalityTag; \
}
}
/// Traits for vector types.
///
@ -135,7 +136,8 @@ VTKM_VECTOR_TYPE(vtkm::Vector4, TypeTraitsRealTag);
/// Traits for tuples.
///
template<typename T, int Size> struct TypeTraits<vtkm::Tuple<T, Size> > {
template<typename T, int Size> struct TypeTraits<vtkm::Tuple<T, Size> >
{
typedef typename TypeTraits<T>::NumericTag NumericTag;
typedef TypeTraitsVectorTag DimensionalityTag;
};

@ -79,8 +79,7 @@
*
*/
namespace vtkm
{
namespace vtkm {
//*****************************************************************************
// Typedefs for basic types.
//*****************************************************************************
@ -179,7 +178,8 @@ struct assign_scalar_to_vector<2>
VTKM_EXEC_CONT_EXPORT
void operator()(VectorType &dest, const ComponentType &src)
{
dest[0] = src; dest[1] = src;
dest[0] = src;
dest[1] = src;
}
};
@ -190,7 +190,9 @@ struct assign_scalar_to_vector<3>
VTKM_EXEC_CONT_EXPORT
void operator()(VectorType &dest, const ComponentType &src)
{
dest[0] = src; dest[1] = src; dest[2] = src;
dest[0] = src;
dest[1] = src;
dest[2] = src;
}
};
@ -221,7 +223,8 @@ struct copy_vector<2>
template<typename T1, typename T2>
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
{
dest[0] = src[0]; dest[1] = src[1];
dest[0] = src[0];
dest[1] = src[1];
}
};
@ -231,7 +234,9 @@ struct copy_vector<3>
template<typename T1, typename T2>
VTKM_EXEC_CONT_EXPORT void operator()(T1 &dest, const T2 &src)
{
dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2];
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
}
};
@ -270,22 +275,23 @@ typedef float Scalar __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
/// Tuple corresponds to a Size-tuple of type T
template<typename T, int Size>
class Tuple {
class Tuple
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS=Size;
VTKM_EXEC_CONT_EXPORT Tuple(){}
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
{
for(int i=0; i < NUM_COMPONENTS;++i)
for(int i=0; i < NUM_COMPONENTS; ++i)
{
this->Components[i]=value;
}
}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType* values)
{
for(int i=0; i < NUM_COMPONENTS;++i)
for(int i=0; i < NUM_COMPONENTS; ++i)
{
this->Components[i]=values[i];
}
@ -309,10 +315,12 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
{
return this->Components[idx];
}
@ -334,9 +342,9 @@ public:
{
//ignore equals as that represents check next value
if(this->Components[i] < other[i])
return true;
{ return true; }
else if(other[i] < this->Components[i])
return false;
{ return false; }
} //if all same we are not less
return false;
}
@ -355,12 +363,13 @@ protected:
// Specializations for common tuple sizes (with special names).
template<typename T>
class Tuple<T,2>{
class Tuple<T,2>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 2;
VTKM_EXEC_CONT_EXPORT Tuple(){}
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
{
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
@ -369,7 +378,8 @@ public:
{
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
}
VTKM_EXEC_CONT_EXPORT Tuple(ComponentType x, ComponentType y) {
VTKM_EXEC_CONT_EXPORT Tuple(ComponentType x, ComponentType y)
{
this->Components[0] = x;
this->Components[1] = y;
}
@ -387,10 +397,12 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
{
return this->Components[idx];
}
@ -426,12 +438,13 @@ typedef vtkm::Tuple<vtkm::Scalar,2>
typedef vtkm::Tuple<vtkm::Id,2> Id2 __attribute__ ((aligned(VTKM_SIZE_ID)));
template<typename T>
class Tuple<T,3>{
class Tuple<T,3>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 3;
VTKM_EXEC_CONT_EXPORT Tuple(){}
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
{
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
@ -441,7 +454,8 @@ public:
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
}
VTKM_EXEC_CONT_EXPORT
Tuple(ComponentType x, ComponentType y, ComponentType z) {
Tuple(ComponentType x, ComponentType y, ComponentType z)
{
this->Components[0] = x;
this->Components[1] = y;
this->Components[2] = z;
@ -460,10 +474,12 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
{
return this->Components[idx];
}
@ -498,12 +514,13 @@ typedef vtkm::Tuple<vtkm::Scalar,3>
Vector3 __attribute__ ((aligned(VTKM_SIZE_SCALAR)));
template<typename T>
class Tuple<T,4>{
class Tuple<T,4>
{
public:
typedef T ComponentType;
static const int NUM_COMPONENTS = 4;
VTKM_EXEC_CONT_EXPORT Tuple(){}
VTKM_EXEC_CONT_EXPORT Tuple() {}
VTKM_EXEC_CONT_EXPORT explicit Tuple(const ComponentType& value)
{
internal::assign_scalar_to_vector<NUM_COMPONENTS>()(this->Components,value);
@ -513,7 +530,8 @@ public:
internal::copy_vector<NUM_COMPONENTS>()(this->Components, values);
}
VTKM_EXEC_CONT_EXPORT
Tuple(ComponentType x, ComponentType y, ComponentType z, ComponentType w) {
Tuple(ComponentType x, ComponentType y, ComponentType z, ComponentType w)
{
this->Components[0] = x;
this->Components[1] = y;
this->Components[2] = z;
@ -533,10 +551,12 @@ public:
return *this;
}
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const {
VTKM_EXEC_CONT_EXPORT const ComponentType &operator[](int idx) const
{
return this->Components[idx];
}
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx) {
VTKM_EXEC_CONT_EXPORT ComponentType &operator[](int idx)
{
return this->Components[idx];
}

@ -38,12 +38,14 @@ struct VectorTraitsTagSingleComponent { };
namespace internal {
template<int numComponents>
struct VectorTraitsMultipleComponentChooser {
struct VectorTraitsMultipleComponentChooser
{
typedef VectorTraitsTagMultipleComponents Type;
};
template<>
struct VectorTraitsMultipleComponentChooser<1> {
struct VectorTraitsMultipleComponentChooser<1>
{
typedef VectorTraitsTagSingleComponent Type;
};

@ -44,7 +44,8 @@ namespace cont {
/// and environment do not share memory. This is wasteful and should be fixed.
///
template<class ArrayPortalType>
struct ArrayContainerControlTagImplicit {
struct ArrayContainerControlTagImplicit
{
typedef ArrayPortalType PortalType;
};
@ -61,16 +62,19 @@ public:
// This is meant to be invalid. Because implicit arrays are read only, you
// should only be able to use the const version.
struct PortalType {
struct PortalType
{
typedef void *ValueType;
typedef void *IteratorType;
};
// All these methods do nothing but raise errors.
PortalType GetPortal() {
PortalType GetPortal()
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
}
PortalConstType GetPortalConst() const {
PortalConstType GetPortalConst() const
{
// This does not work because the ArrayHandle holds the constant
// ArrayPortal, not the container.
throw vtkm::cont::ErrorControlBadValue(
@ -78,7 +82,8 @@ public:
"Perhaps you did not set the ArrayPortal when "
"constructing the ArrayHandle.");
}
vtkm::Id GetNumberOfValues() const {
vtkm::Id GetNumberOfValues() const
{
// This does not work because the ArrayHandle holds the constant
// ArrayPortal, not the container.
throw vtkm::cont::ErrorControlBadValue(
@ -86,13 +91,16 @@ public:
"Perhaps you did not set the ArrayPortal when "
"constructing the ArrayHandle.");
}
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
}
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
}
void ReleaseResources() {
void ReleaseResources()
{
throw vtkm::cont::ErrorControlBadValue("Implicit arrays are read-only.");
}
};
@ -117,17 +125,20 @@ public:
ArrayTransfer() : PortalValid(false) { }
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const {
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const
{
VTKM_ASSERT_CONT(this->PortalValid);
return this->Portal.GetNumberOfValues();
}
VTKM_CONT_EXPORT void LoadDataForInput(PortalConstControl portal) {
VTKM_CONT_EXPORT void LoadDataForInput(PortalConstControl portal)
{
this->Portal = portal;
this->PortalValid = true;
}
VTKM_CONT_EXPORT void LoadDataForInput(const ContainerType &controlArray) {
VTKM_CONT_EXPORT void LoadDataForInput(const ContainerType &controlArray)
{
this->LoadDataForInput(controlArray.GetPortalConst());
}

@ -80,7 +80,8 @@ public:
typedef typename ArrayContainerControlType::PortalConstType
PortalConstControl;
template <typename DeviceAdapterTag>
struct ExecutionTypes {
struct ExecutionTypes
{
typedef typename ExecutionManagerType
::template ExecutionTypes<DeviceAdapterTag>::Portal Portal;
typedef typename ExecutionManagerType
@ -386,8 +387,9 @@ public:
this->Internals->ExecutionArrayValid = false;
}
// private:
struct InternalStruct {
// private:
struct InternalStruct
{
PortalConstControl UserPortal;
bool UserPortalValid;

@ -40,7 +40,8 @@ protected:
Error() { }
Error(const std::string message) : Message(message) { }
void SetMessage(const std::string &message) {
void SetMessage(const std::string &message)
{
this->Message = message;
}

@ -40,7 +40,8 @@ private:
public:
template <typename DeviceAdapter>
struct ExecutionTypes {
struct ExecutionTypes
{
private:
typedef vtkm::cont::internal::ArrayTransfer<T,Container,DeviceAdapter>
ArrayTransferType;

@ -56,7 +56,8 @@ public:
/// Returns the size of the saved portal.
///
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const {
VTKM_CONT_EXPORT vtkm::Id GetNumberOfValues() const
{
VTKM_ASSERT_CONT(this->ConstPortalValid);
return this->ConstPortal.GetNumberOfValues();
}

@ -61,17 +61,20 @@ public:
{ }
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfValues() const {
vtkm::Id GetNumberOfValues() const
{
return std::distance(this->BeginIterator, this->EndIterator);
}
VTKM_CONT_EXPORT
ValueType Get(vtkm::Id index) const {
ValueType Get(vtkm::Id index) const
{
return *this->IteratorAt(index);
}
VTKM_CONT_EXPORT
void Set(vtkm::Id index, ValueType value) const {
void Set(vtkm::Id index, ValueType value) const
{
*this->IteratorAt(index) = value;
}
@ -86,7 +89,8 @@ private:
IteratorType EndIterator;
VTKM_CONT_EXPORT
IteratorType IteratorAt(vtkm::Id index) const {
IteratorType IteratorAt(vtkm::Id index) const
{
VTKM_ASSERT_CONT(index >= 0);
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());

@ -69,26 +69,30 @@ public:
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
VTKM_CONT_EXPORT
ValueType Get(vtkm::Id index) const {
ValueType Get(vtkm::Id index) const
{
VTKM_ASSERT_CONT(index >= 0);
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
return this->DelegatePortal.Get(index);
}
VTKM_CONT_EXPORT
void Set(vtkm::Id index, ValueType value) const {
void Set(vtkm::Id index, ValueType value) const
{
VTKM_ASSERT_CONT(index >= 0);
VTKM_ASSERT_CONT(index < this->GetNumberOfValues());
this->DelegatePortal.Set(index, value);
}
VTKM_CONT_EXPORT
IteratorType GetIteratorBegin() const {
IteratorType GetIteratorBegin() const
{
return this->DelegatePortal.GetIteratorBegin();
}
VTKM_CONT_EXPORT
IteratorType GetIteratorEnd() const {
IteratorType GetIteratorEnd() const
{
IteratorType iterator = this->DelegatePortal.GetIteratorBegin();
std::advance(iterator, this->GetNumberOfValues());
return iterator;
@ -98,7 +102,8 @@ public:
/// (exposed) array.
///
VTKM_CONT_EXPORT
void Shrink(vtkm::Id numberOfValues) {
void Shrink(vtkm::Id numberOfValues)
{
VTKM_ASSERT_CONT(numberOfValues < this->GetNumberOfValues());
this->NumberOfValues = numberOfValues;
}

@ -355,7 +355,8 @@ public:
return elapsedTime;
}
struct TimeStamp {
struct TimeStamp
{
vtkm::internal::Int64Type Seconds;
vtkm::internal::Int64Type Microseconds;
};

@ -29,8 +29,7 @@
#include <algorithm>
namespace
{
namespace {
/// Predicate that takes a single argument \c x, and returns
/// True if it isn't the identity of the Type \p T.
template<typename T>
@ -132,7 +131,8 @@ private:
// Copy
private:
template<class InputPortalType, class OutputPortalType>
struct CopyKernel {
struct CopyKernel
{
InputPortalType InputPortal;
OutputPortalType OutputPortal;
vtkm::Id InputOffset;
@ -150,7 +150,8 @@ private:
{ }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
this->OutputPortal.Set(
index + this->OutputOffset,
this->InputPortal.Get(index + this->InputOffset));
@ -181,7 +182,8 @@ public:
// Lower Bounds
private:
template<class InputPortalType,class ValuesPortalType,class OutputPortalType>
struct LowerBoundsKernel {
struct LowerBoundsKernel
{
InputPortalType InputPortal;
ValuesPortalType ValuesPortal;
OutputPortalType OutputPortal;
@ -195,7 +197,8 @@ private:
OutputPortal(outputPortal) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
// This method assumes that (1) InputPortalType can return working
// iterators in the execution environment and that (2) methods not
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
@ -220,7 +223,8 @@ private:
};
template<class InputPortalType,class ValuesPortalType,class OutputPortalType,class Compare>
struct LowerBoundsComparisonKernel {
struct LowerBoundsComparisonKernel
{
InputPortalType InputPortal;
ValuesPortalType ValuesPortal;
OutputPortalType OutputPortal;
@ -237,7 +241,8 @@ private:
CompareFunctor(comp) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
// This method assumes that (1) InputPortalType can return working
// iterators in the execution environment and that (2) methods not
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
@ -473,7 +478,8 @@ private:
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
typedef typename PortalType::ValueType ValueType;
vtkm::Id groupIndex = index%this->GroupSize;
@ -510,7 +516,8 @@ private:
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
typedef typename PortalType::ValueType ValueType;
vtkm::Id groupIndex = index%this->GroupSize;
@ -729,7 +736,8 @@ public:
// Unique
private:
template<class InputPortalType, class StencilPortalType>
struct ClassifyUniqueKernel {
struct ClassifyUniqueKernel
{
InputPortalType InputPortal;
StencilPortalType StencilPortal;
@ -739,7 +747,8 @@ private:
: InputPortal(inputPortal), StencilPortal(stencilPortal) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
typedef typename StencilPortalType::ValueType ValueType;
if (index == 0)
{
@ -760,7 +769,8 @@ private:
};
template<class InputPortalType, class StencilPortalType, class Compare>
struct ClassifyUniqueComparisonKernel {
struct ClassifyUniqueComparisonKernel
{
InputPortalType InputPortal;
StencilPortalType StencilPortal;
Compare CompareFunctor;
@ -774,7 +784,8 @@ private:
CompareFunctor(comp) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
typedef typename StencilPortalType::ValueType ValueType;
if (index == 0)
{
@ -850,7 +861,8 @@ public:
// Upper bounds
private:
template<class InputPortalType,class ValuesPortalType,class OutputPortalType>
struct UpperBoundsKernel {
struct UpperBoundsKernel
{
InputPortalType InputPortal;
ValuesPortalType ValuesPortal;
OutputPortalType OutputPortal;
@ -864,7 +876,8 @@ private:
OutputPortal(outputPortal) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
// This method assumes that (1) InputPortalType can return working
// iterators in the execution environment and that (2) methods not
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be
@ -890,7 +903,8 @@ private:
template<class InputPortalType,class ValuesPortalType,class OutputPortalType,class Compare>
struct UpperBoundsKernelComparisonKernel {
struct UpperBoundsKernelComparisonKernel
{
InputPortalType InputPortal;
ValuesPortalType ValuesPortal;
OutputPortalType OutputPortal;
@ -907,7 +921,8 @@ private:
CompareFunctor(comp) { }
VTKM_EXEC_EXPORT
void operator()(vtkm::Id index) const {
void operator()(vtkm::Id index) const
{
// This method assumes that (1) InputPortalType can return working
// iterators in the execution environment and that (2) methods not
// specified with VTKM_EXEC_EXPORT (such as the STL algorithms) can be

@ -32,7 +32,8 @@ namespace internal {
namespace detail {
template<class ArrayPortalType>
struct IteratorFromArrayPortalValue {
struct IteratorFromArrayPortalValue
{
typedef typename ArrayPortalType::ValueType ValueType;
VTKM_CONT_EXPORT
@ -59,13 +60,15 @@ struct IteratorFromArrayPortalValue {
}
VTKM_CONT_EXPORT
ValueType operator=(ValueType value) {
ValueType operator=(ValueType value)
{
this->Portal.Set(this->Index, value);
return value;
}
VTKM_CONT_EXPORT
operator ValueType(void) const {
operator ValueType(void) const
{
return this->Portal.Get(this->Index);
}
@ -108,13 +111,15 @@ private:
friend class boost::iterator_core_access;
VTKM_CONT_EXPORT
detail::IteratorFromArrayPortalValue<ArrayPortalType> dereference() const {
detail::IteratorFromArrayPortalValue<ArrayPortalType> dereference() const
{
return detail::IteratorFromArrayPortalValue<ArrayPortalType>(this->Portal,
this->Index);
}
VTKM_CONT_EXPORT
bool equal(const IteratorFromArrayPortal<ArrayPortalType> &other) const {
bool equal(const IteratorFromArrayPortal<ArrayPortalType> &other) const
{
// Technically, we should probably check that the portals are the same,
// but the portal interface does not specify an equal operator. It is
// by its nature undefined what happens when comparing iterators from
@ -123,21 +128,24 @@ private:
}
VTKM_CONT_EXPORT
void increment() {
void increment()
{
this->Index++;
VTKM_ASSERT_CONT(this->Index >= 0);
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
}
VTKM_CONT_EXPORT
void decrement() {
void decrement()
{
this->Index--;
VTKM_ASSERT_CONT(this->Index >= 0);
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
}
VTKM_CONT_EXPORT
void advance(vtkm::Id delta) {
void advance(vtkm::Id delta)
{
this->Index += delta;
VTKM_ASSERT_CONT(this->Index >= 0);
VTKM_ASSERT_CONT(this->Index <= this->Portal.GetNumberOfValues());
@ -145,7 +153,8 @@ private:
VTKM_CONT_EXPORT
vtkm::Id
distance_to(const IteratorFromArrayPortal<ArrayPortalType> &other) const {
distance_to(const IteratorFromArrayPortal<ArrayPortalType> &other) const
{
// Technically, we should probably check that the portals are the same,
// but the portal interface does not specify an equal operator. It is
// by its nature undefined what happens when comparing iterators from
@ -173,11 +182,11 @@ IteratorFromArrayPortal<ArrayPortalType> make_IteratorEnd(
//implementat a custom swap function, since the std::swap won't work
//since we return RValues instead of Lvalues
template<typename T>
void swap( vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> a,
void swap( vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> a,
vtkm::cont::internal::detail::IteratorFromArrayPortalValue<T> b)
{
{
a.Swap(b);
}
}
}

@ -52,7 +52,7 @@ struct TemplatedTests
{
for (IteratorType iter = begin; iter != end; iter++)
{
if (!test_equal(*iter, value)) return false;
if (!test_equal(*iter, value)) { return false; }
}
return true;
}
@ -145,7 +145,8 @@ struct TemplatedTests
"Did not get the right value in the control container.");
}
void operator()() {
void operator()()
{
InputData();
InPlaceData();

@ -33,12 +33,14 @@ struct TemplatedTests
typedef T ValueType;
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
ValueType ExpectedValue(vtkm::Id index, ComponentType value) {
ValueType ExpectedValue(vtkm::Id index, ComponentType value)
{
return ValueType(index + value);
}
template<class IteratorType>
void FillIterator(IteratorType begin, IteratorType end, ComponentType value) {
void FillIterator(IteratorType begin, IteratorType end, ComponentType value)
{
vtkm::Id index = 0;
for (IteratorType iter = begin; iter != end; iter++)
{
@ -50,11 +52,12 @@ struct TemplatedTests
template<class IteratorType>
bool CheckIterator(IteratorType begin,
IteratorType end,
ComponentType value) {
ComponentType value)
{
vtkm::Id index = 0;
for (IteratorType iter = begin; iter != end; iter++)
{
if (*iter != ExpectedValue(index, value)) return false;
if (*iter != ExpectedValue(index, value)) { return false; }
index++;
}
return true;

@ -35,12 +35,14 @@ struct TemplatedTests
typedef T ValueType;
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
ValueType ExpectedValue(vtkm::Id index, ComponentType value) {
ValueType ExpectedValue(vtkm::Id index, ComponentType value)
{
return ValueType(index + value);
}
template<class IteratorType>
void FillIterator(IteratorType begin, IteratorType end, ComponentType value) {
void FillIterator(IteratorType begin, IteratorType end, ComponentType value)
{
vtkm::Id index = 0;
for (IteratorType iter = begin; iter != end; iter++)
{
@ -52,11 +54,12 @@ struct TemplatedTests
template<class IteratorType>
bool CheckIterator(IteratorType begin,
IteratorType end,
ComponentType value) {
ComponentType value)
{
vtkm::Id index = 0;
for (IteratorType iter = begin; iter != end; iter++)
{
if (ValueType(*iter) != ExpectedValue(index, value)) return false;
if (ValueType(*iter) != ExpectedValue(index, value)) { return false; }
index++;
}
return true;

@ -42,10 +42,9 @@ namespace vtkm {
namespace cont {
namespace testing {
namespace
namespace {
struct SortLess
{
struct SortLess
{
template<typename T>
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a,const T& b) const
{
@ -62,7 +61,7 @@ namespace
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
vtkm::TypeTraitsVectorTag) const
{
enum{SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
enum {SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
bool valid = true;
for(unsigned int i=0; i < SIZE && valid; ++i)
{
@ -70,10 +69,10 @@ namespace
}
return valid;
}
};
};
struct SortGreater
{
struct SortGreater
{
template<typename T>
VTKM_EXEC_CONT_EXPORT bool operator()(const T& a,const T& b) const
{
@ -90,7 +89,7 @@ namespace
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
vtkm::TypeTraitsVectorTag) const
{
enum{SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
enum {SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS};
bool valid = true;
for(unsigned int i=0; i < SIZE && valid; ++i)
{
@ -98,7 +97,7 @@ namespace
}
return valid;
}
};
};
}
#define ERROR_MESSAGE "Got an error."
@ -419,28 +418,28 @@ private:
#endif
}
// VTKM_CONT_EXPORT static void TestTimer()
// {
// std::cout << "-------------------------------------------" << std::endl;
// std::cout << "Testing Timer" << std::endl;
// VTKM_CONT_EXPORT static void TestTimer()
// {
// std::cout << "-------------------------------------------" << std::endl;
// std::cout << "Testing Timer" << std::endl;
// vtkm::cont::Timer<DeviceAdapterTag> timer;
// vtkm::cont::Timer<DeviceAdapterTag> timer;
// #ifndef _WIN32
// sleep(1);
// #else
// Sleep(1000);
// #endif
// #ifndef _WIN32
// sleep(1);
// #else
// Sleep(1000);
// #endif
// vtkm::Scalar elapsedTime = timer.GetElapsedTime();
// vtkm::Scalar elapsedTime = timer.GetElapsedTime();
// std::cout << "Elapsed time: " << elapsedTime << std::endl;
// std::cout << "Elapsed time: " << elapsedTime << std::endl;
// VTKM_TEST_ASSERT(elapsedTime > 0.999,
// "Timer did not capture full second wait.");
// VTKM_TEST_ASSERT(elapsedTime < 2.0,
// "Timer counted too far or system really busy.");
// }
// VTKM_TEST_ASSERT(elapsedTime > 0.999,
// "Timer did not capture full second wait.");
// VTKM_TEST_ASSERT(elapsedTime < 2.0,
// "Timer counted too far or system really busy.");
// }
static VTKM_CONT_EXPORT void TestAlgorithmSchedule()
{
@ -802,7 +801,7 @@ private:
{
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
vtkm::Id sorted2 = sorted.GetPortalConstControl().Get(i+1);
// std::cout << sorted1 << " <= " << sorted2 << std::endl;
// std::cout << sorted1 << " <= " << sorted2 << std::endl;
VTKM_TEST_ASSERT(sorted1 <= sorted2, "Values not properly sorted.");
}
@ -813,7 +812,7 @@ private:
{
vtkm::Id sorted1 = sorted.GetPortalConstControl().Get(i);
vtkm::Id sorted2 = comp_sorted.GetPortalConstControl().Get(ARRAY_SIZE - (i + 1));
// std::cout << sorted1 << "==" << sorted2 << std::endl;
// std::cout << sorted1 << "==" << sorted2 << std::endl;
VTKM_TEST_ASSERT(sorted1 == sorted2,
"Got bad sort values when using SortGreater");
}

@ -25,8 +25,7 @@
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/VectorTraits.h>
namespace
{
namespace {
const vtkm::Id ARRAY_SIZE = 10;
@ -55,12 +54,13 @@ struct TemplatedTests
iter != array.GetPortal().GetIteratorEnd();
iter ++)
{
if (!test_equal(*iter, value)) return false;
if (!test_equal(*iter, value)) { return false; }
}
return true;
}
typename vtkm::VectorTraits<ValueType>::ComponentType STOLEN_ARRAY_VALUE() {
typename vtkm::VectorTraits<ValueType>::ComponentType STOLEN_ARRAY_VALUE()
{
return 4529;
}
@ -131,7 +131,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Array shrink do a larger size was possible. This can't be allowed.");
}
catch(vtkm::cont::ErrorControlBadValue){}
catch(vtkm::cont::ErrorControlBadValue) {}
}
void operator()()

@ -28,8 +28,7 @@
#include <vtkm/VectorTraits.h>
namespace
{
namespace {
template <typename T>
struct TestImplicitContainer
@ -56,12 +55,14 @@ struct TestImplicitContainer
}
VTKM_CONT_EXPORT
IteratorType GetIteratorBegin() const {
IteratorType GetIteratorBegin() const
{
return IteratorType(*this);
}
VTKM_CONT_EXPORT
IteratorType GetIteratorEnd() const {
IteratorType GetIteratorEnd() const
{
return IteratorType(*this, this->GetNumberOfValues());
}
@ -86,17 +87,21 @@ struct TemplatedTests
{
ArrayContainerType arrayContainer;
try{ arrayContainer.GetNumberOfValues();
try
{
arrayContainer.GetNumberOfValues();
VTKM_TEST_ASSERT(false == true,
"Implicit Container GetNumberOfValues method didn't throw error.");
}
catch(vtkm::cont::ErrorControlBadValue e){}
catch(vtkm::cont::ErrorControlBadValue e) {}
try{ arrayContainer.Allocate(ARRAY_SIZE);
try
{
arrayContainer.Allocate(ARRAY_SIZE);
VTKM_TEST_ASSERT(false == true,
"Implicit Container Allocate method didn't throw error.");
}
catch(vtkm::cont::ErrorControlBadValue e){}
catch(vtkm::cont::ErrorControlBadValue e) {}
try
{
@ -104,7 +109,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Array shrink do a larger size was possible. This can't be allowed.");
}
catch(vtkm::cont::ErrorControlBadValue){}
catch(vtkm::cont::ErrorControlBadValue) {}
try
{
@ -112,7 +117,7 @@ struct TemplatedTests
VTKM_TEST_ASSERT(true==false,
"Can't Release an implicit array");
}
catch(vtkm::cont::ErrorControlBadValue){}
catch(vtkm::cont::ErrorControlBadValue) {}
}
void BasicAccess()

@ -29,8 +29,7 @@
#include <algorithm>
namespace
{
namespace {
const vtkm::Id ARRAY_SIZE = 10;
vtkm::Scalar TestValue(vtkm::Id index)
@ -44,7 +43,7 @@ bool CheckValues(IteratorType begin, IteratorType end)
vtkm::Id index = 0;
for (IteratorType iter = begin; iter != end; iter++)
{
if (!test_equal(*iter, TestValue(index))) return false;
if (!test_equal(*iter, TestValue(index))) { return false; }
index++;
}
return true;

@ -65,7 +65,7 @@ int UnitTestContTesting(int, char *[])
return 1;
}
//VTKM_ASSERT_CONT only is a valid call when you are building with debug
//VTKM_ASSERT_CONT only is a valid call when you are building with debug
#ifndef NDEBUG
int expectedResult=0;
#else

@ -214,11 +214,11 @@
#ifndef OPTIONPARSER_H_
#define OPTIONPARSER_H_
namespace vtkm { namespace testing {
namespace vtkm {
namespace testing {
/** @brief The namespace of The Lean Mean C++ Option Parser. */
namespace option
{
namespace option {
#ifdef _MSC_VER
#include <intrin.h>
@ -604,7 +604,7 @@ public:
{
Option* p = this;
while (!p->isFirst())
p = p->prev_;
{ p = p->prev_; }
return p;
}
@ -805,12 +805,12 @@ private:
next_ = tag(this);
namelen = 0;
if (name == 0)
return;
{ return; }
namelen = 1;
if (name[0] != '-')
return;
{ return; }
while (name[namelen] != 0 && name[namelen] != '=')
++namelen;
{ ++namelen; }
}
static Option* tag(Option* ptr)
@ -895,9 +895,9 @@ struct Arg
static ArgStatus Optional(const Option& option, bool)
{
if (option.arg && option.name[option.namelen] != 0)
return ARG_OK;
{ return ARG_OK; }
else
return ARG_IGNORE;
{ return ARG_IGNORE; }
}
};
@ -1279,7 +1279,7 @@ private:
{
while (*st1 != 0)
if (*st1++ != *st2++)
return false;
{ return false; }
return (*st2 == 0 || *st2 == '=');
}
@ -1328,7 +1328,7 @@ private:
static bool instr(char ch, const char* st)
{
while (*st != 0 && *st != ch)
++st;
{ ++st; }
return *st == ch;
}
@ -1405,7 +1405,7 @@ public:
bool perform(Option&)
{
if (*buffer_max == 0x7fffffff)
return false; // overflow protection: don't accept number of options that doesn't fit signed int
{ return false; } // overflow protection: don't accept number of options that doesn't fit signed int
++*buffer_max;
return true;
}
@ -1436,7 +1436,7 @@ public:
// find first empty slot in buffer (if any)
int bufidx = 0;
while ((bufmax < 0 || bufidx < bufmax) && buffer[bufidx])
++bufidx;
{ ++bufidx; }
// set parser's optionCount
parser.op_count = bufidx;
@ -1447,14 +1447,14 @@ public:
if (bufmax < 0 || parser.op_count < bufmax)
{
if (parser.op_count == 0x7fffffff)
return false; // overflow protection: don't accept number of options that doesn't fit signed int
{ return false; } // overflow protection: don't accept number of options that doesn't fit signed int
buffer[parser.op_count] = option;
int idx = buffer[parser.op_count].desc->index;
if (options[idx])
options[idx].append(buffer[parser.op_count]);
{ options[idx].append(buffer[parser.op_count]); }
else
options[idx] = buffer[parser.op_count];
{ options[idx] = buffer[parser.op_count]; }
++parser.op_count;
}
return true; // NOTE: an option that is discarded because of a full buffer is not fatal
@ -1490,7 +1490,7 @@ inline void Stats::add(bool gnu, const Descriptor usage[], int argc, const char*
while (usage[i].shortopt != 0)
{
if (usage[i].index + 1 >= options_max)
options_max = (usage[i].index + 1) + 1; // 1 more than necessary as sentinel
{ options_max = (usage[i].index + 1) + 1; } // 1 more than necessary as sentinel
++i;
}
@ -1504,7 +1504,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
{
// protect against NULL pointer
if (args == 0)
numargs = 0;
{ numargs = 0; }
int nonops = 0;
@ -1521,11 +1521,11 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
++nonops;
++args;
if (numargs > 0)
--numargs;
{ --numargs; }
continue;
}
else
break;
{ break; }
}
// -- terminates the option list. The -- itself is skipped.
@ -1534,7 +1534,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
shift(args, nonops);
++args;
if (numargs > 0)
--numargs;
{ --numargs; }
break;
}
@ -1565,55 +1565,56 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
{
idx = 0;
while (usage[idx].longopt != 0 && !streq(usage[idx].longopt, longopt_name))
++idx;
{ ++idx; }
if (usage[idx].longopt == 0 && min_abbr_len > 0) // if we should try to match abbreviated long options
{
int i1 = 0;
while (usage[i1].longopt != 0 && !streqabbr(usage[i1].longopt, longopt_name, min_abbr_len))
++i1;
{ ++i1; }
if (usage[i1].longopt != 0)
{ // now test if the match is unambiguous by checking for another match
{
// now test if the match is unambiguous by checking for another match
int i2 = i1 + 1;
while (usage[i2].longopt != 0 && !streqabbr(usage[i2].longopt, longopt_name, min_abbr_len))
++i2;
{ ++i2; }
if (usage[i2].longopt == 0) // if there was no second match it's unambiguous, so accept i1 as idx
idx = i1;
{ idx = i1; }
}
}
// if we found something, disable handle_short_options (only relevant if single_minus_longopt)
if (usage[idx].longopt != 0)
handle_short_options = false;
{ handle_short_options = false; }
try_single_minus_longopt = false; // prevent looking for longopt in the middle of shortopt group
optarg = longopt_name;
while (*optarg != 0 && *optarg != '=')
++optarg;
{ ++optarg; }
if (*optarg == '=') // attached argument
++optarg;
{ ++optarg; }
else
// possibly detached argument
optarg = (have_more_args ? args[1] : 0);
{ optarg = (have_more_args ? args[1] : 0); }
}
/************************ short option ***********************************/
if (handle_short_options)
{
if (*++param == 0) // point at the 1st/next option character
break; // end of short option group
{ break; } // end of short option group
idx = 0;
while (usage[idx].shortopt != 0 && !instr(*param, usage[idx].shortopt))
++idx;
{ ++idx; }
if (param[1] == 0) // if the potential argument is separate
optarg = (have_more_args ? args[1] : 0);
{ optarg = (have_more_args ? args[1] : 0); }
else
// if the potential argument is attached
optarg = param + 1;
{ optarg = param + 1; }
}
const Descriptor* descriptor = &usage[idx];
@ -1623,7 +1624,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
// look for dummy entry (shortopt == "" and longopt == "") to use as Descriptor for unknown options
idx = 0;
while (usage[idx].shortopt != 0 && (usage[idx].shortopt[0] != 0 || usage[idx].longopt[0] != 0))
++idx;
{ ++idx; }
descriptor = (usage[idx].shortopt == 0 ? 0 : &usage[idx]);
}
@ -1640,7 +1641,7 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
{
shift(args, nonops);
if (numargs > 0)
--numargs;
{ --numargs; }
++args;
}
@ -1655,26 +1656,28 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c
}
if (!action.perform(option))
return false;
{ return false; }
}
} while (handle_short_options);
}
while (handle_short_options);
shift(args, nonops);
++args;
if (numargs > 0)
--numargs;
{ --numargs; }
} // while
if (numargs > 0 && *args == 0) // It's a bug in the caller if numargs is greater than the actual number
numargs = 0; // of arguments, but as a service to the user we fix this if we spot it.
{ numargs = 0; } // of arguments, but as a service to the user we fix this if we spot it.
if (numargs < 0) // if we don't know the number of remaining non-option arguments
{ // we need to count them
{
// we need to count them
numargs = 0;
while (args[numargs] != 0)
++numargs;
{ ++numargs; }
}
return action.finished(numargs + nonops, args - nonops);
@ -1840,7 +1843,7 @@ struct PrintUsageImplementation
{
char space = ' ';
for (int i = 0; i < indent; ++i)
write(&space, 1);
{ write(&space, 1); }
x = want_x;
}
}
@ -1866,7 +1869,7 @@ struct PrintUsageImplementation
static bool isWideChar(unsigned ch)
{
if (ch == 0x303F)
return false;
{ return false; }
return ((0x1100 <= ch && ch <= 0x115F) || (0x2329 <= ch && ch <= 0x232A) || (0x2E80 <= ch && ch <= 0xA4C6)
|| (0xA960 <= ch && ch <= 0xA97C) || (0xAC00 <= ch && ch <= 0xD7FB) || (0xF900 <= ch && ch <= 0xFAFF)
@ -1948,7 +1951,7 @@ struct PrintUsageImplementation
}
// ch is the decoded unicode code point
if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
++screenlen;
{ ++screenlen; }
}
}
}
@ -1973,12 +1976,12 @@ struct PrintUsageImplementation
if (rowdesc != 0)
{
while (tablestart->help != 0 && tablestart->shortopt != 0)
++tablestart;
{ ++tablestart; }
}
// Find the next table after the break (if any)
while (tablestart->help == 0 && tablestart->shortopt != 0)
++tablestart;
{ ++tablestart; }
restartTable();
return rowstart != 0;
@ -2008,12 +2011,12 @@ struct PrintUsageImplementation
}
while (*ptr != 0 && *ptr != '\n')
++ptr;
{ ++ptr; }
if (*ptr == 0)
{
if ((rowdesc + 1)->help == 0) // table break
return false;
{ return false; }
++rowdesc;
rowstart = rowdesc->help;
@ -2052,7 +2055,7 @@ struct PrintUsageImplementation
bool next()
{
if (ptr == 0)
return false;
{ return false; }
if (col == -1)
{
@ -2072,7 +2075,8 @@ struct PrintUsageImplementation
break;
case '\t':
if (!hit_target_line) // if previous column did not have the targetline
{ // then "insert" a 0-length part
{
// then "insert" a 0-length part
update_length();
hit_target_line = true;
return true;
@ -2086,7 +2090,8 @@ struct PrintUsageImplementation
case 0:
case '\n':
if (!hit_target_line) // if previous column did not have the targetline
{ // then "insert" a 0-length part
{
// then "insert" a 0-length part
update_length();
hit_target_line = true;
return true;
@ -2249,7 +2254,7 @@ struct PrintUsageImplementation
void output(IStringWriter& write, const char* data, int len)
{
if (buf_full())
write_one_line(write);
{ write_one_line(write); }
buf_store(data, len);
}
@ -2284,12 +2289,12 @@ struct PrintUsageImplementation
void flush(IStringWriter& write)
{
if (buf_empty())
return;
{ return; }
int _ = 0;
indent(write, _, x);
wrote_something = false;
while (!buf_empty())
write_one_line(write);
{ write_one_line(write); }
write("\n", 1);
}
@ -2346,7 +2351,7 @@ struct PrintUsageImplementation
if (ch >= 0x1100 && isWideChar(ch)) // the test for 0x1100 is here to avoid the function call in the Latin case
{
if (utf8width + 2 > width)
break;
{ break; }
++utf8width;
}
}
@ -2367,7 +2372,7 @@ struct PrintUsageImplementation
int i;
for (i = maxi; i >= 0; --i)
if (data[i] == ' ')
break;
{ break; }
if (i >= 0)
{
@ -2376,7 +2381,8 @@ struct PrintUsageImplementation
len -= i + 1;
}
else // did not find a space to split at => split before data[maxi]
{ // data[maxi] is always the beginning of a character, never a continuation byte
{
// data[maxi] is always the beginning of a character, never a continuation byte
output(write, data, maxi);
data += maxi;
len -= maxi;
@ -2385,7 +2391,7 @@ struct PrintUsageImplementation
}
}
if (!wrote_something) // if we didn't already write something to make space in the buffer
write_one_line(write); // write at most one line of actual output
{ write_one_line(write); } // write at most one line of actual output
}
/**
@ -2398,7 +2404,7 @@ struct PrintUsageImplementation
x(x1), width(x2 - x1), head(0), tail(bufmask)
{
if (width < 2) // because of wide characters we need at least width 2 or the code breaks
width = 2;
{ width = 2; }
}
};
@ -2411,15 +2417,15 @@ struct PrintUsageImplementation
int last_column_min_percent = 50, int last_column_own_line_max_percent = 75)
{
if (width < 1) // protect against nonsense values
width = 80;
{ width = 80; }
if (width > 10000) // protect against overflow in the following computation
width = 10000;
{ width = 10000; }
int last_column_min_width = ((width * last_column_min_percent) + 50) / 100;
int last_column_own_line_max_width = ((width * last_column_own_line_max_percent) + 50) / 100;
if (last_column_own_line_max_width == 0)
last_column_own_line_max_width = 1;
{ last_column_own_line_max_width = 1; }
LinePartIterator part(usage);
while (part.nextTable())
@ -2436,7 +2442,7 @@ struct PrintUsageImplementation
{
lastcolumn = 0;
for (int i = 0; i < maxcolumns; ++i)
col_width[i] = 0;
{ col_width[i] = 0; }
part.restartTable();
while (part.nextRow())
@ -2452,7 +2458,7 @@ struct PrintUsageImplementation
// or explanatory paragraphs that do not participate in the table layout.
if (part.column() > 0 || part.line() > 0 || part.data()[part.length()] == '\t'
|| part.data()[part.length()] == '\v')
upmax(col_width[part.column()], part.screenLength());
{ upmax(col_width[part.column()], part.screenLength()); }
}
}
}
@ -2476,14 +2482,15 @@ struct PrintUsageImplementation
upmax(overlong_column_threshold, col_width[i]);
}
} while (leftwidth > width);
}
while (leftwidth > width);
/**************** Determine tab stops and last column handling **********************/
int tabstop[maxcolumns];
tabstop[0] = 0;
for (int i = 1; i < maxcolumns; ++i)
tabstop[i] = tabstop[i - 1] + col_width[i - 1];
{ tabstop[i] = tabstop[i - 1] + col_width[i - 1]; }
int rightwidth = width - tabstop[lastcolumn];
bool print_last_column_on_own_line = false;
@ -2502,7 +2509,7 @@ struct PrintUsageImplementation
// a bullshit value >100 for last_column_min_percent) => the above if condition
// is false => print_last_column_on_own_line==false
if (lastcolumn == 0)
print_last_column_on_own_line = false;
{ print_last_column_on_own_line = false; }
LineWrapper lastColumnLineWrapper(width - rightwidth, width);
LineWrapper interjectionLineWrapper(0, width);
@ -2517,12 +2524,12 @@ struct PrintUsageImplementation
while (part.next())
{
if (part.column() > lastcolumn)
continue; // drop excess columns (can happen if lastcolumn == maxcolumns-1)
{ continue; } // drop excess columns (can happen if lastcolumn == maxcolumns-1)
if (part.column() == 0)
{
if (x >= 0)
write("\n", 1);
{ write("\n", 1); }
x = 0;
}
@ -2544,7 +2551,7 @@ struct PrintUsageImplementation
LineWrapper& lineWrapper = (part.column() == 0) ? interjectionLineWrapper : lastColumnLineWrapper;
if (!print_last_column_on_own_line)
lineWrapper.process(write, part.data(), part.length());
{ lineWrapper.process(write, part.data(), part.length()); }
}
} // while
@ -2814,7 +2821,8 @@ void printUsage(Function* prn, Stream* stream, const Descriptor descriptors[], i
}
// namespace option
} }
}
}
// namespace vtkm::testing
#endif /* OPTIONPARSER_H_ */

@ -86,7 +86,8 @@ public:
VTKM_CONT_EXPORT const std::string &GetFile() const { return this->File; }
VTKM_CONT_EXPORT vtkm::Id GetLine() const { return this->Line; }
VTKM_CONT_EXPORT const std::string &GetMessage() const {
VTKM_CONT_EXPORT const std::string &GetMessage() const
{
return this->Message;
}
private:
@ -164,68 +165,83 @@ public:
/// Check functors to be used with the TryAllTypes method.
///
struct TypeCheckAlwaysTrue {
struct TypeCheckAlwaysTrue
{
template <typename T, class Functor>
void operator()(T t, Functor function) const { function(t); }
};
struct TypeCheckInteger {
struct TypeCheckInteger
{
template <typename T, class Functor>
void operator()(T t, Functor function) const {
void operator()(T t, Functor function) const
{
this->DoInteger(typename vtkm::TypeTraits<T>::NumericTag(), t, function);
}
private:
template <class Tag, typename T, class Functor>
void DoInteger(Tag, T, const Functor&) const { }
template <typename T, class Functor>
void DoInteger(vtkm::TypeTraitsIntegerTag, T t, Functor function) const {
void DoInteger(vtkm::TypeTraitsIntegerTag, T t, Functor function) const
{
function(t);
}
};
struct TypeCheckReal {
struct TypeCheckReal
{
template <typename T, class Functor>
void operator()(T t, Functor function) const {
void operator()(T t, Functor function) const
{
this->DoReal(typename vtkm::TypeTraits<T>::NumericTag(), t, function);
}
private:
template <class Tag, typename T, class Functor>
void DoReal(Tag, T, const Functor&) const { }
template <typename T, class Functor>
void DoReal(vtkm::TypeTraitsRealTag, T t, Functor function) const {
void DoReal(vtkm::TypeTraitsRealTag, T t, Functor function) const
{
function(t);
}
};
struct TypeCheckScalar {
struct TypeCheckScalar
{
template <typename T, class Functor>
void operator()(T t, Functor func) const {
void operator()(T t, Functor func) const
{
this->DoScalar(typename vtkm::TypeTraits<T>::DimensionalityTag(), t, func);
}
private:
template <class Tag, typename T, class Functor>
void DoScalar(Tag, const T &, const Functor &) const { }
template <typename T, class Functor>
void DoScalar(vtkm::TypeTraitsScalarTag, T t, Functor function) const {
void DoScalar(vtkm::TypeTraitsScalarTag, T t, Functor function) const
{
function(t);
}
};
struct TypeCheckVector {
struct TypeCheckVector
{
template <typename T, class Functor>
void operator()(T t, Functor func) const {
void operator()(T t, Functor func) const
{
this->DoVector(typename vtkm::TypeTraits<T>::DimensionalityTag(), t, func);
}
private:
template <class Tag, typename T, class Functor>
void DoVector(Tag, const T &, const Functor &) const { }
template <typename T, class Functor>
void DoVector(vtkm::TypeTraitsVectorTag, T t, Functor function) const {
void DoVector(vtkm::TypeTraitsVectorTag, T t, Functor function) const
{
function(t);
}
};
template<class FunctionType>
struct InternalPrintOnInvoke {
struct InternalPrintOnInvoke
{
InternalPrintOnInvoke(FunctionType function, std::string toprint)
: Function(function), ToPrint(toprint) { }
template <typename T> void operator()(T t) {
template <typename T> void operator()(T t)
{
std::cout << this->ToPrint << std::endl;
this->Function(t);
}

@ -28,7 +28,8 @@ namespace {
struct TypeTraitTest
{
template <typename T> void operator()(T t) {
template <typename T> void operator()(T t)
{
// If you get compiler errors here, it could be a TypeTraits instance
// has missing or malformed tags.
this->TestDimensionality(t, typename vtkm::TypeTraits<T>::DimensionalityTag());
@ -37,27 +38,31 @@ struct TypeTraitTest
private:
template <typename T>
void TestDimensionality(T, vtkm::TypeTraitsScalarTag) {
void TestDimensionality(T, vtkm::TypeTraitsScalarTag)
{
std::cout << " scalar" << std::endl;
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS == 1,
"Scalar type does not have one component.");
}
template <typename T>
void TestDimensionality(T, vtkm::TypeTraitsVectorTag) {
void TestDimensionality(T, vtkm::TypeTraitsVectorTag)
{
std::cout << " vector" << std::endl;
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS > 1,
"Vector type does not have multiple components.");
}
template <typename T>
void TestNumeric(T, vtkm::TypeTraitsIntegerTag) {
void TestNumeric(T, vtkm::TypeTraitsIntegerTag)
{
std::cout << " integer" << std::endl;
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
VT value = VT(2.001);
VTKM_TEST_ASSERT(value == 2, "Integer does not round to integer.");
}
template <typename T>
void TestNumeric(T, vtkm::TypeTraitsRealTag) {
void TestNumeric(T, vtkm::TypeTraitsRealTag)
{
std::cout << " real" << std::endl;
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
VT value = VT(2.001);

@ -470,7 +470,8 @@ template<> void TypeTest<vtkm::Id>()
struct TypeTestFunctor
{
template <typename T> void operator()(const T&) const {
template <typename T> void operator()(const T&) const
{
TypeTest<T>();
}
};

@ -28,7 +28,8 @@ static const vtkm::Id VectorInit[MAX_VECTOR_SIZE] = { 42, 54, 67, 12, 78 };
struct TestVectorTypeFunctor
{
template <typename T> void operator()(const T&) const {
template <typename T> void operator()(const T&) const
{
typedef vtkm::VectorTraits<T> Traits;
VTKM_TEST_ASSERT(Traits::NUM_COMPONENTS <= MAX_VECTOR_SIZE,
"Need to update test for larger vectors.");