Kaydet (Commit) 433b1fdd authored tarafından Luboš Luňák's avatar Luboš Luňák

add a macro for detecting incorrect number of parameters in opencl

Change-Id: Id8253537025cc373c1ff183c0059158489e11750
Reviewed-on: https://gerrit.libreoffice.org/64239
Tested-by: Jenkins
Reviewed-by: 's avatarLuboš Luňák <l.lunak@collabora.com>
üst 27f27e10
......@@ -4053,6 +4053,13 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken
delete pDynamicKernel;
return nullptr;
}
catch (const InvalidParameterCount& ipc)
{
SAL_INFO("sc.opencl", "Dynamic formula compiler: InvalidParameterCount " << ipc.mParameterCount
<< " at " << ipc.mFile << ":" << ipc.mLineNumber);
delete pDynamicKernel;
return nullptr;
}
catch (const OpenCLError& oce)
{
// I think OpenCLError exceptions are actually exceptional (unexpected), so do use SAL_WARN
......
......@@ -34,6 +34,9 @@ OpenCLError::OpenCLError( const std::string& function, cl_int error, const std::
Unhandled::Unhandled( const std::string& fn, int ln ) :
mFile(fn), mLineNumber(ln) {}
InvalidParameterCount::InvalidParameterCount( int parameterCount, const std::string& file, int ln ) :
mParameterCount(parameterCount), mFile(file), mLineNumber(ln) {}
DynamicKernelArgument::DynamicKernelArgument( const ScCalcConfig& config, const std::string& s,
const FormulaTreeNodeRef& ft ) :
mCalcConfig(config), mSymName(s), mFormulaTree(ft) { }
......
......@@ -60,6 +60,25 @@ public:
int const mLineNumber;
};
class InvalidParameterCount
{
public:
InvalidParameterCount( int parameterCount, const std::string& file, int ln );
int mParameterCount;
std::string mFile;
int const mLineNumber;
};
// Helper macro to be used in code emitting OpenCL code for Calc functions.
// Requires the vSubArguments parameter.
#define CHECK_PARAMETER_COUNT(min, max) \
do { \
const int count = vSubArguments.size(); \
if( count < ( min ) || count > ( max )) \
throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
} while( false )
typedef std::shared_ptr<FormulaTreeNode> FormulaTreeNodeRef;
class FormulaTreeNode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment