Permalink
Browse files

use nullptr instead of NULL

  • Loading branch information...
tcaduser committed Jan 7, 2019
1 parent d0e4f33 commit c80fff9fbb3689f7f0df0dc1b3a58ec9e9c46ac5
@@ -147,7 +147,7 @@ EqObjPtr Add::Simplify()
for (size_t i = 0; i < len; ++i)
{
Add *foo = dynamic_cast<Add *>(tvals[i].get());
if (foo == NULL)
if (foo == nullptr)
{
tmp.push_back(tvals[i]);
}
@@ -39,7 +39,7 @@ extern Eqo::EqObjPtr DLL_PUBLIC default_derivative_rule(Eqo::EqObjPtr, Eqo::EqOb
//// Be able to store rules in the future.
class ContextData {
public:
ContextData() : callback_func_ptr_(NULL), model_derivative_rule_ptr_(Eqo::default_derivative_rule)
ContextData() : callback_func_ptr_(nullptr), model_derivative_rule_ptr_(Eqo::default_derivative_rule)
{
}

@@ -174,12 +174,12 @@ Eqo::EqObjPtr getNegation(Eqo::EqObjPtr x)

bool isBinaryFunction(const std::string &str)
{
return Eqo::getBinaryFuncPtr(str) != NULL;
return Eqo::getBinaryFuncPtr(str) != nullptr;
}

bool isUnaryFunction(const std::string &str)
{
return Eqo::getUnaryFuncPtr(str) != NULL;
return Eqo::getUnaryFuncPtr(str) != nullptr;
}
EqBinaryFuncPtr getBinaryFuncPtr(const std::string &str)
{
@@ -27,35 +27,35 @@ UnaryTblEntry UnaryTable[] = {
{"scale", getConstantFactor,"scale(obj) -- Get constant factor"},
{"unsignedval", getUnsignedValue, "unsignedval(obj) -- Get unsigned value"},
{"sign", getSign, "sign(obj) -- Get sign as 1 or -1"},
{NULL, NULL, NULL}
{nullptr, nullptr, nullptr}
};

BinaryTblEntry BinaryTable[] = {
{"pow", pow, "pow(obj1, obj2) -- Raise obj1 to the power of obj2"},
{"diff", diff, "diff(obj1, obj2) -- Take derivative of obj1 with respect to obj2"},
{NULL, NULL, NULL}
{nullptr, nullptr, nullptr}
};

EqUnaryFuncPtr getUnaryFuncPtr(std::string x) {
size_t i=0;
while (UnaryTable[i].name != NULL)
while (UnaryTable[i].name != nullptr)
{
if (x == UnaryTable[i].name)
return UnaryTable[i].func;
++i;
}
return NULL;
return nullptr;
}

EqBinaryFuncPtr getBinaryFuncPtr(std::string x) {
size_t i=0;
while (BinaryTable[i].name != NULL)
while (BinaryTable[i].name != nullptr)
{
if (x == BinaryTable[i].name)
return BinaryTable[i].func;
++i;
}
return NULL;
return nullptr;
}
}

@@ -191,7 +191,7 @@ void Product::ProductVecSimplify(std::vector<EqObjPtr> &tvals)
for (size_t i = 0; i < len; ++i)
{
Product *foo = dynamic_cast<Product *>(tvals[i].get());
if (foo == NULL)
if (foo == nullptr)
{
tmp.push_back(tvals[i]);
}
@@ -34,12 +34,12 @@ Eqo::EqObjPtr evaluateExpression(const std::string &x, error_t &errors)
y += x;
y += ";";
lerrors = &errors;
YY_BUFFER_STATE yyb = NULL;
YY_BUFFER_STATE yyb = nullptr;
// clearVariableMap();
yyb = mc_scan_string(y.c_str());
int retval = 0;
retval = mcparse();
if (yyb != NULL)
if (yyb != nullptr)
{
mc_delete_buffer(yyb);
}
@@ -52,7 +52,7 @@ Eqo::EqObjPtr evaluateExpression(const std::string &x, error_t &errors)
{
result = Eqo::con(0.0);
}
lerrors=NULL;
lerrors=nullptr;
return result;
}
}
@@ -35,7 +35,7 @@ limitations under the License.
#include <sstream>

namespace {
PyObject *symdiff_exception = NULL;
PyObject *symdiff_exception = nullptr;
};

namespace {
@@ -160,7 +160,7 @@ Takes one argument, which is the command to evaluate
static PyObject *
symdiffCmd(PyObject *, PyObject *args)
{
PyObject *returnObj = NULL;
PyObject *returnObj = nullptr;
std::string errorString;

dsHelper::ret_pair tret = GetStringArgument(args);
@@ -188,7 +188,7 @@ symdiffCmd(PyObject *, PyObject *args)
static PyObject *
symdiffTableCmd(PyObject *, PyObject *args)
{
PyObject *returnObj = NULL;
PyObject *returnObj = nullptr;
std::string errorString;

dsHelper::ret_pair tret = GetStringArgument(args);
@@ -262,7 +262,7 @@ symdiffTableCmd(PyObject *, PyObject *args)
static PyObject *
modelListCmd(PyObject *, PyObject *args)
{
PyObject *returnObj = NULL;
PyObject *returnObj = nullptr;
if (HasZeroArguments(args))
{
const ModelMap_t &model_list = Context::GetInstance().GetModelMap();
@@ -292,7 +292,7 @@ modelListCmd(PyObject *, PyObject *args)
static PyObject *
subexpressionCmd(PyObject *, PyObject *args)
{
PyObject *returnObj = NULL;
PyObject *returnObj = nullptr;
std::string errorString;
dsHelper::ret_pair result;
result.first = false;
@@ -314,7 +314,7 @@ subexpressionCmd(PyObject *, PyObject *args)
static PyObject *
removeZerosCmd(PyObject *, PyObject *args)
{
PyObject *returnObj = NULL;
PyObject *returnObj = nullptr;
if (HasZeroArguments(args))
{
SubExpr subexpr;
@@ -329,7 +329,7 @@ static PyObject *
orderedListCmd(PyObject *, PyObject *args)
{
std::string errorString;
PyObject *returnObj = NULL;
PyObject *returnObj = nullptr;
StringVector_t model_vector_in;
if (GetStringArguments(args, model_vector_in))
{
@@ -373,7 +373,7 @@ static struct PyMethodDef symdiff_methods[] = {
{"subexpression", subexpressionCmd, METH_VARARGS},
{"remove_zeros", removeZerosCmd, METH_VARARGS},
{"ordered_list", orderedListCmd, METH_VARARGS},
{NULL, NULL, 0}
{nullptr, nullptr, 0}
};


@@ -395,16 +395,16 @@ static int symdiff_clear(PyObject *m) {
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"symdiff_py3",
NULL,
nullptr,
sizeof(struct module_state),
symdiff_methods,
NULL,
nullptr,
symdiff_traverse,
symdiff_clear,
NULL
nullptr
};

#define INITERROR return NULL
#define INITERROR return nullptr

DLL_PUBLIC PyObject *PyInit_symdiff_py3(void)
#else
@@ -417,11 +417,11 @@ void DLL_PUBLIC initsymdiff_py2()
#else
PyObject *m = Py_InitModule("symdiff_py2", symdiff_methods);
#endif
if (m == NULL)
if (m == nullptr)
{
INITERROR;
}
symdiff_exception = PyErr_NewException(const_cast<char *>("symdiff.SymdiffError"), NULL, NULL);
symdiff_exception = PyErr_NewException(const_cast<char *>("symdiff.SymdiffError"), nullptr, nullptr);
Py_INCREF(symdiff_exception);
PyModule_AddObject(m, "SymdiffError", symdiff_exception);

@@ -435,7 +435,7 @@ void DLL_PUBLIC initsymdiff_py2()
static struct _inittab symdiffinittab[] =
{
{(char *)"symdiff", initsymdiff},
{(char *)NULL, NULL}
{(char *)nullptr, nullptr}
};
#endif

@@ -53,7 +53,7 @@ CmdDispatch(ClientData clientData, Tcl_Interp *interp,

void AddCommands(Tcl_Interp *interp, Commands *clist)
{
for ( ; (clist->name) != NULL; ++clist)
for ( ; (clist->name) != nullptr; ++clist)
{
void *cdata = dsClientData::CreateData(clist->name, clist->command);

@@ -53,7 +53,7 @@ symdiffCmd(ClientData clientData, Tcl_Interp *interp,

if (objc == 2)
{
const std::string &expr = Tcl_GetStringFromObj(objv[1], NULL);
const std::string &expr = Tcl_GetStringFromObj(objv[1], nullptr);
result = dsHelper::SymdiffEval(expr);

if (!result.first)
@@ -96,7 +96,7 @@ symdiffTableCmd(ClientData clientData, Tcl_Interp *interp,

if (objc == 2)
{
const std::string &expr = Tcl_GetStringFromObj(objv[1], NULL);
const std::string &expr = Tcl_GetStringFromObj(objv[1], nullptr);
result = dsHelper::SymdiffEval(expr);

if (!result.first)
@@ -138,7 +138,7 @@ symdiffTableCmd(ClientData clientData, Tcl_Interp *interp,
const std::vector<size_t> &references = data.references_;

Tcl_Obj *rowobj = Tcl_NewObj();
Tcl_Obj *subobj = NULL;
Tcl_Obj *subobj = nullptr;
subobj = Tcl_NewStringObj(name.c_str(), -1);
Tcl_ListObjAppendElement(interp, rowobj, subobj);
subobj = Tcl_NewStringObj(type.c_str(), -1);
@@ -288,7 +288,7 @@ orderedListCmd(ClientData clientData, Tcl_Interp *interp,

for (size_t i = 1; i < static_cast<size_t>(objc); ++i)
{
const std::string &model_name = Tcl_GetStringFromObj(objv[i], NULL);
const std::string &model_name = Tcl_GetStringFromObj(objv[i], nullptr);
model_vector_in[i-1] = model_name;
}

@@ -336,7 +336,7 @@ Commands TclSymdiffCommands[] = {
{"subexpression", subexpressionCmd},
{"ordered_list", orderedListCmd},
{"remove_zeros", removeZerosCmd},
{NULL, NULL}
{nullptr, nullptr}
};

}
@@ -29,7 +29,7 @@ extern "C" {
int DLL_PUBLIC
Symdifftcl_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == nullptr) {
return TCL_ERROR;
}
if (Tcl_PkgProvide(interp, "symdifftcl", "1.0") == TCL_ERROR) {
@@ -40,8 +40,8 @@ Symdifftcl_Init(Tcl_Interp *interp)
}

DLL_PUBLIC Tcl_PackageInitProc *Symdifftcl_SafeInit = Symdifftcl_Init;
DLL_PUBLIC Tcl_PackageUnloadProc *Symdifftcl_SafeUnload = NULL;
DLL_PUBLIC Tcl_PackageUnloadProc *Symdifftcl_Unload = NULL;
DLL_PUBLIC Tcl_PackageUnloadProc *Symdifftcl_SafeUnload = nullptr;
DLL_PUBLIC Tcl_PackageUnloadProc *Symdifftcl_Unload = nullptr;


}

0 comments on commit c80fff9

Please sign in to comment.