2014-06-25 22:03:44 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2014-06-25 22:03:44 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
$# This file uses the pyexpander macro processing utility to build the
|
|
|
|
$# FunctionInterface facilities that use a variable number of arguments.
|
|
|
|
$# Information, documentation, and downloads for pyexpander can be found at:
|
|
|
|
$#
|
|
|
|
$# http://pyexpander.sourceforge.net/
|
|
|
|
$#
|
|
|
|
$# To build the source code, execute the following (after installing
|
|
|
|
$# pyexpander, of course):
|
|
|
|
$#
|
|
|
|
$# expander.py FunctionInterfaceDetailPre.h.in > FunctionInterfaceDetailPre.h
|
|
|
|
$#
|
|
|
|
$# Ignore the following comment. It is meant for the generated file.
|
|
|
|
// **** DO NOT EDIT THIS FILE!!! ****
|
|
|
|
// This file is automatically generated by FunctionInterfaceDetailPre.h.in
|
|
|
|
|
2014-10-08 16:07:08 +00:00
|
|
|
#ifndef vtk_m_internal_FunctionInterfaceDetailPre_h
|
|
|
|
#define vtk_m_internal_FunctionInterfaceDetailPre_h
|
2014-06-25 22:03:44 +00:00
|
|
|
|
2014-10-08 16:07:08 +00:00
|
|
|
#if !defined(vtk_m_internal_FunctionInterface_h) && !defined(VTKM_TEST_HEADER_BUILD)
|
2014-06-25 22:03:44 +00:00
|
|
|
#error FunctionInterfaceDetailPre.h must be included from FunctionInterface.h
|
|
|
|
#endif
|
|
|
|
|
2022-02-09 20:56:26 +00:00
|
|
|
#include <vtkm/List.h>
|
2014-06-25 22:03:44 +00:00
|
|
|
#include <vtkm/Types.h>
|
2015-01-14 01:26:13 +00:00
|
|
|
#include <vtkm/internal/IndexTag.h>
|
2014-06-25 22:03:44 +00:00
|
|
|
|
2016-08-01 16:37:55 +00:00
|
|
|
#include <type_traits>
|
|
|
|
|
2018-01-04 19:06:16 +00:00
|
|
|
$py(max_parameters=20)\
|
2014-06-25 22:03:44 +00:00
|
|
|
#define VTKM_MAX_FUNCTION_PARAMETERS $(max_parameters)
|
|
|
|
|
|
|
|
$# Python commands used in template expansion.
|
|
|
|
$py(
|
|
|
|
def comma_if(flag):
|
|
|
|
if flag:
|
|
|
|
return ','
|
|
|
|
else:
|
|
|
|
return '';
|
|
|
|
|
|
|
|
def ptype(num, name=""):
|
|
|
|
if num == 0:
|
|
|
|
return '%sR' % name
|
|
|
|
else:
|
|
|
|
return '%sP%d' % (name, num)
|
|
|
|
|
|
|
|
def template_params(num_params, start=0, name=''):
|
|
|
|
if num_params < start:
|
|
|
|
return ''
|
|
|
|
result = 'typename %s' % ptype(start, name)
|
2019-04-04 17:20:56 +00:00
|
|
|
for param in range(start+1, num_params+1):
|
2017-05-31 15:37:29 +00:00
|
|
|
result += ',\n typename %s' % ptype(param, name)
|
2014-06-25 22:03:44 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
def signature(num_params, return_type=ptype(0), name=''):
|
|
|
|
result = '%s(' % return_type
|
|
|
|
if num_params > 0:
|
|
|
|
result += ptype(1, name)
|
2019-04-04 17:20:56 +00:00
|
|
|
for param in range(2, num_params+1):
|
2017-05-31 15:37:29 +00:00
|
|
|
result += ', %s' % ptype(param, name)
|
2014-06-25 22:03:44 +00:00
|
|
|
result += ')'
|
|
|
|
return result
|
|
|
|
)\
|
|
|
|
$#
|
|
|
|
$extend(comma_if, ptype, template_params, signature)\
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
2014-06-25 22:03:44 +00:00
|
|
|
|
|
|
|
/// This struct is used internally by FunctionInterface to store the return
|
|
|
|
/// value of a function. There is a special implementation for a return type of
|
|
|
|
/// void, which stores nothing.
|
|
|
|
///
|
2017-05-31 15:37:29 +00:00
|
|
|
template <typename T>
|
|
|
|
struct FunctionInterfaceReturnContainer
|
|
|
|
{
|
2014-06-25 22:03:44 +00:00
|
|
|
T Value;
|
2018-02-22 16:34:08 +00:00
|
|
|
static constexpr bool VALID = true;
|
2014-06-25 22:03:44 +00:00
|
|
|
};
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
template <>
|
|
|
|
struct FunctionInterfaceReturnContainer<void>
|
|
|
|
{
|
2014-06-25 22:03:44 +00:00
|
|
|
// Nothing to store for void return.
|
2018-02-22 16:34:08 +00:00
|
|
|
static constexpr bool VALID = false;
|
2014-06-25 22:03:44 +00:00
|
|
|
};
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
namespace detail
|
|
|
|
{
|
2014-06-25 22:03:44 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
// This templated class contains the state of parameters. If you get a compiler
|
|
|
|
// error stating that this class is not specialized, that probably means that
|
|
|
|
// you are using FunctionInterface with an unsupported number of arguments.
|
2017-05-31 15:37:29 +00:00
|
|
|
template <typename FunctionSignature>
|
2014-06-25 22:03:44 +00:00
|
|
|
struct ParameterContainer;
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
// clang-format off
|
|
|
|
|
2014-06-25 22:03:44 +00:00
|
|
|
$for(num_params in range(0, max_parameters+1))\
|
2017-05-31 15:37:29 +00:00
|
|
|
template <$template_params(num_params)>
|
|
|
|
struct ParameterContainer<$signature(num_params)>
|
|
|
|
{
|
2014-06-25 22:03:44 +00:00
|
|
|
$for(param_index in range(1, num_params+1))\
|
|
|
|
$ptype(param_index) Parameter$(param_index);
|
|
|
|
$endfor\
|
|
|
|
};
|
|
|
|
|
|
|
|
$endfor\
|
2017-05-31 15:37:29 +00:00
|
|
|
// clang-format on
|
2014-06-25 22:03:44 +00:00
|
|
|
|
2016-04-19 20:04:53 +00:00
|
|
|
//============================================================================
|
2017-05-31 15:37:29 +00:00
|
|
|
template <typename>
|
|
|
|
struct FunctionSigInfo;
|
|
|
|
template <typename R, typename... ArgTypes>
|
2016-08-01 16:37:55 +00:00
|
|
|
struct FunctionSigInfo<R(ArgTypes...)>
|
2016-04-19 20:04:53 +00:00
|
|
|
{
|
2018-02-22 16:34:08 +00:00
|
|
|
static constexpr std::size_t Arity = sizeof...(ArgTypes);
|
2017-07-10 18:11:06 +00:00
|
|
|
using ArityType = std::integral_constant<int, static_cast<int>(Arity)>;
|
2016-08-01 16:37:55 +00:00
|
|
|
|
|
|
|
using ResultType = R;
|
2022-02-09 20:56:26 +00:00
|
|
|
using Components = vtkm::List<R, ArgTypes...>;
|
|
|
|
using Parameters = vtkm::List<ArgTypes...>;
|
2016-08-01 16:37:55 +00:00
|
|
|
};
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
template <int, typename>
|
|
|
|
struct AtType;
|
|
|
|
template <int Index, typename R, typename... ArgTypes>
|
2016-08-01 16:37:55 +00:00
|
|
|
struct AtType<Index, R(ArgTypes...)>
|
|
|
|
{
|
2022-02-09 20:56:26 +00:00
|
|
|
using type = vtkm::ListAt<vtkm::List<R, ArgTypes...>, Index>;
|
2016-08-01 16:37:55 +00:00
|
|
|
};
|
|
|
|
|
2014-06-25 22:03:44 +00:00
|
|
|
//============================================================================
|
|
|
|
|
2019-12-03 18:30:43 +00:00
|
|
|
// clang-format off
|
2014-06-25 22:03:44 +00:00
|
|
|
|
|
|
|
$for(param_index in range(1, max_parameters+1))\
|
2019-12-03 18:30:43 +00:00
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename FunctionSignature>
|
|
|
|
VTKM_EXEC_CONT auto ParameterGet(const ParameterContainer<FunctionSignature>& parameters,
|
|
|
|
vtkm::internal::IndexTag<$(param_index)>)
|
|
|
|
-> decltype(parameters.Parameter$(param_index)) const&
|
2017-05-31 15:37:29 +00:00
|
|
|
{
|
2019-12-03 18:30:43 +00:00
|
|
|
return parameters.Parameter$(param_index);
|
|
|
|
}
|
2016-04-19 20:04:53 +00:00
|
|
|
$endfor\
|
|
|
|
|
2019-12-03 18:30:43 +00:00
|
|
|
// clang-format on
|
2016-04-19 20:04:53 +00:00
|
|
|
|
2014-06-25 22:03:44 +00:00
|
|
|
//============================================================================
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
template <typename OriginalSignature, typename Transform>
|
2014-06-25 22:03:44 +00:00
|
|
|
struct FunctionInterfaceStaticTransformType;
|
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
// clang-format off
|
|
|
|
|
2019-04-04 17:20:56 +00:00
|
|
|
$for(num_params in range(0, max_parameters))\
|
2019-11-26 19:26:32 +00:00
|
|
|
$for(environment in ['Cont'])\
|
2015-09-21 19:26:28 +00:00
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2019-12-03 18:30:43 +00:00
|
|
|
template <typename Result,
|
|
|
|
typename Transform,
|
|
|
|
$template_params(num_params,0,'Original')>
|
|
|
|
VTKM_$(environment.upper()) Result DoStaticTransform$(environment)(
|
2017-05-31 15:37:29 +00:00
|
|
|
const Transform& transform,
|
2019-12-03 18:30:43 +00:00
|
|
|
ParameterContainer<$signature(num_params,ptype(0,'Original'),'Original')>& originalParameters)
|
2014-06-25 22:03:44 +00:00
|
|
|
{
|
|
|
|
$if(num_params < 1)\
|
|
|
|
(void)transform;
|
|
|
|
(void)originalParameters;
|
|
|
|
$else\
|
2019-12-03 18:30:43 +00:00
|
|
|
return Result{
|
2019-04-04 17:20:56 +00:00
|
|
|
$for(param_index in range(1, num_params+1))\
|
2019-11-26 19:26:32 +00:00
|
|
|
transform(originalParameters.Parameter$(param_index), vtkm::internal::IndexTag<$(param_index)>())$comma_if(param_index<num_params)
|
2014-06-25 22:03:44 +00:00
|
|
|
$endfor\
|
2019-11-26 19:26:32 +00:00
|
|
|
};
|
2014-06-25 22:03:44 +00:00
|
|
|
$endif\
|
|
|
|
}
|
|
|
|
|
|
|
|
$endfor\
|
|
|
|
$endfor\
|
2017-05-31 15:37:29 +00:00
|
|
|
// clang-format on
|
2014-06-25 22:03:44 +00:00
|
|
|
|
2017-05-31 15:37:29 +00:00
|
|
|
} // namespace detail
|
2014-06-25 22:03:44 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::internal
|
|
|
|
|
2014-10-08 16:07:08 +00:00
|
|
|
#endif //vtk_m_internal_FunctionInterfaceDetailPre_h
|