Skip to content

Commit

Permalink
Replace remaining uses of NULL with nullptr
Browse files Browse the repository at this point in the history
Follow-up to #38736 (these uses were likely added after this PR was merged).
  • Loading branch information
akien-mga committed Apr 29, 2021
1 parent c115027 commit 5b16020
Show file tree
Hide file tree
Showing 32 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion drivers/vulkan/vulkan_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ Error VulkanContext::_create_physical_device() {
}
}

/* Call with NULL data to get count */
/* Call with nullptr data to get count */
vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queue_family_count, nullptr);
ERR_FAIL_COND_V(queue_family_count == 0, ERR_CANT_CREATE);

Expand Down
2 changes: 1 addition & 1 deletion editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "scene/main/window.h"
#include "scene/resources/font.h"

///////////////////// NULL /////////////////////////
///////////////////// Nil /////////////////////////

void EditorPropertyNil::update_property() {
}
Expand Down
24 changes: 12 additions & 12 deletions modules/camera/camera_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ - (void)cleanup {
if (input) {
[self removeInput:input];
// don't release this
input = NULL;
input = nullptr;
}

// free up our output
if (output) {
[self removeOutput:output];
[output setSampleBufferDelegate:nil queue:NULL];
[output setSampleBufferDelegate:nil queue:nullptr];
[output release];
output = NULL;
output = nullptr;
}

[self commitConfiguration];
Expand All @@ -141,9 +141,9 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
// get our buffers
unsigned char *dataY = (unsigned char *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
unsigned char *dataCbCr = (unsigned char *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
if (dataY == NULL) {
if (dataY == nullptr) {
print_line("Couldn't access Y pixel buffer data");
} else if (dataCbCr == NULL) {
} else if (dataCbCr == nullptr) {
print_line("Couldn't access CbCr pixel buffer data");
} else {
Ref<Image> img[2];
Expand Down Expand Up @@ -220,8 +220,8 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
};

CameraFeedOSX::CameraFeedOSX() {
device = NULL;
capture_session = NULL;
device = nullptr;
capture_session = nullptr;
};

void CameraFeedOSX::set_device(AVCaptureDevice *p_device) {
Expand All @@ -240,14 +240,14 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
};

CameraFeedOSX::~CameraFeedOSX() {
if (capture_session != NULL) {
if (capture_session != nullptr) {
[capture_session release];
capture_session = NULL;
capture_session = nullptr;
};

if (device != NULL) {
if (device != nullptr) {
[device release];
device = NULL;
device = nullptr;
};
};

Expand All @@ -267,7 +267,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
if (capture_session) {
[capture_session cleanup];
[capture_session release];
capture_session = NULL;
capture_session = nullptr;
};
};

Expand Down
2 changes: 1 addition & 1 deletion modules/fbx/editor_scene_importer_fbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_fl
bool is_binary = false;
data.resize(f->get_len());

ERR_FAIL_COND_V(data.size() < 64, NULL);
ERR_FAIL_COND_V(data.size() < 64, nullptr);

f->get_buffer(data.ptrw(), data.size());
PackedByteArray fbx_header;
Expand Down
2 changes: 1 addition & 1 deletion modules/fbx/fbx_parser/FBXAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ AnimationCurve::~AnimationCurve() {

// ------------------------------------------------------------------------------------------------
AnimationCurveNode::AnimationCurveNode(uint64_t id, const ElementPtr element, const std::string &name,
const Document &doc, const char *const *target_prop_whitelist /*= NULL*/,
const Document &doc, const char *const *target_prop_whitelist /*= nullptr*/,
size_t whitelist_size /*= 0*/) :
Object(id, element, name), target(), doc(doc) {
// find target node
Expand Down
4 changes: 2 additions & 2 deletions modules/fbx/fbx_parser/FBXDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class AnimationCurveNode : public Object {

const AnimationMap &Curves() const;

/** Object the curve is assigned to, this can be NULL if the
/** Object the curve is assigned to, this can be nullptr if the
* target object has no DOM representation or could not
* be read for other reasons.*/
Object *Target() const {
Expand Down Expand Up @@ -989,7 +989,7 @@ class Connection {

// note: a connection ensures that the source and dest objects exist, but
// not that they have DOM representations, so the return value of one of
// these functions can still be NULL.
// these functions can still be nullptr.
Object *SourceObject() const;
Object *DestinationObject() const;

Expand Down
8 changes: 4 additions & 4 deletions modules/fbx/fbx_parser/FBXDocumentUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ void DOMError(const std::string &message, const std::shared_ptr<Token> token) {
print_error("[FBX-DOM]" + String(message.c_str()) + ";" + String(token->StringContents().c_str()));
}

void DOMError(const std::string &message, const Element *element /*= NULL*/) {
void DOMError(const std::string &message, const Element *element /*= nullptr*/) {
if (element) {
DOMError(message, element->KeyToken());
}
print_error("[FBX-DOM] " + String(message.c_str()));
}

void DOMError(const std::string &message, const std::shared_ptr<Element> element /*= NULL*/) {
void DOMError(const std::string &message, const std::shared_ptr<Element> element /*= nullptr*/) {
if (element) {
DOMError(message, element->KeyToken());
}
Expand All @@ -117,7 +117,7 @@ void DOMWarning(const std::string &message, const Token *token) {
print_verbose("[FBX-DOM] warning:" + String(message.c_str()) + ";" + String(token->StringContents().c_str()));
}

void DOMWarning(const std::string &message, const Element *element /*= NULL*/) {
void DOMWarning(const std::string &message, const Element *element /*= nullptr*/) {
if (element) {
DOMWarning(message, element->KeyToken());
return;
Expand All @@ -129,7 +129,7 @@ void DOMWarning(const std::string &message, const std::shared_ptr<Token> token)
print_verbose("[FBX-DOM] warning:" + String(message.c_str()) + ";" + String(token->StringContents().c_str()));
}

void DOMWarning(const std::string &message, const std::shared_ptr<Element> element /*= NULL*/) {
void DOMWarning(const std::string &message, const std::shared_ptr<Element> element /*= nullptr*/) {
if (element) {
DOMWarning(message, element->KeyToken());
return;
Expand Down
2 changes: 1 addition & 1 deletion modules/fbx/fbx_parser/FBXMeshGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Geometry : public Object {
Geometry(uint64_t id, const ElementPtr element, const std::string &name, const Document &doc);
virtual ~Geometry();

/** Get the Skin attached to this geometry or NULL */
/** Get the Skin attached to this geometry or nullptr */
const Skin *DeformerSkin() const;

const std::vector<const BlendShape *> &get_blend_shapes() const;
Expand Down
4 changes: 2 additions & 2 deletions modules/fbx/fbx_parser/FBXParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ std::string ParseTokenAsString(const TokenPtr t) {

// ------------------------------------------------------------------------------------------------
// extract a required element from a scope, abort if the element cannot be found
ElementPtr GetRequiredElement(const ScopePtr sc, const std::string &index, const ElementPtr element /*= NULL*/) {
ElementPtr GetRequiredElement(const ScopePtr sc, const std::string &index, const ElementPtr element /*= nullptr*/) {
const ElementPtr el = sc->GetElement(index);
TokenPtr token = el->KeyToken();
ERR_FAIL_COND_V(!token, nullptr);
Expand All @@ -1227,7 +1227,7 @@ bool HasElement(const ScopePtr sc, const std::string &index) {

// ------------------------------------------------------------------------------------------------
// extract a required element from a scope, abort if the element cannot be found
ElementPtr GetOptionalElement(const ScopePtr sc, const std::string &index, const ElementPtr element /*= NULL*/) {
ElementPtr GetOptionalElement(const ScopePtr sc, const std::string &index, const ElementPtr element /*= nullptr*/) {
const ElementPtr el = sc->GetElement(index);
return el;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/fbx/fbx_parser/FBXProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Property::~Property() {
namespace {

// ------------------------------------------------------------------------------------------------
// read a typed property out of a FBX element. The return value is NULL if the property cannot be read.
// read a typed property out of a FBX element. The return value is nullptr if the property cannot be read.
PropertyPtr ReadTypedProperty(const ElementPtr element) {
//ai_assert(element.KeyToken().StringContents() == "P");

Expand Down
4 changes: 2 additions & 2 deletions modules/fbx/tools/import_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ImportUtils {
*/
// static void set_texture_mapping_mode(aiTextureMapMode *map_mode, Ref<ImageTexture> texture) {
// ERR_FAIL_COND(texture.is_null());
// ERR_FAIL_COND(map_mode == NULL);
// ERR_FAIL_COND(map_mode == nullptr);
// aiTextureMapMode tex_mode = map_mode[0];

// int32_t flags = Texture::FLAGS_DEFAULT;
Expand Down Expand Up @@ -382,7 +382,7 @@ class ImportUtils {
// String &path,
// AssimpImageData &image_state) {
// aiString ai_filename = aiString();
// if (AI_SUCCESS == ai_material->GetTexture(texture_type, 0, &ai_filename, NULL, NULL, NULL, NULL, image_state.map_mode)) {
// if (AI_SUCCESS == ai_material->GetTexture(texture_type, 0, &ai_filename, nullptr, nullptr, nullptr, nullptr, image_state.map_mode)) {
// return CreateAssimpTexture(state, ai_filename, filename, path, image_state);
// }

Expand Down
2 changes: 1 addition & 1 deletion modules/gdnative/tests/test_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ TEST_CASE("[GDNative Variant] Variant call") {
godot_string_name_new_with_latin1_chars(&method, "is_valid_identifier");

godot_variant_call_error error;
godot_variant_call(&self, &method, NULL, 0, &ret, &error);
godot_variant_call(&self, &method, nullptr, 0, &ret, &error);

CHECK(godot_variant_get_type(&ret) == GODOT_VARIANT_TYPE_BOOL);
CHECK(godot_variant_as_bool(&ret));
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3070,7 +3070,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
// We cannot determine the exact nature of the identifier here
// Otherwise these codes would work
StringName enumName = ClassDB::get_integer_constant_enum("@GlobalScope", p_symbol, true);
if (enumName != NULL) {
if (enumName != nullptr) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM;
r_result.class_name = "@GlobalScope";
r_result.class_member = enumName;
Expand Down
2 changes: 1 addition & 1 deletion modules/mbedtls/stream_peer_mbedtls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void StreamPeerMbedTLS::poll() {
return;
}

// We could pass NULL as second parameter, but some behaviour sanitizers don't seem to like that.
// We could pass nullptr as second parameter, but some behaviour sanitizers don't seem to like that.
// Passing a 1 byte buffer to workaround it.
uint8_t byte;
int ret = mbedtls_ssl_read(ssl_ctx->get_context(), &byte, 0);
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/editor/godotsharp_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, MonoAssemblyName *re

mono_assembly_get_assemblyref(image, i, reusable_aname);

GDMonoAssembly *ref_assembly = NULL;
GDMonoAssembly *ref_assembly = nullptr;
if (!GDMono::get_singleton()->load_assembly(ref_name, reusable_aname, &ref_assembly, /* refonly: */ true, p_search_dirs)) {
ERR_FAIL_V_MSG(ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + ref_name + "'.");
}
Expand Down
8 changes: 4 additions & 4 deletions modules/mono/mono_gd/support/ios_support.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ void ios_mono_log_callback(const char *log_domain, const char *log_level, const
}

void initialize() {
mono_dllmap_insert(NULL, "System.Native", NULL, "__Internal", NULL);
mono_dllmap_insert(NULL, "System.IO.Compression.Native", NULL, "__Internal", NULL);
mono_dllmap_insert(NULL, "System.Security.Cryptography.Native.Apple", NULL, "__Internal", NULL);
mono_dllmap_insert(nullptr, "System.Native", nullptr, "__Internal", nullptr);
mono_dllmap_insert(nullptr, "System.IO.Compression.Native", nullptr, "__Internal", nullptr);
mono_dllmap_insert(nullptr, "System.Security.Cryptography.Native.Apple", nullptr, "__Internal", nullptr);

#ifdef IOS_DEVICE
// This function is defined in an auto-generated source file
Expand All @@ -85,7 +85,7 @@ void cleanup() {
GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() {
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
if (countryCode == NULL) {
if (countryCode == nullptr) {
return strdup("US");
}
return strdup([countryCode UTF8String]);
Expand Down
2 changes: 1 addition & 1 deletion modules/visual_script/visual_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}

next = node->sequence_outputs[output];
VSDEBUG("GOT NEXT NODE - " + (next ? itos(next->get_id()) : "NULL"));
VSDEBUG("GOT NEXT NODE - " + (next ? itos(next->get_id()) : "Null"));
}

if (flow_stack) {
Expand Down
2 changes: 1 addition & 1 deletion modules/webxr/webxr_interface_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ bool WebXRInterfaceJS::initialize() {
void WebXRInterfaceJS::uninitialize() {
if (initialized) {
XRServer *xr_server = XRServer::get_singleton();
if (xr_server != NULL) {
if (xr_server != nullptr) {
// no longer our primary interface
xr_server->clear_primary_interface_if(this);
}
Expand Down
4 changes: 2 additions & 2 deletions platform/iphone/display_server_iphone.mm
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@
if (rendering_device_vulkan) {
rendering_device_vulkan->finalize();
memdelete(rendering_device_vulkan);
rendering_device_vulkan = NULL;
rendering_device_vulkan = nullptr;
}

if (context_vulkan) {
context_vulkan->window_destroy(MAIN_WINDOW_ID);
memdelete(context_vulkan);
context_vulkan = NULL;
context_vulkan = nullptr;
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions platform/iphone/godot_iphone.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int add_path(int p_argc, char **p_args) {

p_args[p_argc++] = (char *)"--path";
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
p_args[p_argc] = NULL;
p_args[p_argc] = nullptr;

return p_argc;
};
Expand All @@ -69,7 +69,7 @@ int add_cmdline(int p_argc, char **p_args) {
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
};

p_args[p_argc] = NULL;
p_args[p_argc] = nullptr;

return p_argc;
};
Expand Down
10 changes: 5 additions & 5 deletions platform/iphone/godot_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ - (void)layoutSubviews {

- (void)initTouches {
for (int i = 0; i < max_touches; i++) {
godot_touches[i] = NULL;
godot_touches[i] = nullptr;
}
}

- (int)getTouchIDForTouch:(UITouch *)p_touch {
int first = -1;
for (int i = 0; i < max_touches; i++) {
if (first == -1 && godot_touches[i] == NULL) {
if (first == -1 && godot_touches[i] == nullptr) {
first = i;
continue;
}
Expand All @@ -318,11 +318,11 @@ - (int)getTouchIDForTouch:(UITouch *)p_touch {
- (int)removeTouch:(UITouch *)p_touch {
int remaining = 0;
for (int i = 0; i < max_touches; i++) {
if (godot_touches[i] == NULL) {
if (godot_touches[i] == nullptr) {
continue;
}
if (godot_touches[i] == p_touch) {
godot_touches[i] = NULL;
godot_touches[i] = nullptr;
} else {
++remaining;
}
Expand All @@ -332,7 +332,7 @@ - (int)removeTouch:(UITouch *)p_touch {

- (void)clearTouches {
for (int i = 0; i < max_touches; i++) {
godot_touches[i] = NULL;
godot_touches[i] = nullptr;
}
}

Expand Down
8 changes: 4 additions & 4 deletions platform/iphone/ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@
String iOS::get_model() const {
// [[UIDevice currentDevice] model] only returns "iPad" or "iPhone".
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
sysctlbyname("hw.machine", nullptr, &size, nullptr, 0);
char *model = (char *)malloc(size);
if (model == NULL) {
if (model == nullptr) {
return "";
}
sysctlbyname("hw.machine", model, &size, NULL, 0);
sysctlbyname("hw.machine", model, &size, nullptr, 0);
NSString *platform = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];
free(model);
const char *str = [platform UTF8String];
return String(str != NULL ? str : "");
return String(str != nullptr ? str : "");
}

String iOS::get_rate_url(int p_app_id) const {
Expand Down
4 changes: 2 additions & 2 deletions platform/iphone/vulkan_context_iphone.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
Error VulkanContextIPhone::window_create(DisplayServer::WindowID p_window_id, CALayer *p_metal_layer, int p_width, int p_height) {
VkIOSSurfaceCreateInfoMVK createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
createInfo.pNext = NULL;
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.pView = (__bridge const void *)p_metal_layer;

VkSurfaceKHR surface;
VkResult err =
vkCreateIOSSurfaceMVK(_get_instance(), &createInfo, NULL, &surface);
vkCreateIOSSurfaceMVK(_get_instance(), &createInfo, nullptr, &surface);
ERR_FAIL_COND_V(err, ERR_CANT_CREATE);

return _window_create(p_window_id, surface, p_width, p_height);
Expand Down
Loading

0 comments on commit 5b16020

Please sign in to comment.