Refactoring. Use shared data pointer for class QmuParserCallback.
Should speed up copying. --HG-- branch : develop
This commit is contained in:
parent
72399472a1
commit
29db30548d
|
@ -32,4 +32,5 @@ HEADERS += \
|
|||
$$PWD/qmutranslation.h \
|
||||
$$PWD/qmudef.h \
|
||||
$$PWD/qmuformulabase.h \
|
||||
$$PWD/qmutokenparser.h
|
||||
$$PWD/qmutokenparser.h \
|
||||
$$PWD/qmuparsercallback_p.h
|
||||
|
|
|
@ -29,22 +29,13 @@
|
|||
namespace qmu
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//Supressing specific warnings on gcc/g++ http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( a_iPrec ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( a_iCode ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti, a_iPrec, a_iCode))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -52,12 +43,8 @@ QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int
|
|||
* @brief Constructor for constructing funcstion callbacks taking two arguments.
|
||||
* @throw nothrow
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -69,102 +56,58 @@ QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
|
|||
* @param a_eOprtAsct The operators associativity
|
||||
* @throw nothrow
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback (fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eOprtAsct)
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( a_iPrec ), m_eOprtAsct ( a_eOprtAsct ),
|
||||
m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti, a_iPrec, a_eOprtAsct))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -172,120 +115,68 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
|
|||
* @brief Constructor for constructing funcstion callbacks taking two arguments.
|
||||
* @throw nothrow
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( -1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||
: d (new QmuParserCallbackData(a_pFun, a_bAllowOpti))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -294,8 +185,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
|
|||
* @throw nothrow
|
||||
*/
|
||||
QmuParserCallback::QmuParserCallback()
|
||||
: m_pFun ( nullptr ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ),
|
||||
m_iType ( tpVOID ), m_bAllowOpti ( 0 )
|
||||
: d (new QmuParserCallbackData)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -304,24 +194,356 @@ QmuParserCallback::QmuParserCallback()
|
|||
* @throw nothrow
|
||||
*/
|
||||
QmuParserCallback::QmuParserCallback (const QmuParserCallback &a_Fun )
|
||||
: m_pFun ( a_Fun.m_pFun ), m_iArgc ( a_Fun.m_iArgc ), m_iPri ( a_Fun.m_iPri ), m_eOprtAsct ( a_Fun.m_eOprtAsct ),
|
||||
m_iCode ( a_Fun.m_iCode ), m_iType ( a_Fun.m_iType ), m_bAllowOpti ( a_Fun.m_bAllowOpti )
|
||||
: d (a_Fun.d)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QmuParserCallback &QmuParserCallback::operator=(const QmuParserCallback &a_Fun)
|
||||
{
|
||||
if (this != &a_Fun)
|
||||
if ( &a_Fun == this )
|
||||
{
|
||||
m_pFun = a_Fun.m_pFun;
|
||||
m_iArgc = a_Fun.m_iArgc;
|
||||
m_bAllowOpti = a_Fun.m_bAllowOpti;
|
||||
m_iCode = a_Fun.m_iCode;
|
||||
m_iType = a_Fun.m_iType;
|
||||
m_iPri = a_Fun.m_iPri;
|
||||
m_eOprtAsct = a_Fun.m_eOprtAsct;
|
||||
return *this;
|
||||
}
|
||||
d = a_Fun.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return true if the function is conservative.
|
||||
*
|
||||
* Conservative functions return always the same result for the same argument.
|
||||
* @throw nothrow
|
||||
*/
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool QmuParserCallback::IsOptimizable() const
|
||||
{
|
||||
return d->m_bAllowOpti;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Get the callback address for the parser function.
|
||||
*
|
||||
* The type of the address is void. It needs to be recasted according to the argument number to the right type.
|
||||
*
|
||||
* @throw nothrow
|
||||
* @return #pFun
|
||||
*/
|
||||
void* QmuParserCallback::GetAddr() const
|
||||
{
|
||||
return d->m_pFun;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return the callback code.
|
||||
*/
|
||||
ECmdCode QmuParserCallback::GetCode() const
|
||||
{
|
||||
return d->m_iCode;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ETypeCode QmuParserCallback::GetType() const
|
||||
{
|
||||
return d->m_iType;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return the operator precedence.
|
||||
* @throw nothrown
|
||||
*
|
||||
* Only valid if the callback token is an operator token (binary or infix).
|
||||
*/
|
||||
int QmuParserCallback::GetPri() const
|
||||
{
|
||||
return d->m_iPri;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return the operators associativity.
|
||||
* @throw nothrown
|
||||
*
|
||||
* Only valid if the callback token is a binary operator token.
|
||||
*/
|
||||
EOprtAssociativity QmuParserCallback::GetAssociativity() const
|
||||
{
|
||||
return d->m_eOprtAsct;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns the number of function Arguments.
|
||||
*/
|
||||
int QmuParserCallback::GetArgc() const
|
||||
{
|
||||
return d->m_iArgc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//Supressing specific warnings on gcc/g++ http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData()
|
||||
: m_pFun ( nullptr ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ),
|
||||
m_iType ( tpVOID ), m_bAllowOpti ( 0 )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type0 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( a_iPrec ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( a_iCode ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type2 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData (fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eOprtAsct)
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( a_iPrec ), m_eOprtAsct ( a_eOprtAsct ),
|
||||
m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type3 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type4 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type5 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type6 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type7 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type8 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type9 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( fun_type10 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( bulkfun_type10 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( multfun_type a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( -1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( strfun_type1 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( strfun_type2 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
QmuParserCallbackData::QmuParserCallbackData ( strfun_type3 a_pFun, bool a_bAllowOpti )
|
||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QmuParserCallbackData::QmuParserCallbackData(const QmuParserCallbackData &a_Fun)
|
||||
: QSharedData(a_Fun), m_pFun(a_Fun.m_pFun), m_iArgc(a_Fun.m_iArgc), m_iPri(a_Fun.m_iPri),
|
||||
m_eOprtAsct(a_Fun.m_eOprtAsct), m_iCode(a_Fun.m_iCode), m_iType(a_Fun.m_iType), m_bAllowOpti(a_Fun.m_bAllowOpti)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QmuParserCallbackData::~QmuParserCallbackData()
|
||||
{}
|
||||
|
||||
} // namespace qmu
|
||||
|
|
|
@ -25,8 +25,11 @@
|
|||
#include <qcompilerdetection.h>
|
||||
#include <QString>
|
||||
#include <map>
|
||||
#include <QTypeInfo>
|
||||
#include <QSharedDataPointer>
|
||||
|
||||
#include "qmuparserdef.h"
|
||||
#include "qmuparsercallback_p.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
|
@ -82,6 +85,13 @@ public:
|
|||
QmuParserCallback(const QmuParserCallback &a_Fun);
|
||||
QmuParserCallback &operator=(const QmuParserCallback &a_Fun);
|
||||
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
QmuParserCallback &operator=(QmuParserCallback &&a_Fun) Q_DECL_NOTHROW { Swap(a_Fun); return *this; }
|
||||
#endif
|
||||
|
||||
inline void Swap(QmuParserCallback &a_Fun) Q_DECL_NOTHROW
|
||||
{ std::swap(d, a_Fun.d); }
|
||||
|
||||
Q_REQUIRED_RESULT QmuParserCallback* Clone() const;
|
||||
|
||||
bool IsOptimizable() const;
|
||||
|
@ -92,20 +102,7 @@ public:
|
|||
EOprtAssociativity GetAssociativity() const;
|
||||
int GetArgc() const;
|
||||
private:
|
||||
void *m_pFun; ///< Pointer to the callback function, casted to void
|
||||
|
||||
/**
|
||||
* @brief Number of numeric function arguments
|
||||
*
|
||||
* This number is negative for functions with variable number of arguments. in this cases
|
||||
* they represent the actual number of arguments found.
|
||||
*/
|
||||
int m_iArgc;
|
||||
int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
|
||||
EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
|
||||
ECmdCode m_iCode;
|
||||
ETypeCode m_iType;
|
||||
bool m_bAllowOpti; ///< Flag indication optimizeability
|
||||
QSharedDataPointer<QmuParserCallbackData> d;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -123,81 +120,8 @@ inline QmuParserCallback* QmuParserCallback::Clone() const
|
|||
return new QmuParserCallback ( *this );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return true if the function is conservative.
|
||||
*
|
||||
* Conservative functions return always the same result for the same argument.
|
||||
* @throw nothrow
|
||||
*/
|
||||
// cppcheck-suppress unusedFunction
|
||||
inline bool QmuParserCallback::IsOptimizable() const
|
||||
{
|
||||
return m_bAllowOpti;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Get the callback address for the parser function.
|
||||
*
|
||||
* The type of the address is void. It needs to be recasted according to the argument number to the right type.
|
||||
*
|
||||
* @throw nothrow
|
||||
* @return #pFun
|
||||
*/
|
||||
inline void* QmuParserCallback::GetAddr() const
|
||||
{
|
||||
return m_pFun;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return the callback code.
|
||||
*/
|
||||
inline ECmdCode QmuParserCallback::GetCode() const
|
||||
{
|
||||
return m_iCode;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline ETypeCode QmuParserCallback::GetType() const
|
||||
{
|
||||
return m_iType;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return the operator precedence.
|
||||
* @throw nothrown
|
||||
*
|
||||
* Only valid if the callback token is an operator token (binary or infix).
|
||||
*/
|
||||
inline int QmuParserCallback::GetPri() const
|
||||
{
|
||||
return m_iPri;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Return the operators associativity.
|
||||
* @throw nothrown
|
||||
*
|
||||
* Only valid if the callback token is a binary operator token.
|
||||
*/
|
||||
inline EOprtAssociativity QmuParserCallback::GetAssociativity() const
|
||||
{
|
||||
return m_eOprtAsct;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns the number of function Arguments.
|
||||
*/
|
||||
inline int QmuParserCallback::GetArgc() const
|
||||
{
|
||||
return m_iArgc;
|
||||
}
|
||||
|
||||
} // namespace qmu
|
||||
|
||||
Q_DECLARE_TYPEINFO(qmu::QmuParserCallback, Q_MOVABLE_TYPE);
|
||||
|
||||
#endif
|
||||
|
|
95
src/libs/qmuparser/qmuparsercallback_p.h
Normal file
95
src/libs/qmuparser/qmuparsercallback_p.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/**********************************************************************************************************************
|
||||
**
|
||||
** @file qmuparsercallback_p.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 4, 2018
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
** software and associated documentation files (the "Software"), to deal in the Software
|
||||
** without restriction, including without limitation the rights to use, copy, modify,
|
||||
** merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included in all copies or
|
||||
** substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
** NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
**********************************************************************************************************************/
|
||||
#ifndef QMUPARSERCALLBACK_P_H
|
||||
#define QMUPARSERCALLBACK_P_H
|
||||
|
||||
#include <QSharedData>
|
||||
#include "qmuparserdef.h"
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||
|
||||
namespace qmu
|
||||
{
|
||||
|
||||
class QmuParserCallbackData : public QSharedData
|
||||
{
|
||||
public:
|
||||
QmuParserCallbackData();
|
||||
QmuParserCallbackData(fun_type0 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC);
|
||||
QmuParserCallbackData(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eOprtAsct);
|
||||
QmuParserCallbackData(fun_type2 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type3 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type4 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type5 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type6 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type7 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type8 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type9 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(fun_type10 a_pFun, bool a_bAllowOpti);
|
||||
|
||||
QmuParserCallbackData(bulkfun_type0 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type1 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type2 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type3 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type4 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type5 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type6 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type7 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type8 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type9 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(bulkfun_type10 a_pFun, bool a_bAllowOpti);
|
||||
|
||||
QmuParserCallbackData(multfun_type a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(strfun_type1 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(strfun_type2 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(strfun_type3 a_pFun, bool a_bAllowOpti);
|
||||
QmuParserCallbackData(const QmuParserCallbackData &a_Fun);
|
||||
virtual ~QmuParserCallbackData();
|
||||
|
||||
void *m_pFun; ///< Pointer to the callback function, casted to void
|
||||
|
||||
/**
|
||||
* @brief Number of numeric function arguments
|
||||
*
|
||||
* This number is negative for functions with variable number of arguments. in this cases
|
||||
* they represent the actual number of arguments found.
|
||||
*/
|
||||
int m_iArgc;
|
||||
int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
|
||||
EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
|
||||
ECmdCode m_iCode;
|
||||
ETypeCode m_iType;
|
||||
bool m_bAllowOpti; ///< Flag indication optimizeability
|
||||
|
||||
private:
|
||||
QmuParserCallbackData &operator=(const QmuParserCallbackData &) Q_DECL_EQ_DELETE;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // QMUPARSERCALLBACK_P_H
|
Loading…
Reference in New Issue
Block a user