Skip to content

Commit b58622d

Browse files
committed
Embrace the C++11 spelling of NULL.
1 parent 6f61925 commit b58622d

11 files changed

+95
-94
lines changed

src/asyncmessageworker.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class AsyncMapperChannel : public MapperChannel {
122122
// PHP-side shutdown is complete by the time the destructor is called.
123123
// Tear down JS-side queue. (Completion is async, but that's okay.)
124124
uv_async_t *async = js_queue_.async();
125-
async->data = NULL; // can't touch asyncmessageworker after we return.
125+
async->data = nullptr; // can't touch asyncmessageworker after we return.
126126
uv_close(reinterpret_cast<uv_handle_t*>(async), AsyncClose_);
127127
TRACE("<");
128128
}
@@ -162,7 +162,7 @@ class AsyncMapperChannel : public MapperChannel {
162162
};
163163

164164
virtual void HandleOKCallback(JsObjectMapper *m) {
165-
callback->Call(0, NULL);
165+
callback->Call(0, nullptr);
166166
}
167167

168168
private:
@@ -174,13 +174,13 @@ class AsyncMapperChannel : public MapperChannel {
174174
class JsCleanupSyncMsg : MessageToJs {
175175
friend class AsyncMessageWorker;
176176
explicit JsCleanupSyncMsg(AsyncMessageWorker *that)
177-
: MessageToJs(&(that->channel_), NULL, true), that_(that) { }
177+
: MessageToJs(&(that->channel_), nullptr, true), that_(that) { }
178178
void InJs(JsObjectMapper *m) override {
179179
TRACE("> JsCleanupSyncMsg");
180180
// All previous PHP requests should have been serviced by now.
181181
objid_t last = that_->channel_.ClearAllJsIds();
182182
// Empty the JS side queue.
183-
that_->ProcessJs(NULL, false /* we're inside a ProcessJs already */);
183+
that_->ProcessJs(nullptr, false /* we're inside a ProcessJs already */);
184184
// Ok, return to tell PHP the queues are empty.
185185
retval_.SetInt(last);
186186
TRACE("< JsCleanupSyncMsg");
@@ -226,8 +226,8 @@ class AsyncMapperChannel : public MapperChannel {
226226
last = msg.GetLastId(&channel_ TSRMLS_CC);
227227
// Exit this scope to dealloc msg before proceeding.
228228
}
229-
ProcessPhp(NULL TSRMLS_CC); // A precaution; shouldn't be necessary.
230-
a->data = NULL;
229+
ProcessPhp(nullptr TSRMLS_CC); // A precaution; shouldn't be necessary.
230+
a->data = nullptr;
231231
js_queue_.Shutdown();
232232
/* OK, queues are empty now, we can start tearing things down. */
233233
for (objid_t id = 1; id < last; id++) {
@@ -292,14 +292,14 @@ class AsyncMapperChannel : public MapperChannel {
292292
// Kick the tick. See:
293293
// https://github.com/nodejs/nan/issues/284#issuecomment-150887627
294294
if (kickNextTick) {
295-
kick_next_tick_.Call(0, NULL);
295+
kick_next_tick_.Call(0, nullptr);
296296
}
297297
}
298298

299299
NAN_INLINE static NAUV_WORK_CB(JsAsyncMessage_) {
300300
AsyncMessageWorker *worker = static_cast<AsyncMessageWorker*>(async->data);
301301
if (worker) {
302-
worker->ProcessJs(NULL, true /* from uv loop, kick next tick */);
302+
worker->ProcessJs(nullptr, true /* from uv loop, kick next tick */);
303303
} else {
304304
NPE_ERROR("! JsAsyncMessage after shutdown"); // Shouldn't happen.
305305
}
@@ -333,7 +333,7 @@ class AsyncMapperChannel : public MapperChannel {
333333
AsyncMessageWorker *worker = static_cast<AsyncMessageWorker*>(async->data);
334334
if (worker) {
335335
TSRMLS_FETCH();
336-
worker->ProcessPhp(NULL TSRMLS_CC);
336+
worker->ProcessPhp(nullptr TSRMLS_CC);
337337
} else {
338338
NPE_ERROR("! PhpAsyncMessage after shutdown"); // Shouldn't happen.
339339
}
@@ -392,7 +392,7 @@ v8::Local<v8::Object> amw::AsyncMapperChannel::JsObjForId(objid_t id) {
392392
}
393393
if (!IsValid()) {
394394
// This happens when we return an object at the tail of the request.
395-
return scope.Escape(PhpObject::Create(NULL, 0));
395+
return scope.Escape(PhpObject::Create(nullptr, 0));
396396
}
397397
// Make a wrapper!
398398
v8::Local<v8::NativeWeakMap> jsObjToId = Nan::New(js_obj_to_id_);
@@ -466,10 +466,10 @@ zval *amw::AsyncMapperChannel::PhpObjForId(objid_t id TSRMLS_DC) {
466466

467467
// Free PHP references associated with an id.
468468
void amw::AsyncMapperChannel::ClearPhpId(objid_t id TSRMLS_DC) {
469-
zval *z = (id < php_obj_list_.size()) ? php_obj_list_[id] : NULL;
469+
zval *z = (id < php_obj_list_.size()) ? php_obj_list_[id] : nullptr;
470470
if (z) {
471471
node_php_jsobject_maybe_neuter(z TSRMLS_CC);
472-
php_obj_list_[id] = NULL;
472+
php_obj_list_[id] = nullptr;
473473
php_obj_to_id_.erase(Z_OBJ_HANDLE_P(z));
474474
zval_ptr_dtor(&z);
475475
}

src/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static NAN_INLINE v8::Local<v8::String> CAST_STRING(
124124
#if ZEND_MODULE_API_NO >= 20100409
125125
# define ZEND_HASH_KEY_DC , const zend_literal *key
126126
# define ZEND_HASH_KEY_CC , key
127-
# define ZEND_HASH_KEY_NULL , NULL
127+
# define ZEND_HASH_KEY_NULL , nullptr
128128
#else
129129
# define ZEND_HASH_KEY_DC
130130
# define ZEND_HASH_KEY_CC

src/messagequeue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MessageQueue {
3333
_Push(m);
3434
}
3535
void Notify() {
36-
_Push(NULL);
36+
_Push(nullptr);
3737
}
3838
// Processes all messages on the queue.
3939
// Returns true if at least one message was processed.
@@ -50,7 +50,7 @@ class MessageQueue {
5050
// a recursive processing loop.
5151
uv_mutex_lock(&lock_);
5252
if (data_.empty()) {
53-
m = NULL;
53+
m = nullptr;
5454
if (match) {
5555
// We're blocking for a particular message, and there's nothing here.
5656
// Block to wait for some data.

src/messages.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Message {
8484
// in PHP and the response is handled in JavaScript.
8585
class MessageToPhp : public Message {
8686
public:
87-
// Constructed in JS thread. The callback may be NULL for
87+
// Constructed in JS thread. The callback may be nullptr for
8888
// fire-and-forget methods. If provided, it will be invoked
8989
// nodejs-style, with exception as first arg and retval as second.
9090
// The callback will be owned by the message, and deleted after use.
@@ -110,7 +110,7 @@ class MessageToPhp : public Message {
110110
if (retval_.IsEmpty() && exception_.IsEmpty()) {
111111
// If no result, throw an exception.
112112
const char *msg = (!mapper_->IsValid()) ? "shutdown" :
113-
(!IsEmptyRetvalOk()) ? "no return value" : NULL;
113+
(!IsEmptyRetvalOk()) ? "no return value" : nullptr;
114114
if (msg) {
115115
exception_.SetString(msg, strlen(msg));
116116
}
@@ -178,16 +178,16 @@ class MessageToPhp : public Message {
178178
// in JS and the response is handled in PHP.
179179
class MessageToJs : public Message {
180180
public:
181-
// Constructed in PHP thread. The php_callback may be NULL for
181+
// Constructed in PHP thread. The php_callback may be nullptr for
182182
// fire-and-forget methods. If provided, it will be invoked
183183
// as a closure, with the exception as the first arg and the
184184
// return value as the second. The MessageToJs will ref the
185185
// zval and unref it after use. For sync calls, the php_callback
186186
// should be null and is_sync should be true.
187187
MessageToJs(ObjectMapper *m, zval *php_callback, bool is_sync)
188188
: Message(m), php_callback_(php_callback ZEND_FILE_LINE_CC),
189-
is_sync_(is_sync), js_callback_data_(NULL), local_flag_ptr_(NULL),
190-
stashedChannel_(NULL) {
189+
is_sync_(is_sync), js_callback_data_(nullptr), local_flag_ptr_(nullptr),
190+
stashedChannel_(nullptr) {
191191
assert(is_sync ? php_callback_.IsNull() : true);
192192
}
193193
virtual ~MessageToJs() {}
@@ -221,7 +221,7 @@ class MessageToJs : public Message {
221221
}
222222
// We're out of danger now; reset local_flag_ptr_ so that any async
223223
// exeuctions of ExecuteJs don't use our stack pointer after it's popped.
224-
local_flag_ptr_ = NULL;
224+
local_flag_ptr_ = nullptr;
225225
// If an exception was thrown, set exception_
226226
if (tryCatch.HasCaught()) {
227227
exception_.Set(mapper_, tryCatch.Exception());
@@ -245,7 +245,7 @@ class MessageToJs : public Message {
245245
if (retval_.IsEmpty() && exception_.IsEmpty()) {
246246
// If no result, throw an exception.
247247
const char *msg = (!mapper_->IsValid()) ? "shutdown" :
248-
(!IsEmptyRetvalOk()) ? "no return value" : NULL;
248+
(!IsEmptyRetvalOk()) ? "no return value" : nullptr;
249249
if (msg) {
250250
exception_.Set(mapper_, Nan::TypeError(msg));
251251
}

src/node_php_embed.cc

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class node_php_embed::PhpRequestWorker : public AsyncMessageWorker {
8686
// Can't call zend_clear_exception because there isn't a current
8787
// execution stack (ie, `EG(current_execute_data)`)
8888
zval *e = EG(exception);
89-
EG(exception) = NULL;
89+
EG(exception) = nullptr;
9090
convert_to_string(e);
9191
SetErrorMessage(Z_STRVAL_P(e));
9292
zval_ptr_dtor(&e);
@@ -113,10 +113,10 @@ class node_php_embed::PhpRequestWorker : public AsyncMessageWorker {
113113
}
114114
void AfterExecute(TSRMLS_D) override {
115115
TRACE("> PhpRequestWorker");
116-
NODE_PHP_EMBED_G(worker) = NULL;
117-
NODE_PHP_EMBED_G(channel) = NULL;
116+
NODE_PHP_EMBED_G(worker) = nullptr;
117+
NODE_PHP_EMBED_G(channel) = nullptr;
118118
TRACE("- request shutdown");
119-
php_request_shutdown(NULL);
119+
php_request_shutdown(nullptr);
120120
TRACE("< PhpRequestWorker");
121121
}
122122
// Executed when the async work is complete.
@@ -261,10 +261,10 @@ static void node_php_embed_register_server_variables(
261261
// Allow the JS function to be asynchronous.
262262
node_php_embed::node_php_jswait_create(wait.Ptr() TSRMLS_CC);
263263
// Now invoke the JS function, passing in the wrapper
264-
zval *r = NULL;
264+
zval *r = nullptr;
265265
zend_call_method_with_2_params(init_func.PtrPtr(),
266-
Z_OBJCE_P(init_func.Ptr()), NULL, "__invoke",
267-
&r, server.Ptr(), wait.Ptr());
266+
Z_OBJCE_P(init_func.Ptr()), nullptr,
267+
"__invoke", &r, server.Ptr(), wait.Ptr());
268268
if (EG(exception)) {
269269
NPE_ERROR("Exception in server init function");
270270
zend_clear_exception(TSRMLS_C);
@@ -279,7 +279,8 @@ NAN_METHOD(setIniPath) {
279279
if (php_embed_module.php_ini_path_override) {
280280
free(php_embed_module.php_ini_path_override);
281281
}
282-
php_embed_module.php_ini_path_override = (*iniPath) ? strdup(*iniPath) : NULL;
282+
php_embed_module.php_ini_path_override =
283+
(*iniPath) ? strdup(*iniPath) : nullptr;
283284
TRACE("<");
284285
}
285286

@@ -318,8 +319,8 @@ PHP_MINFO_FUNCTION(node_php_embed) {
318319

319320
static void node_php_embed_globals_ctor(
320321
zend_node_php_embed_globals *node_php_embed_globals TSRMLS_DC) {
321-
node_php_embed_globals->worker = NULL;
322-
node_php_embed_globals->channel = NULL;
322+
node_php_embed_globals->worker = nullptr;
323+
node_php_embed_globals->channel = nullptr;
323324
}
324325
static void node_php_embed_globals_dtor(
325326
zend_node_php_embed_globals *node_php_embed_globals TSRMLS_DC) {
@@ -339,17 +340,17 @@ PHP_MINIT_FUNCTION(node_php_embed) {
339340
zend_module_entry node_php_embed_module_entry = {
340341
STANDARD_MODULE_HEADER,
341342
"node-php-embed", /* extension name */
342-
NULL, /* function entries */
343+
nullptr, /* function entries */
343344
PHP_MINIT(node_php_embed), /* MINIT */
344-
NULL, /* MSHUTDOWN */
345-
NULL, /* RINIT */
346-
NULL, /* RSHUTDOWN */
345+
nullptr, /* MSHUTDOWN */
346+
nullptr, /* RINIT */
347+
nullptr, /* RSHUTDOWN */
347348
PHP_MINFO(node_php_embed), /* MINFO */
348349
NODE_PHP_EMBED_VERSION,
349350
ZEND_MODULE_GLOBALS(node_php_embed),
350351
(void(*)(void* TSRMLS_DC))node_php_embed_globals_ctor,
351352
(void(*)(void* TSRMLS_DC))node_php_embed_globals_dtor,
352-
NULL, /* post deactivate func */
353+
nullptr, /* post deactivate func */
353354
STANDARD_MODULE_PROPERTIES_EX
354355
};
355356

@@ -366,22 +367,22 @@ static void node_php_embed_ensure_init(void) {
366367
}
367368
TRACE(">");
368369
node_php_embed_inited = true;
369-
char *argv[] = { NULL };
370+
char *argv[] = { nullptr };
370371
int argc = 0;
371372
php_embed_init(argc, argv PTSRMLS_CC);
372373
// Shutdown the initially-created request; we'll create our own request
373374
// objects inside PhpRequestWorker.
374-
php_request_shutdown(NULL);
375-
node::AtExit(ModuleShutdown, NULL);
375+
php_request_shutdown(nullptr);
376+
node::AtExit(ModuleShutdown, nullptr);
376377
TRACE("<");
377378
}
378379

379380
NAN_MODULE_INIT(ModuleInit) {
380381
TRACE(">");
381-
php_embed_module.php_ini_path_override = NULL;
382+
php_embed_module.php_ini_path_override = nullptr;
382383
php_embed_module.php_ini_ignore = true;
383384
php_embed_module.php_ini_ignore_cwd = true;
384-
php_embed_module.ini_defaults = NULL;
385+
php_embed_module.ini_defaults = nullptr;
385386
php_embed_module.startup = node_php_embed_startup;
386387
php_embed_module.send_header = node_php_embed_send_header;
387388
php_embed_module.ub_write = node_php_embed_ub_write;

src/node_php_jsbuffer_class.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ static zend_object_value node_php_jsbuffer_new(zend_class_entry *ce TSRMLS_DC) {
6262
zend_object_std_init(&c->std, ce TSRMLS_CC);
6363

6464
retval.handle = zend_objects_store_put(
65-
c, NULL,
65+
c, nullptr,
6666
(zend_objects_free_object_storage_t) node_php_jsbuffer_free_storage,
67-
NULL TSRMLS_CC);
67+
nullptr TSRMLS_CC);
6868
retval.handlers = &node_php_jsbuffer_handlers;
6969

7070
TRACE("<");
@@ -91,7 +91,7 @@ void node_php_embed::node_php_jsbuffer_create(zval *res,
9191
c->data = data;
9292
c->length = length;
9393
c->owner = owner;
94-
c->z = NULL;
94+
c->z = nullptr;
9595

9696
TRACE("<");
9797
}
@@ -165,9 +165,9 @@ STUB_METHOD(__wakeup)
165165
static const zend_function_entry node_php_jsbuffer_methods[] = {
166166
PHP_ME(JsBuffer, __construct, node_php_jsbuffer_construct_args,
167167
ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
168-
PHP_ME(JsBuffer, __sleep, NULL,
168+
PHP_ME(JsBuffer, __sleep, nullptr,
169169
ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
170-
PHP_ME(JsBuffer, __wakeup, NULL,
170+
PHP_ME(JsBuffer, __wakeup, nullptr,
171171
ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
172172
PHP_ME(JsBuffer, __toString, node_php_jsbuffer_toString_args,
173173
ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
@@ -188,9 +188,9 @@ PHP_MINIT_FUNCTION(node_php_jsbuffer_class) {
188188
/* JsBuffer handlers */
189189
memcpy(&node_php_jsbuffer_handlers, zend_get_std_object_handlers(),
190190
sizeof(zend_object_handlers));
191-
node_php_jsbuffer_handlers.clone_obj = NULL;
192-
node_php_jsbuffer_handlers.cast_object = NULL;
193-
node_php_jsbuffer_handlers.get_property_ptr_ptr = NULL;
191+
node_php_jsbuffer_handlers.clone_obj = nullptr;
192+
node_php_jsbuffer_handlers.cast_object = nullptr;
193+
node_php_jsbuffer_handlers.get_property_ptr_ptr = nullptr;
194194

195195
TRACE("< PHP_MINIT_FUNCTION");
196196
return SUCCESS;

0 commit comments

Comments
 (0)