Skip to content

Commit

Permalink
Replaced NULL with nullptr in C++ files.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeStrout committed Feb 25, 2024
1 parent 3afe6c7 commit 64e1d49
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 90 deletions.
6 changes: 3 additions & 3 deletions MiniScript-cpp/src/MiniScript/Dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace MiniScript {
template <class K, class V>
class DictionaryStorage : public RefCountedStorage {
private:
DictionaryStorage() : RefCountedStorage(), mSize(0), assignOverride(NULL), evalOverride(NULL) { for (int i=0; i<TABLE_SIZE; i++) mTable[i] = nullptr; }
DictionaryStorage() : RefCountedStorage(), mSize(0), assignOverride(nullptr), evalOverride(nullptr) { for (int i=0; i<TABLE_SIZE; i++) mTable[i] = nullptr; }
~DictionaryStorage() { RemoveAll(); }

void RemoveAll() {
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace MiniScript {
typedef bool (*AssignOverrideCallback)(Dictionary<K,V,HASH> &dict, K key, V value);
void SetAssignOverride(AssignOverrideCallback callback) { ensureStorage(); ds->assignOverride = (void*)callback; }
bool ApplyAssignOverride(K key, V value) {
if (ds == NULL or ds->assignOverride == NULL) return false;
if (ds == nullptr or ds->assignOverride == nullptr) return false;
AssignOverrideCallback cb = (AssignOverrideCallback)(ds->assignOverride);
return cb(*this, key, value);
}
Expand All @@ -144,7 +144,7 @@ namespace MiniScript {
typedef bool (*EvalOverrideCallback)(Dictionary<K,V,HASH> &dict, K key, V& outValue);
void SetEvalOverride(EvalOverrideCallback callback) { ensureStorage(); ds->evalOverride = (void*)callback; }
bool ApplyEvalOverride(K key, V& outValue) {
if (ds == NULL or ds->evalOverride == NULL) return false;
if (ds == nullptr or ds->evalOverride == nullptr) return false;
EvalOverrideCallback cb = (EvalOverrideCallback)(ds->evalOverride);
return cb(*this, key, outValue);
}
Expand Down
2 changes: 1 addition & 1 deletion MiniScript-cpp/src/MiniScript/MiniscriptInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace MiniScript {
if (not vm) return Value::null;

Context* globalContext = vm->GetGlobalContext();
if (globalContext == NULL) return Value::null;
if (globalContext == nullptr) return Value::null;
try
{
return globalContext->GetVar(varName);
Expand Down
4 changes: 2 additions & 2 deletions MiniScript-cpp/src/MiniScript/MiniscriptIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace MiniScript {

static inline void InitRand() {
if (!randInitialized) {
srand((unsigned int)time(NULL));
srand((unsigned int)time(nullptr));
for (int i=0; i<10; i++) rand();
randInitialized = true;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ namespace MiniScript {

for (int i=0; i<Intrinsic::all.Count(); i++) {
Intrinsic* intrinsic = Intrinsic::all[i];
if (intrinsic == NULL || intrinsic->name.empty()) continue;
if (intrinsic == nullptr || intrinsic->name.empty()) continue;
_intrinsicsMap.SetValue(intrinsic->name, intrinsic->GetFunc());
}

Expand Down
10 changes: 5 additions & 5 deletions MiniScript-cpp/src/MiniScript/MiniscriptTAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace MiniScript {
if (op == Op::ElemBofA && opB.type == ValueType::String) {
// You can now look for a String in almost anything...
// and we have a convenient (and relatively fast) method for it:
return Value::Resolve(opA, opB.ToString(), context, NULL);
return Value::Resolve(opA, opB.ToString(), context, nullptr);
}

// check for special cases of comparison to null (works with any type)
Expand Down Expand Up @@ -323,7 +323,7 @@ namespace MiniScript {
size_t totalBytes = lenB * repeats + extraStr.LengthB();
if (totalBytes > Value::maxStringSize) LimitExceededException("string too large").raise();
char *buf = new char[totalBytes+1];
if (buf == NULL) return Value::null;
if (buf == nullptr) return Value::null;
char *ptr = buf;
for (int i = 0; i < repeats; i++) {
strncpy(ptr, sA.c_str(), lenB);
Expand Down Expand Up @@ -573,7 +573,7 @@ namespace MiniScript {

// OK, we don't have a local or module variable with that name.
// Check the global scope (if that's not us already).
if (parent != NULL) {
if (parent != nullptr) {
Context* globals = Root();
if (globals->variables.Get(identifier, &result)) return result;
}
Expand Down Expand Up @@ -758,7 +758,7 @@ namespace MiniScript {
String nullStr;
if (stack.Count() < 1) return nullStr;
Context *globalContext = stack[0];
if (globalContext == NULL) return nullStr;
if (globalContext == nullptr) return nullStr;
for (ValueDictIterator kv = globalContext->variables.GetIterator(); !kv.Done(); kv.Next()) {
if (!kv.Value().RefEquals(val)) continue;
String varName = kv.Key().ToString();
Expand All @@ -772,7 +772,7 @@ namespace MiniScript {
return GetTickCount() * 0.001;
#else
struct timeval timecheck;
gettimeofday(&timecheck, NULL);
gettimeofday(&timecheck, nullptr);
return (long)timecheck.tv_sec * 1.0 + (long)timecheck.tv_usec / 1000000.0;
#endif
}
Expand Down
12 changes: 6 additions & 6 deletions MiniScript-cpp/src/MiniScript/MiniscriptTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace MiniScript {
case ValueType::Map:
{
if (recursionLimit == 0) return "{...}";
if (recursionLimit > 0 && recursionLimit < 3 && vm != NULL) {
if (recursionLimit > 0 && recursionLimit < 3 && vm != nullptr) {
String shortName = vm->FindShortName(*this);
if (!shortName.empty()) return shortName;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ namespace MiniScript {
case ValueType::Handle:
{
// Any handle at all is true.
return (data.ref != NULL);
return (data.ref != nullptr);
}

default:
Expand Down Expand Up @@ -888,13 +888,13 @@ void TestValue::TestBasics()
Assert(c.type == ValueType::Number and c.data.number == 42);

a = "Foo!";
Assert(a.type == ValueType::String and a.ToString(NULL) == "Foo!");
Assert(a.type == ValueType::String and a.ToString(nullptr) == "Foo!");
b = a;
Assert(b.type == ValueType::String and b.ToString(NULL) == "Foo!");
Assert(b.type == ValueType::String and b.ToString(nullptr) == "Foo!");

Assert(c.type == ValueType::Number and c.data.number == 42);
b = 0.0;
Assert(a.type == ValueType::String and a.ToString(NULL) == "Foo!");
Assert(a.type == ValueType::String and a.ToString(nullptr) == "Foo!");

{
List<Value> lst;
Expand All @@ -904,7 +904,7 @@ void TestValue::TestBasics()
a = lst;
}
Assert(a.type == ValueType::List);
String s = a.ToString(NULL);
String s = a.ToString(nullptr);
Assert(s == "[1, \"two\", 3.14157]");
}

Expand Down
2 changes: 1 addition & 1 deletion MiniScript-cpp/src/MiniScript/MiniscriptTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace MiniScript {
return type == ValueType::Null /* || (usesRef() && data.ref == nullptr) */;
}

Value Val(Context *context, ValueDict *outFoundInMap=NULL) const;
Value Val(Context *context, ValueDict *outFoundInMap=nullptr) const;

/// Evaluate each of our contained elements, and if any of those is a variable
/// or temp, then resolve them now. CAUTION: do not mutate the original list
Expand Down
2 changes: 1 addition & 1 deletion MiniScript-cpp/src/MiniScript/SimpleString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace MiniScript {
Assert(s > empty);
Assert(empty < s);
// Test null and empty String are equal
Assert(empty == NULL);
Assert(empty == nullptr);
Assert(empty == "");


Expand Down
24 changes: 12 additions & 12 deletions MiniScript-cpp/src/ShellExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ String readFromFd(HANDLE fd, bool trimTrailingNewline=true) {
bool trimmed = false;

for (;;) {
bSuccess = ReadFile(fd, buffer, bufferSize-1, &bytesRead, NULL);
bSuccess = ReadFile(fd, buffer, bufferSize-1, &bytesRead, nullptr);
if (!bSuccess || bytesRead == 0) break;
buffer[bytesRead] = '\0';
if (trimTrailingNewline and bytesRead < bufferSize-1 and bytesRead > 0 and buffer[bytesRead-1] == '\n') {
Expand Down Expand Up @@ -74,12 +74,12 @@ bool BeginExec(String cmd, double timeout, double currentTime, ValueList* outRes
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
saAttr.lpSecurityDescriptor = nullptr;

HANDLE hChildStd_OUT_Rd = NULL;
HANDLE hChildStd_OUT_Wr = NULL;
HANDLE hChildStd_ERR_Rd = NULL;
HANDLE hChildStd_ERR_Wr = NULL;
HANDLE hChildStd_OUT_Rd = nullptr;
HANDLE hChildStd_OUT_Wr = nullptr;
HANDLE hChildStd_ERR_Rd = nullptr;
HANDLE hChildStd_ERR_Wr = nullptr;

// Create a pipe for the child process's STDOUT and STDERR.
// Disable the INHERIT flag to ensure each handle is not inherited
Expand All @@ -99,14 +99,14 @@ bool BeginExec(String cmd, double timeout, double currentTime, ValueList* outRes
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));

// Start the child process.
if (!CreateProcessA(NULL,
if (!CreateProcessA(nullptr,
(LPSTR)cmd.c_str(), // command line
NULL, // process security attributes
NULL, // primary thread security attributes
nullptr, // process security attributes
nullptr, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
nullptr, // use parent's environment
nullptr, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo)) // receives PROCESS_INFORMATION
{
Expand Down Expand Up @@ -243,7 +243,7 @@ bool BeginExec(String cmd, double timeout, double currentTime, ValueList* outRes

// Call the host environment's command processor. Or if the command
// is empty, then return a nonzero value iff the command processor exists.
const char* cmdPtr = cmd.empty() ? NULL : cmd.c_str();
const char* cmdPtr = cmd.empty() ? nullptr : cmd.c_str();
int cmdResult = std::system(cmdPtr);
cmdResult = WEXITSTATUS(cmdResult);

Expand Down
Loading

0 comments on commit 64e1d49

Please sign in to comment.